! rd_i12 read images in raw format and determine if it''s 8 or 12 bits coded ! Copyright (C) 1999,2010 Gauthier Delerce ! ! This program is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2, or (at your option) ! any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software Foundation, ! Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! ! Gauthier Delerce subroutine rd_i12(filename,image,m,ierr) !**************************************************** ! PORTABILITY PROBLEMS ! UNIX AND WINDOWS SYNTAXES USED ARE NOT COMPATIBLES ! SPEED UP , CHECK 16 BITS PLEASE !**************************************************** implicit none integer::m !integer(2),dimension(m)::img2 integer,dimension(m)::image,image2 integer(4),dimension(m)::img integer::ierr,i,j,bpp,seed,inde integer(1),dimension(2*m)::in character(120)::filename real::rnunf !external rnunf inde=scan(filename,' ') inde=inde-1 !image=0. !image2=0. !bpp=1 ierr=0 !open(unit=10,file=filename,access='direct',recl=m,form='binary',status='old',ACTION='READ',err=10) open(unit=10,file=filename,access='direct',recl=m,status='old',ACTION='READ',err=10) goto 20 10 ierr=1 write(*,*) 'Error reading image' return 20 continue print*, 'Reading image ',filename(1:inde) read(10,rec=1,err=10) in(1:m) read(10,rec=2,err=11) in(m+1:2*m) goto 12 11 print*,'8 bits image ' image(1:m)=in(1:m) forall(i=1:m,image(i)<0.) image(i)=image(i)+256 endforall bpp=1 !print*,image goto 155 12 bpp=2 print*,' Image 12 bits' image(1:m)=in(1:2*m:2) forall(i=1:m,image(i)<0.) image(i)=image(i)+256 endforall image2(1:m)=in(2:2*m:2) forall(i=1:m,image2(i)<0.) image2(i)=image2(i)+256 endforall image=image+image2*256 155 close(10) print*,'Intensite min/max: ',minval(image),maxval(image) print*,'' return end