Ask Your Question
0

Edge Change Ratio - Detect edge pixels using Canny's Algo

asked 2013-05-01 18:44:28 -0500

Hi. I am newbie to OpenCv and doing a project on video shot detection. I wish to implement ECR(Edge change Ratio) using Canny Edge detector. I got the Edges using function for Canny algo. But now I want to use get number of edge pixels from that image. How to do that?

And if Anyone is having some experience with ECR please help me in finding number of entering and exiting pixels between two frames.

Thank You

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2013-05-02 04:00:00 -0500

Guanta gravatar image

From Canny you get an output map with all edges, pass this edge-matrix to findContours() and you will get a vector of all contourpoints for each contour, i.e. for each contour you'll get the number of edge-points simply by the length of the containing points, here an example:

cv::Mat edges;
cv::Canny(img, edges, 50, 200);
std::vector<std::vector<cv::Point> > contours;
std::vector<cv::Vec4i> hierarchy;
cv::findContours(edges, contours, hierarchy, CV_RETR_LIST, CV_CHAIN_APPROX_NONE);
// if you want the number of edge pixels of the first contour:
size_t num_edge_pts_contour0 = contours[0].size();
edit flag offensive delete link more

Comments

Thanks for the help. Do you have some experience with the ECR algorithm. Or can you help me in finding out the entering and exiting pixels of the frames. Here is a small definition of entering and exiting pixels to help you know what I am looking for.

The entering edge pixel is the edge pixels that is present in current frame E and is farther away than r in next frame E’. The exiting edge pixel is the edge pixel that is present in the next frame E’ and is farther away than r in current frame E.

pratpor gravatar imagepratpor ( 2013-05-03 14:05:10 -0500 )edit

If you do it this way you need to somehow register your edges. Why do you not use the original algorithm? In their paper http://www.fischlar.dcu.ie/Papers/AlgthmEdge.pdf ("An Algorithm for Detecting and Classifying Scene Breaks in MPEG Video Bit Streams") they describe how they compute p_in and p_out. Maybe you also want to read: Ramin Zabih, Justin Miller, Kevin Mai: "A feature-based algorithm for detecting and classifying production effects." In: Multimedia Systems Vol. 7, 1999, S. 119–128.

Guanta gravatar imageGuanta ( 2013-05-04 06:30:33 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2013-05-01 18:44:28 -0500

Seen: 1,410 times

Last updated: May 02 '13