www.pudn.com > AM_EPR.zip > AMEPR.m, change:2005-10-19,size:1613b


function [resultImg,k,maxiter]=AMEPR(noiseImg,phi,phigrad,dev2phi,invphigrad,beta,alpha) 
 
Flag=adpmedian(noiseImg); 
 
[m,n]=size(noiseImg); 
 
resultImg=noiseImg; 
Imgdiff1=zeros(m,n); 
Imgdiff2=Imgdiff1; 
 
k=0; 
diff1=1; 
diff2=1; 
maxiter=0; 
 
while diff1>2.55e-2 & diff2>2.55e-2 & k<5000 
    f2=0; 
     
    f = waitbar(0,'Applying neighborhood operation...'); 
    for i=1:m 
        for j=1:n 
            if Flag(i,j)==1 
                partdiffZ=[Imgdiff2(i,max(1,j-1)),Imgdiff2(max(i-1,1),j),Imgdiff2(i,min(j+1,n)),Imgdiff2(min(m,i+1),j)]; 
                partnoiY=[noiseImg(i,max(1,j-1)),noiseImg(max(i-1,1),j),noiseImg(i,min(j+1,n)),noiseImg(min(m,i+1),j)]; 
                d=partdiffZ+partnoiY-noiseImg(i,j); 
                d=sort(d); 
                xi=beta*sum(feval(phigrad,-d,alpha)); 
                if abs(xi)<=1 
                    Imgdiff2(i,j)=0; 
                else 
                    sgn=sign(xi); 
                    [Imgdiff2(i,j),iter]=Newton(d,sgn,phigrad,dev2phi,invphigrad,beta,alpha); 
                    if iter>maxiter 
                        maxiter=iter; 
                    end 
                end 
                f2=f2+abs(Imgdiff2(i,j))+beta*sum(feval(phi,Imgdiff2(i,j)-d,alpha))/2; 
                if k==0 
                    f1=sum(feval(phi,partnoiY-noiseImg(i,j),alpha))*beta/2; 
                end 
            end 
        end 
        waitbar(i/m) 
    end 
    close(f) 
     
    resultImg=noiseImg+Imgdiff2; 
    diff1=max(max(abs(Imgdiff2-Imgdiff1))); 
    diff2=abs(f1-f2)/f1; 
    Imgdiff1=Imgdiff2; 
    f1=f2; 
    k=k+1; 
     
end