-
Notifications
You must be signed in to change notification settings - Fork 2
/
class.f90
115 lines (88 loc) · 2.27 KB
/
class.f90
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
subroutine classj (img,classimg,nx,ny,classval,nclass,i,j)
implicit none
integer :: nx,ny
integer, dimension(nx,ny) :: img, classimg
integer :: classval
integer :: nclass
integer :: i,j,ii,jj,iclass,i1,i2,j1,j2
logical :: qstep
integer :: step
integer :: nx1,ny1
iclass=nclass
classimg(i,j)=iclass
step=1
qstep=.true.
nx1=nx-1
ny1=ny-1
do
if(.not.qstep) exit
qstep=.false.
i1=max(i-step,2)
i2=min(i+step,nx1)
j1=max(j-step,2)
j2=min(j+step,ny1)
do ii=i1,i2
do jj=j1,j2
if (classimg(ii,jj).eq.0) then
if (img(ii,jj).eq.classval) then
if ( &
classimg(ii,jj-1).eq.iclass .or. &
classimg(ii-1,jj).eq.iclass .or. &
classimg(ii+1,jj).eq.iclass .or. &
classimg(ii,jj+1).eq.iclass) then
qstep=.true.
classimg(ii,jj)=iclass
endif
endif
endif
enddo
enddo
step=step+1
enddo
return
end subroutine classj
!*xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
subroutine classb (img,classimg,nx,ny,classval,nclass,i,j)
implicit none
integer nx,ny
integer(kind=1), dimension(nx,ny) :: img
integer(kind=1) :: classval
integer, dimension(nx,ny) :: classimg
integer nclass
integer i,j,ii,jj,iclass,i1,i2,j1,j2
logical qstep
integer step
integer nx1,ny1
iclass=nclass
classimg(i,j)=iclass
step=1
qstep=.true.
nx1=nx-1
ny1=ny-1
do
if (.not.qstep) exit
qstep=.false.
i1=max(i-step,2)
i2=min(i+step,nx1)
j1=max(j-step,2)
j2=min(j+step,ny1)
do ii=i1,i2
do jj=j1,j2
if (classimg(ii,jj).eq.0) then
if (img(ii,jj).eq.classval) then
if ( &
classimg(ii,jj-1).eq.iclass .or. &
classimg(ii-1,jj).eq.iclass .or. &
classimg(ii+1,jj).eq.iclass .or. &
classimg(ii,jj+1).eq.iclass) then
qstep=.true.
classimg(ii,jj)=iclass
endif
endif
endif
enddo
enddo
step=step+1
enddo
return
end subroutine classb