Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.bio.vein
Commits
9a317867
Commit
9a317867
authored
Sep 01, 2017
by
André Anjos
💬
Browse files
Support view mode w/o extracted veins
parent
1060d415
Changes
1
Hide whitespace changes
Inline
Side-by-side
bob/bio/vein/script/view_sample.py
View file @
9a317867
...
...
@@ -93,7 +93,7 @@ def save_figures(title, image, mask, image_pp, binary):
'binarized.png'
))
def
proof_figure
(
title
,
image
,
mask
,
image_pp
,
binary
):
def
proof_figure
(
title
,
image
,
mask
,
image_pp
,
binary
=
None
):
'''Builds a proof canvas out of individual images
...
...
@@ -111,8 +111,9 @@ def proof_figure(title, image, mask, image_pp, binary):
image_pp (numpy.ndarray): A version of the original image, pre-processed by
one of the available algorithms
binary (numpy.ndarray): A binarized version of the original image in which
all pixels (should) represent vein (``True``) or not-vein (``False``)
binary (numpy.ndarray, Optional): A binarized version of the original image
in which all pixels (should) represent vein (``True``) or not-vein
(``False``)
Returns:
...
...
@@ -122,24 +123,27 @@ def proof_figure(title, image, mask, image_pp, binary):
'''
fig
=
mpl
.
figure
(
figsize
=
(
6
,
9
),
dpi
=
50
)
#900 x 300 pixels
fig
=
mpl
.
figure
(
figsize
=
(
6
,
9
),
dpi
=
100
)
images
=
3
if
binary
is
not
None
else
2
# add original image
mpl
.
subplot
(
3
,
1
,
1
)
mpl
.
subplot
(
images
,
1
,
1
)
mpl
.
title
(
'%s - original'
%
title
)
mpl
.
imshow
(
image
,
cmap
=
"gray"
)
# add preprocessed image
from
..preprocessor
import
utils
img
=
utils
.
draw_mask_over_image
(
image_pp
,
mask
)
mpl
.
subplot
(
3
,
1
,
2
)
mpl
.
subplot
(
images
,
1
,
2
)
mpl
.
title
(
'Preprocessed'
)
mpl
.
imshow
(
img
)
# add binary image
mpl
.
subplot
(
3
,
1
,
3
)
mpl
.
title
(
'Binarized'
)
mpl
.
imshow
(
binary
.
astype
(
'uint8'
)
*
255
,
cmap
=
"gray"
)
if
binary
is
not
None
:
# add binary image
mpl
.
subplot
(
3
,
1
,
3
)
mpl
.
title
(
'Binarized'
)
mpl
.
imshow
(
binary
.
astype
(
'uint8'
)
*
255
,
cmap
=
"gray"
)
return
fig
...
...
@@ -172,16 +176,18 @@ def main(user_input=None):
# Loads the image, the mask and save it to a PNG file
for
stem
in
args
[
'<stem>'
]:
image
=
bob
.
bio
.
base
.
load
(
os
.
path
.
join
(
args
[
'<database>'
],
stem
+
'.png'
))
image
=
numpy
.
rot90
(
image
,
k
=-
1
)
pp
=
bob
.
io
.
base
.
HDF5File
(
os
.
path
.
join
(
args
[
'<processed>'
],
'preprocessed'
,
stem
+
'.hdf5'
))
mask
=
pp
.
read
(
'mask'
)
image_pp
=
pp
.
read
(
'image'
)
binary
=
bob
.
io
.
base
.
load
(
os
.
path
.
join
(
args
[
'<processed>'
],
'extracted'
,
stem
+
'.hdf5'
))
binary_path
=
os
.
path
.
join
(
args
[
'<processed>'
],
'extracted'
,
stem
+
'.hdf5'
)
if
os
.
path
.
exists
(
binary_path
):
binary
=
bob
.
io
.
base
.
load
(
binary_path
)
else
:
binary
=
None
fig
=
proof_figure
(
stem
,
image
,
mask
,
image_pp
,
binary
)
#fig.title(stem)
if
args
[
'--save'
]:
#fig.savefig(args['--save'])
save_figures
(
args
[
'--save'
],
image
,
mask
,
image_pp
,
binary
)
else
:
mpl
.
show
()
...
...
Write
Preview
Supports
Markdown
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