Matlab Code = 全变分图像去噪方法(Total Variation-based Image Denoising)

Reference

[1] L. Rudin, S. Osher, E. Fatemi, 'Nonlinear Total Variation based noise removal algorithm', Physica D 60 259-268, 1992.

Related Website

[2] Total Variation Denoising : http://visl.technion.ac.il/~gilboa/PDE-filt/tv_denoising.html

 

function J=tv(I,iter,dt,ep,lam,I0,C)

%% Private function: tv (by Guy Gilboa).

%% Total Variation denoising.

%% Example: J=tv(I,iter,dt,ep,lam,I0)

%% Input: I    - image (double array gray level 1-256),

%%        iter - num of iterations,

%%        dt   - time step [0.2],

%%        ep   - epsilon (of gradient regularization) [1],

%%        lam  - fidelity term lambda [0],

%%        I0   - input (noisy) image [I0=I]

%%       (default values are in [])

%% Output: evolved image

 

if ~exist('ep')

   ep=1;

end

if ~exist('dt')

   dt=ep/5;  % dt below the CFL bound

end

if ~exist('lam')

   lam=0;

end

if ~exist('I0')

       I0=I;

end

if ~exist('C')

       C=0;

end

[ny,nx]=size(I); ep2=ep^2;

 

for i=1:iter,  %% do iterations

   % estimate derivatives

   I_x = (I(:,[2:nx nx])-I(:,[1 1:nx-1]))/2;

       I_y = (I([2:ny ny],:)-I([1 1:ny-1],:))/2;

       I_xx = I(:,[2:nx nx])+I(:,[1 1:nx-1])-2*I;

       I_yy = I([2:ny ny],:)+I([1 1:ny-1],:)-2*I;

       Dp = I([2:ny ny],[2:nx nx])+I([1 1:ny-1],[1 1:nx-1]);

       Dm = I([1 1:ny-1],[2:nx nx])+I([2:ny ny],[1 1:nx-1]);

       I_xy = (Dp-Dm)/4;

   % compute flow

   Num = I_xx.*(ep2+I_y.^2)-2*I_x.*I_y.*I_xy+I_yy.*(ep2+I_x.^2);

   Den = (ep2+I_x.^2+I_y.^2).^(3/2);

   I_t = Num./Den + lam.*(I0-I+C);

   I=I+dt*I_t;  %% evolve image by dt

end % for i

%% return image

%J=I*Imean/mean(mean(I)); % normalize to original mean

J=I;

  • 1
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值