#include <opencv2/opencv.hpp>
#include <iostream>
using namespace std;
using namespace cv;
int main()
{
Mat ori_img=imread("G:\\nianfudong\\zhixin.jpg");
Mat gray_img;
cvtColor(ori_img,gray_img,CV_RGB2GRAY);
gray_img.convertTo(gray_img,CV_32F);
Mat gauss1, gauss2;
GaussianBlur(gray_img,gauss1,Size(5,5),0.3,0.3);
GaussianBlur(gray_img,gauss2,Size(5,5),0.4,0.4);
Mat DoG1,DoG2,DoG3;
DoG1=gauss1-gauss2;
GaussianBlur(gray_img,gauss1,Size(5,5),0.6,0.6);
GaussianBlur(gray_img,gauss2,Size(5,5),0.7,0.7);
DoG2=gauss1-gauss2;
GaussianBlur(gray_img,gauss1,Size(5,5),0.7,0.7);
GaussianBlur(gray_img,gauss2,Size(5,5),0.8,0.8);
DoG3=gauss1-gauss2;
for (int j=1;j<gray_img.rows-1;j++)
{
for (int i=1;i<gray_img.cols-1;i++)
{
if (DoG2.at<float>(j,i)<DoG2.at<float>(j-1,i-1)&&DoG2.at<float>(j,i)<DoG2.at<float>(j-1,i)&&
DoG2.at<float>(j,i)<DoG2.at<float>(j-1,i+1)&&DoG2.at<float>(j,i)<DoG2.at<float>(j,i-1)&&DoG2.at<float>(j,i)<DoG2.at<float>(j,i+1)&&
DoG2.at<float>(j,i)<DoG2.at<float>(j+1,i-1)&&DoG2.at<float>(j,i)<DoG2.at<float>(j+1,i)&&DoG2.at<float>(j,i)<DoG2.at<float>(j+1,i+1)
&&DoG2.at<float>(j,i)<DoG1.at<float>(j,i)&&DoG2.at<float>(j,i)<DoG1.at<float>(j-1,i-1)&&DoG2.at<float>(j,i)<DoG1.at<float>(j-1,i)&&
DoG2.at<float>(j,i)<DoG1.at<float>(j-1,i+1)&&DoG2.at<float>(j,i)<DoG1.at<float>(j,i-1)&&DoG2.at<float>(j,i)<DoG1.at<float>(j,i+1)&&
DoG2.at<float>(j,i)<DoG1.at<float>(j+1,i-1)&&DoG2.at<float>(j,i)<DoG1.at<float>(j+1,i)&&DoG2.at<float>(j,i)<DoG1.at<float>(j+1,i+1)
&&DoG2.at<float>(j,i)<DoG3.at<float>(j,i)&&DoG2.at<float>(j,i)<DoG3.at<float>(j-1,i-1)&&DoG2.at<float>(j,i)<DoG3.at<float>(j-1,i)&&
DoG2.at<float>(j,i)<DoG3.at<float>(j-1,i+1)&&DoG2.at<float>(j,i)<DoG3.at<float>(j,i-1)&&DoG2.at<float>(j,i)<DoG3.at<float>(j,i+1)&&
DoG2.at<float>(j,i)<DoG3.at<float>(j+1,i-1)&&DoG2.at<float>(j,i)<DoG3.at<float>(j+1,i)&&DoG2.at<float>(j,i)<DoG3.at<float>(j+1,i+1))
{
if (DoG2.at<float>(j,i)<-3)
{
circle(ori_img,Point(i,j),3,CV_RGB(0,0,255));
}
}
else
if (DoG2.at<float>(j,i)>DoG2.at<float>(j-1,i-1)&&DoG2.at<float>(j,i)>DoG2.at<float>(j-1,i)&&
DoG2.at<float>(j,i)>DoG2.at<float>(j-1,i+1)&&DoG2.at<float>(j,i)>DoG2.at<float>(j,i-1)&&DoG2.at<float>(j,i)>DoG2.at<float>(j,i+1)&&
DoG2.at<float>(j,i)>DoG2.at<float>(j+1,i-1)&&DoG2.at<float>(j,i)>DoG2.at<float>(j+1,i)&&DoG2.at<float>(j,i)>DoG2.at<float>(j+1,i+1)
&&DoG2.at<float>(j,i)>DoG1.at<float>(j,i)&&DoG2.at<float>(j,i)>DoG1.at<float>(j-1,i-1)&&DoG2.at<float>(j,i)>DoG1.at<float>(j-1,i)&&
DoG2.at<float>(j,i)>DoG1.at<float>(j-1,i+1)&&DoG2.at<float>(j,i)>DoG1.at<float>(j,i-1)&&DoG2.at<float>(j,i)>DoG1.at<float>(j,i+1)&&
DoG2.at<float>(j,i)>DoG1.at<float>(j+1,i-1)&&DoG2.at<float>(j,i)>DoG1.at<float>(j+1,i)&&DoG2.at<float>(j,i)>DoG1.at<float>(j+1,i+1)
&&DoG2.at<float>(j,i)>DoG3.at<float>(j,i)&&DoG2.at<float>(j,i)>DoG3.at<float>(j-1,i-1)&&DoG2.at<float>(j,i)>DoG3.at<float>(j-1,i)&&
DoG2.at<float>(j,i)>DoG3.at<float>(j-1,i+1)&&DoG2.at<float>(j,i)>DoG3.at<float>(j,i-1)&&DoG2.at<float>(j,i)>DoG3.at<float>(j,i+1)&&
DoG2.at<float>(j,i)>DoG3.at<float>(j+1,i-1)&&DoG2.at<float>(j,i)>DoG3.at<float>(j+1,i)&&DoG2.at<float>(j,i)>DoG3.at<float>(j+1,i+1))
{
if (DoG2.at<float>(j,i)>3)
{
circle(ori_img,Point(i,j),3,CV_RGB(255,0,0));
}
}
}
}
imshow("corner",ori_img);
waitKey(0);
}
DoG角点检测(C++&openCV2.4.6版本)
5星 · 超过95%的资源 需积分: 43 113 浏览量
2013-10-21
20:25:16
上传
评论 4
收藏 479KB ZIP 举报
NFD_Year
- 粉丝: 17
- 资源: 1
最新资源
- 直接插入排序,冒泡排序,直接选择排序.zip
- 在排序2的基础上,再次对快排进行优化,其次增加快排非递归,归并排序,归并排序非递归版.zip
- 实现了7种排序算法.三种复杂度排序.三种nlogn复杂度排序(堆排序,归并排序,快速排序)一种线性复杂度的排序.zip
- 冒泡排序 直接选择排序 直接插入排序 随机快速排序 归并排序 堆排序.zip
- 课设-内部排序算法比较 包括冒泡排序、直接插入排序、简单选择排序、快速排序、希尔排序、归并排序和堆排序.zip
- Python排序算法.zip
- C语言实现直接插入排序、希尔排序、选择排序、冒泡排序、堆排序、快速排序、归并排序、计数排序,并带图详解.zip
- 常用工具集参考用于图像等数据处理
- 音乐展示网页、基于Stenography的图像数字水印添加与提取,以及基于颜色矩和Tamura算法的图像相似度评估算法py源码
- 基于EmguCV(OpenCV .net封装),图像数字水印加解密算法的实现,其中包含最低有效位算法,离散傅里叶变换算法+文档书
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