V. Image Restoration Methods
                            The images were restored using the following four methods:


C. Results

     
    Part 1: Noise Removal
    From the tables and the graphs, we can summarize as follows:
    - For Gaussian Noise, Gaussian filtering and k-Nearest Neighbor filtering are the best methods.
    - For Salt and Pepper Noise, Median filtering and k-Nearest Neighbor filtering are the best methods.  The 5x5 mask can clean the noise better than  the 3x3 mask as the noise level goes up.

    There are various kinds of techniques that we can use to clean the noise. However, the performance (in here, we use the RMS error to measure the performance) of each technique depends on how the noise behaves. For the well-behaved noise like Gaussian noise, the suitable filter is the linear types (Box and Gaussian filter). In contrast, the outlier or peak noise like the Salt & Pepper noise is suitable to be cleaned by non-linear filter (Median filter and K-Nearest Neighbor filter).

    a) Performance for each method as different parameters are varied

    i. Mean Filtering
    For Gaussian noise, as the standard deviation  of the noise was increased, it was more difficult to remove the noise. This can be seen from the graph: Mean filter for lenna.gif corrupted with Gaussian noise. The RMS error between original and filtered image for higher standard deviations of Gaussian noise was larger. From the graph, one can see that as the mask size increases, the RMS error increases. Hence a 3x3 mask is better able to remove the noise than a 5x5 mask and a 5x5 mask better than a 7x7 mask.
    For salt and pepper noise, as the percentage of salt and pepper noise added was incresed, it was more difficult for the mean filter to remove the noise. This can be seen from the graph: Mean filter for lenna.gif corrupted with Salt and Pepper Noise. One can also see from the graph that for 10%, 15%, 20%, 25% salt and pepper noise, the 5x5 mask size produced the smallest RMS error between original and filtered image. However for 5% salt and pepper noise, the 3x3 mask has the smallest RMS error.

    ii. Median Filtering
    For Gaussian noise, as the standard deviation  of the noise was increased, it was more difficult to remove the noise. This can be seen from the graph: Median filter for lenna.gif corrupted with Gaussian noise. The RMS error between original and filtered image for higher standard deviations of Gaussian noise was larger. From the graph, one can see that as the mask size increases, the RMS error increases.  Hence a 3x3 mask is better able to remove the noise than a 5x5 mask and a 5x5 mask is better than a 7x7 mask.
    For salt and pepper noise, as the percent of salt and pepper noise added was incresed, it was more difficult for the mean filter to remove the noise. This can be seen from the graph: Median filter for lenna.gif corrupted with Salt and Pepper Noise. One can also see from the graph that for 20% and 25% salt and pepper noise, the 5x5 mask produced the smallest RMS error between the original and filtered image. However for 5%, 10% and 15% salt and pepper noise, the 3x3 mask produced the smallest RMS error.

    iii. Gaussian Filtering
    For Gaussian noise, as the standard deviation  of the noise was increased, it was more difficult to remove the noise. This can be seen from the graph: Gaussian filter for lenna.gif corrupted with Gaussian noise. The RMS error between original and filtered image for higher standard deviations of Gaussian noise was larger. From the graph, one can see that as the mask size increases, the RMS error increases.  Hence a 3x3 mask is better able to remove the noise than a 5x5 mask and a 5x5 mask is better than a 7x7 mask.
    For salt and pepper noise, as the percent of salt and pepper noise added was incresed, it was more difficult for the Gaussian filter to remove the noise. This can be seen from the graph: Gaussian filter for lenna.gif corrupted with Salt and Pepper Noise One can also see from the graph that for 5%, 10%, 15%, 20%, 25% salt and pepper noise, the 5x5 mask size produced the smallest RMS error between original and filtered image.

    iv. k-Nearset Neighbor filtering
    For Gaussian noise, as the standard deviation  of the noise was increased, it was more difficult to remove the noise. This can be seen from the k-Nearest filter for lenna.gif corrupted with Gaussian noise graph. The RMS error between original and filtered image for higher standard deviations of Gaussian noise was larger. From the graph, one can see that for standard deviations of 1,5, 9 for the Gaussian noise as the mask size increases, the RMS error increases.  However for standard deviations of 17 and 21, the 5x5 mask size produces the smallest RMS error.
    For salt and pepper noise, as the percent of salt and pepper noise added was incresed, it was more difficult for the Gaussian filter to remove the noise. This can be seen from the graph k-Nearest filter for lenna.gif corrupted with Salt and Pepper Noise, one can also see from the graph that for 5% and 10% salt and pepper noise, a 5x5 mask size produces the smallest RMS error followed by the 7x7 mask size then the 3x3 mask size. For 15%, 20% and 25% salt and pepper noise, a 7x7 mask size produces the smallest RMS error followed by the 5x5 mask size then the 3x3 mask size.
     

    b) Comparison of the performance of the different methods

    i. Salt and Pepper Noise
    From the graph Comparison of various filters for 25% Salt and Pepper noise on lenna.gif (corresponding to the images here), we can see that the 5x5 median filter works the best in that it produces the smallest RMS error between original image and filtered image.  The 3x3 k-Nearest neighbor filter produced the worst results.

    ii. Gaussian Noise
    From the graph Comparision of various filters for Gaussian noise with std dev 21 on lenna.gif (corresponding to the images here), we can see that the 3x3 Gaussian filter works the best in that it produces the smallest RMS error between original image and filtered image. The 7x7 mean filter produced the worst results.
     
    The complete results for all the cases are present here. The best filter (with regards to the minimum RMS error between the final filtered image and the original images) for each type of noise applied to the lenna.gif image are tabulated below (O-F stands for error between the original image and the final filtered image, N-F stands for the error between the noisy image and the final filtered image):

    Image Noise Type Noise Level Filter RMS error (O-F) RMS error (N-F)
    lenna Gaussian SD=1 3x3-kNearest 1.61% 1.60%
    lenna Gaussian SD=5 3x3-kNearest 2.05% 1.80%
    lenna Gaussian SD=9 3x3-kNearest 2.82% 2.27%
    lenna Gaussian SD=13 3x3-gaussian 3.47% 5.13%
    lenna Gaussian SD=17 3x3-gaussian 3.81% 6.23%
    lenna Gaussian SD=21 3x3-gaussian 4.20% 7.37%
    lenna S and P 5% 3x3-median 3.25% 12.56%
    lenna S and P 10% 3x3-median 3.62% 17.45%
    lenna S and P 15% 3x3-median 4.15% 21.34%
    lenna S and P 20% 5x5-median 4.80% 24.89%
    lenna S and P 25% 5x5-median 5.00% 27.83%


    Part 2: Image restoration

    a) Performance of each method

    i. Inverse Filtering (Results)
    For images corrupted by Gaussian filter and White Additive Gaussian Noise, we found that Inverse filtering using a PSF threshold of 0.5 works the best as it produces a sharp image with little noise. When using a PSF threshold of 0.1, the quality of the "restored image" was not very good due to the presence of a lot of "dots" (noise). For a PSF threshold of 0.1, the "restored image" was not very sharp.
    For images corrupted by camera motion and White Additive Gaussian noise, we found that Inverse filtering using a PSF threshold of 0.1 worked the best in that it managed to remove much of the blurring caused by camera motion and much of the noise to produce a sharp and clean restored image, even as the standard deviation of the Gaussian noise was increased. For a PSF threshold of 0.5, the "restored image" was pretty "off-color" with some wavy texture. The same thing was true of the case using a PSF threshold of 0.8 but slightly worse.
    For images corrupted by sinusoidal waveform and White Additive Gaussian noise, the inverse filter did not do a very good job of restoring the image. Even for the best case of PSF threshold of 0.1, there were still "bands" in the "restored" image although the sinusoidal waveform seemed to be removed. The quality of the "restored" image for PSF thresholds of 0.5 and 0.8 were pretty bad with the lenna image hardly well defined.

    ii. Wiener Filtering (Results)
    For images corrupted by Gaussian filter and White Additive Gaussian noise, the Wiener filter did not do as good a job of restoring the image as the inverse filtering. A PSF threshold of 1.2 seemed to work the best for most cases. However the "restored" images were not very sharp.
    For images corrupted by camrea motion and White Additive Gaussian noise, the Wiener filter removed most of the blurring caused by camera motion, with PSF thrsholds of 0.8 and 1.2 performing the best. However as the standard deviation of the White Additive Gaussian noise was increased, the "restored" image was not as sharp and a little "off-color".
    For images corrupted by sinusoidal waveform and White Additive Gaussian noise, the Wiener filter managed to remove the sinusoidal waveform. However, there were "bands" in the "restored" image. In this case, a PSF threshold of 0.1 gave better results.

    iii. Power Spectrum Filtering (Results)
    For images corrupted by Gaussian filter and White Additive Gaussian noise, the Power Spectrum filter did a good job of restoring the image producing a sharp and clean image. However as the standard deviation of the White Additive Gaussian noise was increased, the "restored" image was more blurry and less sharp.
    For images corrupted by sinusoidal waveform and Additive White Gaussian noise, the power spectrum filter seemed to do a better job of restoring the image than the Inverse Filtering and Wiener Filtering in that the presence of "bands" was not as strong. The filter seemed to remove the sinusoidal waveform but some of it can still be slightly visible. However, as the standard deviation of the White Additive Gaussian noise was increased, the Power Spectrum filter did not produce a good job of restoring the image as the "restored" image was not very sharp and "off-color" as well as the presence of "texture".
    For images corrupted by camera motion and White Additive Gaussian noise, the Power Spectrum filter does a good job of removing the blurr caused by camera motion producing a sharp and clean image. Even as the standard deviation of the White Additive Gaussian noise was increased, the Power Spectrum filter does a good job of restoring the image.

    iv. Constrained Least Squares with Second order derivative smoothing (Results)
    For images corrupted by Gaussian filter and White Additive Gaussian noise, the CLS method does not produce as good results as the inverse filtering and power spectrum filtering. The color of the "restored" image was not as strong and not as sharp especially as the standard deviation of the White Additive Gaussian noise was increased.
    For images corrupted by sinusoidal waveform and White Additive Gaussian noise, the CLS method managed to remove much of the sinusoidal waveform. However, there were still "bands" in the "restored" image similar to that of the Inverse filtering and Wiener filtering. The "restored" image was not as clear as the standard deviation of the White Additive Gaussian noise was increased.
    For images corrupted by camera motion and White Additive Gaussian noise, the CLS method managed to remove the blurring caused by camera motion. When the standard deviation of the White Additive Gaussian Noise was 5, the "restored" image was pretty sharp. However, as the standard deviation of the White Additive Gaussian Noise was increased, the "restored" image was less sharp.

    b) Comparison of different methods

    i. Gaussian filter
    For images corrupted by Gaussian filter, the inverse filtering method with a PSF threshold of 0.5 and Power Spectrum filtering produced the best results. The Constrained Least Squares approach and Wiener filtering approach did not produce as good results.

    ii. Sinusoidal waveform
    For images corrupted by sinusoidal waveform, the inverse filtering, Wiener filtering and Constrained least squares approach produced "restored" images which had "bands". Power Spectrum filter produced better results than the other filters in that "bands" were not present in the restored image.

    iii. Camera motion
    For images corrupted by camera motion, all the filtering methods managed to produce good results in removing the blur caused by camera motion.
     
     

