资源简介
FTVd全变差去模糊(opencv实现)
代码片段和文件信息
#include “subfunction.h“
#define MU 50000
#define BETA_MAX 128
#define ITERMAX 5
Mat Image = imread(“E:/pic/lena.png“ 0);
Mat D1 = (Mat_(1 2) << 1 -1);
Mat D2 = (Mat_(2 1) << 1 -1);
Size sizeg = Image.size();
Mat K = Mat::ones(15 15 CV_32FC1)/225;
Mat noise(sizeg CV_32FC1);
Mat Dx(sizeg CV_32FC1);
Mat Dy(sizeg CV_32FC1);
int beta = 1;
int beta_rate = 2;
int iter = 1;
int outIter = 1;
Mat g Fg u w1 w2 Fk FabsDx FabsDy temp[2] conjDx conjDy conjFk Dux Duytemp1temp2temp3FabsFkFu;
int main(){
system(“color 3f“);
/*************初始化*************/
if (Image.empty()){
cout << “can‘t read Image“ << endl;
return -1;
}
Image.convertTo(Image CV_32FC1);
randn(noise 0 1);
g = blurcircul(Image15Image.rowsImage.cols);
g = g + 0.001*noise;
Dx = psf2otf(D1 sizeg);
Dy = psf2otf(D2 sizeg);
Fk = psf2otf(K sizeg);
conjDx = conj(Dx);
conjDy = conj(Dy);
conjFk = conj(Fk);
Fg = fft2(g);
split(Dx temp);
magnitude(temp[0] temp[1] FabsDx);
split(Dy temp);
magnitude(temp[0] temp[1] FabsDy);
split(Fk temp);
magnitude(temp[0] temp[1] FabsFk);
pow(FabsDx 2 FabsDx);//取模值的平方
pow(FabsDy 2 FabsDy);//取模值的平方
pow(FabsFk 2 FabsFk);//取模值的平方
g.copyTo(u);
/*******************************/
while (beta iter = 1;
while (iter /*******updata w1 and w2*******/
Dux = diffX(u);
Duy = diffY(u);
two_D_shrinkage(Dux Duy beta w1 w2);
/***********updata u***********/
float gamma = MU / beta;
temp1 = fft2(w1);
temp2 = fft2(w2);
temp1 = complexMul(conjDx temp1);
temp2 = complexMul(conjDy temp2);
temp3 = complexMul(conjFk Fg);
temp1 = temp1 + temp2 + gamma*temp3;
temp2 = FabsDx + FabsDy + gamma*FabsFk;
split(temp1 temp);
temp[0] = temp[0] / temp2;
temp[1] = temp[1] / temp2;
merge(temp 2 Fu);
dft(Fu Fu DFT_INVERSE + DFT_SCALE);
split(Fu temp);
u = temp[0];
/******************************/
iter = iter + 1;
}
cout << “outIter = “ << outIter << endl;
outIter = outIter + 1;
beta = beta*beta_rate;
}
displayImage(g “Blurr Image“);
displayImage(u “Deblurr Image“);
waitKey(0);
system(“pause“);
return 0;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-05-18 22:00 FTVD\
目录 0 2016-05-17 16:15 FTVD\Debug\
文件 127488 2016-05-18 21:54 FTVD\Debug\FTVD.exe
文件 2264600 2016-05-18 21:54 FTVD\Debug\FTVD.ilk
文件 2223104 2016-05-18 21:54 FTVD\Debug\FTVD.pdb
目录 0 2016-05-18 21:54 FTVD\FTVD\
目录 0 2016-05-18 21:54 FTVD\FTVD\Debug\
文件 2509 2016-05-18 21:54 FTVD\FTVD\Debug\FTVD.log
目录 0 2016-05-18 21:54 FTVD\FTVD\Debug\FTVD.tlog\
文件 26586 2016-05-18 21:54 FTVD\FTVD\Debug\FTVD.tlog\CL.read.1.tlog
文件 1314 2016-05-18 21:54 FTVD\FTVD\Debug\FTVD.tlog\CL.write.1.tlog
文件 158 2016-05-18 21:54 FTVD\FTVD\Debug\FTVD.tlog\FTVD.lastbuildstate
文件 1210 2016-05-18 21:54 FTVD\FTVD\Debug\FTVD.tlog\cl.command.1.tlog
文件 4176 2016-05-18 21:54 FTVD\FTVD\Debug\FTVD.tlog\li
文件 5296 2016-05-18 21:54 FTVD\FTVD\Debug\FTVD.tlog\li
文件 446 2016-05-18 21:54 FTVD\FTVD\Debug\FTVD.tlog\li
文件 307260 2016-05-18 21:54 FTVD\FTVD\Debug\main.obj
文件 301221 2016-05-17 16:34 FTVD\FTVD\Debug\subfunction.obj
文件 658432 2016-05-18 21:54 FTVD\FTVD\Debug\vc120.idb
文件 946176 2016-05-18 21:54 FTVD\FTVD\Debug\vc120.pdb
文件 4376 2016-05-17 15:37 FTVD\FTVD\FTVD.vcxproj
文件 1164 2016-05-17 15:37 FTVD\FTVD\FTVD.vcxproj.filters
文件 2294 2016-05-18 21:54 FTVD\FTVD\main.cpp
文件 5296 2016-05-17 16:34 FTVD\FTVD\subfunction.cpp
文件 542 2016-05-17 16:33 FTVD\FTVD\subfunction.h
文件 15269888 2016-05-18 22:00 FTVD\FTVD.sdf
文件 958 2016-05-17 14:35 FTVD\FTVD.sln
文件 21504 2016-05-18 22:00 FTVD\FTVD.v12.suo
- 上一篇:压缩相位恢复ADMM-L1相位恢复
- 下一篇:RAAR相位恢复 opencv
评论
共有 条评论