此乃流程

三维重建之LoG特征点检测算法流程及C++实现_2d


#include<iostream>
#include<opencv2/opencv.hpp>
#include<features2d/features2d.hpp>
#include<opencv2/objdetect/objdetect.hpp>
#include"opencv2/imgproc/imgproc.hpp"
using namespace std;
using namespace cv;
int main(int argc, char** argv)
{
Mat img = imread("D:\\myProject\\my3DCV\\vs2019\\workspace\\Project1\\images\\kxm1.jpg");
if (img.empty())
{
std::cout << "You didn't read the image sucessfully!" << std::endl;
return 0;
}
namedWindow("src");
imshow("src", img);
waitKey(20);
Mat imgGaussian, 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);
return 0;
}

算法实现包括高斯模糊,LoG特征点检测,Sobel算子,Canny边缘检测

结果如下:

原图:

三维重建之LoG特征点检测算法流程及C++实现_边缘检测_02

高斯模糊:

三维重建之LoG特征点检测算法流程及C++实现_2d_03

LoG检测

三维重建之LoG特征点检测算法流程及C++实现_边缘检测_04

Sobel算子

三维重建之LoG特征点检测算法流程及C++实现_2d_05

Canny边缘检测

三维重建之LoG特征点检测算法流程及C++实现_边缘检测_06