Skip to main content
The Image Processing (imgproc) module provides a comprehensive suite of image processing functions for filtering, geometric transformations, color space conversions, and feature detection.

Overview

From opencv2/imgproc.hpp:48-52:
This module offers a comprehensive suite of image processing functions, enabling tasks such as filtering, geometric transformations, color space conversions, histograms, structural analysis, and feature detection.

Filtering

Linear and non-linear image filtering operations

Transforms

Geometric transformations like resize, rotate, warp

Color Spaces

Conversions between BGR, HSV, Lab, and other formats

Feature Detection

Edge detection, corner detection, and shape analysis

Image Filtering

From imgproc.hpp:54-84, OpenCV provides various filtering operations:

Linear Filters

Morphological Operations

From imgproc.hpp:216-241:

Derivatives and Gradients

Geometric Transformations

From imgproc.hpp:90-127, geometric transformations deform the pixel grid:

Resizing and Interpolation

Affine Transformations

Perspective Transformations

Remapping

Color Space Conversions

From imgproc.hpp:158-172:

Thresholding

Edge Detection

Example from samples/cpp/edge.cpp:

Histograms

Contours and Shapes

Drawing Functions

From imgproc.hpp:130-156:

Distance Transform

Connected Components

Image Moments

Hough Transforms

Watershed Segmentation

Template Matching

Practical Example: Image Enhancement

Best Practices

Border Handling: Most filtering functions need to extrapolate pixels outside image boundaries. Choose the appropriate border type:
  • BORDER_REPLICATE - Good for most filtering
  • BORDER_REFLECT_101 - Better for derivatives
  • BORDER_CONSTANT - When you need specific padding values
Interpolation: Choose interpolation based on your needs:
  • INTER_NEAREST - Fastest, but lowest quality
  • INTER_LINEAR - Good balance of speed and quality
  • INTER_AREA - Best for downsampling
  • INTER_CUBIC - Best quality for upsampling
  • INTER_LANCZOS4 - Highest quality, slowest

Source Reference

Key header: ~/workspace/source/modules/imgproc/include/opencv2/imgproc.hpp