1
$\begingroup$

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?

$\endgroup$
  • $\begingroup$ Could you tell us about the Image (Is it UINT8 / UINT16, Floating Point, which Gaussian Filter do you use, etc...)? $\endgroup$ – Royi Jul 24 '16 at 5:23
  • $\begingroup$ I've edited my question to include more information. $\endgroup$ – Quevun Jul 24 '16 at 6:18
3
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ You're right, I converted it to floating point and smoothed it. The ripples are gone! Thank you so much! $\endgroup$ – Quevun Jul 24 '16 at 11:19
  • $\begingroup$ You're most welcome. Enjoy... $\endgroup$ – Royi Jul 24 '16 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.