资源简介
简单的一维高斯滤波程序。适用于图像处理初学者。开发平台vs2008+OpenCV2.3.1
代码片段和文件信息
// GaussianFilterOneDimension.cpp : 定义控制台应用程序的入口点。
//
#include “stdafx.h“
#include “cv.h“
#include “highgui.h“
#define GaussianSize 7//方形高斯核尺寸
#define MedianSize 7
#define pi 3.141592653589793
void GaussianFilter(IplImage* imageint size);
void GetOneDimensionGaussianKernel(CvMat* GaussianKernelint size);
//void MedianFilter(IplImage*imageint size);
int _tmain(int argc _TCHAR* argv[])
{
IplImage* SrcImage =cvLoadImage(“./佳人.jpg“CV_LOAD_IMAGE_UNCHANGED);
IplImage* GaussianImage=cvCreateImage(cvGetSize(SrcImage)IPL_DEPTH_8USrcImage->nChannels);
IplImage* MedianImage =cvCreateImage(cvGetSize(SrcImage)IPL_DEPTH_8USrcImage->nChannels);
cvCopyImage(SrcImageGaussianImage);
cvCopyImage(SrcImageMedianImage);
GaussianFilter(GaussianImageGaussianSize);
cvSmooth(MedianImageMedianImageCV_MEDIANMedianSizeMedianSize)
//MedianFilter(MedianImageMedianSize);
cvNamedWindow(“原始图片“);
cvNamedWindow(“高斯滤波后图片“);
cvNamedWindow(“中值滤波后图片“);
cvMoveWindow(“‘原始图片“200);
cvMoveWindow(“高斯滤波后图片“4500);
cvMoveWindow(“中值滤波后图片“8000);
cvShowImage(“原始图片“SrcImage);
cvShowImage(“高斯滤波后图片“GaussianImage);
cvShowImage(“中值滤波后图片“MedianImage);
cvWaitKey(-1);
cvDestroyAllWindows();
cvReleaseImage(&SrcImage);
return 0;
}
void GaussianFilter(IplImage* imageint size)
{
CvMat* GaussianKernel=cvCreateMat(1sizeCV_32FC1);
GetOneDimensionGaussianKernel(GaussianKernelsize);
unsigned char* ImagePin=(unsigned char*)image->imageData;
float* GaussianKernelPin=GaussianKernel->data.fl;
float* tempData=new float[image->widthStep*image->height];
float FilterSum=0.0f;
float KernelSum=0.0f;
int HalfSize=size/2;
int hwstcolorchannel;
for (colorchannel=0;colorchannel<3;colorchannel++)
{
for (h=0;hheight;h++)
{
for(w=0;wwidth;w++)
{
FilterSum=0.0f;
KernelSum=0.0f;
for (st=0;st {
if ((w-HalfSize+st)>=0&&(w-HalfSize+st)width)
{
KernelSum+=ImagePin[h*image->widthStep+3*(w-HalfSize+st)+colorchannel]*GaussianKernelPin[st-HalfSize];
FilterSum+=GaussianKernelPin[st-HalfSize];
}
}
tempData[h*image->widthStep+3*w+colorchannel]=KernelSum/FilterSum;
}
}
for (h=0;hheight;h++)
{
for(w=0;wwidth;w++)
{
FilterSum=0.0f;
KernelSum=0.0f;
for (st=0;st {
if ((h-HalfSize+st)>=0&&(h-HalfSize+st)height)
{
KernelSum+=tempData[(h-HalfSize+st)*image->widthStep+3*w+colorchannel]*GaussianKernelPin[st-HalfSize];
FilterSum+=GaussianKernelPin[st-HalfSize];
}
}
ImagePin[h*image->widthStep+3*w+colorchannel]=KernelSum/FilterSum;
}
}
}
delete []tempData;
}
void GetOneDimensionGaussianKernel(CvMat* GaussianKernelint size)
{
int HalfSize=size/2;
float Sigma;
Sigma=(size/2.0-1)*0.3+0.8;
float* GaussianKernelPin=GaussianKernel->data.fl;
float DataSum=0.0f;
for (int i=0;i
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-11-28 09:03 GaussianFilterOneDimension\
目录 0 2014-02-10 19:14 GaussianFilterOneDimension\Debug\
文件 33792 2014-02-10 19:15 GaussianFilterOneDimension\Debug\GaussianFilterOneDimension.exe
文件 376036 2014-02-10 19:15 GaussianFilterOneDimension\Debug\GaussianFilterOneDimension.ilk
文件 1436672 2014-02-10 19:15 GaussianFilterOneDimension\Debug\GaussianFilterOneDimension.pdb
目录 0 2014-02-10 19:16 GaussianFilterOneDimension\GaussianFilterOneDimension\
目录 0 2014-02-10 19:15 GaussianFilterOneDimension\GaussianFilterOneDimension\Debug\
文件 71 2013-11-28 09:24 GaussianFilterOneDimension\GaussianFilterOneDimension\Debug\BAT00001237525904.bat
文件 9928 2014-02-10 19:15 GaussianFilterOneDimension\GaussianFilterOneDimension\Debug\BuildLog.htm
文件 663 2014-02-10 19:14 GaussianFilterOneDimension\GaussianFilterOneDimension\Debug\GaussianFilterOneDimension.exe.em
文件 728 2014-02-10 19:14 GaussianFilterOneDimension\GaussianFilterOneDimension\Debug\GaussianFilterOneDimension.exe.em
文件 621 2014-02-10 19:15 GaussianFilterOneDimension\GaussianFilterOneDimension\Debug\GaussianFilterOneDimension.exe.intermediate.manifest
文件 135399 2014-02-10 19:15 GaussianFilterOneDimension\GaussianFilterOneDimension\Debug\GaussianFilterOneDimension.obj
文件 3211264 2014-02-10 19:14 GaussianFilterOneDimension\GaussianFilterOneDimension\Debug\GaussianFilterOneDimension.pch
文件 65 2014-02-10 19:15 GaussianFilterOneDimension\GaussianFilterOneDimension\Debug\mt.dep
文件 12693 2014-02-10 19:14 GaussianFilterOneDimension\GaussianFilterOneDimension\Debug\stdafx.obj
文件 830464 2014-02-10 19:15 GaussianFilterOneDimension\GaussianFilterOneDimension\Debug\vc90.idb
文件 995328 2014-02-10 19:15 GaussianFilterOneDimension\GaussianFilterOneDimension\Debug\vc90.pdb
文件 4019 2014-02-10 19:16 GaussianFilterOneDimension\GaussianFilterOneDimension\GaussianFilterOneDimension.cpp
文件 4747 2013-11-28 09:03 GaussianFilterOneDimension\GaussianFilterOneDimension\GaussianFilterOneDimension.vcproj
文件 1409 2014-02-10 19:16 GaussianFilterOneDimension\GaussianFilterOneDimension\GaussianFilterOneDimension.vcproj.MAD-PC.MAD.user
文件 1297 2013-11-28 09:01 GaussianFilterOneDimension\GaussianFilterOneDimension\ReadMe.txt
文件 231 2013-11-28 09:01 GaussianFilterOneDimension\GaussianFilterOneDimension\stdafx.cpp
文件 233 2013-11-28 09:01 GaussianFilterOneDimension\GaussianFilterOneDimension\stdafx.h
文件 498 2013-11-28 09:01 GaussianFilterOneDimension\GaussianFilterOneDimension\targetver.h
文件 7850 2013-05-24 14:14 GaussianFilterOneDimension\GaussianFilterOneDimension\佳人.jpg
文件 944 2013-11-28 09:01 GaussianFilterOneDimension\GaussianFilterOneDimension.sln
文件 15723520 2014-02-10 19:16 GaussianFilterOneDimension\GaussianFilterOneDimension.ncb
文件 40587 2013-06-16 14:45 GaussianFilterOneDimension\GaussianFilterOneDimension\小清新.jpg
文件 13824 2014-02-10 19:16 GaussianFilterOneDimension\GaussianFilterOneDimension.suo
文件 1637814 2013-11-28 09:07 GaussianFilterOneDimension\GaussianFilterOneDimension\嘿嘿.bmp
............此处省略1个文件信息
- 上一篇:拉法联科固件
- 下一篇:NX12 机电一体化设计平台 MCD 西门子培训教材
相关资源
- FreeType 结合opencv在图像上显示中文程
- Mastering OpenCV with Practical Computer Visio
- opencv计算机视觉编程攻略图片集
- Opencv安装过程中使用的vgg_generated_12
- opencv计算两平行线之间的距离
- 计算圆轮廓面积提取圆心
- 服务器截屏并使用socket发送给客户端
- Keras图像深度学习实战原版
- 训练得到的900维 HOG特征-检测算子进行
- msvcp120d .dll、msvcr120d.dll包括32位和64位
- qt+opencv的视频采集 与保存
- opencv做的姿态检测项目
- opencv运动目标检测帧差法
- 基于opencv的双目摄像头图像获取
- opencv vlc 访问海康网络摄像头
- 快速小波变换 基于opencv带注释
- opencvman_old.pdf
- 车牌识别系统vc源码基于opencv
- 基于opencv的双摄像头读取程序含Dire
- 序列图像16位转8位OpenCV
- Opencv图像Mat写入中文汉字
- opencv学习,道路检测
- 基于OpenCV的二维码检测识别基础demo
- Wallis滤波
- Opencv 人脸图像素描化
- 基于OpenCV读取摄像头的人脸检测和识
- 基于OpenCv的旋转匹配
- opencv果实分割与识别
- qt环境下使用opencv打开双摄像头并保存
- opencv学习手势轮廓识别源代码
评论
共有 条评论