Ask Your Question
1

canny edge detection with two input arrays

asked 2017-08-29 15:25:13 -0500

2ros0 gravatar image

updated 2017-08-29 15:26:15 -0500

Hi,

I saw a version of the canny function with two input arrays in the samples/cpp/edge.cpp. Here is a code excerpt:

/// Canny detector with scharr
Mat dx,dy;
Scharr(blurImage,dx,CV_16S,1,0);
Scharr(blurImage,dy,CV_16S,0,1);
Canny(dx, dy, edge2, edgeThreshScharr, edgeThreshScharr*3);
/// Using Canny's output as a mask, we display our result
cedge = Scalar::all(0);
image.copyTo(cedge, edge2);
imshow(window_name2, cedge);

All the documentation/API I can find just has the single input array into canny like so:

void Canny(InputArray image, OutputArray edges, double threshold1, double threshold2, int apertureSize=3, bool L2gradient=false )

And so what am I missing?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
2

answered 2017-09-26 15:25:22 -0500

2ros0 gravatar image

updated 2017-09-26 21:40:45 -0500

This is a new overloaded member function since OpenCV 3.2. It means that you can provide an arbitrary gradient image such as the Scharr gradient to the Canny edge detector using the dx and dy function parameters (initially it was only Sobel).

It doesn't even have to be a standard edge detector. For instance: if you only wanted to detect horizontal edges you could provide dy as a set of zeros and just provide dx by running the appropriate gradient filter over the image.

documentation link

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-08-29 15:25:13 -0500

Seen: 705 times

Last updated: Sep 26 '17