New User?   Join Now     Login            Forgot Password?    
Image Denoising  (66552 hits)
 Share this Article
 
Posted by Prabu Arumugam on Jul-05-2010
Languages: C#

What is Image Noise?

Image noise is undesired variation in pixel intensity values in a captured or transmitted image. Images captured with digital cameras or conventional film cameras or any other image sensor will pick up noise from variety of sources. Imperfect instruments, problems with the data acquisition process, interfering natural phenomena, transmission errors and compression can all introduce image noise and degrade the image quality. Image noise is an unavoidable side-effect during image capture. It is a phenemenon that no photographer can ignore. Even if noise is not clearly visible in a picture, some kind of image noise is bound to exist.

In digital images, noise corrupts the smooth surface with non-uniform specks, thereby degrading the image quality to greater extent. Various factors like lighting conditions, sensitivity setting in the camera, exposure time and temperature produce random variation of brightness or color information in images. For more information on image noise types and sources, see http://en.wikipedia.org/wiki/Image_noise.

The following is a noisy image with excessive random noise.

 

Image Denoising

Image denoising is the process of removing noise from images. It has remained a fundamental problem in the field of image processing. Digital images play an important role in daily life applications like satellite television, magnetic resonance imaging, computer tomography, geographical information systems, astronomy and many other research fields. While we cannot completely avoid image noise, we can certainly reduce them. The image noise is removed usually by image smoothing operation.

There are two basic approaches to image denoising, namely spatial filtering and transform domain filtering. Spatial filters operate on a set of pixels related to a given pixel, usually by a sliding window. The window (or kernel) is usually square but can be any shape. Transform domain filters, in general, change the basis of signal space to aid some processing on the image data. Examples of transform domain filtering are fourier transform and wavelet transform.

Mean Filter

Mean filter is a simple and intuitive way to reduce the image noise. It is a sliding-window spatial filter that replaces the center value in the window with the average (mean) of all the pixel values in the window. The idea is to eliminate the pixel values which are unrepresentative of their surrounding pixels. The window size is usually 3x3. Larger window sizes or repeated (iterative) mean filters introduce blurring and other unwanted effects in the image data.

The following C# function illustrates the concept of a basic iterative 3x3 mean filter. The GetAllNeighbors() function returns all valid pixels in the 3x3 window of current pixel. Invalid pixels are those that does not exist; for example corner pixels have only four neighbors including itself.

public static PGM ApplyMeanFilter(PGM inputImage, int iterationCount)
{
    PGM outputImage = new PGM(inputImage.Size.Width, inputImage.Size.Height);
	
    for (int iteration = 0; iteration < iterationCount; iteration++)
    {
        for (int x = 0; x < inputImage.Size.Width - 1; x++)
        {
            for (int y = 0; y < inputImage.Size.Height - 1; y++)
            {
                //find average intensity of neighbors of current-pixel
                List<int> validNeighbors = inputImage.GetAllNeighbors(x, y);
                double averageIntensity = validNeighbors.Average();
				
                //set average as new intensity of current-pixel
                outputImage.Pixels[x, y] = (short)averageIntensity;
            }
        }
		
        //set input to next iteration
        inputImage = outputImage.Clone();
    }
	
    return (outputImage);
}

The following image shows the mean-filtered version of above noisy image (5 iterations).

 

Median Filter

The median-filter is also a sliding-window spatial filter, but the center value in the window is replaced by median (middle) of all the pixel values in the window. It is a more robust method than mean filter, because it is particularly effective in preserving the sharp edges in the image. Many variations to median filter are proposed such as weighted median filter, relaxed median filter, etc.

The following C# function illustrates the concept of a basic iterative 3x3 median filter.

public static PGM ApplyMedianFilter(PGM inputImage, int iterationCount)
{
    PGM outputImage = new PGM(inputImage.Size.Width, inputImage.Size.Height);
	
    for (int iteration = 0; iteration < iterationCount; iteration++)
    {
        for (int x = 0; x < inputImage.Size.Width - 1; x++)
        {
            for (int y = 0; y < inputImage.Size.Height - 1; y++)
            {
                //get all neighbors of current-pixel
                List<int> validNeighbors = inputImage.GetAllNeighbors(x, y);
				
                //sort and find middle intensity value from all neighbors
                validNeighbors.Sort();
                int medianIndex = validNeighbors.Count / 2;
                short medianPixel = (short)validNeighbors[medianIndex];
				
                //set median-pixel as intensity of current-pixel
                outputImage.Pixels[x, y] = medianPixel;
            }
        }
		
        //set input to next iteration
        inputImage = outputImage.Clone();
    }
	
    return (outputImage);
}

The following image shows the median-filtered version of above noisy image (5 iterations).

 

C# Demo

A windows-forms application has been created in C# to illustrate the image denoising algorithms explained in this article. The full source-code of the demo can be downloaded below. This demo uses the PGM class explained in this article, but this demo is self-contained and includes the PGM class. A screenshot of the demo is given below.

An ideal denoising procedure requires a prior knowledge of noise, whereas a practical procedure may not have the required information about the noise model. More advanced image-denoising methods have been developed and it remains a continous field of research in signal processing. Many latest digital cameras have employed some noise removal techniques based on the light sensitivity during image and video capture.


 Downloads for this article
File Language Tools
PGM-Noise-Samples  748.94 kb  (678 downloads)
ImageDenoising-Demo-Source  18.49 kb  (991 downloads) C# Visual Studio 2008

 Share this Article

 Comments on this Article
Comment by samantha on Feb-14-2015
do you have the codes of median filter in java? A basic java code for median filtering of a 8-bit grey image?
Comment by Anubharathi on Jul-15-2014
i want source code for image denoising in c#.net
Comment by anshul yadav on Nov-13-2013
thanks
Comment by anupama on Jan-20-2012
can we get the code for a hybrid technique for noise removal
Comment by Komkanit99 on Dec-05-2011
Thank you
Comment by krushna on Mar-10-2011
want source code in cuda prog.
Comment by cincoutprabu on Feb-23-2011
Hi zaza, PGM is a standard grayscale file format used to illustrate any image processing algorithm. All such algorithms can be applied to RGB images, by applying the underlying formula to three colors (R, G, B) separately instead of one color (gray).
Comment by zaza on Feb-23-2011
hurmm why only use image file pgm??
Comment by Ankur on Jan-30-2011
very gud article...gud for basics in image denoising
Comment by reena manandhar on Jan-11-2011
no comment
 Post your comment here
Your Name
Your Email
Comment
Post Comment

About      Terms      Contact