⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inpaint_iterate.m

📁 采用总变分法(TV)进行图像修复的matlab源代码。包括热扩散修复和多尺度方法。
💻 M
字号:
function [I,Ihist] = inpaint_iterate(I,M,fn,args,tolfn,tolargs)
% function [I,Ihist] = inpaint_iterate(I,M,fn,args,tolfn,tolargs)
% 
% draws the image I in the current figure window
% repeatedly calls I = feval(fn,I,M,args)
% and then updates the display
%
% M is a logical matrix the same size as I and
% M=true indicates missing data in I
%
% fn is a fn handle (or a fn name) that
% presumably runs an inpainting algorithm on the
% image at the missing pixels
%
% after each iteration calls 
% feval(tolfn,Inew,Iold,M,count,tolargs)
% if this is true, then iterations stop
% count is the number of iterations so far
%
% if tolfn is an integer, then this is the number
% of iterations
%
% if Ihist is present, then it is a history
% of each step in the image evolution

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% input / output processing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

tic

if nargout == 2, DoHist = logical(1); else DoHist = logical(0); end

if nargin < 6, tolargs = []; end

if isa(tolfn,'double'),
    n = tolfn; 
    clear tolfn
    tolfn = inline(['count >= ' num2str(n) ';'],'Inew','I','M','count','tolargs');
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% initialization
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

count = 0;

imagesc(I,[0 1]);

if DoHist
    Ihist{1} = I;
end

DoBreak = 0;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% iteration
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

while 1
    
    % inpaint
    Inew = feval(fn,I,M,args);
    
    count = count + 1;
    
    % record history
    if DoHist
        Ihist{count} = Inew;
    end
    
    % check end conditions
    if feval(tolfn,Inew,I,M,count,tolargs)
        DoBreak = 1;
    end
    I = Inew;
    
    % draw the image
    imagesc(I,[0 1]);
    if ~mod(count,10), disp(['count = ' num2str(count) '   time = ' num2str(toc)]), pause(0.01), end

    % end
    if DoBreak, disp(['count = ' num2str(count) '   time = ' num2str(toc)]), pause(0.01), break, end
    
end

return

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -