📄 inpaint.m
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -