While watching the DCRaw (web, wiki) presentation from the last Linux Graphic Meeting in Poland, Dave Coffin mentioned that DCRaw offers denoising before RAW demosaicing, which is the best way to deal with noise – ie as early in the process as possible. The “Treshold” slider in UFRaw allows for an easy control of this parameter.
And this made me think some more about noise and how to treat it.
The base picture
Sorry for the subject (a ficus). It is taken at ISO 3200 (Pentax *istDS maximum ISO) and in dim light. There are some dark areas that make noise pop up. This is what we need for this experiment – note that scaling down the image for the web makes the noise much less disturbing than when viewed at 100%:
But when viewed at 100%, we see that the noise is very present and very colored – not pretty:
The base picture is a RAW file which I developed to my taste in UFRaw as a 16 bits TIFF, keeping noise reduction threshold to 0. This TIFF file is the basic input I will use for GREYCstoration. I then reloaded the Ufraw profile and applied noise reduction without changing any other parameters.
As David mentioned, noise very much boils down to personal taste so you may not share my tastes. I decided to go for a strong reduction (since I had a few ideas about further treatment), so set the cursor to 450. Here is what it looks at 100%:
A typical noise reducted picture: many details have disappeared with the typical water colored overall look and there is still a bit of noise here and there… My goal was to remove colored noise and that was the price to pay for it.
At the moment, GREYCstoration is not very easy to use. My way is to load the Gimp plug-in, find the best possible parameters, take a screenshot (don’t laugh) and then apply GREYCstoration from the command line (keeping 16 bits channel quality).
I didn’t use the new patch based algorithm, since I wasn’t able to get a better output with it than with the normal one – maybe due to the pixel nature of the *istDS noise. So I applied GREYCstoration to my TIFF file with parameters giving an ouput close to that of UFRaw. If you are curious here are my parameters:
-restore ficus_noisy.tif -bits 16 -o ficus_grey.tif \
-dt 100 -p 0.7 -a 0.05 -alpha 1 -sigma 1.78 -dl 0.8 \
-da 30 -fast true -iter 2 -interp 2 -sdt 0
Here is the result at 100%:
A couple of comments here:
- GREYCstoration is very slow. Don’t start a batch from the command line for 20 16bits TIFF files, you’ll need 3 days of processing. Use GREYCstoration for the image worth high quality printing…
- The output is very close to UFRaw which is impressive since denoising prior to demosaicing should give better results than afterwards.
- There is an ugly artifact that shows around the strong image variation (leaves) – which probably can be corrected with choosing better values but I didn’t had the patience to restart the processing all over again…
The great advantage of GREYCstoration is that it can be used in other file types than RAW and gives the best possible result. Unfortunately, the process time and difficulty to find the right settings make GREYCstoration a “use once” tool rather than an “easy to add to your batch” tool.
When trying to find the right settings for noise reduction, I was frustrated that there is no way to just “suppress noise”: if you denoise too much, your images looses a lot of detail, if not enough it keeps these ugly color points everywhere. In both cases, you won’t be able to apply as much unsharp mask as normal. Sorry for stating the obvious, but noise is an image degradation and no matter how much software treatment you apply to it, it is just that: a degradation.
So instead of trying to suppress noise (which doesn’t work at least in such an extreme case), I went back to my previous experiments at working with noise (vs suppressing it). Even if we live in the era of super sharp, super saturated and super digital-looking images, I appreciate a grainy picture a lot, especially in Black & White – although color can be very nice too. The problem is that when scaled down for screen viewing, the grain isn’t rendered to its advantage – but a good print from a grainy image is beautiful.
Although I have touched the subject beforehand, I intend to be a bit more systematic here and give a workable how to. Basically, to go from noise to grain we need to
- suppress color noise but keep (re-add) b&w noise.
- re-add noise in the highlights: digital noise is more present in the darker areas than in the highlight (unlike grain which is present equally everywhere).
Re-adding B&W noise
The noise reduction we inflicted to our ficus got rid of noise all together – giving the image this water colored, detail washed look. To re-add noise, simply open the noisy image in Gimp, convert it to B&W, chose “image / color to alpha…” and pick white. You will end up with black grains on a transparent background, which you can save as PNG (here is how the layer looks like on a white background, which makes it more readable):
In Cinepaint (for 16bits), load the PNG on top of your denoised image (as a second layer) – detail (or at least the impression of detail) is back but the image is a lot darker. Add 5 points of saturation to the denoised image (touching up the curves will loose a bit of saturation) and set the noise layer to a transparency of about 60. Flatten the image and add some light via the curves. Here is the global output:
and viewed at 100%:
Don’t do that yet if you plan to go on with the next step, this is just an example of where we are so far.
Adding noise in the light areas
In order to re-add noise in the light areas of the image, we need to start with a noisy uniform image: take a shot of your white ceiling (or wall) as equally lit as possible, with the same ISO setting as your base image (3200 here).
In my case, the image still showed vignetting – to correct it, open the image with Gimp, add a layer, draw a circular gradient on it, add a layer mask and chose mask to selection. Go back to your first layer (white noisy image) and tweak the brightness to correct vignetting as much as possible. Don’t worry about noise appearing in the process 🙂 Afterwards, convert the image to B&W and save it – you can reuse this image as “noise frame” for any other noise processing you want to do.
From there, we need to select the light areas from our ficus and apply the selection to our noise frame. Just open the previous PNG file as a second layer on top of our noise frame. From the PNG, add layer mask and mask to selection (using transparency), invert selection (it is the highlight we are interested in) and apply the selection to the noisy frame. Copy and paste as a new layer. This is how it looks like – on a white background:
Indeed, the light areas are the one where we will add noise – it looks like a negative, if anyone still remembers… Save it (with a transparent background) as a second PNG.
In Cinepaint (again), load the denoised version of the image and the two PNG (B&W noise and highlight noise). Add 5 points of saturation to the denoised image, bring down the transparency of the B&W noise and hightlight noise to 60%. Flatten the image and touch up the curves a bit. Here is the output:
And a 100% view:
There isn’t a lot of difference with the previous one (to the point that I wonder if it is worth the trouble) but if you look at the leaves (very light) sides they don’t stand out as much as before. So even if the improvement is tiny, it is there – it would be interesting to test the procedure on a washed out sky…
Ufraw or GREYCstoration?
Just for info, I have used the UFRaw image for my procedure so far. But here is the 100% output starting from the GREYCstoration image:
Not a lot of difference, if you ask me. What makes this image interesting is more the noise treatment than which software was used to process it.
I think that trying to “denoise” images reaches its limits quickly. Rather than hoping for the magical software that removes noise (and doesn’t exists AFAIK), a much better approach is to work around noise to make it as pleasant as possible, ie looking like film grain.
And indeed, we have ways to do just that – although it requires a bit of handy work. I guess most of it could be handled by a script – a nice little project to put in the pile somewhere. And when checking the output from NoiseNinja in a previous post, the output looks very much like what we have here – we must be onto something 🙂 .