[853718]: / tests / test_data-utils.py

Download this file

36 lines (26 with data), 1.3 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
Testing default benchmarks in single thred and parallel configuration
Check whether it generates correct outputs and resulting values
Copyright (C) 2017-2019 Jiri Borovec <jiri.borovec@fel.cvut.cz>
"""
import os
import sys
import unittest
from parameterized import parameterized
sys.path += [os.path.abspath('.'), os.path.abspath('..')] # Add path to root
from birl.utilities.data_io import load_image, update_path
from birl.utilities.dataset import CONVERT_RGB, image_histogram_matching
PATH_ROOT = os.path.dirname(update_path('birl'))
PATH_DATA = update_path('data-images')
PATH_IMAGE_REF = os.path.join(PATH_DATA, 'rat-kidney_', 'scale-5pc', 'Rat-Kidney_HE.jpg')
PATH_IMAGE_SRC = os.path.join(PATH_DATA, 'rat-kidney_', 'scale-5pc', 'Rat-Kidney_PanCytokeratin.jpg')
class TestHistogramMatching(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.img_ref = load_image(PATH_IMAGE_REF)
cls.img_src = load_image(PATH_IMAGE_SRC)
@parameterized.expand(list(CONVERT_RGB.keys()))
def test_hist_matching(self, clr_space):
""" test run in parallel with failing experiment """
img = image_histogram_matching(self.img_src, self.img_ref, use_color=clr_space)
self.assertAlmostEqual(self.img_src.shape, img.shape)