www.pudn.com > ROLD-EPR.zip > main.m, change:2008-07-01,size:2981b


 
orginalImg=imread('bridge.tif'); 
intorgI=double(orginalImg); 
[m,n]=size(intorgI); 
 
for thres1=5.4:0.1:5.4  
thres1; 
fid=fopen(strcat('bridge(thres=',num2str(thres1),'.per).txt'),'a'); 
 
for noise=0.4:0.1:0.4 
    noise 
    noiseImg=imread(strcat('bridge_noiseImg(',num2str(noise),').tif')); 
    fprintf(fid,'#####################################################\r'); 
    fprintf(fid,'    noise=%f      ',noise); 
    noiI=im2double(noiseImg); 
    intnoiI=double(noiseImg); 
    [psnr,mae]=para(intorgI,intnoiI); 
    fprintf(fid,'PSNR=%f      MAE=%f\r',psnr,mae); 
    fprintf(fid,'#####################################################\r\r'); 
    Flag=intnoiI~=intorgI; 
    Flag2=(abs(intnoiI-intorgI)<=2)&Flag; 
 
    diffallpixel=intorgI(Flag)-intnoiI(Flag); 
    allmae=mean(abs(diffallpixel)); 
    allmse=mean(diffallpixel.^2); 
    fprintf(fid,'\r all MAE=%f    all MSE=%f\r',allmae,allmse); 
     
    noinum=length(find(Flag)); 
    gdnum=length(find(~Flag)); 
    fprintf(fid,'the number of noisy pixels = %d        the number of well pixels = %d\r',noinum,gdnum); 
     
    %threshold 
    noi_rold=ROLD(noiI,5); 
    thres=thres1; 
    F=noi_rold>thres; 
    per=length(find(F))/m/n 
    thres=thres*(1-per) 
    fprintf(fid,'thres = %f      per = %f\r',thres,per); 
 
    psnr1=0; 
    resI1=intnoiI; 
    resF1=zeros(m,n); 
    res_rold=noi_rold; 
    for iter=1:25 
        iter 
        fprintf(fid,'iteration = %d\r',iter); 
         
        F=res_rold>thres; 
                         
        noisevec=intnoiI(F); 
        [resI2,k,i]=RGLMethod1(resI1,F,@phi6,@phigrad6,1.3); 
             
        [psnr2,mae,cor]=para(intorgI,resI2) 
        fprintf(fid,'PSNR=%f      MAE=%f        COR=%f\r',psnr2,mae,cor); 
        fprintf(fid,'k=%d      i=%f\r',k,i);         
        resF2=F|resF1; 
        nF=Flag&resF2; 
        gF=~Flag&resF2; 
        npnum=sum(nF(:)); 
        gpnum=sum(gF(:)); 
        fprintf(fid,'miss noisy pixels = %d     false pixels = %d       veracity = %f\r',noinum-npnum,gpnum,npnum/(npnum+gpnum));         
        resF3=resF2|Flag2; 
        nF2=Flag&resF3; 
        npnum2=sum(nF2(:)); 
        fprintf(fid,'new miss noisy pixels = %d\r',noinum-npnum2); 
           
        if psnr2-psnr1<1e-4 | iter==25 
            nF=Flag&resF1; 
            missF=Flag&(~nF); 
            diffmisspixel=intorgI(missF)-intnoiI(missF); 
            missmae=mean(abs(diffmisspixel)); 
            missmse=mean(diffmisspixel.^2); 
            fprintf(fid,'\r miss MAE=%f     miss MSE=%f\r',missmae,missmse);         
            %resI1=uint8(resI1); 
            imwrite(uint8(resI1),strcat('bridge_ROLDresultImg1(',num2str(noise),',',num2str(thres1),').tif')); 
            %figure,imshow(uint8(resI1)); 
           break; 
        else 
           psnr1=psnr2; 
           resI1=resI2; 
           resF1=resF2; 
           res_rold=ROLD(resI1/255,5); 
           thres=thres*(1-per) 
       end 
   end 
end 
 
fclose('all'); 
end