Ask Your Question
1

Overlay Canny Edges on Original Image

asked 2015-10-26 16:37:43 -0600

wes101 gravatar image

updated 2020-12-09 08:46:35 -0600

Hello,

Is there a way to overlay the edges obtained from the Canny Edge Detection onto the original image?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2015-10-26 17:15:18 -0600

theodore gravatar image

updated 2015-10-26 18:49:19 -0600

you can blend the two images with addweighted() function or you can just apply something like src += canny_image; but you will need first convert your canny image to bgr.

Mat dst, detected_edges;
Canny( gray, detected_edges, 30, 100, 3 );

imshow("canny", detected_edges);

dst = Scalar::all(0);

Mat addweight;
src.copyTo( dst, detected_edges); // copy part of src image according the canny output, canny is used as mask
cvtColor(detected_edges, detected_edges, CV_GRAY2BGR); // convert canny image to bgr
addWeighted( src, 0.5, detected_edges, 0.5, 0.0, addweight); // blend src image with canny image
src += detected_edges; // add src image with canny image

imshow("addition", src );
imshow("copyTo", dst );
imshow("addwweighted", addweight );
waitkey();

source:

image description

canny:

image description

addition:

image description

copyTo:

image description

addweighted:

image description

edit flag offensive delete link more

Comments

Thank you!

wes101 gravatar imagewes101 ( 2015-10-27 04:30:59 -0600 )edit

Question Tools

3 followers

Stats

Asked: 2015-10-26 16:37:43 -0600

Seen: 8,387 times

Last updated: Oct 26 '15