Billy
Billy

Reputation: 751

How to process the result of OpenCV:: Canny Edge Detection

I try the Canny edge detection algorithm to find the edge of a simple circle.

cv:: Canny() 

The function returns a

cv::Mat edge 

But I do not know how to use these "edge".

My goal is the draw the "edge" back to the original image and read the information within that edge (in this case, the edge is a circle)

I look through the cv:: read function and only find the drawContour function which is not an edge.

And I also do not how to find the coordinate of the edge so that I can do something about the inner part of the circle edge.

I am new to openCV, any suggestion is appreciated.

Upvotes: 0

Views: 1061

Answers (2)

Lyn1993
Lyn1993

Reputation: 11

You need learn how to traverse a cv::Mat object. http://docs.opencv.org/2.4/doc/tutorials/core/how_to_scan_images/how_to_scan_images.html#the-efficient-way

Besides, I suggest u read first few chapters of the book learning opencv to master the basic usage of this library, now there is a third edition. You can also find many examples in "InstallPath\opencv\sources\samples" and the official tutorial: http://docs.opencv.org/2.4/doc/tutorials/tutorials.html

Upvotes: 0

MBo
MBo

Reputation: 80232

edges is array (Mat) of the same size as source picture, and it contains zero pixels and max value (255) pixels at edges that Canny function found

You can emphasize edges at source image (by white color), making bitwise_or operation with edges (in my). Or transform edges to color image to draw color edges. Here is example of using edges as mask.

Edges is raster result. To get set of segments, use findContours function on edges, then you can use drawContours

Note that this information is well-googlable.

Upvotes: 1

Related Questions