您的位置:首页 > 其它

图像算法之六:特征提取算法之LoG

2016-09-29 09:41 441 查看
1、产生:

      Laplace算子对通过图像进行操作实现边缘检测的时,对离散点和噪声比较敏感。于是,首先对图像进行高斯暖卷积滤波进行降噪处理,再采用Laplace算子进行边缘检测,就可以提高算子对噪声和离散点的Robust,
这一个过程中Laplacian of Gaussian(LOG)算子就诞生了。




2、基本理论

高斯卷积函数定义为:



而原始图像与高斯卷积定义为:



因为:



所以Laplacian of Gaussian(LOG)可以通过先对高斯函数进行偏导操作,然后进行卷积求解。公式表示为:






因此,我们可以LOG核函数定义为:



    

Laplacian of Gaussian计算可以利用高斯差分来近似,其中差分是由两个高斯滤波与不同变量的卷积结果求得的。



3、算法实现

#include<iostream>
#include<opencv2/opencv.hpp>
#include<features2d/features2d.hpp>
#include<opencv2/objdetect/objdetect.hpp>
#include"opencv2/imgproc/imgproc.hpp"
usingnamespace std;
usingnamespace cv;
intmain(intargc,char**argv)
{
Matimg = imread("bear.jpg");
if(img.empty())
{
std::cout<< "You didn't read the image sucessfully!" << std::endl;
return0;
}
namedWindow("src");
imshow("src", img);
waitKey(20);
MatimgGaussian,img16S,imgLoG,imgSobelx,imgSobely,imgSobel,imgCanny;
GaussianBlur(img, imgGaussian,Size(3, 3),1);//高斯模糊
namedWindow("Gaussian");
imshow("Gaussian", imgGaussian);
waitKey(0);
Laplacian(imgGaussian, img16S, 3);
convertScaleAbs(img16S,imgLoG,1);
namedWindow("LoG");
imshow("LoG", imgLoG);
waitKey(0);
Sobel(img, img16S, 3, 1, 0);
convertScaleAbs(img16S, imgSobelx, 1);
Sobel(img, img16S, 3, 0, 1);
convertScaleAbs(img16S, imgSobely, 1);
add(imgSobelx, imgSobely, imgSobel);
namedWindow("Sobel");
imshow("Sobel", imgSobel);
waitKey(0);
Canny(img, imgCanny, 100, 200);
namedWindow("Canny");
imshow("Canny", imgCanny);
waitKey(0);
return0;
}


实验效果:











内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: