Overlay Canny Edges on Original Image
Hello,
Is there a way to overlay the edges obtained from the Canny Edge Detection onto the original image?
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:
canny:
addition:
copyTo:
addweighted:
Asked: 2015-10-26 16:37:43 -0600
Seen: 8,045 times
Last updated: Oct 26 '15