[go: up one dir, main page]

Menu

[r34]: / common / rd_i12.f90  Maximize  Restore  History

Download this file

93 lines (75 with data), 2.3 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
! 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 <gauthier@delerce.fr>
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(256)::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