Sunday, April 7, 2019

filters - How to Get Rid of Ripples from a Gradient Image of a Smoothed Image?


I have a gray scale UINT8 image. When I smooth it with a Gaussian filter and then compute the gradient image with a Sobel filter in OpenCV, ripples would appear.


The first image is what happens when I use a 25x25 Gaussian filter with sigma value 4 and compute the second order derivative in the x direction with a size 3 Sobel filter.


enter image description here


The more I smooth the image, the more significant the ripples become.


The second image is what I got when I use a 49x49 Gaussian filter with sigma value 7. The Sobel filter is the same as the first image.


enter image description here


Why is the Gaussian filter creating more noise when it's suppose to get rid of them? How should I deal with this?



Answer




I think it happens due to 2 things:




  1. Quantization
    You are working using UINT8 Image, try convert it into floating Point Image.
    You may do this by mO = im2double(mI) where mI is the UINT8 and mO is a floating point image in the range [0, 1]. You may also do it using mO = double(mI) / 255.




  2. Gaussian Kernel Radius vs STD Ratio
    Your Gaussian Filter Radius is 12 while $ \sigma = 4 $. This is a ratio of 3. Try higher ratios, something like kernelRadius = ceil(5 * kernelStd) this will make the Gaussian Filter result much smoother.





No comments:

Post a Comment

digital communications - Understanding the Matched Filter

I have a question about matched filtering. Does the matched filter maximise the SNR at the moment of decision only? As far as I understand, ...