I am new to image processing and I need to calculate the strength of edges present in an image. Assume a situation where you have an image and you add blur effect to that image. The strength of the edges of these two images are different. I need to calculate that edge strength for both images separately.
So far I have got the canny edge detection of the image using the code below.
Mat src1;
src1 = imread("D.PNG", CV_LOAD_IMAGE_COLOR);
namedWindow("Original image", CV_WINDOW_AUTOSIZE);
imshow("Original image", src1);
Mat gray, edge, draw;
cvtColor(src1, gray, CV_BGR2GRAY);
Canny(gray, edge, 50, 150, 3);
edge.convertTo(draw, CV_8U);
namedWindow("image", CV_WINDOW_AUTOSIZE);
imshow("image", draw);
waitKey(0);
return 0;
Is there any method to calculate of the strength of this edge image..?
mean
will give you the mean value of your image. If you're usingCanny
as above you can do:To get the mean of only the edge pixels, you would use the image as the mask as well:
Unfortunately, since
Canny
sets all edge pixels to255
, your mean will always be255
. If this is the measure you're looking for, you'll probably want to useSobel
(after Gaussian Blur) and calculate the gradients to get the relative edge strengths.