简体   繁体   中英

Implement Chambolle dual formulation method in matlab

I would like to implement an Chambolle dual formulation method. The method can be summarize as following 在此处输入图片说明

This is my implementation in matlab. However, it does not give true result. Could you see it and please give me some comment/suggestion for that code

    %% Note that div, grad is written correctly. d is given
     u=rand(row,col,dim);
     a=sum(u,3);
     N=2;
     for k = 1 : N
        u(:,:,k)=u(:,:,k)./a;            
    end
    v=zeros(size(I)); %I is image
    for i=1: numIter
    for ii=1:N 
    grad_E = d(:,:,ii);    
    % solve for u
    p1 = zeros([size(u(:,:,1)) N]);
    p2 = zeros([size(u(:,:,1)) N]);
    for j = 1:5
        %% Compute Eq 24
        [d1 d2] = grad(div(p1(:,:,ii),p2(:,:,ii))-u(:,:,ii)/(theta*gamma)); 
        Nu = 1+tau*sqrt(d1.^2+d2.^2);
        p1(:,:,ii) = (p1(:,:,ii) + tau*d1)./Nu;
        p2(:,:,ii) = (p2(:,:,ii) + tau*d2)./Nu;
    end % end of inner iteration
    v = u(:,:,ii) - theta*gamma*div(p1(:,:,ii),p2(:,:,ii)); %% Eq 23
    % solve for v
    u(:,:,ii) = min(max(((v-theta*gamma*grad_E-theta*lambda*gamma*(sum(u(:,:,1:size(u,3) ~= ii),3)-1))...
        ./(1+theta*gamma)),0),1); % Eq 25
    end
    end

You may not have implemented div and grad correctly. They need to be complementary, eg using forward differences for grad, and backward differences for div. See the implementations of div and grad in Toolbox image .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM