matlab rof算法,ROF|MATLAB 其它技术应用|MATLAB技术论坛 - Powered by Discuz!

谢谢您的回复 那个程序是下的

%% ROFdenoise

%

%  This denoising method is based on total-variation, originally proposed by

%  Rudin, Osher and Fatemi. In this particular case fixed point iteration

%  is utilized.

%

%  For the included image, a fairly good result is obtained by using a

%  theta value around 12-16. A possible addition would be to analyze the

%  residual with an entropy function and add back areas that have a lower

%  entropy, i.e. there are some correlation between the surrounding pixels.

%

%  Philippe Magiera & Carl L鰊dahl, 2008

%

function A = ROFdenoise(Image, Theta)

[Image_h Image_w] = size(Image);

g = 1; dt = 1/4; nbrOfIterations = 5;

Image = double(Image);

p = zeros(Image_h,Image_w,2);

d = zeros(Image_h,Image_w,2);

div_p = zeros(Image_h,Image_w);

for i = 1:nbrOfIterations

for x = 1:Image_w

for y = 2:Image_h-1

div_p(y,x) = p(y,x,1) - p(y-1,x,1);

end

end

for x = 2:Image_w-1

for y = 1:Image_h

div_p(y,x) = div_p(y,x) + p(y,x,2) - p(y,x-1,2);

end

end

% Handle boundaries

div_p(:,1) = p(:,1,2);

div_p(:,Image_w) = -p(:,Image_w-1,2);

div_p(1,:) = p(1,:,1);

div_p(Image_h,:) = -p(Image_h-1,:,1);

% Update u

u = Image-Theta*div_p;

% Calculate forward derivatives

du(:,:,2) = u(:,[2:Image_w, Image_w])-u;

du(:,:,1) = u([2:Image_h, Image_h],:)-u;

% Iterate

d(:,:,1) = (1+(dt/Theta/g).*abs(sqrt(du(:,:,1).^2+du(:,:,2).^2)));

d(:,:,2) = (1+(dt/Theta/g).*abs(sqrt(du(:,:,1).^2+du(:,:,2).^2)));

p = (p-(dt/Theta).*du)./d;

end

A = u;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值