Commit 9a317867 authored by André Anjos's avatar André Anjos 💬

Support view mode w/o extracted veins

parent 1060d415
...@@ -93,7 +93,7 @@ def save_figures(title, image, mask, image_pp, binary): ...@@ -93,7 +93,7 @@ def save_figures(title, image, mask, image_pp, binary):
'binarized.png')) '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 '''Builds a proof canvas out of individual images
...@@ -111,8 +111,9 @@ def proof_figure(title, image, mask, image_pp, binary): ...@@ -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 image_pp (numpy.ndarray): A version of the original image, pre-processed by
one of the available algorithms one of the available algorithms
binary (numpy.ndarray): A binarized version of the original image in which binary (numpy.ndarray, Optional): A binarized version of the original image
all pixels (should) represent vein (``True``) or not-vein (``False``) in which all pixels (should) represent vein (``True``) or not-vein
(``False``)
Returns: Returns:
...@@ -122,24 +123,27 @@ def proof_figure(title, image, mask, image_pp, binary): ...@@ -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 # add original image
mpl.subplot(3, 1, 1) mpl.subplot(images, 1, 1)
mpl.title('%s - original' % title) mpl.title('%s - original' % title)
mpl.imshow(image, cmap="gray") mpl.imshow(image, cmap="gray")
# add preprocessed image # add preprocessed image
from ..preprocessor import utils from ..preprocessor import utils
img = utils.draw_mask_over_image(image_pp, mask) img = utils.draw_mask_over_image(image_pp, mask)
mpl.subplot(3, 1, 2) mpl.subplot(images, 1, 2)
mpl.title('Preprocessed') mpl.title('Preprocessed')
mpl.imshow(img) mpl.imshow(img)
# add binary image if binary is not None:
mpl.subplot(3, 1, 3) # add binary image
mpl.title('Binarized') mpl.subplot(3, 1, 3)
mpl.imshow(binary.astype('uint8')*255, cmap="gray") mpl.title('Binarized')
mpl.imshow(binary.astype('uint8')*255, cmap="gray")
return fig return fig
...@@ -172,16 +176,18 @@ def main(user_input=None): ...@@ -172,16 +176,18 @@ def main(user_input=None):
# Loads the image, the mask and save it to a PNG file # Loads the image, the mask and save it to a PNG file
for stem in args['<stem>']: for stem in args['<stem>']:
image = bob.bio.base.load(os.path.join(args['<database>'], stem + '.png')) 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>'], pp = bob.io.base.HDF5File(os.path.join(args['<processed>'],
'preprocessed', stem + '.hdf5')) 'preprocessed', stem + '.hdf5'))
mask = pp.read('mask') mask = pp.read('mask')
image_pp = pp.read('image') image_pp = pp.read('image')
binary = bob.io.base.load(os.path.join(args['<processed>'], binary_path = os.path.join(args['<processed>'], 'extracted', stem + '.hdf5')
'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 = proof_figure(stem, image, mask, image_pp, binary)
#fig.title(stem)
if args['--save']: if args['--save']:
#fig.savefig(args['--save'])
save_figures(args['--save'], image, mask, image_pp, binary) save_figures(args['--save'], image, mask, image_pp, binary)
else: else:
mpl.show() mpl.show()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment