Commit a21d16c5 authored by Teodors EGLITIS's avatar Teodors EGLITIS

Utils for ROI annotations and more

parent a42fe58c
Pipeline #5084 failed with stages
in 10 minutes and 46 seconds
include README.rst bootstrap-buildout.py buildout.cfg COPYING include README.rst bootstrap-buildout.py buildout.cfg COPYING
recursive-include doc *.py *.rst recursive-include doc *.py *.rst
recursive-include bob/bio/vein/tests *.png *.mat recursive-include bob/bio/vein/tests *.png *.mat *.txt *.npy
from .utils import ManualRoiCut
from .utils import ConstructVeinImage
from .utils import RotateImage
# gets sphinx autodoc done right - don't remove it
__all__ = [_ for _ in dir() if not _.startswith('_')]
This diff is collapsed.
26 0
27 7
29 24
31 38
40 80
45 104
50 124
58 156
61 171
65 187
67 194
69 205
71 223
74 251
76 274
79 298
81 324
83 341
83 358
86 385
87 408
89 445
90 474
91 518
91 534
91 559
90 581
90 620
90 633
88 648
89 655
89 672
277 672
279 648
280 606
284 552
284 482
280 413
280 358
281 309
286 277
288 238
288 195
285 165
285 138
285 111
288 49
291 20
294 0
11 91
8 322
76 320
114 307
140 300
176 292
225 292
269 288
330 287
405 288
436 290
456 288
468 276
473 242
472 208
470 184
466 146
455 116
440 93
424 77
397 69
358 64
298 60
247 52
201 38
160 25
130 7
106 7
81 16
46 46
22 71
...@@ -14,6 +14,7 @@ the generated sphinx documentation) ...@@ -14,6 +14,7 @@ the generated sphinx documentation)
import os import os
import numpy import numpy
import numpy as np
import nose.tools import nose.tools
import pkg_resources import pkg_resources
...@@ -186,3 +187,59 @@ def test_miura_match(): ...@@ -186,3 +187,59 @@ def test_miura_match():
score_imp = MM.score(template_vein, probe_imp_vein) score_imp = MM.score(template_vein, probe_imp_vein)
assert numpy.isclose(score_imp, 0.172906739278421) assert numpy.isclose(score_imp, 0.172906739278421)
def test_manualRoiCut():
from bob.bio.vein.preprocessors.utils.utils import ManualRoiCut
image_path = F(('preprocessors', '0019_3_1_120509-160517.png'))
annotation_path = F(('preprocessors', '0019_3_1_120509-160517.txt'))
c = ManualRoiCut(annotation_path, image_path)
mask_1 = c.roi_mask()
image_1 = c.roi_image()
# create mask using size:
c = ManualRoiCut(annotation_path, sizes=(672,380))
mask_2 = c.roi_mask()
# loading image:
image = bob.io.base.load(image_path)
c = ManualRoiCut(annotation_path, image)
mask_3 = c.roi_mask()
image_3 = c.roi_image()
# load text file:
with open(annotation_path,'r') as f:
retval = numpy.loadtxt(f, ndmin=2)
# carefully -- this is BOB format --- (x,y)
annotation = list([tuple([k[0], k[1]]) for k in retval])
c = ManualRoiCut(annotation, image)
mask_4 = c.roi_mask()
image_4 = c.roi_image()
assert (mask_1 == mask_2).all()
assert (mask_1 == mask_3).all()
assert (mask_1 == mask_4).all()
assert (image_1 == image_3).all()
assert (image_1 == image_4).all()
def test_ConstructAnnotations():
"""
Test ConstructAnnotations preprocessor
"""
image_filename = "/idiap/home/teglitis/Desktop/REFACTOR_ALL/src/bob.bio.vein/bob/bio/vein/tests/preprocessors/ConstructAnnotations.png"
roi_annotations_filename = "/idiap/home/teglitis/Desktop/REFACTOR_ALL/src/bob.bio.vein/bob/bio/vein/tests/preprocessors/ConstructAnnotations.txt"
vein_annotations_filename = "/idiap/home/teglitis/Desktop/REFACTOR_ALL/src/bob.bio.vein/bob/bio/vein/tests/preprocessors/ConstructAnnotations.npy"
image = bob.io.base.load( image_filename )
roi_annotations = np.loadtxt(roi_annotations_filename, dtype='uint16')
roi_annotations = [tuple([point[0], point[1]]) for point in roi_annotations]
fp = open(vein_annotations_filename, 'rt')
vein_annotations = np.load(fp)
vein_annotations = vein_annotations['arr_0'].tolist()
fp.close()
vein_annotations = [[tuple([point[0], point[1]]) for point in line] for line in vein_annotations]
annotation_dictionary = {"image" : image, "roi_annotations" : roi_annotations, "vein_annotations" : vein_annotations}
from bob.bio.vein.preprocessors import ConstructAnnotations
preprocessor = ConstructAnnotations(center = True, rotate = True)
output = preprocessor(annotation_dictionary)
assert np.array_equal(output, image)
...@@ -24,6 +24,11 @@ Pre-processors ...@@ -24,6 +24,11 @@ Pre-processors
.. automodule:: bob.bio.vein.preprocessor .. automodule:: bob.bio.vein.preprocessor
Pre-processor utilities
-----------------------
.. automodule:: bob.bio.vein.preprocessor.utils
Feature Extractors Feature Extractors
------------------ ------------------
......
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