D. Conclusions:

  1. For part 1, we implemented the various filters to remove Gaussian noise and Salt and Pepper noise. We then compared the performance of the various filters. We found that the performance of the various filters depends on the mask sizes of the filter as well as the type of noise corrupting the image. We also found that the 5x5 median filter is best able to remove Salt and Pepper noise as expected. k-Nearest neighbor filter comes close second after the median filter. Mean filter is the worst filter for Salt and Pepper noise as it has an effect of blurring the image beyond recognition. These were supported by the magnitude of RMS error between original image and filtered image. This confirms the fact that median filter is an outlier filter. For Gaussian noise, a 3x3 Gaussian filter works the best in terms of RMS error. However, one might question the use of RMS errors to evaluate the filters for all purposes. Once the RMS errors get large (say more than 15-20%), they do not make much sense (due to the fact that two totally different images may have an RMS error as low as 30-40%, hence once we near that range, the numbers make little sense). In such cases, visual indication/comparison may be the best classifier.

  2. For part 2, we compared the performance of various image restoration filters (in the frequency domain). Many factors influence the effectiveness of the restoration process. We found that the performance of each filter depends on the image, the type of corruption and the various parameters that can be varied for each respective filter. All the filters are very sensitive to cut-offs/thresholds, hence care should be taken to choose the optimum values for every case.
       
    E. Links to all the graphs/results:
       
    F. Links to the Source Code: