Image Operations
Learn how to perform basic image operations in OpenCV, including resizing, cropping, rotating, flipping, and applying various filters to images.Reading and Displaying Images
Before performing any operations, you need to load an image:- Python
- C++
Resizing Images
Resize images to specific dimensions or by a scale factor:- Python
- C++
Interpolation methods:
INTER_LINEAR: Bilinear interpolation (default)INTER_AREA: Best for shrinking imagesINTER_CUBIC: Bicubic interpolation for enlargingINTER_LANCZOS4: Lanczos interpolation over 8x8 neighborhood
Cropping Images
Crop images using array slicing:- Python
- C++
Rotating Images
Simple 90-degree Rotations
- Python
- C++
Arbitrary Angle Rotation
- Python
- C++
Flipping Images
- Python
- C++
Image Filtering and Smoothing
Gaussian Blur
Remove noise and detail from images:- Python
- C++
Median Blur
Excellent for removing salt-and-pepper noise:- Python
- C++
Bilateral Filter
Smooths images while preserving edges:- Python
- C++
Complete Example: Image Processing Pipeline
- Python
- C++
When working with images, always check if the image was loaded successfully before performing operations. Use
if img is None: in Python or if (img.empty()) in C++.Additional Operations
Color Space Conversion
Color Space Conversion
Convert between different color spaces:
Image Thresholding
Image Thresholding
Create binary images:
Next Steps
- Learn about Video Processing for working with video streams
- Explore Feature Detection for finding keypoints in images
- Master Object Detection to identify objects in images
