! A.Bijaoui 2007 November 17th ! Pixel values transform into log ! Modified 03/11/09 Implicit None Real Sigma,Fond Character(Len=80) Imagein,Imagelog,Mouch,String Character(Len=60) Comment Character(Len=100) paramoption(50) Integer Status,BP,Nc,Nl,Np,Ip,err,i,nkeys Real, allocatable :: T(:) Integer Nodef Real Xd,Yd,Dx,Dy Imagelog="dummy" ImageIn="dummy" mouch='mouch.lis' Sigma=1. Fond=0. call getline(nkeys,paramoption) if (nkeys.eq.0) then Write(*,*) 'Syntax : -i Image -b Background -s Sigma -o Image_log -l logfile' Write(*,*) 'Logarithm conversion taking into account background and deviation' Write(*,*) '-i Input Image (required)' Write(*,*) '-b Background: bacckground to be subtracted (0.)' Write(*,*) '-s Sigma : standard noise deviation (1.)' Write(*,*) '-o Image_log : name of the converted image (required)' Write(*,*) '-l logfile : name of the log file (def. mouch.lis)' Stop endif do i=1,Nkeys,2 if(paramoption(i).eq.'-i') Imagein =paramoption(i+1) if(paramoption(i).eq.'-b') Read(paramoption(i+1),*) Fond if(paramoption(i).eq.'-s') Read(paramoption(i+1),*) Sigma if(paramoption(i).eq.'-o') Imagelog =paramoption(i+1) if(paramoption(i).eq.'-l') Mouch =paramoption(i+1) enddo If(Imagein.eq."dummy") Stop "No name for input image" If(Imagelog.eq."dummy") Stop "No name for resulting image" Call Debut('OVN_tlog',Mouch) Call WC('Logarithm conversion taking into account background and deviation') Call WC('Input Image '//Imagein) Call OFits(21,ImageIn,Bp,String,Nc,Nl,Dx,Dy,Xd,Yd) If(BP.ne.-32) Stop 'This program processes only real data' Np=Nc*Nl Allocate(T(Np),stat=err) ; If(err/=0) Stop "Allocation problem" Status=0 Call FTGPVE(21,0,1,Np,0,T,Nodef,Status) Call FtClos(21,Status) Call WR('Background ',Fond,1) Call WR('Noise sigma ',Sigma,1) T=T-Fond Do Ip=1,Np If(T(Ip) >= 0.) Then T(Ip)=Alog10(1.+T(Ip)/Sigma) Else T(Ip)=-Alog10(1.-T(Ip)/Sigma) Endif Enddo Call WC('Resulting Image: '//Imagelog) Comment='Image converted into log values' Call CFits(Imagelog,21,Comment,Nc,Nl,Dx,Dy,Xd,Yd,BP) Call FtpprE(21,0,1,Np,T,Status) Call FTClos(21,Status) Call Lafin('OVN_tlog') End