资源简介
花了本人三天时间实现维纳滤波对图像进行复原,亲测无误,注意我是用的opencv静态库,你可能需要配置一下
代码片段和文件信息
#include
#include
#include
#include
#include //存储int型变量用32位
//#include
#include
#define max(xy) (x)>=(y)?(x):(y)
#define eps 2.22044604925031e-016;
#define pi 3.1415;
using namespace std;
#define SWAP(ab) tempr=(a);(a)=(b);(b)=tempr
# pragma comment(linker “/NODEFAULTLIB:atlthunk.lib“)
# pragma comment(linker “/NODEFAULTLIB:LIBCMT“)
# pragma comment(linker “/NODEFAULTLIB:MSVCRTD“)
BOOL fourn(double * data/*psrc*/ unsigned long nn[]/*w*/ int ndim/*2*/ int isign);
double CY_sign(double cosphi);
void CYmeshgrid(int xmint xnint ymint ynCvMat* &XCvMat* &Y);
void CY_special(double lendouble thetaCvMat *&h_last);
void main(int argc char argv[])
{
IplImage *Gray1 = cvLoadImage(“ceshi1.jpg“-1);
IplImage *Gray = cvCreateImage(cvSize(256256)Gray1->depth1);
cvResize(Gray1GrayCV_INTER_CUBIC);
cvNamedWindow(“src“1);
cvShowImage(“src“Gray1);
int lHeight = Gray->height;
int lWidth = Gray->width;
int lLineBytes = Gray->widthStep;
int lw = 1;
int lh = 1;
int wp = 0;
int hp = 0;
//保证离散傅里叶变换的宽度和高度为2的整数幂
while(lw*2 <= lLineBytes)
{
lw = lw*2;
wp++;
}
while(lh*2 <= lHeight)
{
lh = lh*2;
hp++;
}
//输入退化图像的长和宽必须为2的整数倍;
if(lw != (int)lLineBytes)
{
return;
}
if(lh != (int)lHeight)
{
return;
}
//用于做FFT的数组
// 指向源图像倒数第j行,第i个象素的指针
double *fftSrc *fftKernel *laplacianKernel;
fftSrc = new double [lHeight*lLineBytes*2+1];
fftKernel = new double [lHeight*lLineBytes*2+1];
laplacianKernel = new double [lHeight*lLineBytes*2+1];
unsigned long nn[3] = {0};
nn[1] = lHeight;
nn[2] = lLineBytes;
LPSTR lpSrc;
unsigned char pixel;
double len = 30;
double theta = 0;
CvMat *h_last;
CY_special(lenthetah_last);
int h_row = h_last->height;
int h_col = h_last->width;
for (int j = 0;j < lHeight ;j++)
{
for(int i = 0;i < lLineBytes ;i++)
{
// 指向源图像倒数第j行,第i个象素的指针
lpSrc = (char *)Gray->imageData + lLineBytes * j + i;
pixel = (unsigned char)*lpSrc;
fftSrc[(2*lLineBytes)*j + 2*i + 1] = (double)pixel;
fftSrc[(2*lLineBytes)*j + 2*i + 2] = 0.0;
laplacianKernel[(2*lLineBytes)*j + 2*i + 1] = 0.0;
laplacianKernel[(2*lLineBytes)*j + 2*i + 2] = 0.0;
if(i < h_col && j < h_row)
{
float h_value = CV_MAT_ELEM(*h_lastfloatji);
fftKernel[(2*lLineBytes)*j + 2*i + 1] = double(h_value);
}
else
{
fftKernel[(2*lLineBytes)*j + 2*i + 1] = 0.0;
}
fftKernel[(2*lLineBytes)*j + 2*i + 2] = 0.0;
}
}
laplacianKernel[(2*lLineBytes)*0+2*1+1] = 1.0;
laplacianKernel[(2*lLineBytes)*1+2*0+1] = 1.0;
laplacianKernel[(2*lLineBytes)*1+2*1+1] = -4.0;
laplacianKernel[(2*lLineBytes)*0+2*2+1] = 1.0;
laplacianKernel[(2*lLineBytes)*2+2*1+1] = 1.0;
//对源图像进行FFT
fourn(fftSrcnn21);
//对卷积核图像进行FFT
fourn(fftKernelnn21);
//对过滤器进行FFT;
fourn(laplacianKernelnn21);
double abcdefnorm1norm
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6899712 2013-01-09 10:31 Least Square\Debug\Least Square.exe
文件 345654 2013-01-09 10:31 Least Square\Debug\Least Square.exp
文件 7429508 2013-01-09 10:31 Least Square\Debug\Least Square.ilk
文件 578936 2013-01-09 10:31 Least Square\Debug\Least Square.lib
文件 16722944 2013-01-09 10:31 Least Square\Debug\Least Square.pdb
文件 4020 2013-01-09 10:30 Least Square\Least Square\ceshi1.jpg
文件 1484 2013-01-09 09:15 Least Square\Least Square\ceshi2.jpg
文件 1244 2013-01-09 09:46 Least Square\Least Square\ceshi4.jpg
文件 7443 2013-01-09 09:59 Least Square\Least Square\ceshi5.jpg
文件 4648 2013-01-09 10:13 Least Square\Least Square\ceshi6.jpg
文件 8718 2013-01-09 10:31 Least Square\Least Square\Debug\BuildLog.htm
文件 663 2013-01-09 10:09 Least Square\Least Square\Debug\Least Square.exe.em
文件 728 2013-01-09 10:09 Least Square\Least Square\Debug\Least Square.exe.em
文件 621 2013-01-09 10:31 Least Square\Least Square\Debug\Least Square.exe.intermediate.manifest
文件 87740 2013-01-09 10:31 Least Square\Least Square\Debug\Least Square.obj
文件 65 2013-01-09 10:31 Least Square\Least Square\Debug\mt.dep
文件 986112 2013-01-09 10:31 Least Square\Least Square\Debug\vc90.idb
文件 528384 2013-01-09 10:31 Least Square\Least Square\Debug\vc90.pdb
文件 9090 2013-01-09 10:31 Least Square\Least Square\Least Square.cpp
文件 4391 2013-01-06 14:11 Least Square\Least Square\Least Square.vcproj
文件 1411 2013-01-09 10:31 Least Square\Least Square\Least Square.vcproj.chen-PC.Administrator.user
文件 817 2013-01-08 18:03 Least Square\Least Square\yy2.jpg
文件 902 2013-01-06 13:58 Least Square\Least Square.sln
..A..H. 12288 2013-01-09 10:27 Least Square\Least Square.suo
目录 0 2013-01-09 10:31 Least Square\Least Square\Debug
目录 0 2013-01-09 10:31 Least Square\Debug
目录 0 2013-01-09 10:31 Least Square\Least Square
目录 0 2013-01-09 10:28 Least Square
----------- --------- ---------- ----- ----
33637523 28
............此处省略1个文件信息
相关资源
- xpdf-3.02(vs2008工程含第三方库)
- opencv3.2交叉编译出来的库文件
- 基于opencv人脸识别的封装
- xfeatures2d.rar
- 基于OpenCV的视频车牌识别
- opencv 普通相机畸变标定校正
- 特征点匹配Demo
- OpenCV2.2 64位
- 卡尔曼滤波与维纳滤波 现代时间序列
- 基于SVM的手写数字识别Opencv+图像集
- 利用OpenCV(2.4.13)的SURF/SIFT + RANSAC
- asm算法 opencv实现
- OpenCV2.4.9_基于背景差分法的视频目标
- 基于OpenCV的疲劳驾驶检测系统的设计
- OpenCV三维重构代码
- 双目测距-opencv
- opencv人脸/人眼/人体识别分类器
- opencv4.0结合TensorFlow实现mask rcnn的目标
- opencv+qt通过CGI读取网络摄像头工程
- 安装opencv342缺失的boostdesc_bgm.i系列文
- OpenCV2.4.4实现HOG行人检测
- opencv的运动跟踪
- sift算法VC实现需要OPENCV
- opencv标定单目相机
- VS2008 使用API函数获取网卡信息及状态
- opencv 数字识别
- itti视觉显著性计算模型opencv实现
- 异常行为检测
- qt+opencv视频图像采集与基于tcp协议的
- opencv2.4.3和4.0函数手册带目录可搜索
评论
共有 条评论