资源简介
花了本人三天时间实现维纳滤波对图像进行复原,亲测无误,注意我是用的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个文件信息
相关资源
- 基于OpenCV的数字识别468815
- 使用opencv去掉二值化图像中黑色面积
- opencv环境配置
- win10 64位下编译的opencv4.5.5库,opencv
- Visual_Assist_X VS2008专用
- NVIDIAOpticalFlowSDK-79c6cee80a2df9a196f20afd6
- opencv_contrib-3.4.0.zip
- opencv2.4.9源码分析——SIFT
- 用两个摄像头实现,双目标定,双目
- opencv_traincascade训练分类器,手势识别
- opencv3.0交叉编译用parallel.cpp
- 基于opencv的图像识别识别图像中的色
- 基于openCV的识别特定颜色区域
- 基于OpenCV的分水岭算法实现
- QT+opencv+OCR 身份证号码,银行卡号识别
- opencv视频特定颜色区域识别
- 把RGB转换为HSV和HSI然后根据黄色和蓝
- opencv视觉测距
- 基于Qt和opencv的身份证号码识别系统
- opencv_ffmpeg249.dll
- SfM稀疏三维点云重建--完整工程文件
- 基于opencv的数人头程序源代码
- 利用OpenCV中的Stitcher类实现全景图像拼
- opencv实现的sift算法源码,包含了图像
- openCV 上的小波变换
- 基于OPENCV的车牌识别系统设计
- Visual Assist X VA_X插件及破解工具,适用
- 617张国内车牌60-17bmp图片用于OpenCV正样
- hog特征提取,c版本代码
- 基于Qt5.8+OpenCV3.2的Basler多相机触发开
评论
共有 条评论