8.1K views

Uploaded by Denis Perevalov

Attribution Non-Commercial (BY-NC)

- Computer Vision as universal controller for interactive media
- OpenCV Lections: 3. Mat class
- OpenCV Lections: 4. Working with the channels, the threshold processing, flood fill
- OpenCV Lections: 7. Working with camera. Background and motion analysis
- opencv
- OpenCV Lections: 5. Smoothing
- OpenCV Lections: 2. Configuring Visual Studio. The first program in OpenCV
- OpenCV Lections: 1. Introduction. Problem of image analysis
- OpenCV Lection: 3D cameras Kinect and Xtion
- What Computer Vision with the OpenCV
- Opencv Tutorials
- Opencv c++ Only
- Android OpenCV Face detection
- Opencv Beginners
- Open Frameworks and OpenCV
- OpenCV Tutorial
- Opencv-0 9 5 Doc Full
- OpenFrameworks lections: Interactive sound
- opencv
- OpenCV Shape Detection - PyImageSearch

You are on page 1of 20

6. Contours

http://howto.nicubunu.ro/gears/gears_16.png

www.uralvision.blogspot.com perevalovds@gmail.com

USU / IMM Fall 2010

The concept of contour

The concept of contour

Contour of the object - A line that represents the edge forms object.

If there is a partition of the image into regions corresponding to different objects, their

external contours can be specified uniquely.

To indicate Interior contours need 3d model of the object. In this case, the contours are the

projection of the image lines of bending 3d object.

http://cvpr.uni-muenster.de/research/rack/index.html

The concept of contour

If given the image that should be allocated contours

but No no partition on the field, no 3d-models

then there ambiguity determine what the circuit

associated with

-scale (How small objects of interest)

-texture (Whether the contours of the elements of texture)

-semantics (Sometimes the line in the image are simply painted on site, and do not reflect

the bending of its shape)

or objects considered as individual leaves?

The concept of contour

Therefore, machine vision is often considered the problem of not finding the contours of

objects, and the search contours on image.

Contour in the image - this is the line along which a jump in brightness or color.

Contours on image moreThan the contours of objects in the image. Therefore, after solving

the problem of finding contours in an image made them an additional analysis to identify

the contours of objects of interest.

Why do I need to find the contour

1. Recognition

Therefore, the contour can often determine the type of object

that we observe.

2. Measurements

their rotation and the location - it is important for industrial

automation, robotics, interactive systems.

Search the contour points

Sobel filter

Mat & dst //Output image size and channels - as in src

int ddepth //Depth of the result, for example, CV_32F

int xorder //Order of the derivative of x

int yorder //Order of the derivative of y

int ksize= 3, //window size: 1, 3, 5, 7

double scale= 1, double delta= 0, //zoom and shift the result

int borderType= BORDER_DEFAULT) //Work with the boundary

Filter performs a Gaussian smoothing and taking the partial derivatives of 1, 2, 3 order, or

mixed (xorder on x, yorder on y).

(Gaussian smoothing can get a result that is resistant to noise in the image.)

Sobel filter

Example

Mat image = imread ("lodka.jpg"); // Load image from disk

imshow ("image", image); // Show image

Mat imageDX, imageDY;

Sobel (image, imageDX, CV_32F, 1, 0, 3, 1.0 / 255.0); // derivative x

Sobel (image, imageDY, CV_32F, 0, 1, 3, 1.0 / 255.0); // derivative of y

Please note that only show positive values. Negative and zero values - are shown in black.

Sobel filter

Example, continued

and take the sqrt (imageDX ^ 2 + imageDY ^ 2) - we underline the contour points.

Applying to them the threshold processing, we obtain a set of contour points.

cvtColor (imageDX, grayX, CV_RGB2GRAY);

cvtColor (imageDY, grayY, CV_RGB2GRAY);

pow (grayX, 2, grayX);

pow (grayY, 2, grayY);

sqrt (contImg, contImg);

contImg.convertTo (temp, CV_8UC3, 255.0);

Mat binary;

threshold (contImg, binary, 0.7, 1.0, CV_THRESH_BINARY);

Sobel filter

Example, continued

Other filters underscore the contour

points

1. Scharr (),

2. Laplacian (),

3. difference of two Gaussians (see the lecture about smoothing).

