findcontourscv

Finds and draws contours in an image.

Syntax

R = findcontourscv(handle, mode, method...)

R = findcontourscv(handle, mode, method, offset, color, thickness, type)

Inputs

handle
Handle of an image.
Type: integer
mode
Contour retrieval mode. Valid values are:
0
Mode cv::RETR_EXTERNAL: Retrieves extreme outer contours.
1
Type cv::RETR_LIST: Retrieves all contours.
2
Type cv::RETR_CCOMP: Retrieves contours, organizes in 2-level hierarchy.
3
Type cv::RETR_TREE: Retrieves contours, reconstructs full hierarchy of nested contours.
4
Type cv::RETR_FLOODFILL
Type: integer
method
Contour approximation method. Valid values are:
1
Mode cv::CHAIN_APPROX_NONE: Stores all contour points.
2
Type cv::CHAIN_APPROX_SIMPLE: Compresses horizontal, vertical and diagonal segments.
3
Type cv::CHAIN_APPROX_TC89_L1: Applies a flavor of Teh-Chin chain approximation algorithm.
4
Type cv::CHAIN_APPROX_TC89_KCOS: Applies a flavor of Teh-Chin chain approximation algorithm.
Type: integer
offset
Optional offset by which every contour point is shifted. Must be a two-element integral vector.
Type: vector
color
Optional color used for drawing contours. If no color is specified, randomized colors are used. If specified, it must be a 3-element integral vector.
Type: vector
thickness
Optional parameter specifying the thickness of the contour line drawn. Default value is 1.
Type: integer
type
Optional parameter specifying the type of contour drawn. Default value of type is 8. Valid values are:
1
cv::FILLED: Filled line.
4
cv::LINE_4: Line is drawn using 4-connected Bresenham algorithm.
8(default)
cv::LINE_8: Line is drawn using 8-connected Bresenham algorithm.
16
cv::LINE_AA: Antialiased line.
Type: integer

Outputs

R
Handle of the output image.
Type: integer

Example

Find and draw contours:
src = imreadcv('cv2.jpg');
mode = 0;
method = 2;
R = findcontourscv(src, mode, method);


Figure 1. Input image


Figure 2. Output image