How to Get Rid of Ripples from a Gradient Image of a Smoothed Image?
I think it happens due to 2 things:


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