Is there a built-in way to downsample an image in OpenCV 2.3.1 without prior Gaussian smoothing (which is performed by pyrDown C++ function).
Thanks.
Gaussian blurring is commonly used when reducing the size of an image. When downsampling an image, it is common to apply a low-pass filter to the image prior to resampling. This is to ensure that spurious high-frequency information does not appear in the downsampled image (aliasing).
According to Adobe, when you decrease the number of pixels (downsampling), the application removes data. When data is removed the image also degrades to some extent, although not nearly as much as when you upsample.
To avoid aliasing, a signal must not contain frequencies that are higher than one half the sample rate. Likewise, an input image must not contain details that are smaller than one pixel in the output image. This can be accomplished by appropriately filtering the signal or blurring the image before resampling it.
If a discrete-time signal's baseband spectral support is not limited to an interval of width 2 π / M radians, downsampling by M results in aliasing. Aliasing is the distortion that occurs when overlapping copies of the signal's spectrum are added together.
Maybe you're looking for resize().
# Python code:
import cv2
large_img = cv2.imread('our_large_image.jpg')
small_to_large_image_size_ratio = 0.2
small_img = cv2.resize(large_img, # original image
(0,0), # set fx and fy, not the final size
fx=small_to_large_image_size_ratio,
fy=small_to_large_image_size_ratio,
interpolation=cv2.INTER_NEAREST)
Instead of interpolation=cv2.INTER_NEAREST
you can use any of these interpolation methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With