Marr-Hildreth 边缘检测 OpenCV C++实现
2021-01-30 02:13
标签:color 实现 ros https 代码实现 term pre -o kernel
原图: 结果图: Marr-Hildreth 边缘检测 OpenCV C++实现 标签:color 实现 ros https 代码实现 term pre -o kernel 原文地址:https://www.cnblogs.com/ybqjymy/p/12821819.html算法原理
C++代码实现
1 Mat MarrEdgeDetection(Mat src, int kernelDiameter, double sigma) {
2 int kernel_size = kernelDiameter / 2;
3 Mat kernel(kernelDiameter, kernelDiameter, CV_64FC1);
4 for (int i = -kernel_size; i ) {
5 for (int j = -kernel_size; j ) {
6 kernel.atdouble>(i + kernel_size, j + kernel_size) = exp(-((pow(j, 2) + pow(i, 2)) /
7 (pow(sigma, 2) * 2)))
8 * (((pow(j, 2) + pow(i, 2) - 2 *
9 pow(sigma, 2)) / (2 * pow(sigma, 4))));
10 }
11 }
12 Mat laplacian(src.rows - kernel_size * 2, src.cols - kernel_size * 2, CV_64FC1);
13 Mat dst = Mat::zeros(src.rows - kernel_size * 2, src.cols - kernel_size * 2, CV_8UC1);
14 for (int i = kernel_size; i ) {
15 for (int j = kernel_size; j ) {
16 double sum = 0;
17 for (int x = -kernel_size; x ){
18 for (int y = -kernel_size; y ) {
19 sum += src.at
效果
文章标题:Marr-Hildreth 边缘检测 OpenCV C++实现
文章链接:http://soscw.com/essay/48946.html