All the methods considered this shortcoming: they work at the level of individual pixels,

and so get the contours are not continuous smooth lines.

Canny edge detector

contour points Sobel filter, and further vectoring units.

The idea - to trace the contour of moving along the points with

a maximum value of "loop".

The output of the algorithm gives a binary image with the found

pixels corresponding to the contours.

Canny edge detector

void Canny(Const Mat & image //Input image, 1-channel, 8-bit

Mat & edges, //Output image

double threshold1, //Thresholds, the highest - for contour seed

double threshold2, //Smallest - for contour joins

int apertureSize= 3, //window for the Sobel filter

bool L2gradient=false //whether to use the Euclidean length of vector

// as Sobel, sqrt (dx * dx + dy * dy),

// or simply | dx | + | dy |

);

Canny edge detector

Example

Mat imageGray, edges;

cvtColor (image, imageGray, CV_RGB2GRAY);

Canny (imageGray, edges, 230, 150);

Contours vectorization

Trace Contour

construction contour’s vector representation.

processing and analysis of the circuit:

- Modification (rotation, extension).

- Matching, analysis and recognition of objects by their

contours.

Tracing the contours

void findContours(Const Mat & image //Input image

//1-channel, 8-bit

//interpreted as a binary (0 and 0)

vector <vector <Point> > &contours //Found the contours

int mode //The search loops

int method //Method for approximating the contours

Point offset=Point() //shift all rezultruyuschih contours

)

Values mode:

CV_RETR_EXTERNAL - Only the outer contours

CV_RETR_LIST - List all units

Used another form of features, see the documentation:

CV_RETR_CCOMP - 2-level hierarchy - the outer boundaries and holes

CV_RETR_TREE - is a tree of nested loops,

Values method:

CV_CHAIN_APPROX_NONE- Without approximation

CV_CHAIN_APPROX_SIMPLE - vybrasyavaet horizontal and vertical points within the segments

CV_CHAIN_APPROX_TC89_L1, CV_CHAIN_APPROX_TC89_KCOS - approximation methodTeh-Chin

Tracing the contours

Example

vector <vector <Point>> contours;

findContours (edges, contours, CV_RETR_LIST, CV_CHAIN_APPROX_TC89_L1);

drawContours (draw, contours, -1, Scalar (255, 0, 0));

imshow ("find cont", draw);

Contour analysis

characteristics

- The length of the contour

- Area be fenced loop

- The distribution of curvature along the contour

Also, the statistical moments and Fourier transform algorithms for direct

comparison of the contours.

Problems

- If the object is essentially three-dimensional, then its outer contour can vary

during the rotation of the object.

- If the object is blocked by another object, it adds complexity to the recognition

algorithm.

- Computer Vision as universal controller for interactive mediaUploaded byDenis Perevalov
- OpenCV Lections: 3. Mat classUploaded byDenis Perevalov
- OpenCV Lections: 4. Working with the channels, the threshold processing, flood fillUploaded byDenis Perevalov
- OpenCV Lections: 7. Working with camera. Background and motion analysisUploaded byDenis Perevalov
- opencvUploaded byDongpyo Hong
- OpenCV Lections: 5. SmoothingUploaded byDenis Perevalov
- OpenCV Lections: 2. Configuring Visual Studio. The first program in OpenCVUploaded byDenis Perevalov
- OpenCV Lections: 1. Introduction. Problem of image analysisUploaded byDenis Perevalov
- OpenCV Lection: 3D cameras Kinect and XtionUploaded byDenis Perevalov
- What Computer Vision with the OpenCVUploaded byDenis Perevalov
- Opencv TutorialsUploaded byLili Saab
- Opencv c++ OnlyUploaded byd-fbuser-119595565
- Android OpenCV Face detectionUploaded bypi194043
- Opencv BeginnersUploaded byRishabh Mehan
- Open Frameworks and OpenCVUploaded byDenis Perevalov
- OpenCV TutorialUploaded byapi-24457305
- Opencv-0 9 5 Doc FullUploaded byworkhardplayhard
- OpenFrameworks lections: Interactive soundUploaded byDenis Perevalov
- opencvUploaded byellany mutiara
- OpenCV Shape Detection - PyImageSearchUploaded byAnonymous rTTJELcsut
- Obukhov OpenCV Rev5Uploaded bySiddharth Purohit
- OpenCVReferenceManualUploaded byChayan Halder
- Stavens Opencv Optical FlowUploaded byapi-3709615
- Opencv2Uploaded byAdriano Raia
- OpenFrameworks lection: 2d graphicsUploaded byDenis Perevalov
- Opencv TutorialUploaded byBilgi Sayar
- OpenCV InstallUploaded byj54willis
- Contour Detection My Ppt (1)Uploaded bylahari
- Using OpenCV With MFCUploaded byLã Thế Long
- opencv2refmanUploaded bysndupont

- SYNC2013_AppForm_A_ENUploaded byDenis Perevalov
- SYNC2013_AppForm_B_ENUploaded byDenis Perevalov
- SYNC 2013 EN FullUploaded byDenis Perevalov
- OpenFrameworks_lection_07Uploaded byDenis Perevalov
- OpenFrameworks lections: 1. Interactive multimedia systems.Uploaded byDenis Perevalov
- OpenCV Lection: 3D cameras Kinect and XtionUploaded byDenis Perevalov
- Lections on Open FrameworksUploaded byDenis Perevalov
- OpenCV Lections: 5. SmoothingUploaded byDenis Perevalov
- What Computer Vision with the OpenCVUploaded byDenis Perevalov
- Shaders in OpenFrameworksUploaded byDenis Perevalov
- Algorithms for Media-ArtistsUploaded byDenis Perevalov
- OpenFrameworks lections: Interactive soundUploaded byDenis Perevalov
- Open Frameworks and OpenCVUploaded byDenis Perevalov
- OpenFrameworks: Introduction to Computer VisionUploaded byDenis Perevalov
- OpenCV Lections: 1. Introduction. Problem of image analysisUploaded byDenis Perevalov
- OpenFrameworks lection: 2d graphicsUploaded byDenis Perevalov
- Viola-Jones algorithm with two-point featuresUploaded byDenis Perevalov
- OpenCV Lections: 2. Configuring Visual Studio. The first program in OpenCVUploaded byDenis Perevalov
- Что может и не может OpenCVUploaded bycaptain_arctic

- Econ 704Uploaded byindra
- Session_11_Fluid_Effects_in_Maya.pdfUploaded byNguyễn Huỳnh
- CCFP4.0-RDBMSAssignmentsUploaded byD-suman
- 02 Klein System Engineering and CATIAUploaded byYuriy
- 2017 c Formula SheetUploaded byJustine Powell
- Krus Wal IUploaded byNarmi
- Attribs of Output PrimitivesUploaded byVenkatakrishnan Subramaniyan
- Two Tailed Hypothesis TestUploaded bysanjeevlr
- BlueprintUploaded by1414646
- Charan SQLUploaded byNagendra Kashyap
- Autocad Lecture 5Uploaded bykavogt
- a05d4Lecture7 and 8Uploaded byPallavi Dasgupta
- -HDLUploaded byjosesmn
- 13fa-3680-11c-sqlUploaded bybenben08
- Article Virtual Design and Construction Mark Van RijsbergenUploaded byjose_guerra_73
- Computer Graphics (Video)Uploaded byViji Chinnappan
- Expected Value of Discrete Random Variable PDFUploaded byJennifer
- Engineering Standards Consults PresentationUploaded byTakrama Michael
- FSD- Class Diagram Week 6Uploaded bySreePrakash
- UT Dallas Syllabus for stat3355.501 05s taught by Dan Watson (daw016600)Uploaded byUT Dallas Provost's Technology Group
- Excel Data Analysis Modeling and Simulation Download PDFUploaded byChristina
- sqlUploaded byBABAI5S
- A Review on Removal of Shadow from a Single ImageUploaded byInternational Journal for Scientific Research and Development - IJSRD
- Case Tools StudyUploaded byPrabhavathi Aadhi
- Petri NetsUploaded byWael Abdulal
- Machine Learning AssignmentsUploaded byUjesh Maurya
- cse8Uploaded byshiblikalayath
- SQL_NotesUploaded bykwsephiroth
- Deep Learning Essentials 1Uploaded byget_together
- ch06-BasicSQLUploaded bycmpatel.chem