divyang4481 / photivo

Automatically exported from code.google.com/p/photivo
GNU General Public License v3.0
0 stars 0 forks source link

Extreme noise - bug or makeshift support for the Canon Powershot G1 #111

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Photivo (tested: latest version, 2012-12-27) introduces a veil of extreme noise 
to RAWs from the good old Canon Powershot G1 (not the new G1X!). This is 
obviously an artifact, as both DCRAW and Adobe Camera RAW give much cleaner 
(just call it normal) results. (Comparison done of course with any processing 
beyond white balance disabled). The introduced noise is colorful, but badly 
affects the L channel too.

I shot an image under conditions ideal to demonstrate the problem & facilitate 
experimenting (low light&maximum sensitivity, dark parts with detail, pure 
white parts without clipping, and all three base colors present).

The attachment storage quota is exceeded, so I had to upload the files here 
(15,5 MBytes):
http://rapidshare.com/files/1526075018/Photivo%20G1%20noise.zip

The PNG file has been processed after a neutral reset, with the demosaicing 
algorithm set to "VNG 4 color" (the others give terrible results, probably 
because of the unusual sensor), and white balance measured on a wheat bag. The 
PPM file comes from DCRAW, using the command line arguments -W -t 6 -A 1726 662 
100 50, for reference. I also included the RAW file. Important note: my camera 
is modified for infrared photography (this is why I use it despite its age), 
the image has been shot with an external hot mirror, which differs from the 
original one, so the white balance is offset from normal, and the colors aren't 
going to be very accurate. Also, there's another bug (I'll further investigate 
and report it separately), so if you load the PTS file, the WB will be 
incorrect, so it must be measured again and again all times it's loaded. 

What I suspect (don't take it for sure):
This camera has a non-conventional CFA (cyan-yellow-magenta-green), so some 
extra miles need to be run to support it. I discovered that when these RAWs are 
processed using the flat, or any other standard camera's ICC profile, the 
mentioned noise artifact disappears, but the colors become faint and abnormal 
(red becomes green, green and blue becomes purple, etc). Processing an image 
from a conventional GRGB camera using the G1's profile yields distorted and 
strongly exaggerated colors.
So maybe there's something in Photivo which behaves erroneously with CYMG data, 
and outputs incorrect and squashed color information, which is attempted to be 
corrected using by the ICC profile, which, in turn, dramatically amplifies 
noise.
But this may be totally wrong, currently I don't know very much abot the guts 
of Photivo.

PS: I hope that this team is more serious than that of a certain similar RAW 
processor, which, when I asked them if the G1 could be supported in the future, 
told that they are sorry, but the camera is obsolete, period. (So they 
indirectly said that all the photos made with old cameras are worthless because 
they carry some signs of the older technology on them...) I think it's exactly 
a good picture made with an old camera where modern, advanced denoising 
algorithms can really show what they can do... Where every single pixel 
counts...

Of course, I'm ready to further assist or help solving this issue.

Original issue reported on code.google.com by gabor.sz...@gmail.com on 23 Feb 2013 at 12:13

GoogleCodeExporter commented 9 years ago
Well, it seems you're right, the different pattern is causing problems. VNG4 
should be the only algorithm giving reasonable results, since the others work 
on three colors and your camera has 4. Considering demosaicing it seems Photivo 
does it right, but the color profile application might be wrong giving the bad 
results with other then flat profiles. 
So, the question is, who is willing to go these extra miles you mention. 
Someone needs to invest his/her spare time to a problem that is very rare, 
since as you say, it is an old model and it seems only few people use it any 
more. I'm honest here, I won't dig into this; I've very little time for the 
project and there are more urgent things to do. So, the only thing I could 
offer, is some guidance on our code base so that you can dig into this issue 
yourself. I'm happy to include your corrections into Photivo afterwards. 
This is not a matter of seriousness of the team in our or any other project, 
just consider the motivation people have working in their spare time on open 
source projects without payment; we have a family, a day job and photography as 
a hobby, too ;-)

