Skip to content
Snippets Groups Projects
Commit 5c9171c3 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

[test] Implement (optional) image viewing; Fix minor test

parent cf9c1fe8
No related branches found
No related tags found
2 merge requests!3Merging master branch into package-update,!2Marge master to the package-update
...@@ -29,6 +29,21 @@ def F(parts): ...@@ -29,6 +29,21 @@ def F(parts):
return pkg_resources.resource_filename(__name__, os.path.join(*parts)) return pkg_resources.resource_filename(__name__, os.path.join(*parts))
def _show_image(image):
"""Shows a single image
Parameters:
image (numpy.ndarray): A 2D numpy.ndarray compose of 8-bit unsigned
integers containing the original image
"""
from PIL import Image
img = Image.fromarray(image)
img.show()
def _show_mask_over_image(image, mask, color='red'): def _show_mask_over_image(image, mask, color='red'):
"""Plots the mask over the image of a finger, for debugging purposes """Plots the mask over the image of a finger, for debugging purposes
...@@ -66,12 +81,15 @@ def test_finger_crop(): ...@@ -66,12 +81,15 @@ def test_finger_crop():
preproc, mask = preprocess(img) preproc, mask = preprocess(img)
#_show_mask_over_image(preproc, mask) #_show_mask_over_image(preproc, mask)
mask_ref = bob.io.base.load(output_fvr_filename) mask_ref = bob.io.base.load(output_fvr_filename).astype('bool')
preproc_ref = bob.io.base.load(output_img_filename) preproc_ref = bob.core.convert(bob.io.base.load(output_img_filename),
numpy.uint8, (0,255), (0.0,1.0))
assert numpy.mean(numpy.abs(mask - mask_ref)) < 1e-2
# Very loose comparison! # Very loose comparison!
assert numpy.mean(numpy.abs(mask.astype('float64') - mask_ref)) < 1e-2 #_show_image(numpy.abs(preproc.astype('int16') - preproc_ref.astype('int16')).astype('uint8'))
assert numpy.mean(numpy.abs(preproc - preproc_ref)) < 1e2 assert numpy.mean(numpy.abs(preproc - preproc_ref)) < 1.3e2
def test_miuramax(): def test_miuramax():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment