How to choose sigma/kernel size when downsampling image
Hello!
I simply want to downscale an image using cv2.resize() and I read that to avoid visual distortion, a blur should be applied before resizing. Therefore I opted for the Gaussian Blur. However, I couldn't find how the downscale factor relates to the either the sigma for the blur nor the kernel size of the gaussian.
On the wikipedia page for gaussian filtering I found the equation linking the cut off frequency to the sigma:
Which means for a cutoff frequency of 1/(2*M) (with M being the downsample factor, and the cutoff frequency chosen to at least reach the Nyquist frequency - from the wikipedia page on anti-aliasing), the formula should be sigma = downscale/pi
. This somewhat roughly matches with what skimage uses to calculate the sigma from the downsample factor sigma = 2 * downscale / 6.0
(source)
My question is: is this correct? I was surprised not to be able to find any tutorials or forum posts/discussions on this.
Lack of posts may mean that is is old folklore and totally unnecessary unless perhaps a nearest neighbour algorithm is used and not a more sophisticated one. I've never seen anyone do it.
see the documentation
To shrink an image, it will generally look best with INTER_AREA interpolation, whereas to enlarge an image, it will generally look best with c::INTER_CUBIC (slow) or INTER_LINEAR (faster but still looks OK).