/////////////////////////////////////////////////////////////////////
//Author��Michael.Chen
//Description: Iplement the DoG(Difference of Gaussian).
// It's just a demo to show the algorithm.
// You can change the code as you like.
//
// I use OpenCV2.1
// You have to config the environment firs.
//
//
// I would to discuss with you. You can contact me by QQ or Email.
// Thanks for your reading.
//
//Date: 2011-09-25
//QQ: 1241159842
//Email: 1241159842@qq.com
/////////////////////////////////////////////////////////////////////
#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
int main(void)
{
IplImage* pSrc = cvLoadImage("e:\\lena.jpg");
IplImage* pGray = cvCreateImage(cvGetSize(pSrc), IPL_DEPTH_8U, 1);
cvCvtColor(pSrc, pGray, CV_RGB2GRAY);
IplImage* pGray32 = cvCreateImage(cvGetSize(pSrc), IPL_DEPTH_32F, 1);
cvCvtScale(pGray, pGray32, 1.00 / 255.00);
IplImage* pGaussian1 = cvCreateImage(cvGetSize(pSrc), IPL_DEPTH_32F, 1);
IplImage* pGaussian2 = cvCreateImage(cvGetSize(pSrc), IPL_DEPTH_32F, 1);
double sigma = 1.6;
double k = 1.414;
cvSmooth(pGray32, pGaussian1, CV_GAUSSIAN, 0, 0, sigma, sigma);
cvSmooth(pGaussian1, pGaussian2, CV_GAUSSIAN, 0, 0, sigma * k, sigma * k);
IplImage* pDog1 = cvCreateImage(cvGetSize(pSrc), IPL_DEPTH_32F, 1);
cvSub(pGaussian2, pGaussian1, pDog1);
IplImage* pShow = cvCreateImage(cvGetSize(pSrc), IPL_DEPTH_8U, 1);
cvNormalize(pDog1, pShow, 0, 255, CV_MINMAX);
cvNamedWindow("Dog");
cvShowImage("Dog", pShow);
cvWaitKey();
return 0;
}
Dog(Difference of Gaussian: 高斯差分)
5星 · 超过95%的资源 需积分: 50 113 浏览量
2011-09-25
16:00:52
上传
评论 1
收藏 5KB RAR 举报
极乐净土0822
- 粉丝: 194
- 资源: 54
最新资源
- 高等数学第一章第二节数列的极限
- Python 版冒泡排序算法源代码
- tensorflow-gpu-2.7.2-cp38-cp38-manylinux2010-x86-64.whl
- tensorflow-2.7.3-cp39-cp39-manylinux2010-x86-64.whl
- tensorflow-2.7.2-cp39-cp39-manylinux2010-x86-64.whl
- Python版本快速排序源代码
- Python 语言版的快速排序算法实现
- 450815388207377安卓_base.apk
- 超微主板 X9DRE-TF+ bios 支持 nvme启动
- 基于Python通过下载气象数据和插值拟合离散数据曲线实现对寒潮过程的能量分析
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
- 3
- 4
前往页