I would like to do image resizing using the app cv2.resize
. I would like to do
bicubic interpolation while resizing. How would I do it?
Bilinear interpolation Linear (or bilinear, in two dimensions) interpolation is typically good for changing the size of an image, but causes some undesirable softening of details and can still be somewhat jagged.
Image interpolation occurs when you resize or distort your image from one pixel grid to another. Image resizing is necessary when you need to increase or decrease the total number of pixels, whereas remapping can occur when you are correcting for lens distortion or rotating an image.
Secondly, we have the cv2.INTER_LINEAR method, which performs bilinear interpolation — this is the method that OpenCV uses by default when resizing images.
In image processing, bicubic interpolation is often chosen over bilinear or nearest-neighbor interpolation in image resampling, when speed is not an issue. In contrast to bilinear interpolation, which only takes 4 pixels (2×2) into account, bicubic interpolation considers 16 pixels (4×4).
img = cv2.imread('source to image here')
img_resized = cv2.resize(img, fx=scale_x, fy=scale_y, interpolation=cv2.INTER_CUBIC)
I haven't tested it out. Check http://docs.opencv.org/modules/imgproc/doc/geometric_transformations.html#resize for more details
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