I'm trying to downsample my image(using anti-aliasing
) using Python-Pillow's im.thumbnail()
method.
My code looks like:
MAXSIZE = 1024
im.thumbnail(MAXSIZE, Image.ANTIALIAS)
Can you tell me some alternative in opencv-python
to perform this re-sizing operation ?
You can use ffmpeg-python to create a thumbnail and upload it for use with your video. If you don't want to get into learning FFMPEG, you can also use api. video's endpoint that allows you to pick a time from the video, and have it set as the video thumbnail for you automatically.
You can use cv2.resize . Documentation here: http://docs.opencv.org/modules/imgproc/doc/geometric_transformations.html#resize
In your case, assuming the input image im is a numpy array:
maxsize = (1024,1024)
imRes = cv2.resize(im,maxsize,interpolation=cv2.CV_INTER_AREA)
There are different types of interpolation available (INTER_CUBIC, INTER_NEAREST, INTER_AREA,...) but according to the documentation if you need to shrink the image, you should get better results with CV_INTER_AREA.
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