www.pudn.com > ROLD-EPR.zip > RGLMethod1.m, change:2005-10-26,size:1612b


function [resultImg,k,i]=RGLMethod1(Img,Flag,phi,phigrad,alpha) 
%global noisecoord nearcoordinate Imgsize nearvec 
% RGLMethod 用GBBMethod整体处理噪声点 
 
%[Img,Flag]=adpmedian(noiseImg); 
%Flag=logical(Flag); 
 
Imgsize=size(Img); 
%allImgsize=Imgsize(1)*Imgsize(2); 
 
%noisecoord=find(Flag); 
 
%F=noisecoord<=Imgsize(1); 
%tempnear1=noisecoord-Imgsize(1); 
%tempnear1(F)=noisecoord(F); 
%tempnear2=noisecoord-1; 
%F=mod(noisecoord,Imgsize(1))==1; 
%tempnear2(F)=noisecoord(F); 
%tempnear3=noisecoord+Imgsize(1); 
%F=tempnear3>allImgsize; 
%tempnear3(F)=noisecoord(F); 
%tempnear4=noisecoord+1; 
%F=mod(noisecoord,Imgsize(1))==0; 
%tempnear4(F)=noisecoord(F); 
%nearcoordinate=[tempnear1,tempnear2,tempnear3,tempnear4]; 
%Img2=noiseImg; 
%Img2(Flag)=0; 
 
[row,column]=find(Flag); 
nearcoordinate=[sub2ind(Imgsize,row,max(column-1,1)),sub2ind(Imgsize,max(row-1,1),column), ... 
                sub2ind(Imgsize,min(row+1,Imgsize(1)),column),sub2ind(Imgsize,row,min(column+1,Imgsize(2)))];   %邻域点坐标 
noisecoord=find(Flag); 
 
nearvec(:,1)=(Flag(nearcoordinate(:,1))==1); 
nearvec(:,2)=(Flag(nearcoordinate(:,2))==1); 
nearvec(:,3)=(Flag(nearcoordinate(:,3))==1); 
nearvec(:,4)=(Flag(nearcoordinate(:,4))==1); 
nearvec=logical(nearvec); 
 
%per=length(row)/(Imgsize(1)*Imgsize(2));      
 
%alpha=(5*per+13)/9; 
%fprintf(fid4,'alpha=%f\r',alpha); 
 
%tic; 
[resultImg,k,i]=GBBMethod(Img,phi,phigrad,alpha,noisecoord,nearcoordinate,Imgsize,nearvec);     
%t=toc; 
 
%[psnr,mae]=para(originalImg,resultImg) 
%fprintf(fid4,'       time=%f       k=%d       i=%d        PSNR=%f     MAE=%f\r',t,k,i,psnr,mae);