Commit 5c9171c3 authored by André Anjos's avatar André Anjos 💬

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

parent cf9c1fe8
......@@ -29,6 +29,21 @@ def F(parts):
return pkg_resources.resource_filename(__name__, os.path.join(*parts))
def _show_image(image):
"""Shows a single image
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)
def _show_mask_over_image(image, mask, color='red'):
"""Plots the mask over the image of a finger, for debugging purposes
......@@ -66,12 +81,15 @@ def test_finger_crop():
preproc, mask = preprocess(img)
#_show_mask_over_image(preproc, mask)
mask_ref =
preproc_ref =
mask_ref ='bool')
preproc_ref = bob.core.convert(,
numpy.uint8, (0,255), (0.0,1.0))
assert numpy.mean(numpy.abs(mask - mask_ref)) < 1e-2
# Very loose comparison!
assert numpy.mean(numpy.abs(mask.astype('float64') - mask_ref)) < 1e-2
assert numpy.mean(numpy.abs(preproc - preproc_ref)) < 1e2
#_show_image(numpy.abs(preproc.astype('int16') - preproc_ref.astype('int16')).astype('uint8'))
assert numpy.mean(numpy.abs(preproc - preproc_ref)) < 1.3e2
def test_miuramax():
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment