8.1K views

Uploaded by Denis Perevalov

save

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.

- Opencv TutorialsUploaded byLili Saab
- opencvUploaded byellany mutiara
- OpenCV Lections: 5. SmoothingUploaded byDenis Perevalov
- opencvUploaded byDongpyo Hong
- OpenCV TutorialUploaded byapi-24457305
- OpenCV Lections: 1. Introduction. Problem of image analysisUploaded byDenis Perevalov
- OpenCV Lection: 3D cameras Kinect and XtionUploaded byDenis Perevalov
- Opencv BeginnersUploaded byRishabh Mehan
- 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
- Opencv c++ OnlyUploaded byd-fbuser-119595565
- OpenCV Lections: 2. Configuring Visual Studio. The first program in OpenCVUploaded byDenis Perevalov
- OpenCV Lections: 3. Mat classUploaded byDenis Perevalov
- Open Frameworks and OpenCVUploaded byDenis Perevalov
- What Computer Vision with the OpenCVUploaded byDenis Perevalov
- opencvUploaded byokram87
- Opencv-0 9 5 Doc FullUploaded byworkhardplayhard
- Opencv TutorialUploaded byBilgi Sayar
- OpenCV Installation and Getting Started GuideUploaded byBoyke
- Obukhov OpenCV Rev5Uploaded bySiddharth Purohit
- Android OpenCV Face detectionUploaded bypi194043
- OpenCVReferenceManualUploaded byChayan Halder
- Stavens Opencv Optical FlowUploaded byapi-3709615
- Opencv Object TrackingUploaded byrazimi99
- Opencv2Uploaded byAdriano Raia
- OpenFrameworks lection: 2d graphicsUploaded byDenis Perevalov
- OpenCV Shape Detection - PyImageSearchUploaded byAnonymous rTTJELcsut
- OpenFrameworks lections: Interactive soundUploaded byDenis Perevalov
- Computer Vision as universal controller for interactive mediaUploaded byDenis Perevalov
- OpenCV InstallUploaded byj54willis

- OpenCV Lection: 3D cameras Kinect and XtionUploaded byDenis Perevalov
- Lections on Open FrameworksUploaded byDenis Perevalov
- OpenFrameworks: 2d-графикаUploaded byDenis Perevalov
- OpenFrameworks: Introduction to Computer VisionUploaded byDenis Perevalov
- Open Frameworks и OpenCVUploaded byDenis Perevalov
- SYNC 2013 EN FullUploaded byDenis Perevalov
- Shaders in OpenFrameworksUploaded byDenis Perevalov
- OpenFrameworks lection: 2d graphicsUploaded byDenis Perevalov
- OpenFrameworks lections: Interactive soundUploaded byDenis Perevalov
- SYNC2013_AppForm_B_ENUploaded byDenis Perevalov
- Шейдеры в OpenFrameworksUploaded byDenis Perevalov
- Open Frameworks and OpenCVUploaded byDenis Perevalov
- Viola-Jones algorithm with two-point featuresUploaded byDenis Perevalov
- SYNC2013_AppForm_A_ENUploaded byDenis Perevalov
- Algorithms for Media-ArtistsUploaded byDenis Perevalov
- OpenFrameworks_lection_07Uploaded byDenis Perevalov
- perevalov_21May2010Uploaded byDenis Perevalov
- 44527812-Лекции-OpenCV-6-Выделение-контуровUploaded bydmt_463221966
- OpenCV Lections: 1. Introduction. Problem of image analysisUploaded byDenis Perevalov
- Что может и не может OpenCVUploaded bycaptain_arctic
- Openframeworks_lection_06Uploaded 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
- OpenCV Lections: 2. Configuring Visual Studio. The first program in OpenCVUploaded byDenis Perevalov
- OpenCV Lections: 3. Mat classUploaded byDenis Perevalov
- OpenFrameworks lections: 1. Interactive multimedia systems.Uploaded byDenis Perevalov
- What Computer Vision with the OpenCVUploaded byDenis Perevalov
- Computer Vision as universal controller for interactive mediaUploaded byDenis Perevalov

- Microsoft Visual Studio 2010. Księga ekspertaUploaded byhelionsa
- Actividad 1 de 2Uploaded byAlfredo Guevara M
- NERC CIP 2-Factor Authentication Process Flow V3Uploaded byRoby Raj
- VPN Lite 400G Manual (1)Uploaded byKimmy Panday
- MAKE KEYGEN TUTORIALUploaded byBeck Kain
- Actividad5_Arquitectura de ComputadorasUploaded bydracopast
- s7plcsim_advanced_readme_en-US_en-US.pdfUploaded byDalethSepúlveda
- Splunk AWS DocumentationUploaded bybobwillmore
- Release Notes WizconUploaded bylettolima
- TutorialUploaded byR̶o̶m̶m̶e̶l̶ ̶A̶r̶a̶c̶a̶
- Internet ProgrammingUploaded bySaravanan Pa
- 9.2 Elaboracion Del RegistroUploaded bysayumi1692
- MongoDB ExpoUploaded byWellis Gilberto Arevalo Cordova
- Template Config Alu7750 Bng_dhcp Relay_radius Auth.Uploaded byAgung Aryo
- Ataques Básicos Con Kali Linux _ RavmnUploaded byhgola
- ApplyingReinforcementLearningToTetris Donald Carr RU AC ZAUploaded bykorch23
- p1450.1-D14Uploaded byRajeev Varshney
- Anti VirusUploaded bytatituta
- DipUploaded byLokesh Ch
- MSFTbriefing Leistungsbeschreibung: Windows 10 - Client-StrategieUploaded byAvispador - die neue Beratungskultur seit 2014
- Instalacion ida de Windows XP Con DEPLOYUploaded byfranpancho620
- Chapter 2. Network Monitoring and MeasurementUploaded byAhmad Rizki Faizal
- AR235-275_SM_PLUploaded byCristian Bobaru
- Speech System for Dumb PeopleUploaded byJaspreet Singh Walia
- Assignment1 Network Based Scientific CalculatoreUploaded bytesfu
- 1 Using the Samsung Series 7 Slate Windows 8 Consumer PreviewUploaded bykq201
- GitLab Docker ImagesUploaded byWalter Angolar Da Silva
- TE_FPR_24052011Uploaded byRaul Rosado
- In memory databesesUploaded byRenato Sirovina
- On-Chip Network-Enabled Multicore Platforms.pdfUploaded byvenkatmusala