greets mike

Original comment by m...@mm-log.com on 23 Feb 2013 at 9:13

GoogleCodeExporter commented 9 years ago
"VNG4 should be the only algorithm giving reasonable results, since the others 
work on three colors and your camera has 4."

Actually, they work well with most (dichromatic) infrared shots. The blue 
artifacts avoided in this case by the VNG4 show up only with certain white 
balances encountered when using the external hot mirror, and only at 
highlights. It's more like some internal clipping issue.

"Considering demosaicing it seems Photivo does it right, but the color profile 
application might be wrong giving the bad results with other then flat 
profiles. "

No, the flat profile or any other profile give invalid color information, while 
the profile designed for this camera gives correct colors, but also the extra 
noise. Using the latter on GRGB RAWs produce distorted and extremely strong 
colors.
For me, the strange profile seems to be a simple-but-dirty solution to the 
problem.

"So, the only thing I could offer, is some guidance on our code base so that 
you can dig into this issue yourself. I'm happy to include your corrections 
into Photivo afterwards. "

If you help me (I'll definitely need it), I'll give it a try. I never 
officially learned to program, but have already developed a few simple but 
sophisticated apps, often learning things on the fly. So of course I can't 
promise anything except my effort to try to solve it.

Also, I have a trade offer: if I don't manage to solve the problem myself, but 
someone does it, in return I'll spend time in areas where I'm good, like 
testing (I tend to notice every small detail), hunting down bugs or improving 
GUI (just one quick idea: implementing custom step values for sliders, and 
adjusting them individually for each, according to the changes usually needed 
to be made to it, and also a "low gear" dragging using the middle mouse button).
And of course a good Hungarian translation (that's my mother tongue), but i'll 
make that anyway soon.

Maybe it's also worth to mention that 4-color CFAs might come back and become 
widespread, as some companies experiment with RGBW and RGBE arrays (W for 
white, E for emerald). Yes, simply ignoring the W or E pixels will likely work, 
but by doing so, not only will their advantage be renounced, but also a quarter 
of useful pixel information wasted, resulting in inferior resolution.

Original comment by gabor.sz...@gmail.com on 23 Feb 2013 at 4:41

GoogleCodeExporter commented 9 years ago
Alternative solution: since Photivo already incorporates DCRAW as far as I 
know, maybe we could add an "Use DCRAW to process" checkbox. After the Camera 
tab no low level image data is needed, or is any?

DCRAW not only supports CYMG arrays flawlessly, but is also said to read even 
many unknown or partially corrupted raws refused by other SW, so this 
compatibility feature could be useful for lots of people.

Original comment by gabor.sz...@gmail.com on 24 Feb 2013 at 1:48

GoogleCodeExporter commented 9 years ago
Hello Gabor,

having dcraw as external fall back would indeed be possible, but several of the 
current options on the input tab would stop working in that case and that 
wouldn't be the simplest change to Photivo. 
Considering your investigation: I would start with a environment, in which you 
can easily compile and test Photivo. Simplest here is Linux 
(http://photivo.org/photivo/download_and_setup/linux), but it also works with 
Windows (http://photivo.org/photivo/download_and_setup/windows). Once that is 
in place, the file ptdcraw.cpp contains the demosaicing steps. You find 4 
functions with phase in their name in there. These do all the work of the input 
tab. For demosaicing you just need phase 1 and 2. Please have a first look 
there and try to get a feeling what's going on in the called functions; not 
mathematically but from the effect (e.g. demosaicing, RAW decoding, color 
scaling, etc.) I hope that helps as a first step. (You might need quite some 
motivation here, it's not the simplest stuff :-) ) I'll try to help if you have 
questions.

greets mike

Original comment by m...@mm-log.com on 24 Feb 2013 at 8:34