OpenCV demonstrator - Function list

Below you can find the list of functions and demonstrations currently handled by the MMI:

DerivationGradient computingThe gradient means computing the partial derivative (along the x and y dimensions) of an image. Because at the coutours of objects the gradient is often high, the gradient computing has many applications in image processing. This demonstration enables you to compute the gradient, with different possible masks and pre-filtering levels.
Gradient computing
Laplacian computingThe laplacian is the sum of the second derivative along x and y axis. This operator finds a lot of applications. For instance, at the contours point of an image, the laplacian cancels.
Laplacian computing
Image sharpeningThe laplacian is used to enhance the contours of an image. To do this, a fraction of the laplacian is substracted to the image itself.
Image sharpening
ContoursCanny edge detectorThe Canny algorithm is a multi-steps method to localize the contour points in an image. It is based on the gradient of an image, the selection of local maxima of the gradient magnitude in the direction of the gradient, and finally a thresholding with histerys to suppress false positives (isolated contour points).
Canny edge detector
Contours delimitationThis example enable to test the contour separation algorithm, that is the function findContours() of OpenCV. As input, this function takes a contour mask (typicaly the output of the Canny() function), and computes the contours of the different objects in the image.
Contours delimitation
Hough transformHough transform (lines)The Hough transform is a robust method to detect lines or segments. The OpenCV implementation makes use of the Canny algorithm to detect contour points. Thus, there are two thresholds to tune. This demonstration allows you to test lines detection with OpenCV, with the standard method and with the probabilist variant (segments detection).
Hough transform (lines)
Hough transform (circles)The Hough transform can also be adapted to detect circles. In this case, the parameter space has 3 dimensions: center position (x,y) and radius. In practice, so as to reduce the complexity, the search is done in two steps: (1) localization of potential centers using the image gradient (at the circle contour, the gradient points toward the center), and then radius computation.
Hough transform (circles)
Quadrilateral object detectionQuadrilateres detection et automatic perspective correction. This demonstration is based on the tutorial Automatic perspective correction for quadrilateral objects, which can be found at the following address: The algorithm is based on the following steps: (1) Contours detection (Canny algorithm), (2) Hough transform (probabilist variant), (3) Localization of the intersections points between the previously detected lines, (4) Estimation of a polygone from these points et verification that it is in fact a quadrilatere, (5) Application of a perspective transform.
Quadrilateral object detection
HistogramsHistogram computingThe histogram is an estimate of the distribution of the pixels on one or several images. This demonstration enables you to compute the RGB, HSV or luminance histogram.
Histogram computing
Histogram equalizationHistogram equalization consists in enhancing image constrast by better using the range of possible pixel values. Attention : the equalization of composants other than luminance (example: RGB equalization) can make artificial colors (not present in the original image) appear.
Histogram equalization
BackprojectionYou can select with the mouse a rectangular area in the input image. This zone will be used to compute the reference histogram. From this histogram, the backprojection algorithm compute for each pixel of the whole image the probability that it is of the same type that one of the selected area. It can be helpful to locate similar (of the same hue) objects on an image, or to follow a moving object (fundation of the camshift algorithm).
SegmentationThresholdingImage thresholding (for gray levels images) enables you to select only the pixels which value is above a given threshold. The threshold can be: (1) fixed, (2) automaticaly computed from the image (Otsu algorithm), (3) adaptative, in which case the mean value in the neighborhood of each pixel is taken into account. This enables to dimish the impact of luminosity variation accros the image.
Distance transformThe distance transform consists in, from a binary image, computing the distance between each pixel and the nearest black pixel.
Distance transform
Foreground detection (grabcut)Background / foreground separation, based on the coarse prelocalisation of the foreground using an outer rectangle. Note : The seperation could be enhanced by selecting manually other points as being foreground or background.
Foreground detection (grabcut)
Watershed segmentation (unsupervised)This demonstration is based on the following tutorials: Image Segmentation with Watershed Algorithm (, et Image Segmentation using Unsupervised Watershed Algorithm with an Over-segmentation Reduction Technique ( It allows to segment different objects, even if they are close. It can be useful to count similar objects on a image. The principle is to localize the initial seeds positions for the watershed algorithm with thresholding and morphological operations.
Watershed segmentation (unsupervised)
Basic image processingFilteringThis demonstration enables you to try some linear (moving average, gaussian) and non linear (median, bilateral) filters, on image with tunable level of noise (white noise and salt and pepper noise).
Morphological operationsThis demonstration enables you to try several morphological operators (dilatation, erosion, closing, opening, gradient, etc.), with different kernel shapes and sizes. Morphological operations have many applications ; they are in particular used to reduce the impact of noise and to select the dimension of the interest objects before applying an image segmentation.
Morphological operations
Fourier transformThis demonstration of the DFT (Discret Fourier Transform) is based on the sample discrete_fourier_transform.cpp included in OpenCV.
Fourier transform
Cascad detectorsFace detectionFace detection (frontal view), default cascad classifier included in OpenCV.
Face detection
Eye detectorEyes detection, default cascad classifier included in OpenCV.
Eye detector
Car platesCar plates detection (russian models), default cascad classifier included in OpenCV.
Car plates
Interest points and features detectionCorner / interest point detectionThis demonstration allows you to test different interest points detectors included in OpenCV (Harris, FAST, ORB). Interest points have a lot of applications: they are used especially to find correspondances between several images (exemple: realization of panorama from different photographies).
Corner / interest point detection
MatchingThis demonstration allows to test interest point matching from 2 images. This demonstration is freely inspired from the OpenCV tutorial "Features2D + Homography to find a known object" (
Video processingOptical flowThe optical flow is an estimate of the speed of objects in the image (direction and absolute value). There are two kinds of algorithm: (1) Dense algorithms, which try to compute the optical flow on each pixel, (2) Sparse algorithms, which try to compute the optical flow only on interest points, choosen at positions where the optical flow can be estimated reliably (good conditionning). This demonstration allows you to test the OpenCV implementation of Farneback algorithm (dense optical flow).
Optical flow
Background substractionThis demonstration allows you to test the background substraction algorithms included in OpenCV. Background substraction can be useful to detect moving or ponctual objects on a fixed or slow-changing background.
Background substraction
Object tracking (camshift)The camshift algorithm allows you to track a moving object. The detection is based on histogram backprojection.
Object tracking (camshift)
PhotographyPanoramas (image stiching)This demonstration allows you to make a panorama from different images. It is based on the stitching module of OpenCV.
Panoramas (image stiching)
High definition (HDR)This demonstration enables you to fusion low resolution (8 bits) image, using the HDR module of OpenCV.
High definition (HDR)
Image inpaintingThis demonstation enables you to test the inpainting function of OpenCV. You can use the mouse to selet the area to repair (click on the image).
Image inpainting
3D processingCamera calibrationThis little demonstration enables to test the camera calibration functions included in OpenCV. To simplify, only one image is used to compute the camera matrix, but the results could be more accurate with more than one image. Note how the line are improved (look at the edge of the chessboard on both images). This demonstration is based on the sample calibration.cpp included in OpenCV, and the image is taken from the same sample.
Camera calibration
Disparity mapCompute the disparity map between two images, which must have been correctly rectified before (the images must be vertically aligned).
Disparity map