www.pudn.com > ROLD-EPR.zip > GBBMethod.m, change:2005-10-15,size:1659b


function [Img,k,i]=GBBMethod(Img,phi,phigrad,beta,noisecoord,nearcoordinate,Imgsize,nearvec) 
%global noisecoord nearcoordinate Imgsize nearvec 
 
gamma=1e-4; 
%epsilon=1e-6; 
sigma=0.3; 
alpha=1; 
k=0; 
j=1; 
kmax=500; 
M=10; 
 
temp_f=zeros(1,M); 
noisevec=Img(noisecoord); 
[temp_f(1),pass1,pass2,pass3,pass4]=OBJfun(Img,noisevec,phi,beta,nearcoordinate,nearvec); 
x1=noisevec; 
grad1=OBJfungrad(pass1,pass2,pass3,pass4,phigrad,beta); 
%temp_grad=norm(grad1); 
 
diff1=1; 
diff2=1; 
i=0; 
 
%while temp_grad>1e-4 & diff>1e-6 & k<kmax 
while diff1>1e-4 & diff2>1e-4 & k<kmax 
 %   if alpha<=epsilon | alpha>=1/epsilon 
 %       delta=1; 
 %       if temp_grad<1e-3 
 %           delta=1e3; 
 %       elseif temp_grad<=1 
%            delta=1/temp_grad; 
%        end         
%        alpha=delta; 
%    end 
    lambda=1/alpha; 
    tempnoi=Img(noisecoord); 
    Img(noisecoord)=tempnoi-lambda*grad1; 
    [m1,pass1,pass2,pass3,pass4]=OBJfun(Img,Img(noisecoord),phi,beta,nearcoordinate,nearvec); 
    maxf=max(temp_f(1:j)); 
    m2=maxf-gamma*lambda*grad1'*grad1; 
    while m1>m2 
        lambda=sigma*lambda; 
        Img(noisecoord)=tempnoi-lambda*grad1; 
        [m1,pass1,pass2,pass3,pass4]=OBJfun(Img,Img(noisecoord),phi,beta,nearcoordinate,nearvec); 
        m2=maxf-gamma*lambda*grad1'*grad1; 
        i=i+1; 
    end 
    grad2=OBJfungrad(pass1,pass2,pass3,pass4,phigrad,beta); 
    x2=Img(noisecoord); 
    diff1=abs(m1-temp_f(j))/temp_f(j); 
    diff2=norm(x1-x2)/norm(x1); 
    j=mod(j,M)+1; 
    alpha=-(grad1'*(grad2-grad1))/(lambda*grad1'*grad1); 
    grad1=grad2; 
    %temp_grad=norm(grad1); 
    temp_f(j)=m1; 
    x1=x2; 
    k=k+1; 
end