# 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. 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. Why is the Gaussian filter creating more noise when it's suppose to get rid of them? How should I deal with this?

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

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.
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.