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
c35479d3
Commit
c35479d3
authored
Jul 26, 2016
by
André Anjos
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[preproc] Improve finger post-processing (heq); Fix warnings
parent
bc0745df
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
19 deletions
+39
-19
bob/bio/vein/preprocessors/FingerCrop.py
bob/bio/vein/preprocessors/FingerCrop.py
+39
-19
No files found.
bob/bio/vein/preprocessors/FingerCrop.py
View file @
c35479d3
...
...
@@ -29,7 +29,7 @@ class FingerCrop (Preprocessor):
1. Padded
2. The mask is extracted
3. The finger is normalized (made horizontal)
3
. (optionally) Post processed
4
. (optionally) Post processed
Parameters:
...
...
@@ -220,15 +220,15 @@ class FingerCrop (Preprocessor):
# Right region has always the finger ending, crop the padding with the
# meadian
finger_mask
[:,
numpy
.
median
(
y_rg
)
+
img_filt_rg
.
shape
[
1
]
:]
=
False
finger_mask
[:,
int
(
numpy
.
median
(
y_rg
)
+
img_filt_rg
.
shape
[
1
])
:]
=
False
# Extract y-position of finger edges
edges
=
numpy
.
zeros
((
2
,
img_w
))
edges
[
0
,:]
=
y_up
edges
[
0
,
0
:
round
(
numpy
.
mean
(
y_lf
))
+
1
]
=
edges
[
0
,
round
(
numpy
.
mean
(
y_lf
))
+
1
]
edges
[
0
,
0
:
int
(
round
(
numpy
.
mean
(
y_lf
))
+
1
)]
=
edges
[
0
,
int
(
round
(
numpy
.
mean
(
y_lf
))
+
1
)
]
edges
[
1
,:]
=
numpy
.
round
(
y_lo
+
img_filt_lo
.
shape
[
0
])
edges
[
1
,
0
:
round
(
numpy
.
mean
(
y_lf
))
+
1
]
=
edges
[
1
,
round
(
numpy
.
mean
(
y_lf
))
+
1
]
edges
[
1
,
0
:
int
(
round
(
numpy
.
mean
(
y_lf
))
+
1
)]
=
edges
[
1
,
int
(
round
(
numpy
.
mean
(
y_lf
))
+
1
)
]
return
finger_mask
,
edges
...
...
@@ -401,8 +401,13 @@ class FingerCrop (Preprocessor):
return
(
image_norm
,
mask_norm
)
def
__HE__
(
self
,
image
):
"""Applies histogram equalization on the input image
def
__HE__
(
self
,
image
,
mask
):
"""Applies histogram equalization on the input image inside the mask
In this implementation, only the pixels that lie inside the mask will be
used to calculate the histogram equalization parameters. Because of this
particularity, we don't use Bob's implementation for histogram equalization
and have one based exclusively on NumPy.
Parameters:
...
...
@@ -410,6 +415,10 @@ class FingerCrop (Preprocessor):
image (numpy.ndarray): raw image to be filtered, as 2D array of
unsigned 8-bit integers
mask (numpy.ndarray): mask of the same size of the image, but composed
of boolean values indicating which values should be considered for
the histogram equalization
Returns:
...
...
@@ -418,9 +427,19 @@ class FingerCrop (Preprocessor):
"""
#Umbralization based on the pixels non zero
retval
=
numpy
.
zeros
(
image
.
shape
,
dtype
=
numpy
.
uint8
)
bob
.
ip
.
base
.
histogram_equalization
(
image
,
retval
)
image_histogram
,
bins
=
numpy
.
histogram
(
image
[
mask
],
256
,
normed
=
True
)
cdf
=
image_histogram
.
cumsum
()
# cumulative distribution function
cdf
=
255
*
cdf
/
cdf
[
-
1
]
# normalize
# use linear interpolation of cdf to find new pixel values
image_equalized
=
numpy
.
interp
(
image
.
flatten
(),
bins
[:
-
1
],
cdf
)
image_equalized
=
image_equalized
.
reshape
(
image
.
shape
)
# normalized image to be returned is a composition of the original image
# (background) and the equalized image (finger area)
retval
=
image
.
copy
()
retval
[
mask
]
=
image_equalized
[
mask
]
return
retval
...
...
@@ -521,32 +540,33 @@ class FingerCrop (Preprocessor):
"""Reads the input image, extract the mask of the fingervein, postprocesses
"""
import
ipdb
;
ipdb
.
set_trace
()
# 1. Pads the input image if any padding should be added
image
=
numpy
.
pad
(
image
,
self
.
padding_width
,
'constant'
,
constant_values
=
self
.
padding_constant
)
## Finger edges and contour extraction:
if
self
.
fingercontour
==
'leemaskMatlab'
:
finger_mask
,
finger_
edges
=
self
.
__leemaskMatlab__
(
image
)
#for UTFVP
mask
,
edges
=
self
.
__leemaskMatlab__
(
image
)
#for UTFVP
elif
self
.
fingercontour
==
'leemaskMod'
:
finger_mask
,
finger_
edges
=
self
.
__leemaskMod__
(
image
)
#for VERA
mask
,
edges
=
self
.
__leemaskMod__
(
image
)
#for VERA
elif
self
.
fingercontour
==
'konomask'
:
finger_mask
,
finger_
edges
=
self
.
__konomask__
(
image
,
sigma
=
5
)
mask
,
edges
=
self
.
__konomask__
(
image
,
sigma
=
5
)
## Finger region normalization:
image_norm
,
finger_mask_norm
=
self
.
__huangnormalization__
(
image
,
finger_mask
,
finger_edges
)
image_norm
,
mask_norm
=
self
.
__huangnormalization__
(
image
,
mask
,
edges
)
## veins enhancement:
if
self
.
postprocessing
==
'HE'
:
image_norm
=
self
.
__HE__
(
image_norm
)
image_norm
=
self
.
__HE__
(
image_norm
,
mask_norm
)
elif
self
.
postprocessing
==
'HFE'
:
image_norm
=
self
.
__HFE__
(
image_norm
)
elif
self
.
postprocessing
==
'CircGabor'
:
image_norm
=
self
.
__circularGabor__
(
image_norm
,
1.12
,
5
)
## returns the normalized image and the finger mask
return
image_norm
,
finger_
mask_norm
return
image_norm
,
mask_norm
def
write_data
(
self
,
data
,
filename
):
...
...
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