Block 113: Geometric Transformations
Resize, crop, rotate, and flip images.
Concepts
- cv2.resize() with interpolation methods
- Cropping via array slicing: img[y1:y2, x1:x2]
- cv2.rotate() and cv2.warpAffine()
- cv2.flip()
Code Examples
See exercise below.
Exercise
Resize an image to 50% and 200% of original. Display both. Rotate an image 45° around its center without cropping (use warpAffine with full canvas).
Homework
What is interpolation in image resizing? Compare INTER_NEAREST vs INTER_CUBIC visually.