Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
bob.bio.vein
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bob
bob.bio.vein
Commits
c9a94c90
Commit
c9a94c90
authored
Jun 30, 2017
by
André Anjos
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Speeds-up the evaluation of vein probabilities
parent
a63d2044
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
22 deletions
+17
-22
bob/bio/vein/extractor/MaximumCurvature.py
bob/bio/vein/extractor/MaximumCurvature.py
+15
-15
bob/bio/vein/tests/test.py
bob/bio/vein/tests/test.py
+1
-2
matlab/compare.py
matlab/compare.py
+1
-5
No files found.
bob/bio/vein/extractor/MaximumCurvature.py
View file @
c9a94c90
...
...
@@ -217,7 +217,7 @@ class MaximumCurvature (Extractor):
'''
V
=
numpy
.
zeros
_like
(
k
)
V
=
numpy
.
zeros
(
k
.
shape
[:
2
],
dtype
=
'float64'
)
def
_prob_1d
(
a
):
'''Finds "vein probabilities" in a 1-D signal
...
...
@@ -289,17 +289,17 @@ class MaximumCurvature (Extractor):
# Horizontal direction
for
index
in
range
(
k
.
shape
[
0
]):
V
[
index
,:
,
0
]
+=
_prob_1d
(
k
[
index
,:,
0
])
V
[
index
,:]
+=
_prob_1d
(
k
[
index
,:,
0
])
# Vertical direction
for
index
in
range
(
k
.
shape
[
1
]):
V
[:,
index
,
1
]
+=
_prob_1d
(
k
[:,
index
,
1
])
V
[:,
index
]
+=
_prob_1d
(
k
[:,
index
,
1
])
# Direction: 45 degrees (\)
curv
=
k
[:,:,
2
]
i
,
j
=
numpy
.
indices
(
curv
.
shape
)
for
index
in
range
(
-
curv
.
shape
[
0
]
+
1
,
curv
.
shape
[
1
]):
V
[
i
==
(
j
-
index
)
,
2
]
+=
_prob_1d
(
curv
.
diagonal
(
index
))
V
[
i
==
(
j
-
index
)]
+=
_prob_1d
(
curv
.
diagonal
(
index
))
# Direction: -45 degrees (/)
# NOTE: due to the way the access to the diagonals are implemented, in this
...
...
@@ -308,7 +308,7 @@ class MaximumCurvature (Extractor):
curv
=
numpy
.
flipud
(
k
[:,:,
3
])
#required so we get "/" diagonals correctly
Vud
=
numpy
.
flipud
(
V
)
#match above inversion
for
index
in
reversed
(
range
(
curv
.
shape
[
1
]
-
1
,
-
curv
.
shape
[
0
],
-
1
)):
Vud
[
i
==
(
j
-
index
)
,
3
]
+=
_prob_1d
(
curv
.
diagonal
(
index
))
Vud
[
i
==
(
j
-
index
)]
+=
_prob_1d
(
curv
.
diagonal
(
index
))
return
V
...
...
@@ -472,36 +472,36 @@ class MaximumCurvature (Extractor):
finger_image
=
image
[
0
]
finger_mask
=
image
[
1
]
import
time
start
=
time
.
time
()
#
import time
#
start = time.time()
kappa
=
self
.
detect_valleys
(
finger_image
,
finger_mask
)
#self._view_four(kappa, "Valley Detectors - $\kappa$")
print
(
'filtering took %.2f seconds'
%
(
time
.
time
()
-
start
))
start
=
time
.
time
()
#
print('filtering took %.2f seconds' % (time.time() - start))
#
start = time.time()
V
=
self
.
eval_vein_probabilities
(
kappa
)
#self._view_four(V, "Center Probabilities - $V_i$")
#self._view_single(V.sum(axis=2), "Accumulated Probabilities - V")
print
(
'probabilities took %.2f seconds'
%
(
time
.
time
()
-
start
))
start
=
time
.
time
()
#
print('probabilities took %.2f seconds' % (time.time() - start))
#
start = time.time()
Cd
=
self
.
connect_centres
(
V
.
sum
(
axis
=
2
)
)
Cd
=
self
.
connect_centres
(
V
)
#self._view_four(Cd, "Connected Centers - $C_{di}$")
#self._view_single(numpy.amax(Cd, axis=2), "Connected Centers - G")
print
(
'connections took %.2f seconds'
%
(
time
.
time
()
-
start
))
start
=
time
.
time
()
#
print('connections took %.2f seconds' % (time.time() - start))
#
start = time.time()
retval
=
self
.
binarise
(
numpy
.
amax
(
Cd
,
axis
=
2
))
#self._view_single(retval, "Final Binarised Image")
print
(
'binarization took %.2f seconds'
%
(
time
.
time
()
-
start
))
#
print('binarization took %.2f seconds' % (time.time() - start))
return
retval
bob/bio/vein/tests/test.py
View file @
c9a94c90
...
...
@@ -86,8 +86,7 @@ def test_max_curvature():
MC
=
MaximumCurvature
(
3
)
#value used to create references
kappa
=
MC
.
detect_valleys
(
image
,
mask
)
V
=
MC
.
eval_vein_probabilities
(
kappa
)
Vt
=
V
.
sum
(
axis
=
2
)
Vt
=
MC
.
eval_vein_probabilities
(
kappa
)
Cd
=
MC
.
connect_centres
(
Vt
)
G
=
numpy
.
amax
(
Cd
,
axis
=
2
)
bina
=
MC
.
binarise
(
G
)
...
...
matlab/compare.py
View file @
c9a94c90
...
...
@@ -32,8 +32,7 @@ from bob.bio.vein.extractor.MaximumCurvature import MaximumCurvature
MC
=
MaximumCurvature
(
3
)
kappa
=
MC
.
detect_valleys
(
image
,
region
)
#OK
V
=
MC
.
eval_vein_probabilities
(
kappa
)
#OK
Vt
=
V
.
sum
(
axis
=
2
)
#OK
Vt
=
MC
.
eval_vein_probabilities
(
kappa
)
#OK
Cd
=
MC
.
connect_centres
(
Vt
)
#OK
G
=
numpy
.
amax
(
Cd
,
axis
=
2
)
#OK
...
...
@@ -42,9 +41,6 @@ for k in range(4):
print
(
'Comparing kappa[%d]: %s'
%
(
k
,
numpy
.
abs
(
kappa
[...,
k
]
-
kappa_matlab
[...,
k
]).
sum
()))
for
k
in
range
(
4
):
print
(
'Comparing V[%d]: %s'
%
(
k
,
numpy
.
abs
(
V
[...,
k
]
-
V_matlab
[...,
k
]).
sum
()))
print
(
'Comparing Vt: %s'
%
numpy
.
abs
(
Vt
-
Vt_matlab
).
sum
())
for
k
in
range
(
4
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment