• 大小: 0.49M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-04-21
  • 语言: Matlab
  • 标签: 图像修复  NLTV  

资源简介

非局部全变分小波域图像修复代码,实现算法WAVELET INPAINTING BY NONLOCAL TOTAL VARIATION,Xiaoqun Zhang,Tony F. Chan,Inverse Problems and Imaging,2010,4(1)

资源截图

代码片段和文件信息

name=‘barba_partial_128‘;
type=‘mask‘;
ratio=0.3;
writefile=0;
I=double(imread([name‘.png‘]));
gmax=max(I(:));
I=I./gmax;
gmin=0.;
gmax=1.;
[mn]=size(I);

%% Generate data and initilization
wave_opts.type = ‘cdf‘;
if(n<512)
wave_opts.Jmin=5;
else
wave_opts.Jmin=6;
end
    
wave_opts.bio=1;%determine if it is biorthogonal or orthognal;
wave_opts.level=log2(n)-1-wave_opts.Jmin;%determine if it is biorthogonal or orthognal;
coefs =forward_wave2d(Iwave_opts);
lost_opts=[];
lost_opts.type=lower(type);
lost_opts.pctage=ratio;
lost_opts.block_num=floor(numel(I)*(1-ratio)./(32*32));
lost_opts.Jmin=wave_opts.Jmin;
[I_nonzeroreal_ratio] = generate_known_index(nmlost_opts);%
coefs_n=coefs;
y0=coefs_n.*I_nonzero;

tic
I0 = backward_wave2d(y0wave_opts);%fast implention with wavelab mex installed
I0_time=toc;
fprintf(‘ratio=%fRecieved image PSNR=%fdiff(coefs)=%f\n‘ratio PSNR(II0)norm(y0-coefs));

subplot(221)imshow((I)[gmingmax])title([‘Original: ‘num2str(n)‘x‘num2str(m)]);
subplot(222)imshow((I0)[gmingmax])title([‘Received PSNR=‘num2str(PSNR(II0))]);
%%

Init_I=I0;
delta =1;   
btol=1e-5;
Itol=1e-5;
nInner=10;
nOuter=50;

%% TV
mu_tv=0.05;
[Itvenergy_tvtime_tvpsnr_tvrelmse_tv]=tvWI_op_breg(y0I_nonzeromu_tvdeltanInnernOuterwave_optsbtolIItolInit_I);
 subplot(223)imshow((Itv)[gmin gmax]) title([‘TV PSNR=‘num2str(PSNR(IItv))]);
 
%% NLTV
mu_nltv=0.01;
h0=0.2;
weight_update=1;
nNLTV=5;
nwin=2;
nbloc=7;
Init_I=I0;
wopts=update_weight(Init_Ih0nwinnbloc);
%
[Inltvenergy_nltvtime_nltvpsnr_nltvrelmse_nltv]= nltvWI_op_breg(y0I_nonzeromu_nltvdeltanNLTVnInnernOuterwave_optsh0btolwoptsIweight_updateInit_IItol);
subplot(224)imshow((Inltv)[gmin gmax]) title([‘NLTV PSNR=‘num2str(PSNR(IInltv))]);
 fprintf(‘PSNR Results:\n Real_ratio=%f\n I0 PSNR=%f\n TV PSNR=%f\n nltv_PSNR=%f\n‘length(find(I_nonzero))/numel(I)PSNR(II0)PSNR(IItv)PSNR(IInltv));


%% coordinate of first zoom-out
I0_result= struct(‘Img‘0‘time‘ 0‘energy‘0‘psnr_n‘0‘relmse‘0);
tv_result=I0_result;
nltv_result=tv_result;
I0_result=writeresult(I0_resultI0I0_time00PSNR(II0));
tv_result=writeresult(tv_resultItvtime_tvenergy_tvrelmse_tvpsnr_tv);
nltv_result=writeresult(nltv_resultInltvtime_nltvenergy_nltvrelmse_nltvpsnr_nltv);
w=65;
h=40;
x=25;
y=30;
abox1=[ym-x-hwh];

image_name=[nametype‘_original_zoom_1.eps‘];
f_name=fullfile([pwd ‘\tests‘]image_name);
figureimshow(I(y:y+h-1x:x+w-1)[01]);
f1=gcf;
fhandle=[‘-f‘num2str(f1)];
print (fhandle‘-depsc‘ f_name);

image_name=[nametype‘_received_zoom_1.eps‘];
f_name=fullfile([pwd ‘\tests‘]image_name);
figureimshow(I0(y:y+h-1x:x+w-1)[01]);
f1=gcf;
fhandle=[‘-f‘num2str(f1)];
print (fhandle‘-depsc‘ f_name);

image_name=[nametype‘_TV_zoom_1.eps‘];
f_name=fullfile([pwd ‘\tests‘]image_name);
figureimshow(tv_result.Img(y:y+h-1x:x+w-1)[01]);
f1=gcf;
fh

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        4012  2009-07-15 09:47  figure_LH.m
     文件        4292  2009-07-15 12:22  figure_noise.m
     文件        4715  2009-07-15 19:29  figure_random.m
     文件        3538  2009-07-16 14:22  figure_random_LL.m
     文件         160  2009-07-16 14:37  setup.m
     文件       11918  2009-04-30 14:04  Images\barba_partial_128.png
     文件       43807  2009-05-07 20:47  Images\barba256.png
     文件       20164  2009-02-05 19:24  Images\block_mask.TIF
     文件      151926  2009-02-05 10:51  Images\boat.png
     文件         623  2009-07-14 23:31  solvers\backward_wave2d.m
     文件         423  2009-06-03 15:28  solvers\coefsInterp2.m
     文件       42884  2009-05-19 11:08  solvers\compute_NLWeights_mex.c
     文件       24576  2009-07-16 14:36  solvers\compute_NLWeights_mex.mexw32
     文件        1057  2009-06-04 14:34  solvers\denoising_SBNLTV.m
     文件         719  2009-07-14 23:32  solvers\forward_wave2d.m
     文件        4740  2006-01-03 13:20  solvers\MakeBSFilter.m
     文件        1213  2009-01-16 13:19  solvers\NLTV_split_ortho.m
     文件        2959  2009-07-14 18:19  solvers\nltvWI_op_breg.m
     文件       10950  2009-02-24 18:30  solvers\SBNLTV_mex.c
     文件        9216  2009-07-16 14:36  solvers\SBNLTV_mex.mexw32
     文件        3469  2008-10-10 14:08  solvers\TV_PDHG.m
     文件        3407  2009-07-14 18:44  solvers\tvWI_op_breg.m
     文件        1131  2009-06-04 14:20  solvers\update_weight.m
     文件        1901  2006-06-09 19:19  utilities\compute_quadrant_selection.m
     文件        2172  2009-05-06 21:43  utilities\dsxy2figxy.m
     文件        2574  2009-02-26 16:39  utilities\generate_known_index.m
     文件         340  2008-07-31 10:46  utilities\normalize.m
     文件         310  2009-05-06 21:59  utilities\printfile.m
     文件         771  2008-11-22 10:14  utilities\PSNR.m
     文件         168  2008-11-21 09:04  utilities\writeresult.m
     目录           0  2009-07-14 19:23  WaveLab_2D\Biorthogonal\
............此处省略155个文件信息

评论

共有 条评论