Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opencv2: bicubic interpolation while resizing image

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?

like image 272
thetna Avatar asked Sep 22 '14 14:09

thetna


People also ask

Which interpolation is best for image resizing?

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.

Why may interpolation be needed when resizing an image?

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.

What is interpolation in cv2 resize?

Secondly, we have the cv2.INTER_LINEAR method, which performs bilinear interpolation — this is the method that OpenCV uses by default when resizing images.

What is bicubic interpolation in image processing?

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


1 Answers

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

like image 129
The Nomadic Coder Avatar answered Oct 29 '22 12:10

The Nomadic Coder