1

我是图像处理的新手,我需要计算图像中存在的边缘强度。假设您有一张图像,并为该图像添加了模糊效果。这两个图像的边缘强度不同。我需要分别计算两个图像边缘强度。

到目前为止,我已经使用下面的代码对图像进行了精明的边缘检测。

  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;

有什么方法可以计算这个边缘图像的强度..?

4

1 回答 1

0

mean will give you the mean value of your image. If you're using Canny as above you can do:

Scalar pixelMean = mean(draw);

To get the mean of only the edge pixels, you would use the image as the mask as well:

Scalar edgeMean = mean(draw, draw);

Unfortunately, since Canny sets all edge pixels to 255, your mean will always be 255. If this is the measure you're looking for, you'll probably want to use Sobel (after Gaussian Blur) and calculate the gradients to get the relative edge strengths.

于 2014-11-21T18:11:21.377 回答