Thursday, August 9, 2012

Filtering image noise

Every image we shoot with a digital camera has some noise in it. Depending on the environment where we shoot the noise can be noticeable or unnoticeable. A very big component of the camera noise depends on the ISO speed. Higher the ISO value we select, more sensitive will the camera sensor be and a more noise picture we will get. The noise can be divided to color and luminance noise.

To get a prettier image we need to filter the noise out. In Nomacs RAW Loader we added median filtering of the image because it is a good method to filter noise without ruining the edges in the image. We replace every pixel in the image with the median value of the pixels within a square around the pixel we are replacing. The size of the square is called window size and it has to be an odd number. Because we only want to filter color noise we transform the RGB image to the YCrCb color space where we filter both chroma channels and then we transform back to the RGB space.

The only parameter in the median filter is the window size. Bigger the window size more time will the filtering take and also we can over filter an image. This is why we need to be careful which window size we select for each ISO value. To find them we did a small scientific research.

We put a Nikon D300 on a tripod and shoot a Colorchecker SG card 19 times. Each time we changed the ISO value that ranged from 100 to 6400. For determining the noise of a picture we calculated the peak signal to noise ratio (PSNR) . For the reference we used the image with the lower noise = ISO 100. Bottom graph shows the PSNR value to ISO value dependency. Higher is the PSNR value, lower is the noise.



We see that in general the PSNR value is decreasing with increasing the ISO value. Because the exposure is not the same in every image there is some zigzagging but the general trend is clearly visible. Lets now take a look what happens with PSNR values after median filtering with increasing the window size: 3,5,...,13:


We see that the PSNR value is increasing. But we also see that there is a limit to where the noise can be reduced. For higher ISO values we need higher window size to get there. The best way to decide the window size for each ISO is to take a look at PSNR as a function of window size. Bellow are the graphs for ISO 250 and 3200.

ISO = 250:
ISO = 3200:

We can see that the noise is decreasing with the increase of window size but if the number is too big the noise starts to increase again. For the window size we select the value where the noise stops to improve. The results for the window size are:

ISO > 6400: winSize = 13
ISO >= 3200: winSize = 11
ISO >= 2500: winSize = 9
ISO >= 400: winSize = 7
ISO < 400: winSize = 5

No comments:

Post a Comment