OpenCV: Difference between revisions

411 bytes added ,  13 April 2022
Line 103: Line 103:


img = cv2.imread('messi5.jpg')
img = cv2.imread('messi5.jpg')
new_img = cv2.resize(img, (500,200), interpolation = cv.INTER_CUBIC)
# Resize to resolution
new_img = cv2.resize(img, (500,200), interpolation=v2.INTER_CUBIC)
# Resize by factor
cv2.resize(img, (0, 0), fx=1/4, fy=1/4, interpolation=cv2.INTER_AREA)
</syntaxhighlight>
</syntaxhighlight>
;Interpolation options
* INTER_NEAREST
* INTER_LINEAR
* INTER_CUBIC
* INTER_AREA
* INTER_LANCZOS4
For downscaling, use `INTER_AREA` to avoid aliasing. However, `INTER_NEAREST` will give the the optimal speed.
For upscaling, use `INTER_CUBIC` for best results or `INTER_LINEAR` for best performance.


==Video==
==Video==