Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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 artefacts a blur should be applied before resizing. Therefore I opted for the [Gaussian Blur] (https://docs.opencv.org/2.4/modules/imgproc/doc/filtering.html?highlight=gaussianblur#gaussianblur). 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: image description

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 = samplerate/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.

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 artefacts distortion a blur should be applied before resizing. Therefore I opted for the [Gaussian Blur] (https://docs.opencv.org/2.4/modules/imgproc/doc/filtering.html?highlight=gaussianblur#gaussianblur). 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: image description

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 = samplerate/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.

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 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: image description

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 = samplerate/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.

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: image description

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 = samplerate/pidownscale/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.