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
700025b3
Commit
700025b3
authored
Oct 17, 2017
by
André Anjos
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Option to save figures discretely
parent
58a17cd8
Pipeline
#13267
passed with stages
in 22 minutes and 56 seconds
Changes
1
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
13 deletions
+37
-13
bob/bio/vein/script/watershed_mask.py
bob/bio/vein/script/watershed_mask.py
+37
-13
No files found.
bob/bio/vein/script/watershed_mask.py
View file @
700025b3
...
...
@@ -37,8 +37,10 @@ Options:
-S, --scan If set, ignores settings for the threshold and
scans the whole range of threshold printing the
Jaccard, M1 and M2 merith figures
-s <path>, --save=<path> If set, saves image into a file instead of
displaying it
-s <path>, --save=<path> If set, saves individual image into files instead
of displaying the result of processing. Pass the
name of directory that will be created and
suffixed with the paths of original images.
Examples:
...
...
@@ -47,10 +49,10 @@ Examples:
$ %(prog)s model.hdf5 verafinger sample-stem
Save the results of the preprocessing to
a file. In this case, the program
runs non-interactively:
Save the results of the preprocessing to
several files. In this case, the
program
runs non-interactively:
$ %(prog)s -s graphics
.png
model.hdf5 verafinger sample-stem
$ %(prog)s -s graphics model.hdf5 verafinger sample-stem
Scans the set of possible thresholds printing Jaccard, M1 and M2 indexes:
...
...
@@ -125,6 +127,28 @@ def validate(args):
return
sch
.
validate
(
args
)
def
save_figures
(
title
,
image
,
markers
,
edges
,
mask
):
'''Saves individual images on a directory
'''
dirname
=
os
.
path
.
dirname
(
title
)
if
not
os
.
path
.
exists
(
dirname
):
os
.
makedirs
(
dirname
)
bob
.
io
.
base
.
save
(
image
,
os
.
path
.
join
(
title
,
'original.png'
))
_
=
markers
.
copy
().
astype
(
'uint8'
)
_
[
_
==
1
]
=
128
bob
.
io
.
base
.
save
(
_
,
os
.
path
.
join
(
title
,
'markers.png'
))
bob
.
io
.
base
.
save
((
255
*
edges
).
astype
(
'uint8'
),
os
.
path
.
join
(
title
,
'edges.png'
))
bob
.
io
.
base
.
save
(
mask
.
astype
(
'uint8'
)
*
255
,
os
.
path
.
join
(
title
,
'mask.png'
))
from
..preprocessor.utils
import
draw_mask_over_image
masked_image
=
draw_mask_over_image
(
image
,
mask
)
masked_image
.
save
(
os
.
path
.
join
(
title
,
'masked.png'
))
def
make_figure
(
image
,
markers
,
edges
,
mask
):
'''Returns a matplotlib figure with the detailed processing result'''
...
...
@@ -138,7 +162,7 @@ def make_figure(image, markers, edges, mask):
plt
.
subplot
(
2
,
2
,
2
)
_
=
numpy
.
dstack
([
(
_
|
(
255
0
*
edges
).
astype
(
'uint8'
)),
(
_
|
(
255
*
edges
).
astype
(
'uint8'
)),
_
,
_
,
])
...
...
@@ -193,15 +217,15 @@ def process_one(args, image, path):
if
not
args
[
'--scan'
]:
if
args
[
'--save'
]:
dest
=
os
.
path
.
join
(
args
[
'--save'
],
path
)
save_figures
(
dest
,
image
,
markers
,
edges
,
mask
)
else
:
fig
=
make_figure
(
image
,
markers
,
edges
,
mask
)
fig
.
suptitle
(
'%s @ %s - JI=%.4f, M1=%.4f, M2=%.4f
\
n
'
\
'($
\
\
tau_{FG}$ = %.2f - $
\
\
tau_{BG}$ = %.2f)'
%
\
(
path
,
args
[
'<database>'
],
ji
,
m1
,
m2
,
args
[
'--fg-threshold'
],
args
[
'--bg-threshold'
]),
fontsize
=
12
)
if
args
[
'--save'
]:
fig
.
savefig
(
args
[
'--save'
])
else
:
print
(
'Close the figure to continue...'
)
plt
.
show
()
...
...
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