inpaint.m
来自「采用总变分法(TV)进行图像修复的matlab源代码。包括热扩散修复和多尺度方法」· M 代码 · 共 53 行
M
53 行
clf
colormap(gray)
%I = zeros(100,200);
%I(40:60,50:150)=255;
%I=255-I;
I = imresize(double(rgb2gray(imread('test.bmp')))/255,0.4);
M = logical(roipoly(I));
%M = logical(zeros(50,50)); M(25:50,25:50) = logical(1);
% original image
subplot(2,2,1)
imagesc(I,[0 1])
title('original')
% masked image
subplot(2,2,2)
IM = I;
IM(find(M))=1 ; %rand(size(find(M))); %=1;
imagesc(IM,[0 1]);
title('missing data')
%harmonic inpainting
subplot(2,2,4)
Ih = inpaint_iterate(IM,M,@ip_mean,[],1);
title('harmonic inpainting')
figure(gcf);
pause(0.1)
subplot(2,2,3)
args{1} = 0.00000001; % a
fn = @ip_tvh; %_filter;
%args{2} = 0.005; % delta t
%args{3} = 25; % contextarea
%args{4} = 1; % b
%*sqrt(length(find(M)))
tolfn = inline('max(abs(Inew(:) - Iold(:))) <= tolargs{1}*sqrt(length(find(M)));','Inew','Iold','M','count','tolargs');
tolargs{1} = 1/100000; % criterion
%n = 300;
Inew = inpaint_iterate_ms(Ih,M,fn,args,tolfn,tolargs);
title(['ip\_tvh a = ' num2str(args{1}) ' tol = ' num2str(tolargs{1})])
zoom on
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?