From bfe67849794bd26e66224209c743a73403ee3db5 Mon Sep 17 00:00:00 2001
From: dcarron <daniel.carron@idiap.ch>
Date: Wed, 15 May 2024 10:52:39 +0200
Subject: [PATCH] [tests] Add tests for drive database

---
 .../libs/classification/tests/__init__.py     |   0
 .../libs/classification/tests/conftest.py     | 270 ++++++++++++++++++
 src/mednet/libs/common/tests/__init__.py      |   0
 src/mednet/libs/common/tests/conftest.py      | 254 ----------------
 .../libs/segmentation/tests/__init__.py       |   0
 .../libs/segmentation/tests/conftest.py       | 265 +++++++++++++++++
 .../histograms_lwnet_drive_default.json       |  16 ++
 .../raw_data/histograms_drive_default.json    |  16 ++
 .../libs/segmentation/tests/test_drive.py     | 142 +++++++++
 9 files changed, 709 insertions(+), 254 deletions(-)
 create mode 100644 src/mednet/libs/classification/tests/__init__.py
 create mode 100644 src/mednet/libs/classification/tests/conftest.py
 create mode 100644 src/mednet/libs/common/tests/__init__.py
 create mode 100644 src/mednet/libs/segmentation/tests/__init__.py
 create mode 100644 src/mednet/libs/segmentation/tests/conftest.py
 create mode 100644 src/mednet/libs/segmentation/tests/data/histograms/models/histograms_lwnet_drive_default.json
 create mode 100644 src/mednet/libs/segmentation/tests/data/histograms/raw_data/histograms_drive_default.json
 create mode 100644 src/mednet/libs/segmentation/tests/test_drive.py

diff --git a/src/mednet/libs/classification/tests/__init__.py b/src/mednet/libs/classification/tests/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/src/mednet/libs/classification/tests/conftest.py b/src/mednet/libs/classification/tests/conftest.py
new file mode 100644
index 00000000..ecd74256
--- /dev/null
+++ b/src/mednet/libs/classification/tests/conftest.py
@@ -0,0 +1,270 @@
+# SPDX-FileCopyrightText: Copyright © 2023 Idiap Research Institute <contact@idiap.ch>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+import pathlib
+import typing
+
+import numpy
+import pytest
+import torch
+from mednet.libs.common.data.split import JSONDatabaseSplit
+from mednet.libs.common.data.typing import DatabaseSplit
+
+
+@pytest.fixture
+def datadir(request) -> pathlib.Path:
+    """Return the directory in which the test is sitting. Check the pytest
+    documentation for more information.
+
+    Parameters
+    ----------
+    request
+        Information of the requesting test function.
+
+    Returns
+    -------
+    pathlib.Path
+        The directory in which the test is sitting.
+    """
+
+    return pathlib.Path(request.module.__file__).parents[0] / "data"
+
+
+def pytest_configure(config):
+    """This function is run once for pytest setup.
+
+    Parameters
+    ----------
+    config
+        Configuration values. Check the pytest documentation for more
+        information.
+    """
+
+    config.addinivalue_line(
+        "markers",
+        "skip_if_rc_var_not_set(name): this mark skips the test if a certain "
+        "~/.config/mednet.libs.classification.toml variable is not set",
+    )
+
+    config.addinivalue_line("markers", "slow: this mark indicates slow tests")
+
+
+def pytest_runtest_setup(item):
+    """This function is run for every test candidate in this directory.
+
+    The test is run if this function returns ``None``.  To skip a test,
+    call ``pytest.skip()``, specifying a reason.
+
+    Parameters
+    ----------
+    item
+        A test invocation item. Check the pytest documentation for more
+        information.
+    """
+
+    from mednet.libs.classification.utils.rc import load_rc
+
+    rc = load_rc()
+
+    # iterates over all markers for the item being examined, get the first
+    # argument and accumulate these names
+    rc_names = [
+        mark.args[0]
+        for mark in item.iter_markers(name="skip_if_rc_var_not_set")
+    ]
+
+    # checks all names mentioned are set in ~/.config/mednet.libs.classification.toml, otherwise,
+    # skip the test
+    if rc_names:
+        missing = [k for k in rc_names if rc.get(k) is None]
+        if any(missing):
+            pytest.skip(
+                f"Test skipped because {', '.join(missing)} is **not** "
+                f"set in ~/.config/mednet.libs.classification.toml",
+            )
+
+
+def rc_variable_set(name):
+    from mednet.libs.classification.utils.rc import load_rc
+
+    rc = load_rc()
+    pytest.mark.skipif(
+        name not in rc,
+        reason=f"RC variable '{name}' is not set",
+    )
+
+
+@pytest.fixture(scope="session")
+def temporary_basedir(tmp_path_factory):
+    return tmp_path_factory.mktemp("test-cli")
+
+
+class DatabaseCheckers:
+    """Helpers for database tests."""
+
+    @staticmethod
+    def check_split(
+        split: DatabaseSplit,
+        lengths: dict[str, int],
+        prefixes: typing.Sequence[str],
+        possible_labels: typing.Sequence[int],
+    ):
+        """Run a simple consistency check on the data split.
+
+        Parameters
+        ----------
+        split
+            An instance of DatabaseSplit.
+        lengths
+            A dictionary that contains keys matching those of the split (this
+            will be checked).  The values of the dictionary should correspond
+            to the sizes of each of the datasets in the split.
+        prefixes
+            Each file named in a split should start with at least one of these
+            prefixes.
+        possible_labels
+            These are the list of possible labels contained in any split.
+        """
+
+        assert len(split) == len(lengths)
+
+        for k in lengths.keys():
+            # dataset must have been declared
+            assert k in split
+
+            assert len(split[k]) == lengths[k]
+            for s in split[k]:
+                assert any([s[0].startswith(k) for k in prefixes]), (
+                    f"Sample with name {s[0]} does not start with any of the "
+                    f"prefixes in {prefixes}"
+                )
+                if isinstance(s[1], list):
+                    assert all([k in possible_labels for k in s[1]])
+                else:
+                    assert s[1] in possible_labels
+
+    @staticmethod
+    def check_loaded_batch(
+        batch,
+        batch_size: int,
+        color_planes: int,
+        prefixes: typing.Sequence[str],
+        possible_labels: typing.Sequence[int],
+        expected_num_labels: int,
+        expected_image_shape: tuple[int, ...] | None = None,
+    ):
+        """Check the consistency of an individual (loaded) batch.
+
+        Parameters
+        ----------
+        batch
+            The loaded batch to be checked.
+        batch_size
+            The mini-batch size.
+        color_planes
+            The number of color planes in the images.
+        prefixes
+            Each file named in a split should start with at least one of these
+            prefixes.
+        possible_labels
+            These are the list of possible labels contained in any split.
+        expected_num_labels
+            The expected number of labels each sample should have.
+        expected_image_shape
+            The expected shape of the image (num_channels, width, height).
+        """
+
+        assert len(batch) == 2  # data, metadata
+
+        assert isinstance(batch[0], torch.Tensor)
+        assert batch[0].shape[0] == batch_size  # mini-batch size
+        assert batch[0].shape[1] == color_planes
+
+        if expected_image_shape:
+            assert all(
+                [data.shape == expected_image_shape for data in batch[0]],
+            )
+
+        assert isinstance(batch[1], dict)  # metadata
+        assert len(batch[1]) == 2  # label and name
+
+        assert "target" in batch[1]
+        assert all([k in possible_labels for k in batch[1]["target"]])
+
+        if expected_num_labels:
+            assert len(batch[1]["target"]) == expected_num_labels
+
+        assert "name" in batch[1]
+        assert all(
+            [
+                any([k.startswith(j) for j in prefixes])
+                for k in batch[1]["name"]
+            ],
+        )
+
+        # use the code below to view generated images
+        # from torchvision.transforms.functional import to_pil_image
+        # to_pil_image(batch[0][0]).show()
+        # __import__("pdb").set_trace()
+
+    @staticmethod
+    def check_image_quality(
+        datamodule,
+        reference_histogram_file,
+        compare_type="equal",
+        pearson_coeff_threshold=0.005,
+    ):
+        ref_histogram_splits = JSONDatabaseSplit(reference_histogram_file)
+
+        for split_name in ref_histogram_splits:
+            raw_samples = datamodule.splits[split_name][0][0]
+
+            # It is not possible to get a sample from a Dataset by name/path,
+            # only by index. This creates a dict of sample name to dataset
+            # index.
+            raw_samples_indices = {}
+            for idx, rs in enumerate(raw_samples):
+                raw_samples_indices[rs[0]] = idx
+
+            for ref_hist_path, ref_hist_data in ref_histogram_splits[
+                split_name
+            ]:
+                # Get index in the dataset that will return the data
+                # corresponding to the specified sample name
+                dataset_sample_index = raw_samples_indices[ref_hist_path]
+
+                image_tensor = datamodule._datasets[split_name][  # noqa: SLF001
+                    dataset_sample_index
+                ][0]
+
+                histogram = []
+                for color_channel in image_tensor:
+                    color_channel = numpy.multiply(
+                        color_channel.numpy(),
+                        255,
+                    ).astype(int)
+                    histogram.extend(
+                        numpy.histogram(
+                            color_channel,
+                            bins=256,
+                            range=(0, 256),
+                        )[0].tolist(),
+                    )
+
+                if compare_type == "statistical":
+                    # Compute pearson coefficients between histogram and
+                    # reference and check the similarity within a certain
+                    # threshold
+                    pearson_coeffs = numpy.corrcoef(histogram, ref_hist_data)
+                    assert (
+                        1 - pearson_coeff_threshold <= pearson_coeffs[0][1] <= 1
+                    )
+
+                else:
+                    assert histogram == ref_hist_data
+
+
+@pytest.fixture
+def database_checkers():
+    return DatabaseCheckers
diff --git a/src/mednet/libs/common/tests/__init__.py b/src/mednet/libs/common/tests/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/src/mednet/libs/common/tests/conftest.py b/src/mednet/libs/common/tests/conftest.py
index c732ed83..07dbdce9 100644
--- a/src/mednet/libs/common/tests/conftest.py
+++ b/src/mednet/libs/common/tests/conftest.py
@@ -4,14 +4,8 @@
 
 import json
 import pathlib
-import typing
 
-import numpy
-import numpy.typing
 import pytest
-import torch
-from mednet.libs.common.data.split import JSONDatabaseSplit
-from mednet.libs.common.data.typing import DatabaseSplit
 
 
 @pytest.fixture
@@ -31,251 +25,3 @@ def datadir(request) -> pathlib.Path:
     """
 
     return pathlib.Path(request.module.__file__).parents[0] / "data"
-
-
-def pytest_configure(config):
-    """This function is run once for pytest setup.
-
-    Parameters
-    ----------
-    config
-        Configuration values. Check the pytest documentation for more
-        information.
-    """
-
-    config.addinivalue_line(
-        "markers",
-        "skip_if_rc_var_not_set(name): this mark skips the test if a certain "
-        "~/.config/mednet.libs.classification.toml variable is not set",
-    )
-
-    config.addinivalue_line("markers", "slow: this mark indicates slow tests")
-
-
-def pytest_runtest_setup(item):
-    """This function is run for every test candidate in this directory.
-
-    The test is run if this function returns ``None``.  To skip a test,
-    call ``pytest.skip()``, specifying a reason.
-
-    Parameters
-    ----------
-    item
-        A test invocation item. Check the pytest documentation for more
-        information.
-    """
-
-    from mednet.libs.classification.utils.rc import load_rc
-
-    rc = load_rc()
-
-    # iterates over all markers for the item being examined, get the first
-    # argument and accumulate these names
-    rc_names = [
-        mark.args[0] for mark in item.iter_markers(name="skip_if_rc_var_not_set")
-    ]
-
-    # checks all names mentioned are set in ~/.config/mednet.libs.classification.toml, otherwise,
-    # skip the test
-    if rc_names:
-        missing = [k for k in rc_names if rc.get(k) is None]
-        if any(missing):
-            pytest.skip(
-                f"Test skipped because {', '.join(missing)} is **not** "
-                f"set in ~/.config/mednet.libs.classification.toml",
-            )
-
-
-def rc_variable_set(name):
-    from mednet.libs.classification.utils.rc import load_rc
-
-    rc = load_rc()
-    pytest.mark.skipif(
-        name not in rc,
-        reason=f"RC variable '{name}' is not set",
-    )
-
-
-@pytest.fixture(scope="session")
-def temporary_basedir(tmp_path_factory):
-    return tmp_path_factory.mktemp("test-cli")
-
-
-class DatabaseCheckers:
-    """Helpers for database tests."""
-
-    @staticmethod
-    def check_split(
-        split: DatabaseSplit,
-        lengths: dict[str, int],
-        prefixes: typing.Sequence[str],
-        possible_labels: typing.Sequence[int],
-    ) -> None:
-        """Run a simple consistency check on the data split.
-
-        Parameters
-        ----------
-        split
-            An instance of DatabaseSplit.
-        lengths
-            A dictionary that contains keys matching those of the split (this
-            will be checked).  The values of the dictionary should correspond
-            to the sizes of each of the datasets in the split.
-        prefixes
-            Each file named in a split should start with at least one of these
-            prefixes.
-        possible_labels
-            These are the list of possible labels contained in any split.
-        """
-
-        assert len(split) == len(lengths)
-
-        for k in lengths.keys():
-            # dataset must have been declared
-            assert k in split
-
-            assert len(split[k]) == lengths[k]
-            for s in split[k]:
-                assert any([s[0].startswith(k) for k in prefixes]), (
-                    f"Sample with name {s[0]} does not start with any of the "
-                    f"prefixes in {prefixes}"
-                )
-                if isinstance(s[1], list):
-                    assert all([k in possible_labels for k in s[1]])
-                else:
-                    assert s[1] in possible_labels
-
-    @staticmethod
-    def check_loaded_batch(
-        batch,
-        batch_size: int,
-        color_planes: int,
-        prefixes: typing.Sequence[str],
-        possible_labels: typing.Sequence[int],
-        expected_num_labels: int,
-        expected_image_shape: tuple[int, ...] | None = None,
-    ) -> None:
-        """Check the consistency of an individual (loaded) batch.
-
-        Parameters
-        ----------
-        batch
-            The loaded batch to be checked.
-        batch_size
-            The mini-batch size.
-        color_planes
-            The number of color planes in the images.
-        prefixes
-            Each file named in a split should start with at least one of these
-            prefixes.
-        possible_labels
-            These are the list of possible labels contained in any split.
-        expected_num_labels
-            The expected number of labels each sample should have.
-        expected_image_shape
-            The expected shape of the image (num_channels, width, height).
-        """
-
-        assert len(batch) == 2  # data, metadata
-
-        assert isinstance(batch[0], torch.Tensor)
-        assert batch[0].shape[0] == batch_size  # mini-batch size
-        assert batch[0].shape[1] == color_planes
-
-        if expected_image_shape:
-            assert all(
-                [data.shape == expected_image_shape for data in batch[0]],
-            )
-
-        assert isinstance(batch[1], dict)  # metadata
-        assert len(batch[1]) == 2  # label and name
-
-        assert "target" in batch[1]
-        assert all([k in possible_labels for k in batch[1]["target"]])
-
-        if expected_num_labels:
-            assert len(batch[1]["target"]) == expected_num_labels
-
-        assert "name" in batch[1]
-        assert all(
-            [any([k.startswith(j) for j in prefixes]) for k in batch[1]["name"]],
-        )
-
-        # use the code below to view generated images
-        # from torchvision.transforms.functional import to_pil_image
-        # to_pil_image(batch[0][0]).show()
-        # __import__("pdb").set_trace()
-
-    @staticmethod
-    def _make_histo(data: numpy.typing.NDArray[numpy.uint8]) -> list[int]:
-        from itertools import chain
-
-        def _mk_single_channel(data: numpy.typing.NDArray[numpy.uint8]) -> list[int]:
-            return numpy.histogram(data, bins=256, range=(0, 256))[0].tolist()
-
-        return list(chain(*[_mk_single_channel(k) for k in data[0, :]]))
-
-    @staticmethod
-    def check_image_quality(
-        datamodule,
-        reference_histogram_file: pathlib.Path,
-        compare_type: typing.Literal["equal", "statistical"] = "equal",
-        pearson_coeff_threshold: float = 0.005,
-    ) -> None:
-        reference = {}
-        for split, values in JSONDatabaseSplit(reference_histogram_file).items():
-            reference[split] = {k[0]: k[1] for k in values}
-
-        for split_name, loader in datamodule.predict_dataloader().items():
-            for sample in loader:
-                uint8_array = (255 * sample[0]).byte().numpy()
-                histogram = DatabaseCheckers._make_histo(uint8_array)
-
-                if sample[1]["name"][0] in reference[split_name]:
-                    ref_histogram = reference[split_name].pop(sample[1]["name"][0])
-                else:
-                    continue
-
-                if compare_type == "statistical":
-                    # Compute pearson coefficients between histogram and
-                    # reference and check the similarity within a certain
-                    # threshold
-                    pearson_coeffs = numpy.corrcoef(histogram, ref_histogram)
-                    assert (1 - pearson_coeff_threshold) <= pearson_coeffs[0][1] <= 1
-
-                else:
-                    assert histogram == ref_histogram, (
-                        f"Current and reference histograms for sample "
-                        f"`{sample[1]['name'][0]}` at split `{split_name}` "
-                        f"do not match: current = {histogram}, "
-                        f"reference = {ref_histogram}"
-                    )
-
-        # all references must have been consumed
-        for ref_split, left_values in reference.items():
-            assert len(left_values) == 0, (
-                f"Not all references at split `{ref_split}` were consumed: "
-                f"{len(left_values)} are left"
-            )
-
-    @staticmethod
-    def write_image_quality_histogram(
-        datamodule,
-        reference_histogram_file: pathlib.Path,
-    ) -> None:
-        data: dict[str, list] = {}
-        for split_name, loader in datamodule.predict_dataloader().items():
-            data[split_name] = []
-            for sample in loader:
-                uint8_array = (255 * sample[0]).byte().numpy()
-                data[split_name].append(
-                    [sample[1]["name"][0], DatabaseCheckers._make_histo(uint8_array)]
-                )
-
-        with reference_histogram_file.open("w") as f:
-            json.dump(data, f)
-
-
-@pytest.fixture
-def database_checkers():
-    return DatabaseCheckers
diff --git a/src/mednet/libs/segmentation/tests/__init__.py b/src/mednet/libs/segmentation/tests/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/src/mednet/libs/segmentation/tests/conftest.py b/src/mednet/libs/segmentation/tests/conftest.py
new file mode 100644
index 00000000..648d9674
--- /dev/null
+++ b/src/mednet/libs/segmentation/tests/conftest.py
@@ -0,0 +1,265 @@
+# SPDX-FileCopyrightText: Copyright © 2023 Idiap Research Institute <contact@idiap.ch>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+import pathlib
+import typing
+
+import numpy
+import pytest
+import torch
+from mednet.libs.common.data.split import JSONDatabaseSplit
+from mednet.libs.common.data.typing import DatabaseSplit
+
+
+@pytest.fixture
+def datadir(request) -> pathlib.Path:
+    """Return the directory in which the test is sitting. Check the pytest
+    documentation for more information.
+
+    Parameters
+    ----------
+    request
+        Information of the requesting test function.
+
+    Returns
+    -------
+    pathlib.Path
+        The directory in which the test is sitting.
+    """
+
+    return pathlib.Path(request.module.__file__).parents[0] / "data"
+
+
+def pytest_configure(config):
+    """This function is run once for pytest setup.
+
+    Parameters
+    ----------
+    config
+        Configuration values. Check the pytest documentation for more
+        information.
+    """
+
+    config.addinivalue_line(
+        "markers",
+        "skip_if_rc_var_not_set(name): this mark skips the test if a certain "
+        "~/.config/mednet.libs.segmentation.toml variable is not set",
+    )
+
+    config.addinivalue_line("markers", "slow: this mark indicates slow tests")
+
+
+def pytest_runtest_setup(item):
+    """This function is run for every test candidate in this directory.
+
+    The test is run if this function returns ``None``.  To skip a test,
+    call ``pytest.skip()``, specifying a reason.
+
+    Parameters
+    ----------
+    item
+        A test invocation item. Check the pytest documentation for more
+        information.
+    """
+
+    from mednet.libs.segmentation.utils.rc import load_rc
+
+    rc = load_rc()
+
+    # iterates over all markers for the item being examined, get the first
+    # argument and accumulate these names
+    rc_names = [
+        mark.args[0]
+        for mark in item.iter_markers(name="skip_if_rc_var_not_set")
+    ]
+
+    # checks all names mentioned are set in ~/.config/mednet.libs.segmentation.toml, otherwise,
+    # skip the test
+    if rc_names:
+        missing = [k for k in rc_names if rc.get(k) is None]
+        if any(missing):
+            pytest.skip(
+                f"Test skipped because {', '.join(missing)} is **not** "
+                f"set in ~/.config/mednet.libs.segmentation.toml",
+            )
+
+
+def rc_variable_set(name):
+    from mednet.libs.segmentation.utils.rc import load_rc
+
+    rc = load_rc()
+    pytest.mark.skipif(
+        name not in rc,
+        reason=f"RC variable '{name}' is not set",
+    )
+
+
+@pytest.fixture(scope="session")
+def temporary_basedir(tmp_path_factory):
+    return tmp_path_factory.mktemp("test-cli")
+
+
+class DatabaseCheckers:
+    """Helpers for database tests."""
+
+    @staticmethod
+    def check_split(
+        split: DatabaseSplit,
+        lengths: dict[str, int],
+        prefixes: typing.Sequence[str] = None,
+    ):
+        """Run a simple consistency check on the data split.
+
+        Parameters
+        ----------
+        split
+            An instance of DatabaseSplit.
+        lengths
+            A dictionary that contains keys matching those of the split (this
+            will be checked).  The values of the dictionary should correspond
+            to the sizes of each of the datasets in the split.
+        prefixes
+            Each file named in a split should start with at least one of these
+            prefixes.
+        """
+
+        assert len(split) == len(lengths)
+
+        for k in lengths.keys():
+            # dataset must have been declared
+            assert k in split
+
+            assert len(split[k]) == lengths[k]
+            for s in split[k]:
+                if prefixes is not None:
+                    assert any([s[0].startswith(k) for k in prefixes]), (
+                        f"Sample with name {s[0]} does not start with any of the "
+                        f"prefixes in {prefixes}"
+                    )
+
+    @staticmethod
+    def check_loaded_batch(
+        batch,
+        batch_size: int,
+        color_planes: int,
+        expected_num_targets: int,
+        prefixes: typing.Sequence[str] = None,
+        expected_image_shape: tuple[int, ...] | None = None,
+    ):
+        """Check the consistency of an individual (loaded) batch.
+
+        Parameters
+        ----------
+        batch
+            The loaded batch to be checked.
+        batch_size
+            The mini-batch size.
+        color_planes
+            The number of color planes in the images.
+        expected_num_targets
+            The expected number of labels each sample should have.
+        prefixes
+            Each file named in a split should start with at least one of these
+            prefixes.
+        expected_image_shape
+            The expected shape of the image (num_channels, width, height).
+        """
+
+        assert len(batch) == 2  # sample, metadata
+
+        assert isinstance(batch[0], torch.Tensor)
+        assert batch[0].shape[0] == batch_size  # mini-batch size
+        assert batch[0].shape[1] == color_planes
+        assert all([isinstance(image, torch.Tensor) for image in batch[0]])
+
+        if expected_image_shape:
+            assert all(
+                [data.shape == expected_image_shape for data in batch[0]],
+            )
+
+        assert isinstance(batch[1], dict)  # metadata
+        assert len(batch[1]) in [2, 3]  # target, Optional(mask), name
+
+        assert "target" in batch[1]
+        assert all(
+            [isinstance(target, torch.Tensor) for target in batch[1]["target"]]
+        )
+
+        if expected_num_targets:
+            assert len(batch[1]["target"]) == expected_num_targets
+
+        if "mask" in batch[1]:
+            assert all(
+                [isinstance(mask, torch.Tensor) for mask in batch[1]["mask"]]
+            )
+
+        assert "name" in batch[1]
+        if prefixes is not None:
+            assert all(
+                [
+                    any([k.startswith(j) for j in prefixes])
+                    for k in batch[1]["name"]
+                ],
+            )
+
+    @staticmethod
+    def check_image_quality(
+        datamodule,
+        reference_histogram_file,
+        compare_type="equal",
+        pearson_coeff_threshold=0.005,
+    ):
+        ref_histogram_splits = JSONDatabaseSplit(reference_histogram_file)
+
+        for split_name in ref_histogram_splits:
+            raw_samples = datamodule.splits[split_name][0][0]
+
+            # It is not possible to get a sample from a Dataset by name/path,
+            # only by index. This creates a dict of sample name to dataset
+            # index.
+            raw_samples_indices = {}
+            for idx, rs in enumerate(raw_samples):
+                raw_samples_indices[rs[0]] = idx
+
+            for ref_hist_path, ref_hist_data in ref_histogram_splits[
+                split_name
+            ]:
+                # Get index in the dataset that will return the data
+                # corresponding to the specified sample name
+                dataset_sample_index = raw_samples_indices[ref_hist_path]
+
+                image_tensor = datamodule._datasets[split_name][  # noqa: SLF001
+                    dataset_sample_index
+                ][0]
+
+                histogram = []
+                for color_channel in image_tensor:
+                    color_channel = numpy.multiply(
+                        color_channel.numpy(),
+                        255,
+                    ).astype(int)
+                    histogram.extend(
+                        numpy.histogram(
+                            color_channel,
+                            bins=256,
+                            range=(0, 256),
+                        )[0].tolist(),
+                    )
+
+                if compare_type == "statistical":
+                    # Compute pearson coefficients between histogram and
+                    # reference and check the similarity within a certain
+                    # threshold
+                    pearson_coeffs = numpy.corrcoef(histogram, ref_hist_data)
+                    assert (
+                        1 - pearson_coeff_threshold <= pearson_coeffs[0][1] <= 1
+                    )
+
+                else:
+                    assert histogram == ref_hist_data
+
+
+@pytest.fixture
+def database_checkers():
+    return DatabaseCheckers
diff --git a/src/mednet/libs/segmentation/tests/data/histograms/models/histograms_lwnet_drive_default.json b/src/mednet/libs/segmentation/tests/data/histograms/models/histograms_lwnet_drive_default.json
new file mode 100644
index 00000000..f289170e
--- /dev/null
+++ b/src/mednet/libs/segmentation/tests/data/histograms/models/histograms_lwnet_drive_default.json
@@ -0,0 +1,16 @@
+{
+  "train": [
+    ["training/images/24_training.tif", [5, 20, 22, 90, 241, 455, 3058, 11873, 20536, 17203, 7670, 3202, 1775, 1003, 579, 335, 217, 117, 70, 63, 47, 50, 54, 41, 30, 24, 40, 46, 35, 32, 36, 33, 18, 31, 27, 29, 35, 22, 37, 37, 26, 18, 31, 29, 21, 25, 38, 25, 27, 25, 33, 18, 32, 25, 24, 23, 37, 26, 15, 25, 37, 24, 23, 41, 46, 21, 35, 44, 21, 36, 32, 31, 30, 27, 25, 16, 30, 21, 24, 23, 24, 24, 11, 27, 21, 14, 16, 20, 18, 13, 16, 13, 19, 22, 16, 15, 22, 25, 14, 14, 17, 11, 11, 17, 16, 10, 25, 14, 15, 11, 12, 21, 13, 6, 15, 19, 17, 21, 19, 14, 25, 13, 16, 18, 16, 21, 18, 21, 24, 16, 12, 20, 18, 17, 22, 17, 18, 21, 22, 19, 23, 18, 21, 31, 23, 22, 24, 40, 38, 35, 40, 47, 47, 58, 53, 89, 94, 110, 147, 164, 159, 159, 173, 223, 272, 267, 319, 294, 292, 309, 326, 361, 356, 448, 417, 466, 526, 658, 742, 931, 1095, 1283, 1359, 1568, 1632, 1798, 1908, 1893, 1811, 1836, 1686, 1739, 1538, 1500, 1498, 1425, 1382, 1465, 1448, 1513, 1477, 1500, 1527, 1541, 1496, 1527, 1567, 1496, 1517, 1586, 1468, 1485, 1540, 1525, 1441, 1459, 1393, 1428, 1509, 1440, 1458, 1488, 1383, 1472, 1464, 1442, 1425, 1449, 1518, 1517, 1510, 1558, 1513, 1438, 1427, 1409, 1486, 1441, 1437, 1453, 1422, 1406, 1417, 1440, 1443, 1601, 1616, 1628, 1683, 1608, 1668, 1772, 1747, 1805, 1878, 101003, 1891, 205, 240, 267, 525, 3287, 13827, 22902, 17268, 6991, 2033, 606, 193, 75, 47, 19, 25, 32, 15, 20, 23, 23, 19, 24, 22, 24, 17, 18, 15, 13, 21, 21, 23, 15, 12, 18, 23, 16, 13, 15, 18, 21, 11, 15, 10, 29, 14, 17, 16, 10, 16, 11, 14, 10, 22, 14, 16, 15, 10, 7, 15, 21, 13, 16, 19, 19, 8, 23, 20, 16, 25, 34, 49, 46, 50, 69, 83, 94, 129, 133, 149, 141, 181, 211, 232, 264, 347, 410, 493, 522, 546, 625, 725, 794, 811, 903, 996, 1126, 1190, 1484, 1757, 2235, 2599, 2986, 3295, 3607, 3958, 4129, 4414, 4792, 4952, 5438, 6073, 6750, 7531, 8275, 8905, 9287, 9777, 9979, 9713, 9323, 8668, 7813, 6852, 5790, 5281, 4355, 3823, 3451, 2979, 2675, 2354, 2013, 1827, 1555, 1431, 1288, 1150, 1078, 992, 942, 848, 795, 766, 674, 648, 644, 581, 559, 498, 487, 459, 458, 431, 395, 344, 357, 345, 332, 293, 279, 277, 261, 247, 214, 215, 216, 199, 192, 178, 174, 187, 164, 149, 131, 143, 155, 148, 126, 134, 128, 97, 111, 93, 80, 81, 62, 56, 69, 53, 56, 56, 41, 35, 39, 46, 42, 37, 57, 41, 38, 47, 39, 31, 41, 37, 32, 31, 23, 25, 28, 25, 29, 27, 22, 24, 17, 13, 14, 13, 11, 13, 12, 15, 10, 10, 3, 12, 5, 6, 6, 6, 5, 2, 5, 3, 2, 4, 2, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2901, 126, 136, 268, 915, 3277, 9057, 20283, 20167, 9303, 2904, 908, 434, 233, 119, 77, 44, 32, 35, 23, 28, 24, 32, 33, 24, 22, 27, 31, 24, 23, 29, 26, 26, 34, 29, 27, 19, 37, 25, 36, 40, 45, 47, 48, 78, 90, 115, 144, 193, 265, 360, 454, 645, 970, 1346, 2065, 3248, 4637, 6254, 8312, 10077, 11856, 13430, 14779, 15976, 16111, 15723, 14583, 12881, 11026, 9102, 7223, 5831, 4770, 3797, 3113, 2634, 2335, 1929, 1673, 1424, 1365, 1208, 1050, 929, 900, 806, 705, 635, 591, 489, 545, 497, 481, 414, 425, 401, 379, 285, 316, 227, 223, 210, 150, 112, 85, 85, 68, 50, 45, 47, 44, 39, 38, 31, 29, 28, 28, 25, 18, 27, 23, 12, 22, 14, 13, 19, 15, 10, 12, 11, 11, 15, 15, 13, 13, 18, 16, 19, 14, 19, 15, 20, 21, 20, 11, 14, 14, 9, 11, 3, 11, 9, 3, 2, 3, 0, 3, 0, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
+    ["training/images/21_training.tif", [5, 59, 38, 198, 381, 548, 3421, 14141, 22453, 16578, 6221, 2074, 1059, 580, 321, 178, 120, 82, 52, 47, 39, 44, 52, 35, 36, 30, 37, 29, 31, 24, 31, 33, 25, 28, 30, 30, 41, 23, 32, 23, 29, 43, 24, 33, 33, 25, 25, 26, 30, 24, 33, 23, 22, 25, 17, 28, 35, 29, 21, 24, 27, 16, 27, 20, 26, 15, 21, 21, 21, 26, 29, 20, 18, 24, 35, 19, 23, 12, 16, 26, 22, 23, 24, 19, 18, 21, 20, 24, 24, 18, 34, 17, 19, 27, 32, 28, 24, 35, 27, 23, 31, 21, 28, 24, 23, 28, 17, 24, 24, 21, 19, 25, 20, 20, 19, 23, 28, 20, 19, 14, 22, 28, 29, 34, 38, 34, 39, 50, 38, 59, 66, 95, 107, 128, 172, 221, 295, 358, 458, 524, 648, 775, 828, 890, 940, 1032, 1132, 1133, 1160, 1238, 1231, 1347, 1394, 1439, 1504, 1462, 1524, 1609, 1649, 1724, 1810, 1935, 2102, 2124, 2120, 2161, 2098, 1941, 2033, 2004, 2075, 1972, 2069, 1984, 1913, 1909, 1794, 1771, 1729, 1721, 1630, 1615, 1676, 1800, 1757, 1899, 1928, 2026, 2034, 2122, 2130, 2177, 2140, 2207, 2283, 2252, 2315, 2274, 2419, 2480, 2335, 2313, 2237, 2196, 2138, 2219, 2212, 2139, 2258, 2246, 2299, 2311, 2415, 2612, 2692, 2862, 2781, 2863, 2858, 2925, 2953, 2960, 2805, 2823, 2924, 2757, 2614, 2571, 2474, 2505, 2422, 2299, 2255, 2320, 2149, 2120, 1967, 1908, 1858, 1686, 1588, 1501, 1391, 1297, 1190, 1046, 979, 925, 835, 711, 626, 569, 527, 439, 348, 5673, 1875, 260, 258, 249, 452, 2516, 11543, 22895, 20044, 7634, 1958, 570, 158, 60, 40, 38, 34, 29, 24, 20, 20, 32, 23, 16, 20, 16, 17, 28, 24, 21, 23, 26, 22, 23, 15, 29, 19, 23, 14, 27, 17, 26, 16, 19, 13, 20, 7, 31, 12, 15, 19, 19, 12, 22, 24, 22, 9, 17, 26, 26, 18, 13, 20, 19, 19, 18, 23, 18, 25, 20, 22, 29, 16, 15, 20, 12, 23, 23, 24, 49, 54, 71, 91, 83, 137, 208, 231, 306, 368, 421, 490, 601, 662, 802, 933, 1172, 1419, 1682, 2132, 2430, 2606, 2893, 3088, 3480, 3665, 4330, 5349, 6545, 7965, 8853, 9643, 9517, 9230, 8609, 7958, 7526, 7115, 6586, 6408, 6258, 5969, 5598, 5468, 5137, 4940, 4550, 4281, 4032, 3516, 3239, 2984, 2739, 2476, 2196, 2046, 1880, 1598, 1383, 1250, 1162, 968, 834, 797, 717, 665, 590, 589, 501, 518, 413, 401, 371, 363, 351, 334, 295, 285, 267, 233, 219, 218, 201, 200, 189, 176, 158, 138, 115, 121, 138, 112, 100, 101, 107, 77, 92, 72, 72, 65, 53, 66, 62, 45, 58, 52, 62, 65, 58, 58, 50, 59, 47, 55, 64, 44, 45, 49, 48, 35, 46, 47, 49, 39, 30, 38, 52, 55, 50, 33, 41, 36, 37, 38, 29, 30, 30, 31, 38, 27, 29, 19, 18, 34, 19, 35, 30, 25, 29, 32, 31, 32, 25, 33, 40, 52, 36, 43, 34, 30, 39, 35, 33, 41, 35, 36, 37, 29, 33, 31, 49, 55, 61, 69, 60, 71, 328, 2792, 118, 205, 430, 1690, 6501, 12556, 20103, 17458, 6197, 1747, 641, 321, 171, 133, 71, 45, 33, 36, 32, 37, 30, 33, 44, 34, 33, 21, 39, 29, 35, 35, 32, 35, 44, 35, 32, 30, 27, 28, 30, 40, 33, 29, 30, 32, 37, 31, 42, 29, 36, 26, 37, 35, 46, 49, 53, 56, 103, 136, 208, 285, 379, 546, 789, 1171, 1756, 2599, 3823, 5474, 7709, 10078, 12421, 14689, 16155, 16650, 16828, 15957, 14839, 13334, 11482, 9297, 7707, 6123, 4991, 3975, 3228, 2699, 2205, 1868, 1540, 1256, 1055, 922, 854, 702, 626, 511, 433, 374, 342, 272, 237, 177, 187, 168, 145, 157, 145, 126, 125, 132, 116, 132, 107, 74, 97, 87, 102, 88, 64, 67, 68, 59, 63, 74, 83, 88, 90, 84, 98, 99, 79, 99, 70, 71, 80, 138, 81, 155, 65, 194, 45, 148, 72, 32, 64, 24, 56, 22, 35, 20, 12, 15, 9, 13, 7, 5, 2, 2, 0, 2, 4, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
+    ["training/images/29_training.tif", [5, 25, 24, 142, 321, 593, 4362, 15836, 24139, 14786, 4714, 1851, 938, 439, 239, 142, 107, 82, 71, 64, 49, 52, 60, 56, 50, 56, 58, 66, 62, 55, 40, 52, 70, 34, 47, 49, 63, 55, 49, 49, 53, 42, 48, 41, 39, 37, 32, 37, 30, 32, 40, 25, 39, 32, 36, 33, 34, 45, 26, 22, 35, 30, 37, 34, 19, 45, 22, 32, 40, 43, 29, 37, 33, 51, 46, 43, 43, 49, 45, 60, 66, 65, 104, 104, 164, 238, 260, 336, 370, 421, 418, 477, 540, 556, 591, 659, 717, 784, 867, 893, 844, 856, 820, 827, 817, 796, 772, 765, 774, 774, 800, 842, 912, 980, 898, 1007, 1015, 1079, 1126, 1198, 1255, 1327, 1401, 1417, 1422, 1463, 1481, 1539, 1518, 1457, 1467, 1455, 1515, 1511, 1596, 1728, 1699, 1753, 1778, 1864, 1970, 2141, 2278, 2269, 2227, 2299, 2313, 2408, 2276, 2266, 2262, 2199, 2226, 2231, 2216, 2072, 2150, 2142, 2007, 2100, 2242, 2176, 2204, 2264, 2249, 2203, 2238, 2299, 2206, 2202, 2139, 2271, 2397, 2272, 2326, 2365, 2361, 2276, 2324, 2368, 2310, 2395, 2395, 2504, 2491, 2355, 2154, 2092, 1921, 1746, 1620, 1458, 1453, 1301, 1198, 1202, 1218, 1154, 1134, 1174, 1233, 1262, 1339, 1429, 1383, 1397, 1364, 1383, 1340, 1361, 1318, 1366, 1312, 1343, 1329, 1362, 1216, 1187, 1185, 1021, 994, 921, 870, 863, 749, 741, 692, 677, 678, 642, 684, 637, 609, 586, 498, 488, 477, 495, 443, 447, 444, 372, 306, 290, 247, 198, 211, 166, 122, 108, 100, 72, 61, 57, 31, 495, 1709, 352, 275, 281, 772, 6170, 21313, 24453, 11823, 2786, 519, 144, 64, 70, 54, 51, 39, 53, 51, 44, 49, 36, 52, 44, 43, 43, 55, 54, 42, 45, 46, 56, 43, 54, 57, 63, 91, 84, 124, 157, 243, 306, 452, 610, 850, 1132, 1403, 1780, 2248, 2858, 3544, 4357, 4739, 4997, 5148, 5183, 5215, 5039, 5166, 5220, 5512, 5613, 5831, 6122, 6414, 6699, 6979, 6916, 6975, 6641, 6295, 5797, 5483, 5242, 4983, 4888, 4734, 4606, 4503, 4355, 4204, 4273, 4123, 3886, 3661, 3391, 3046, 2729, 2478, 2183, 1868, 1576, 1539, 1185, 976, 861, 691, 591, 474, 407, 339, 306, 277, 238, 199, 149, 164, 107, 90, 93, 74, 82, 57, 81, 69, 64, 60, 45, 60, 65, 45, 54, 38, 37, 41, 46, 42, 47, 39, 40, 48, 33, 38, 30, 52, 44, 51, 39, 39, 35, 39, 54, 47, 32, 34, 28, 39, 22, 28, 22, 28, 14, 17, 11, 9, 25, 7, 12, 12, 10, 11, 9, 11, 9, 5, 10, 13, 11, 9, 8, 8, 11, 11, 12, 11, 6, 9, 16, 9, 5, 5, 14, 10, 5, 12, 5, 4, 10, 6, 8, 11, 9, 10, 11, 10, 11, 15, 13, 12, 13, 14, 10, 7, 4, 8, 4, 5, 7, 13, 7, 5, 6, 4, 4, 5, 3, 6, 3, 1, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2041, 179, 221, 329, 840, 2619, 9454, 24858, 18911, 7662, 2785, 914, 344, 172, 126, 73, 77, 73, 89, 80, 93, 78, 94, 89, 85, 89, 96, 129, 160, 184, 283, 369, 641, 1036, 1709, 2710, 3735, 4946, 6168, 7526, 8451, 9163, 9731, 10693, 10850, 11275, 11396, 11163, 10493, 9609, 8816, 8297, 7736, 7518, 7291, 7050, 6547, 6027, 5299, 4563, 3915, 3048, 2559, 2105, 1598, 1258, 1069, 855, 708, 575, 485, 392, 332, 281, 208, 191, 151, 134, 126, 113, 95, 93, 94, 77, 98, 71, 75, 74, 79, 69, 51, 49, 43, 39, 39, 37, 29, 23, 20, 23, 21, 17, 16, 13, 32, 15, 11, 9, 13, 19, 13, 10, 17, 19, 15, 13, 14, 17, 16, 9, 13, 15, 16, 9, 15, 12, 22, 9, 17, 19, 22, 17, 18, 13, 13, 10, 7, 10, 5, 11, 5, 5, 6, 6, 6, 2, 3, 3, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
+    ["training/images/28_training.tif", [12, 54, 28, 166, 301, 482, 3183, 13378, 23501, 17769, 6053, 1872, 898, 424, 250, 148, 92, 65, 56, 52, 58, 33, 58, 56, 45, 43, 35, 40, 52, 48, 44, 56, 48, 42, 44, 52, 45, 39, 39, 56, 23, 47, 53, 58, 43, 44, 57, 28, 46, 39, 42, 25, 29, 39, 19, 27, 36, 31, 24, 35, 29, 22, 33, 28, 29, 34, 20, 36, 20, 35, 20, 23, 26, 19, 24, 19, 31, 18, 20, 24, 29, 31, 23, 21, 26, 22, 25, 18, 18, 26, 25, 21, 20, 22, 33, 23, 28, 24, 30, 30, 26, 33, 46, 35, 34, 59, 67, 82, 59, 89, 97, 113, 133, 160, 179, 222, 286, 376, 427, 480, 600, 761, 894, 1013, 1141, 1282, 1406, 1510, 1505, 1549, 1690, 1702, 1791, 1814, 1770, 1848, 1850, 1806, 1988, 2089, 2039, 2132, 2213, 2310, 2286, 2193, 2378, 2124, 2138, 2112, 2071, 2083, 2084, 2070, 2137, 2102, 2220, 2222, 2219, 2196, 2230, 2174, 2130, 2231, 2192, 2207, 2141, 2243, 2377, 2411, 2512, 2716, 2746, 2740, 2743, 2792, 2738, 2844, 2796, 2804, 2832, 2851, 2810, 2830, 2900, 3066, 3075, 3074, 3131, 3199, 3058, 3054, 2866, 2762, 2591, 2630, 2540, 2577, 2661, 2681, 2698, 2662, 2621, 2607, 2478, 2434, 2219, 2171, 1898, 1775, 1590, 1389, 1325, 1163, 1096, 1035, 900, 856, 731, 707, 664, 517, 491, 473, 377, 330, 264, 234, 182, 138, 128, 110, 69, 76, 42, 55, 46, 45, 49, 43, 40, 35, 52, 43, 38, 40, 41, 53, 44, 39, 52, 59, 46, 33, 30, 1840, 1810, 223, 226, 275, 501, 3410, 15457, 24359, 16830, 5734, 1316, 347, 112, 56, 31, 27, 24, 29, 24, 24, 20, 38, 23, 18, 21, 26, 32, 14, 28, 20, 26, 22, 30, 25, 25, 21, 13, 26, 12, 23, 26, 26, 31, 26, 33, 30, 21, 23, 22, 19, 21, 19, 25, 25, 14, 29, 18, 23, 28, 18, 23, 32, 20, 20, 19, 31, 31, 26, 37, 49, 55, 82, 96, 106, 137, 165, 211, 249, 277, 343, 310, 336, 361, 411, 481, 554, 674, 730, 912, 1037, 1325, 1541, 1804, 2341, 2896, 3210, 3755, 4224, 4436, 4774, 5108, 5329, 5652, 5860, 5915, 5567, 5381, 5397, 5080, 5131, 5306, 5546, 5745, 6266, 6280, 6548, 6272, 6097, 6014, 5621, 5352, 5195, 4921, 4672, 4593, 4433, 4240, 4116, 3866, 3712, 3391, 3064, 2570, 2143, 1905, 1423, 1214, 1000, 762, 720, 615, 593, 483, 458, 439, 404, 385, 340, 285, 296, 227, 186, 150, 159, 170, 156, 116, 124, 138, 129, 121, 105, 106, 123, 100, 92, 75, 72, 52, 63, 49, 42, 46, 42, 50, 66, 40, 42, 53, 36, 67, 59, 46, 36, 51, 45, 43, 38, 46, 37, 32, 50, 29, 39, 39, 47, 42, 49, 54, 56, 56, 62, 49, 59, 54, 27, 31, 30, 24, 25, 17, 10, 13, 15, 7, 12, 4, 1, 2, 3, 3, 0, 2, 2, 2, 1, 5, 0, 0, 1, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2407, 123, 185, 279, 778, 2686, 7921, 21743, 21841, 8947, 2797, 941, 357, 190, 120, 66, 41, 42, 44, 45, 31, 44, 32, 31, 45, 33, 44, 41, 29, 43, 45, 42, 39, 45, 51, 50, 48, 56, 47, 46, 85, 78, 77, 117, 132, 189, 198, 307, 423, 510, 700, 931, 1161, 1604, 2166, 2874, 3682, 4787, 6332, 8042, 10076, 12366, 13932, 15553, 16024, 16035, 15001, 13396, 12089, 10350, 8903, 7459, 6089, 5084, 4049, 3282, 2739, 2193, 1766, 1529, 1280, 1108, 977, 778, 744, 642, 542, 488, 392, 346, 351, 310, 308, 276, 219, 183, 201, 149, 152, 138, 163, 151, 136, 105, 115, 115, 104, 98, 99, 105, 75, 71, 59, 40, 40, 26, 34, 23, 20, 14, 13, 6, 5, 6, 6, 3, 3, 5, 1, 3, 0, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
+    ["training/images/28_training.tif", [12, 54, 28, 166, 301, 482, 3183, 13378, 23501, 17769, 6053, 1872, 898, 424, 250, 148, 92, 65, 56, 52, 58, 33, 58, 56, 45, 43, 35, 40, 52, 48, 44, 56, 48, 42, 44, 52, 45, 39, 39, 56, 23, 47, 53, 58, 43, 44, 57, 28, 46, 39, 42, 25, 29, 39, 19, 27, 36, 31, 24, 35, 29, 22, 33, 28, 29, 34, 20, 36, 20, 35, 20, 23, 26, 19, 24, 19, 31, 18, 20, 24, 29, 31, 23, 21, 26, 22, 25, 18, 18, 26, 25, 21, 20, 22, 33, 23, 28, 24, 30, 30, 26, 33, 46, 35, 34, 59, 67, 82, 59, 89, 97, 113, 133, 160, 179, 222, 286, 376, 427, 480, 600, 761, 894, 1013, 1141, 1282, 1406, 1510, 1505, 1549, 1690, 1702, 1791, 1814, 1770, 1848, 1850, 1806, 1988, 2089, 2039, 2132, 2213, 2310, 2286, 2193, 2378, 2124, 2138, 2112, 2071, 2083, 2084, 2070, 2137, 2102, 2220, 2222, 2219, 2196, 2230, 2174, 2130, 2231, 2192, 2207, 2141, 2243, 2377, 2411, 2512, 2716, 2746, 2740, 2743, 2792, 2738, 2844, 2796, 2804, 2832, 2851, 2810, 2830, 2900, 3066, 3075, 3074, 3131, 3199, 3058, 3054, 2866, 2762, 2591, 2630, 2540, 2577, 2661, 2681, 2698, 2662, 2621, 2607, 2478, 2434, 2219, 2171, 1898, 1775, 1590, 1389, 1325, 1163, 1096, 1035, 900, 856, 731, 707, 664, 517, 491, 473, 377, 330, 264, 234, 182, 138, 128, 110, 69, 76, 42, 55, 46, 45, 49, 43, 40, 35, 52, 43, 38, 40, 41, 53, 44, 39, 52, 59, 46, 33, 30, 1840, 1810, 223, 226, 275, 501, 3410, 15457, 24359, 16830, 5734, 1316, 347, 112, 56, 31, 27, 24, 29, 24, 24, 20, 38, 23, 18, 21, 26, 32, 14, 28, 20, 26, 22, 30, 25, 25, 21, 13, 26, 12, 23, 26, 26, 31, 26, 33, 30, 21, 23, 22, 19, 21, 19, 25, 25, 14, 29, 18, 23, 28, 18, 23, 32, 20, 20, 19, 31, 31, 26, 37, 49, 55, 82, 96, 106, 137, 165, 211, 249, 277, 343, 310, 336, 361, 411, 481, 554, 674, 730, 912, 1037, 1325, 1541, 1804, 2341, 2896, 3210, 3755, 4224, 4436, 4774, 5108, 5329, 5652, 5860, 5915, 5567, 5381, 5397, 5080, 5131, 5306, 5546, 5745, 6266, 6280, 6548, 6272, 6097, 6014, 5621, 5352, 5195, 4921, 4672, 4593, 4433, 4240, 4116, 3866, 3712, 3391, 3064, 2570, 2143, 1905, 1423, 1214, 1000, 762, 720, 615, 593, 483, 458, 439, 404, 385, 340, 285, 296, 227, 186, 150, 159, 170, 156, 116, 124, 138, 129, 121, 105, 106, 123, 100, 92, 75, 72, 52, 63, 49, 42, 46, 42, 50, 66, 40, 42, 53, 36, 67, 59, 46, 36, 51, 45, 43, 38, 46, 37, 32, 50, 29, 39, 39, 47, 42, 49, 54, 56, 56, 62, 49, 59, 54, 27, 31, 30, 24, 25, 17, 10, 13, 15, 7, 12, 4, 1, 2, 3, 3, 0, 2, 2, 2, 1, 5, 0, 0, 1, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2407, 123, 185, 279, 778, 2686, 7921, 21743, 21841, 8947, 2797, 941, 357, 190, 120, 66, 41, 42, 44, 45, 31, 44, 32, 31, 45, 33, 44, 41, 29, 43, 45, 42, 39, 45, 51, 50, 48, 56, 47, 46, 85, 78, 77, 117, 132, 189, 198, 307, 423, 510, 700, 931, 1161, 1604, 2166, 2874, 3682, 4787, 6332, 8042, 10076, 12366, 13932, 15553, 16024, 16035, 15001, 13396, 12089, 10350, 8903, 7459, 6089, 5084, 4049, 3282, 2739, 2193, 1766, 1529, 1280, 1108, 977, 778, 744, 642, 542, 488, 392, 346, 351, 310, 308, 276, 219, 183, 201, 149, 152, 138, 163, 151, 136, 105, 115, 115, 104, 98, 99, 105, 75, 71, 59, 40, 40, 26, 34, 23, 20, 14, 13, 6, 5, 6, 6, 3, 3, 5, 1, 3, 0, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
+  ],
+  "test": [
+    ["test/images/05_test.tif", [8, 26, 23, 132, 330, 528, 3357, 13534, 23340, 16942, 5795, 2236, 1067, 521, 295, 135, 94, 73, 56, 53, 48, 42, 40, 56, 38, 55, 37, 44, 47, 37, 39, 50, 22, 28, 30, 58, 44, 33, 49, 35, 42, 40, 29, 32, 38, 38, 35, 25, 43, 45, 32, 21, 25, 32, 25, 33, 32, 49, 14, 32, 35, 28, 16, 32, 34, 23, 23, 30, 22, 36, 34, 31, 29, 26, 36, 15, 15, 22, 22, 19, 21, 17, 20, 26, 22, 18, 27, 19, 18, 16, 17, 22, 25, 24, 19, 21, 19, 21, 16, 13, 17, 27, 21, 28, 20, 22, 28, 30, 18, 23, 30, 21, 27, 26, 23, 28, 15, 26, 32, 32, 40, 41, 42, 56, 82, 100, 100, 120, 141, 163, 215, 249, 297, 308, 397, 450, 519, 571, 703, 721, 849, 890, 896, 965, 1006, 1136, 1213, 1292, 1367, 1437, 1502, 1485, 1605, 1639, 1677, 1731, 1703, 1764, 1814, 1879, 1714, 1701, 1612, 1687, 1557, 1665, 1626, 1664, 1825, 1789, 1727, 1844, 1840, 1889, 1964, 1920, 1934, 1985, 2037, 2143, 2067, 2071, 2083, 2097, 2079, 2040, 2190, 2252, 2504, 2591, 2712, 2856, 2829, 2819, 2933, 3091, 3099, 3225, 3286, 3311, 3364, 3472, 3437, 3549, 3445, 3477, 3363, 3288, 3247, 3209, 3119, 2895, 2949, 2887, 2806, 2925, 2920, 2900, 2966, 2941, 2976, 2922, 2893, 2739, 2738, 2430, 2347, 2180, 2028, 1764, 1564, 1447, 1340, 1213, 1073, 916, 822, 711, 558, 562, 453, 444, 354, 330, 259, 219, 198, 146, 138, 88, 65, 56, 62, 52, 58, 1747, 2017, 272, 279, 377, 733, 4992, 18683, 24602, 13740, 3700, 862, 208, 72, 45, 32, 27, 36, 33, 47, 30, 33, 29, 30, 41, 28, 28, 23, 31, 32, 31, 35, 28, 24, 26, 36, 30, 31, 20, 26, 26, 30, 31, 21, 21, 32, 33, 28, 25, 29, 31, 46, 47, 85, 140, 181, 289, 347, 417, 509, 600, 684, 787, 966, 1105, 1202, 1474, 1855, 2449, 3360, 4707, 6304, 8142, 10058, 10997, 11895, 12129, 11946, 11891, 11441, 11247, 10821, 10538, 9933, 9090, 8379, 7501, 6391, 5547, 4623, 3751, 3165, 2560, 2096, 1605, 1303, 1035, 842, 602, 485, 400, 375, 319, 278, 230, 210, 211, 177, 132, 136, 116, 120, 121, 119, 106, 120, 104, 121, 113, 93, 92, 78, 92, 81, 77, 94, 77, 86, 68, 83, 66, 68, 62, 48, 60, 40, 40, 32, 52, 33, 46, 38, 38, 45, 41, 36, 37, 34, 32, 34, 23, 23, 30, 29, 32, 26, 27, 28, 33, 44, 31, 22, 20, 18, 20, 26, 24, 19, 19, 16, 27, 30, 36, 38, 45, 51, 47, 49, 50, 31, 34, 38, 46, 26, 31, 33, 18, 26, 24, 15, 12, 21, 11, 9, 16, 17, 12, 12, 4, 12, 8, 10, 14, 9, 11, 6, 5, 5, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2654, 131, 178, 283, 871, 2892, 8978, 22997, 20381, 7677, 2652, 891, 327, 188, 118, 64, 56, 41, 55, 47, 55, 38, 52, 51, 36, 37, 55, 66, 87, 112, 180, 312, 526, 890, 1547, 2724, 4728, 7596, 11548, 15867, 20221, 23534, 24866, 23148, 20147, 16675, 13034, 9813, 7228, 5025, 3544, 2390, 1647, 1121, 788, 553, 433, 339, 283, 264, 193, 190, 155, 143, 145, 151, 136, 115, 121, 96, 100, 90, 105, 110, 96, 112, 112, 99, 81, 61, 58, 59, 53, 44, 39, 28, 33, 27, 25, 20, 21, 19, 19, 5, 7, 6, 3, 0, 1, 4, 3, 5, 3, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
+    ["test/images/04_test.tif", [5, 42, 43, 166, 310, 478, 2927, 12740, 23401, 17393, 6049, 2366, 1115, 508, 250, 163, 112, 97, 64, 65, 65, 46, 46, 53, 54, 43, 48, 36, 45, 48, 45, 51, 44, 46, 40, 46, 36, 38, 44, 45, 43, 33, 43, 38, 32, 40, 33, 27, 40, 49, 38, 30, 36, 45, 21, 32, 38, 38, 27, 36, 40, 19, 31, 38, 35, 31, 33, 33, 34, 34, 35, 27, 31, 34, 39, 29, 33, 37, 32, 32, 42, 51, 37, 48, 34, 25, 36, 45, 55, 45, 55, 49, 43, 58, 63, 65, 65, 96, 111, 109, 99, 141, 109, 118, 139, 168, 157, 184, 183, 187, 223, 222, 247, 266, 319, 300, 366, 332, 391, 431, 451, 460, 462, 549, 537, 533, 573, 567, 667, 667, 688, 796, 847, 869, 911, 978, 1001, 1047, 1047, 1072, 1129, 1213, 1338, 1366, 1443, 1535, 1555, 1563, 1549, 1510, 1556, 1569, 1561, 1540, 1522, 1445, 1427, 1416, 1376, 1350, 1382, 1381, 1362, 1319, 1335, 1322, 1371, 1351, 1422, 1480, 1454, 1531, 1571, 1538, 1634, 1653, 1821, 1778, 1790, 1979, 1972, 2154, 2135, 2216, 2381, 2522, 2571, 2771, 2757, 2768, 2738, 2743, 2639, 2637, 2608, 2504, 2472, 2351, 2234, 2331, 2227, 2275, 2217, 2225, 2194, 2156, 2159, 2066, 2140, 1965, 1930, 1863, 1796, 1743, 1606, 1649, 1510, 1514, 1521, 1418, 1449, 1417, 1388, 1272, 1276, 1214, 1229, 1213, 1196, 1165, 1199, 1123, 1205, 1118, 1207, 1190, 1228, 1272, 1232, 1221, 1180, 1288, 1205, 1194, 1230, 1232, 1205, 1198, 1201, 1071, 1046, 1084, 860, 833, 820, 16335, 2069, 330, 270, 260, 645, 4537, 18075, 24590, 14371, 4076, 888, 231, 89, 61, 41, 40, 24, 42, 38, 28, 39, 32, 38, 37, 28, 44, 31, 43, 32, 42, 23, 23, 34, 25, 34, 29, 35, 32, 27, 36, 36, 41, 56, 60, 62, 82, 74, 109, 113, 150, 169, 213, 245, 279, 343, 415, 513, 531, 631, 701, 837, 884, 924, 1073, 1166, 1315, 1413, 1618, 1889, 2159, 2512, 2764, 3135, 3461, 3807, 4056, 4305, 4429, 4635, 4836, 4929, 5035, 5362, 5459, 5780, 5868, 6070, 6234, 6234, 6127, 6132, 5984, 5647, 5222, 4868, 4629, 4227, 4062, 3853, 3625, 3385, 3139, 3017, 2774, 2594, 2459, 2286, 2288, 2128, 1977, 1862, 1761, 1639, 1638, 1433, 1406, 1284, 1126, 1056, 1088, 1075, 1053, 913, 835, 861, 811, 696, 691, 655, 663, 599, 604, 554, 546, 494, 460, 421, 383, 364, 344, 349, 327, 310, 277, 308, 243, 285, 222, 234, 216, 214, 192, 194, 175, 177, 183, 166, 184, 167, 168, 154, 144, 163, 151, 129, 166, 163, 138, 155, 108, 110, 112, 108, 94, 85, 92, 84, 81, 69, 65, 86, 81, 77, 75, 75, 69, 67, 52, 73, 63, 56, 59, 64, 61, 55, 31, 53, 66, 47, 44, 41, 40, 32, 49, 45, 47, 51, 54, 49, 44, 52, 29, 35, 39, 31, 19, 25, 23, 15, 15, 11, 14, 12, 12, 16, 11, 6, 17, 11, 13, 9, 6, 15, 12, 8, 14, 7, 10, 9, 8, 14, 13, 13, 12, 3, 12, 19, 14, 15, 22, 21, 19, 28, 20, 25, 395, 2622, 181, 210, 350, 917, 3203, 8766, 22387, 20601, 7963, 2628, 881, 340, 169, 81, 60, 57, 62, 62, 54, 61, 56, 69, 73, 57, 66, 94, 89, 135, 145, 177, 257, 343, 422, 593, 773, 1006, 1302, 1588, 2002, 2408, 2994, 3457, 4074, 4957, 6023, 7237, 8570, 10020, 11278, 12293, 12879, 12618, 11645, 11154, 10031, 8991, 8139, 7756, 6985, 6118, 5340, 4390, 3694, 3119, 2694, 2204, 1939, 1694, 1470, 1290, 1161, 1030, 919, 796, 778, 669, 568, 562, 491, 468, 428, 357, 379, 318, 327, 335, 297, 256, 268, 291, 252, 284, 266, 224, 259, 245, 213, 238, 239, 226, 236, 216, 217, 188, 227, 189, 192, 176, 166, 157, 121, 116, 126, 137, 84, 83, 83, 60, 74, 54, 68, 65, 53, 43, 44, 55, 57, 67, 110, 51, 91, 46, 70, 55, 106, 89, 29, 80, 27, 66, 32, 42, 26, 15, 27, 16, 19, 10, 14, 11, 10, 6, 2, 7, 3, 5, 2, 2, 0, 1, 0, 0, 3, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
+    ["test/images/18_test.tif", [4, 22, 15, 92, 290, 517, 3537, 12682, 21431, 16772, 7066, 2764, 1488, 776, 489, 263, 178, 97, 79, 53, 41, 36, 39, 38, 32, 37, 43, 27, 38, 37, 38, 34, 49, 46, 38, 39, 33, 38, 28, 36, 36, 32, 34, 30, 27, 32, 35, 21, 33, 37, 44, 11, 54, 43, 18, 43, 56, 53, 16, 35, 22, 31, 30, 26, 23, 18, 25, 26, 18, 20, 22, 24, 25, 27, 17, 17, 31, 22, 13, 29, 18, 15, 19, 21, 19, 10, 15, 18, 24, 18, 15, 16, 14, 19, 19, 13, 19, 14, 22, 18, 20, 27, 20, 14, 19, 17, 18, 13, 14, 24, 18, 9, 15, 20, 29, 19, 24, 11, 24, 20, 23, 18, 23, 17, 18, 19, 18, 20, 19, 22, 18, 23, 21, 31, 23, 21, 41, 49, 41, 70, 111, 115, 140, 140, 199, 227, 262, 375, 487, 593, 727, 920, 1099, 1234, 1326, 1436, 1534, 1577, 1585, 1573, 1663, 1664, 1612, 1695, 1646, 1675, 1698, 1613, 1805, 1807, 1909, 1816, 1723, 1783, 1653, 1639, 1573, 1548, 1571, 1590, 1562, 1564, 1613, 1704, 1669, 1690, 1710, 1671, 1687, 1693, 1820, 1726, 1773, 1881, 1928, 1973, 1879, 1861, 1910, 1939, 1931, 1886, 2030, 1993, 2110, 2146, 2144, 2090, 2072, 1995, 1998, 1985, 1950, 1949, 1884, 1936, 1778, 1761, 1845, 1799, 1711, 1884, 1883, 1871, 2047, 2169, 2211, 2187, 2188, 2048, 2081, 2162, 2139, 2106, 2153, 2244, 2322, 2275, 2355, 2480, 2547, 2520, 2613, 2677, 2683, 2632, 2522, 2630, 2463, 2431, 2485, 2325, 2279, 2224, 2076, 20661, 1858, 258, 256, 288, 650, 3767, 15327, 23190, 16409, 5962, 1683, 529, 163, 53, 38, 24, 26, 16, 31, 38, 21, 28, 25, 20, 18, 24, 20, 18, 28, 26, 25, 16, 24, 20, 17, 20, 17, 21, 20, 12, 21, 26, 16, 17, 19, 12, 14, 11, 18, 19, 15, 24, 23, 14, 12, 21, 21, 17, 13, 18, 22, 21, 15, 18, 16, 16, 24, 13, 22, 18, 15, 15, 27, 12, 20, 21, 20, 35, 28, 31, 43, 54, 59, 89, 121, 142, 185, 242, 300, 383, 455, 577, 724, 842, 1011, 1179, 1489, 1954, 2711, 3486, 4051, 4427, 4688, 4672, 5036, 5427, 5997, 7014, 7554, 8468, 9248, 9140, 9317, 9152, 8774, 8342, 7510, 7082, 6697, 6191, 6117, 5904, 5673, 5217, 4874, 4358, 4034, 3676, 3344, 2951, 2726, 2369, 2100, 1784, 1557, 1283, 1127, 974, 830, 733, 644, 605, 551, 459, 400, 373, 347, 298, 254, 254, 195, 183, 137, 132, 94, 102, 71, 66, 78, 61, 42, 42, 50, 44, 34, 30, 29, 35, 31, 24, 35, 17, 31, 24, 25, 24, 23, 31, 30, 21, 29, 18, 30, 26, 29, 21, 38, 33, 23, 25, 28, 38, 31, 35, 30, 34, 34, 21, 25, 23, 25, 31, 30, 43, 49, 42, 36, 43, 44, 35, 30, 27, 26, 23, 27, 16, 30, 26, 16, 20, 27, 20, 19, 20, 18, 24, 18, 17, 16, 18, 14, 20, 15, 15, 11, 13, 14, 16, 14, 7, 11, 6, 6, 9, 14, 11, 9, 10, 15, 12, 14, 17, 32, 12, 21, 75, 2837, 104, 190, 291, 922, 3147, 8942, 21009, 20298, 8685, 2851, 965, 457, 214, 127, 94, 50, 36, 35, 23, 22, 26, 31, 31, 42, 25, 32, 32, 29, 29, 30, 28, 22, 27, 32, 39, 31, 32, 32, 28, 30, 49, 52, 50, 42, 86, 85, 116, 186, 220, 297, 381, 496, 657, 1023, 1687, 2547, 4057, 5976, 8314, 10740, 13470, 15565, 16852, 17697, 17328, 16613, 15149, 13649, 11565, 9620, 7602, 6107, 4845, 3870, 2937, 2269, 1819, 1400, 1152, 891, 732, 592, 540, 417, 383, 305, 278, 250, 242, 235, 210, 167, 185, 159, 142, 157, 126, 124, 102, 106, 95, 76, 79, 89, 56, 66, 45, 38, 53, 45, 32, 32, 31, 30, 27, 26, 33, 40, 66, 55, 21, 34, 15, 17, 2, 10, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
+    ["test/images/03_test.tif", [109, 136, 141, 249, 464, 682, 3149, 20256, 30468, 8285, 1665, 922, 628, 371, 293, 214, 159, 121, 97, 65, 74, 61, 65, 59, 59, 60, 60, 58, 72, 64, 52, 72, 79, 57, 61, 54, 74, 47, 60, 70, 40, 54, 48, 48, 36, 43, 47, 36, 30, 37, 25, 38, 31, 37, 34, 28, 25, 19, 32, 31, 22, 34, 23, 30, 30, 32, 28, 28, 26, 20, 29, 20, 34, 21, 21, 24, 18, 18, 28, 27, 26, 26, 30, 38, 51, 71, 70, 90, 79, 105, 143, 148, 148, 169, 201, 273, 339, 398, 465, 557, 652, 770, 845, 984, 1222, 1462, 1598, 1728, 1763, 1700, 1741, 1738, 1960, 2029, 1979, 1896, 1930, 1866, 1824, 1818, 1933, 1972, 2009, 1937, 1985, 1996, 2075, 1974, 2059, 1974, 2140, 2069, 2147, 2211, 2350, 2421, 2451, 2603, 2618, 2580, 2508, 2554, 2542, 2584, 2690, 2816, 2969, 2978, 3075, 3039, 3029, 3024, 3185, 3162, 3400, 3474, 3473, 3542, 3788, 3776, 3919, 3910, 3842, 3894, 3985, 4040, 4039, 4158, 4328, 4363, 4196, 4194, 3957, 3839, 3778, 3413, 3186, 2862, 2705, 2235, 2028, 1618, 1448, 1129, 823, 679, 523, 365, 262, 202, 144, 110, 103, 81, 59, 52, 66, 52, 47, 57, 43, 42, 43, 37, 24, 18, 10, 8, 2, 5, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1644, 163, 272, 322, 372, 648, 2768, 19591, 30875, 10248, 2207, 733, 367, 186, 94, 75, 59, 47, 31, 36, 19, 29, 27, 23, 31, 27, 26, 28, 18, 22, 29, 26, 30, 23, 23, 18, 33, 31, 26, 46, 67, 104, 148, 190, 246, 353, 472, 513, 574, 601, 706, 757, 932, 931, 1181, 1504, 1880, 2596, 3523, 4173, 4778, 5249, 5713, 6022, 6397, 6704, 7459, 8494, 9628, 10388, 11177, 11125, 11166, 10610, 10283, 9903, 9209, 8742, 8059, 6995, 6040, 5258, 4409, 3549, 2877, 2322, 1752, 1438, 1162, 942, 782, 669, 557, 449, 426, 371, 316, 219, 197, 164, 130, 98, 102, 88, 85, 71, 57, 69, 47, 43, 49, 33, 39, 32, 22, 31, 21, 34, 28, 25, 27, 19, 13, 12, 10, 5, 2, 5, 0, 2, 2, 1, 0, 0, 2, 0, 4, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3038, 487, 843, 2339, 5673, 20003, 29192, 6812, 1302, 575, 345, 285, 188, 165, 126, 143, 185, 310, 528, 1023, 1846, 3149, 5241, 8107, 11511, 14504, 17580, 19733, 21299, 21203, 20754, 18178, 15484, 12089, 9208, 6678, 4649, 3183, 2123, 1434, 981, 719, 478, 380, 294, 240, 184, 166, 143, 87, 95, 64, 69, 58, 50, 60, 43, 51, 45, 34, 23, 30, 24, 16, 17, 8, 9, 10, 8, 6, 8, 3, 6, 5, 0, 2, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
+    ["test/images/19_test.tif", [17, 96, 77, 258, 381, 1062, 7583, 22121, 22668, 9962, 2361, 926, 481, 251, 137, 87, 91, 60, 53, 67, 56, 69, 66, 59, 52, 59, 54, 53, 59, 60, 53, 54, 59, 44, 51, 52, 78, 55, 74, 89, 45, 65, 81, 58, 41, 55, 62, 34, 50, 42, 29, 25, 38, 37, 27, 24, 30, 22, 24, 16, 24, 27, 26, 30, 20, 22, 9, 35, 22, 40, 29, 24, 31, 25, 34, 33, 36, 20, 40, 38, 42, 41, 32, 47, 47, 41, 61, 62, 85, 121, 124, 152, 240, 242, 366, 410, 567, 695, 864, 1013, 1174, 1423, 1553, 1792, 1775, 1915, 1966, 2011, 1990, 2092, 2111, 2092, 2233, 2296, 2476, 2537, 2647, 2886, 2823, 2807, 2903, 3030, 3032, 3128, 3244, 3260, 3369, 3444, 3499, 3584, 3626, 3472, 3626, 3540, 3506, 3409, 3375, 3275, 3379, 3321, 3477, 3407, 3516, 3400, 3371, 3375, 3322, 3252, 3353, 3282, 3311, 3274, 3226, 3286, 3296, 3257, 3382, 3375, 3321, 3294, 3323, 3195, 3008, 2771, 2501, 2249, 2048, 1700, 1571, 1405, 1328, 1314, 1267, 1162, 1155, 1100, 981, 898, 921, 824, 759, 707, 627, 588, 508, 458, 401, 370, 316, 295, 263, 214, 207, 182, 165, 151, 118, 92, 75, 73, 71, 59, 60, 60, 38, 35, 30, 41, 33, 35, 31, 24, 24, 27, 33, 35, 22, 28, 33, 23, 29, 19, 33, 35, 27, 44, 30, 22, 22, 27, 35, 33, 28, 35, 40, 22, 25, 32, 24, 25, 26, 31, 32, 26, 30, 26, 25, 21, 23, 21, 11, 10, 15, 14, 14, 37, 1645, 275, 294, 300, 653, 4170, 16405, 26570, 15496, 3712, 691, 182, 71, 45, 37, 36, 36, 51, 47, 32, 30, 33, 28, 21, 41, 26, 38, 35, 34, 29, 35, 37, 38, 44, 40, 42, 48, 61, 79, 110, 103, 133, 165, 169, 230, 271, 296, 296, 413, 452, 558, 614, 724, 824, 1053, 1192, 1472, 1749, 2151, 2673, 3374, 4177, 4837, 5437, 6071, 6543, 7122, 7453, 7744, 7788, 7789, 7644, 7590, 7618, 7904, 8231, 8375, 8542, 8410, 8263, 7907, 7696, 6944, 6349, 5384, 4701, 4181, 3348, 3027, 2350, 1887, 1488, 1224, 993, 792, 654, 543, 449, 457, 392, 352, 348, 329, 288, 289, 256, 271, 225, 240, 222, 217, 190, 173, 159, 168, 162, 168, 143, 138, 110, 121, 111, 134, 83, 92, 116, 99, 78, 79, 78, 58, 69, 62, 56, 69, 49, 50, 43, 44, 45, 53, 41, 58, 50, 48, 43, 49, 41, 46, 49, 50, 44, 50, 33, 35, 38, 36, 36, 40, 30, 25, 28, 20, 19, 20, 18, 16, 13, 11, 15, 11, 13, 6, 3, 5, 6, 8, 3, 1, 9, 4, 4, 4, 1, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2460, 157, 253, 555, 2378, 7839, 13444, 23329, 14498, 4262, 1356, 468, 187, 109, 78, 60, 49, 70, 62, 53, 53, 60, 83, 79, 84, 104, 118, 115, 163, 198, 283, 331, 470, 602, 781, 1188, 1697, 2329, 3181, 4216, 5379, 7050, 8846, 10610, 12877, 14724, 15996, 16845, 16707, 15761, 14365, 12475, 10229, 8293, 6517, 4990, 3776, 2936, 2286, 1790, 1509, 1233, 1100, 971, 838, 786, 667, 607, 585, 530, 557, 482, 430, 414, 406, 371, 357, 358, 338, 331, 295, 273, 276, 208, 204, 184, 128, 121, 87, 95, 80, 67, 70, 54, 57, 47, 39, 48, 33, 47, 37, 24, 33, 33, 25, 16, 17, 22, 22, 21, 16, 13, 11, 11, 18, 13, 14, 10, 12, 6, 11, 2, 6, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
+  ]
+}
diff --git a/src/mednet/libs/segmentation/tests/data/histograms/raw_data/histograms_drive_default.json b/src/mednet/libs/segmentation/tests/data/histograms/raw_data/histograms_drive_default.json
new file mode 100644
index 00000000..6920c3ad
--- /dev/null
+++ b/src/mednet/libs/segmentation/tests/data/histograms/raw_data/histograms_drive_default.json
@@ -0,0 +1,16 @@
+{
+  "train": [
+    ["training/images/24_training.tif", [4636, 622, 38, 118, 282, 637, 4618, 18022, 30156, 24384, 10307, 3840, 1985, 1062, 610, 354, 236, 127, 75, 69, 55, 54, 61, 46, 39, 30, 44, 50, 40, 35, 41, 36, 22, 34, 30, 31, 38, 27, 39, 40, 29, 18, 35, 33, 27, 30, 45, 29, 32, 26, 47, 24, 39, 30, 24, 29, 42, 32, 17, 29, 43, 24, 25, 45, 58, 25, 42, 55, 25, 41, 33, 34, 33, 31, 27, 16, 31, 22, 25, 23, 26, 24, 11, 27, 25, 14, 16, 23, 19, 13, 16, 13, 19, 23, 20, 15, 22, 26, 15, 15, 19, 13, 13, 20, 18, 11, 26, 17, 19, 14, 13, 23, 13, 7, 17, 19, 20, 22, 21, 15, 29, 16, 20, 19, 18, 23, 19, 21, 26, 16, 13, 23, 20, 17, 23, 17, 18, 21, 22, 19, 23, 18, 23, 31, 25, 22, 24, 40, 38, 35, 40, 49, 47, 58, 53, 89, 94, 110, 147, 164, 159, 159, 173, 223, 272, 267, 320, 295, 292, 309, 326, 362, 356, 448, 417, 466, 527, 658, 743, 931, 1095, 1283, 1359, 1568, 1632, 1798, 1908, 1893, 1812, 1836, 1686, 1741, 1538, 1500, 1498, 1425, 1382, 1465, 1448, 1514, 1478, 1500, 1527, 1541, 1496, 1527, 1568, 1496, 1518, 1586, 1468, 1486, 1542, 1527, 1441, 1460, 1396, 1429, 1510, 1441, 1459, 1488, 1386, 1474, 1464, 1442, 1426, 1450, 1522, 1518, 1511, 1560, 1513, 1438, 1427, 1409, 1486, 1442, 1437, 1453, 1422, 1406, 1417, 1440, 1443, 1601, 1616, 1628, 1683, 1608, 1668, 1772, 1747, 1805, 1878, 101003, 6812, 816, 264, 297, 672, 4881, 20360, 33151, 24210, 9320, 2477, 669, 212, 78, 59, 35, 31, 32, 17, 20, 23, 25, 21, 26, 23, 25, 18, 18, 16, 15, 22, 24, 23, 15, 12, 18, 25, 16, 14, 16, 21, 21, 13, 15, 11, 30, 15, 18, 16, 10, 17, 12, 14, 10, 23, 15, 16, 15, 13, 8, 15, 21, 13, 16, 19, 20, 8, 23, 20, 16, 25, 34, 49, 46, 50, 69, 83, 95, 129, 133, 149, 141, 181, 211, 233, 264, 348, 410, 493, 523, 546, 625, 725, 794, 811, 903, 996, 1126, 1190, 1484, 1757, 2236, 2599, 2986, 3295, 3607, 3959, 4129, 4414, 4792, 4952, 5438, 6073, 6750, 7531, 8276, 8905, 9287, 9777, 9979, 9713, 9323, 8668, 7814, 6852, 5791, 5281, 4355, 3823, 3451, 2980, 2675, 2354, 2013, 1827, 1557, 1431, 1288, 1150, 1078, 992, 942, 848, 795, 767, 675, 648, 644, 581, 559, 499, 489, 459, 458, 431, 395, 347, 357, 345, 334, 295, 279, 277, 262, 247, 214, 217, 217, 199, 194, 178, 174, 189, 165, 150, 131, 143, 155, 150, 128, 134, 128, 99, 111, 94, 80, 81, 62, 56, 69, 53, 56, 56, 41, 35, 39, 46, 42, 37, 57, 41, 38, 47, 39, 31, 41, 37, 32, 31, 23, 25, 28, 25, 29, 27, 22, 24, 17, 13, 14, 13, 11, 13, 12, 15, 10, 10, 3, 12, 5, 6, 6, 6, 5, 2, 5, 3, 2, 4, 2, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7757, 690, 205, 315, 1158, 4426, 12879, 29568, 28997, 13146, 3891, 1093, 460, 236, 121, 92, 52, 38, 35, 24, 31, 25, 33, 33, 25, 25, 29, 32, 26, 24, 31, 26, 27, 34, 31, 27, 20, 38, 26, 37, 42, 45, 48, 48, 79, 92, 117, 147, 193, 265, 360, 454, 647, 971, 1346, 2065, 3248, 4637, 6254, 8315, 10077, 11856, 13430, 14779, 15976, 16111, 15724, 14583, 12881, 11026, 9102, 7223, 5831, 4770, 3797, 3113, 2634, 2335, 1930, 1673, 1425, 1366, 1208, 1050, 929, 901, 806, 705, 635, 591, 489, 545, 497, 481, 416, 425, 401, 379, 285, 316, 227, 223, 210, 150, 112, 86, 85, 68, 50, 45, 48, 45, 39, 38, 32, 29, 29, 29, 25, 18, 27, 23, 12, 23, 15, 13, 19, 16, 12, 14, 12, 12, 17, 15, 13, 14, 20, 17, 19, 15, 19, 18, 21, 23, 20, 12, 15, 15, 10, 12, 4, 11, 9, 4, 2, 3, 0, 3, 0, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
+    ["training/images/21_training.tif", [4899, 389, 56, 216, 418, 731, 5274, 21328, 32754, 22920, 8101, 2473, 1176, 628, 335, 208, 125, 87, 64, 50, 45, 52, 57, 47, 40, 36, 46, 29, 32, 26, 32, 36, 27, 29, 35, 31, 44, 26, 32, 26, 32, 45, 25, 34, 38, 26, 26, 29, 34, 26, 37, 26, 27, 33, 18, 29, 40, 34, 27, 26, 28, 19, 27, 21, 27, 16, 22, 23, 23, 28, 31, 20, 18, 25, 36, 19, 24, 18, 18, 28, 27, 28, 26, 23, 27, 21, 22, 25, 26, 19, 34, 18, 21, 28, 32, 30, 26, 36, 29, 25, 35, 25, 31, 26, 24, 29, 19, 26, 24, 21, 21, 25, 20, 22, 22, 23, 28, 21, 20, 14, 24, 29, 29, 36, 41, 36, 40, 53, 39, 59, 71, 98, 108, 135, 176, 226, 307, 364, 470, 530, 655, 785, 835, 894, 945, 1032, 1132, 1133, 1160, 1238, 1231, 1347, 1394, 1439, 1504, 1462, 1524, 1609, 1649, 1724, 1810, 1935, 2102, 2124, 2120, 2161, 2098, 1941, 2033, 2004, 2075, 1972, 2069, 1984, 1913, 1909, 1794, 1771, 1729, 1721, 1630, 1615, 1676, 1800, 1757, 1899, 1928, 2026, 2034, 2122, 2130, 2177, 2140, 2207, 2283, 2252, 2315, 2274, 2419, 2480, 2335, 2313, 2237, 2196, 2138, 2219, 2212, 2139, 2258, 2246, 2299, 2311, 2415, 2612, 2692, 2862, 2781, 2863, 2858, 2925, 2953, 2960, 2805, 2823, 2924, 2757, 2614, 2571, 2474, 2505, 2422, 2299, 2255, 2320, 2149, 2120, 1967, 1908, 1858, 1686, 1588, 1501, 1391, 1297, 1190, 1046, 979, 925, 835, 711, 626, 569, 527, 439, 348, 5673, 6992, 588, 290, 269, 575, 3690, 17157, 33251, 28152, 10141, 2382, 621, 169, 65, 48, 60, 37, 33, 25, 20, 21, 34, 23, 17, 20, 16, 17, 29, 24, 22, 24, 26, 22, 23, 15, 30, 19, 23, 14, 28, 17, 26, 16, 21, 13, 20, 7, 31, 13, 17, 19, 19, 13, 22, 24, 22, 9, 19, 26, 27, 19, 14, 21, 19, 20, 19, 23, 18, 26, 21, 22, 29, 18, 15, 20, 12, 24, 25, 25, 50, 56, 72, 91, 87, 141, 212, 235, 312, 375, 425, 498, 610, 666, 815, 939, 1176, 1422, 1682, 2133, 2430, 2606, 2893, 3088, 3480, 3665, 4330, 5349, 6545, 7965, 8853, 9643, 9517, 9230, 8609, 7958, 7526, 7115, 6586, 6408, 6258, 5969, 5598, 5468, 5137, 4940, 4550, 4281, 4032, 3516, 3239, 2984, 2739, 2476, 2196, 2046, 1880, 1598, 1383, 1250, 1162, 968, 834, 797, 717, 665, 590, 589, 501, 518, 413, 401, 371, 363, 351, 334, 295, 285, 267, 233, 219, 218, 201, 200, 189, 176, 158, 138, 115, 121, 138, 112, 100, 101, 107, 77, 92, 72, 72, 65, 53, 66, 62, 45, 58, 52, 62, 65, 58, 58, 50, 59, 47, 55, 64, 44, 45, 49, 48, 35, 46, 47, 49, 39, 30, 38, 52, 55, 50, 33, 41, 36, 37, 38, 29, 30, 30, 31, 38, 27, 29, 19, 18, 34, 19, 35, 30, 25, 29, 32, 31, 32, 25, 33, 40, 52, 36, 43, 34, 30, 39, 35, 33, 41, 35, 36, 37, 29, 33, 31, 49, 55, 61, 69, 60, 71, 328, 7923, 386, 284, 520, 2315, 9233, 17871, 29440, 24802, 8555, 2257, 736, 338, 180, 137, 83, 52, 47, 38, 33, 42, 33, 34, 48, 37, 35, 22, 40, 32, 37, 35, 32, 36, 45, 37, 32, 30, 28, 28, 30, 41, 33, 29, 31, 33, 37, 32, 43, 29, 36, 27, 37, 37, 48, 50, 53, 57, 106, 139, 211, 286, 380, 549, 792, 1172, 1758, 2601, 3827, 5475, 7711, 10079, 12422, 14690, 16155, 16650, 16828, 15957, 14839, 13334, 11482, 9297, 7707, 6123, 4991, 3975, 3228, 2699, 2205, 1868, 1540, 1256, 1055, 922, 854, 702, 626, 511, 433, 374, 342, 272, 237, 177, 187, 168, 145, 157, 145, 126, 125, 132, 116, 132, 107, 74, 97, 87, 102, 88, 64, 67, 68, 59, 63, 74, 83, 88, 90, 84, 98, 99, 79, 99, 70, 71, 80, 138, 81, 155, 65, 194, 45, 148, 72, 32, 64, 24, 56, 22, 35, 20, 12, 15, 9, 13, 7, 5, 2, 2, 0, 2, 4, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
+    ["training/images/29_training.tif", [4716, 530, 36, 147, 345, 800, 6541, 23499, 34737, 20687, 6120, 2162, 1022, 465, 255, 167, 122, 93, 81, 73, 53, 58, 64, 57, 58, 67, 66, 72, 66, 58, 41, 54, 70, 36, 48, 53, 66, 55, 49, 49, 53, 43, 49, 48, 40, 38, 33, 40, 34, 34, 42, 27, 41, 33, 40, 33, 38, 47, 27, 22, 36, 31, 38, 35, 20, 47, 25, 32, 40, 44, 32, 39, 36, 54, 48, 45, 48, 53, 53, 64, 79, 82, 119, 117, 179, 257, 275, 345, 379, 428, 423, 481, 543, 560, 592, 660, 717, 786, 867, 893, 844, 856, 820, 827, 817, 796, 772, 765, 774, 774, 800, 842, 912, 980, 898, 1007, 1015, 1079, 1126, 1198, 1255, 1327, 1401, 1417, 1422, 1463, 1481, 1539, 1518, 1457, 1467, 1455, 1515, 1511, 1596, 1728, 1699, 1753, 1778, 1864, 1970, 2141, 2278, 2269, 2227, 2299, 2313, 2408, 2276, 2266, 2262, 2199, 2226, 2231, 2216, 2072, 2150, 2142, 2007, 2100, 2242, 2176, 2204, 2264, 2249, 2203, 2238, 2299, 2206, 2202, 2139, 2271, 2397, 2272, 2326, 2365, 2361, 2276, 2324, 2368, 2310, 2395, 2395, 2504, 2491, 2355, 2154, 2092, 1921, 1746, 1620, 1458, 1453, 1301, 1198, 1202, 1218, 1154, 1134, 1174, 1233, 1262, 1339, 1429, 1383, 1397, 1364, 1383, 1340, 1361, 1318, 1366, 1312, 1343, 1329, 1362, 1216, 1187, 1185, 1021, 994, 921, 870, 863, 749, 741, 692, 677, 678, 642, 684, 637, 609, 586, 498, 488, 477, 495, 443, 447, 444, 372, 306, 290, 247, 198, 211, 166, 122, 108, 100, 72, 61, 57, 31, 495, 6549, 802, 315, 326, 1059, 8710, 30410, 35093, 16674, 3702, 614, 154, 67, 73, 59, 70, 46, 59, 52, 45, 52, 37, 54, 46, 45, 44, 55, 57, 45, 48, 50, 56, 45, 57, 60, 68, 92, 88, 128, 168, 249, 311, 461, 613, 860, 1144, 1424, 1800, 2258, 2866, 3546, 4361, 4739, 4997, 5149, 5183, 5215, 5039, 5166, 5220, 5512, 5613, 5831, 6122, 6414, 6699, 6979, 6916, 6975, 6641, 6295, 5797, 5483, 5242, 4983, 4888, 4734, 4606, 4503, 4355, 4204, 4273, 4123, 3886, 3661, 3391, 3046, 2729, 2478, 2183, 1868, 1576, 1539, 1185, 976, 861, 691, 591, 474, 407, 339, 306, 277, 238, 199, 149, 164, 107, 90, 93, 74, 82, 57, 81, 69, 64, 60, 45, 60, 65, 45, 54, 38, 37, 41, 46, 42, 47, 39, 40, 48, 33, 38, 30, 52, 44, 51, 39, 39, 35, 39, 54, 47, 32, 34, 28, 39, 22, 28, 22, 28, 14, 17, 11, 9, 25, 7, 12, 12, 10, 11, 9, 11, 9, 5, 10, 13, 11, 9, 8, 8, 11, 11, 12, 11, 6, 9, 16, 9, 5, 5, 14, 10, 5, 12, 5, 4, 10, 6, 8, 11, 9, 10, 11, 10, 11, 15, 13, 12, 13, 14, 10, 7, 4, 8, 4, 5, 7, 13, 7, 5, 6, 4, 4, 5, 3, 6, 3, 1, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6844, 620, 293, 370, 1084, 3554, 13375, 35695, 27142, 10770, 3801, 1087, 383, 183, 140, 94, 89, 78, 90, 81, 95, 78, 96, 91, 87, 89, 101, 130, 166, 188, 290, 372, 646, 1042, 1714, 2720, 3743, 4954, 6175, 7533, 8456, 9164, 9733, 10693, 10850, 11275, 11396, 11163, 10493, 9609, 8816, 8297, 7736, 7518, 7291, 7050, 6547, 6027, 5299, 4563, 3915, 3048, 2559, 2105, 1598, 1258, 1069, 855, 708, 575, 485, 392, 332, 281, 208, 191, 151, 134, 126, 113, 95, 93, 94, 77, 98, 71, 75, 74, 79, 69, 51, 49, 43, 39, 39, 37, 29, 23, 20, 23, 21, 17, 16, 13, 32, 15, 11, 9, 13, 19, 13, 10, 17, 19, 15, 13, 14, 17, 16, 9, 13, 15, 16, 9, 15, 12, 22, 9, 17, 19, 22, 17, 18, 13, 13, 10, 7, 10, 5, 11, 5, 5, 6, 6, 6, 2, 3, 3, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
+    ["training/images/28_training.tif", [3782, 1466, 98, 238, 392, 616, 4592, 19472, 33833, 25022, 8340, 2393, 1064, 514, 287, 176, 105, 70, 58, 55, 60, 34, 60, 58, 46, 46, 37, 43, 52, 48, 45, 57, 51, 43, 46, 55, 45, 43, 40, 57, 24, 48, 57, 59, 44, 44, 57, 29, 47, 40, 47, 26, 30, 39, 20, 29, 38, 33, 25, 37, 29, 23, 35, 33, 31, 37, 22, 38, 24, 36, 26, 23, 28, 22, 24, 19, 35, 18, 21, 26, 30, 34, 24, 23, 29, 23, 26, 22, 20, 26, 28, 25, 20, 23, 38, 23, 29, 26, 33, 32, 29, 34, 47, 37, 34, 60, 68, 83, 60, 89, 98, 114, 136, 161, 180, 223, 287, 378, 429, 483, 602, 763, 897, 1017, 1144, 1287, 1410, 1512, 1511, 1552, 1691, 1709, 1798, 1821, 1773, 1853, 1851, 1808, 1988, 2089, 2040, 2132, 2213, 2310, 2286, 2193, 2378, 2124, 2138, 2112, 2071, 2083, 2084, 2070, 2137, 2102, 2220, 2222, 2219, 2196, 2230, 2174, 2130, 2231, 2192, 2207, 2141, 2243, 2377, 2411, 2512, 2716, 2746, 2740, 2743, 2792, 2738, 2844, 2796, 2804, 2832, 2851, 2810, 2830, 2900, 3066, 3075, 3074, 3131, 3199, 3058, 3054, 2866, 2762, 2591, 2630, 2540, 2577, 2661, 2681, 2698, 2662, 2621, 2607, 2478, 2434, 2219, 2171, 1898, 1775, 1590, 1389, 1325, 1163, 1096, 1035, 900, 856, 731, 707, 664, 517, 491, 473, 377, 330, 264, 234, 182, 138, 128, 110, 69, 76, 42, 55, 46, 45, 49, 43, 40, 35, 52, 43, 38, 40, 41, 53, 44, 39, 52, 59, 46, 33, 30, 1840, 5807, 1582, 302, 309, 659, 4917, 22259, 34840, 23725, 7769, 1664, 419, 127, 58, 39, 41, 34, 32, 27, 25, 21, 39, 26, 22, 23, 30, 35, 18, 29, 22, 28, 25, 31, 28, 26, 22, 15, 28, 15, 25, 26, 26, 34, 27, 34, 32, 21, 28, 23, 19, 24, 21, 26, 26, 16, 29, 21, 23, 31, 20, 25, 36, 22, 23, 20, 32, 34, 28, 37, 49, 55, 83, 97, 106, 138, 166, 211, 250, 279, 344, 311, 338, 363, 413, 481, 558, 675, 731, 912, 1037, 1327, 1543, 1806, 2344, 2899, 3213, 3756, 4228, 4442, 4780, 5119, 5334, 5661, 5866, 5920, 5574, 5385, 5401, 5082, 5132, 5307, 5546, 5747, 6266, 6280, 6549, 6272, 6097, 6014, 5621, 5352, 5195, 4921, 4672, 4593, 4433, 4240, 4116, 3866, 3712, 3391, 3064, 2570, 2143, 1905, 1423, 1214, 1000, 762, 720, 615, 593, 483, 458, 439, 404, 385, 340, 285, 296, 227, 186, 150, 159, 170, 156, 116, 124, 138, 129, 121, 105, 106, 123, 100, 92, 75, 72, 52, 63, 49, 42, 46, 42, 50, 66, 40, 42, 53, 36, 67, 59, 46, 36, 51, 45, 43, 38, 46, 37, 32, 50, 29, 39, 39, 47, 42, 49, 54, 56, 56, 62, 49, 59, 54, 27, 31, 30, 24, 25, 17, 10, 13, 15, 7, 12, 4, 1, 2, 3, 3, 0, 2, 2, 2, 1, 5, 0, 0, 1, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6614, 1476, 258, 317, 929, 3495, 10976, 31107, 31266, 12761, 3991, 1221, 432, 218, 135, 87, 51, 46, 47, 45, 31, 46, 33, 32, 46, 34, 45, 41, 30, 44, 49, 43, 39, 48, 51, 51, 48, 56, 48, 48, 85, 80, 77, 120, 135, 190, 200, 310, 429, 514, 703, 934, 1164, 1611, 2173, 2883, 3690, 4792, 6336, 8044, 10078, 12369, 13932, 15555, 16026, 16035, 15001, 13396, 12089, 10350, 8903, 7459, 6089, 5084, 4049, 3282, 2739, 2193, 1766, 1529, 1280, 1108, 977, 778, 744, 642, 542, 488, 392, 346, 351, 310, 308, 276, 219, 183, 201, 149, 152, 138, 163, 151, 136, 105, 115, 115, 104, 98, 99, 105, 75, 71, 59, 40, 40, 26, 34, 23, 20, 14, 13, 6, 5, 6, 6, 3, 3, 5, 1, 3, 0, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
+    ["training/images/28_training.tif", [3782, 1466, 98, 238, 392, 616, 4592, 19472, 33833, 25022, 8340, 2393, 1064, 514, 287, 176, 105, 70, 58, 55, 60, 34, 60, 58, 46, 46, 37, 43, 52, 48, 45, 57, 51, 43, 46, 55, 45, 43, 40, 57, 24, 48, 57, 59, 44, 44, 57, 29, 47, 40, 47, 26, 30, 39, 20, 29, 38, 33, 25, 37, 29, 23, 35, 33, 31, 37, 22, 38, 24, 36, 26, 23, 28, 22, 24, 19, 35, 18, 21, 26, 30, 34, 24, 23, 29, 23, 26, 22, 20, 26, 28, 25, 20, 23, 38, 23, 29, 26, 33, 32, 29, 34, 47, 37, 34, 60, 68, 83, 60, 89, 98, 114, 136, 161, 180, 223, 287, 378, 429, 483, 602, 763, 897, 1017, 1144, 1287, 1410, 1512, 1511, 1552, 1691, 1709, 1798, 1821, 1773, 1853, 1851, 1808, 1988, 2089, 2040, 2132, 2213, 2310, 2286, 2193, 2378, 2124, 2138, 2112, 2071, 2083, 2084, 2070, 2137, 2102, 2220, 2222, 2219, 2196, 2230, 2174, 2130, 2231, 2192, 2207, 2141, 2243, 2377, 2411, 2512, 2716, 2746, 2740, 2743, 2792, 2738, 2844, 2796, 2804, 2832, 2851, 2810, 2830, 2900, 3066, 3075, 3074, 3131, 3199, 3058, 3054, 2866, 2762, 2591, 2630, 2540, 2577, 2661, 2681, 2698, 2662, 2621, 2607, 2478, 2434, 2219, 2171, 1898, 1775, 1590, 1389, 1325, 1163, 1096, 1035, 900, 856, 731, 707, 664, 517, 491, 473, 377, 330, 264, 234, 182, 138, 128, 110, 69, 76, 42, 55, 46, 45, 49, 43, 40, 35, 52, 43, 38, 40, 41, 53, 44, 39, 52, 59, 46, 33, 30, 1840, 5807, 1582, 302, 309, 659, 4917, 22259, 34840, 23725, 7769, 1664, 419, 127, 58, 39, 41, 34, 32, 27, 25, 21, 39, 26, 22, 23, 30, 35, 18, 29, 22, 28, 25, 31, 28, 26, 22, 15, 28, 15, 25, 26, 26, 34, 27, 34, 32, 21, 28, 23, 19, 24, 21, 26, 26, 16, 29, 21, 23, 31, 20, 25, 36, 22, 23, 20, 32, 34, 28, 37, 49, 55, 83, 97, 106, 138, 166, 211, 250, 279, 344, 311, 338, 363, 413, 481, 558, 675, 731, 912, 1037, 1327, 1543, 1806, 2344, 2899, 3213, 3756, 4228, 4442, 4780, 5119, 5334, 5661, 5866, 5920, 5574, 5385, 5401, 5082, 5132, 5307, 5546, 5747, 6266, 6280, 6549, 6272, 6097, 6014, 5621, 5352, 5195, 4921, 4672, 4593, 4433, 4240, 4116, 3866, 3712, 3391, 3064, 2570, 2143, 1905, 1423, 1214, 1000, 762, 720, 615, 593, 483, 458, 439, 404, 385, 340, 285, 296, 227, 186, 150, 159, 170, 156, 116, 124, 138, 129, 121, 105, 106, 123, 100, 92, 75, 72, 52, 63, 49, 42, 46, 42, 50, 66, 40, 42, 53, 36, 67, 59, 46, 36, 51, 45, 43, 38, 46, 37, 32, 50, 29, 39, 39, 47, 42, 49, 54, 56, 56, 62, 49, 59, 54, 27, 31, 30, 24, 25, 17, 10, 13, 15, 7, 12, 4, 1, 2, 3, 3, 0, 2, 2, 2, 1, 5, 0, 0, 1, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6614, 1476, 258, 317, 929, 3495, 10976, 31107, 31266, 12761, 3991, 1221, 432, 218, 135, 87, 51, 46, 47, 45, 31, 46, 33, 32, 46, 34, 45, 41, 30, 44, 49, 43, 39, 48, 51, 51, 48, 56, 48, 48, 85, 80, 77, 120, 135, 190, 200, 310, 429, 514, 703, 934, 1164, 1611, 2173, 2883, 3690, 4792, 6336, 8044, 10078, 12369, 13932, 15555, 16026, 16035, 15001, 13396, 12089, 10350, 8903, 7459, 6089, 5084, 4049, 3282, 2739, 2193, 1766, 1529, 1280, 1108, 977, 778, 744, 642, 542, 488, 392, 346, 351, 310, 308, 276, 219, 183, 201, 149, 152, 138, 163, 151, 136, 105, 115, 115, 104, 98, 99, 105, 75, 71, 59, 40, 40, 26, 34, 23, 20, 14, 13, 6, 5, 6, 6, 3, 3, 5, 1, 3, 0, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
+  ],
+  "test": [
+    ["test/images/05_test.tif", [4437, 792, 58, 153, 361, 683, 5037, 20154, 33995, 23495, 7665, 2824, 1237, 558, 322, 149, 107, 78, 56, 56, 50, 42, 42, 57, 38, 56, 38, 45, 49, 39, 39, 50, 25, 28, 31, 60, 46, 33, 50, 35, 43, 40, 29, 33, 40, 39, 38, 25, 44, 46, 32, 22, 26, 34, 28, 33, 34, 51, 16, 34, 37, 30, 18, 33, 34, 24, 27, 32, 22, 36, 36, 31, 29, 28, 37, 16, 16, 23, 23, 20, 22, 17, 20, 28, 22, 18, 28, 20, 19, 16, 18, 22, 25, 24, 20, 22, 19, 23, 17, 15, 18, 27, 22, 28, 21, 23, 29, 30, 19, 23, 30, 22, 30, 26, 26, 29, 17, 28, 34, 34, 40, 41, 43, 57, 82, 104, 101, 120, 141, 166, 219, 249, 297, 309, 398, 452, 524, 575, 711, 727, 861, 904, 903, 972, 1019, 1162, 1232, 1320, 1386, 1459, 1518, 1496, 1611, 1642, 1679, 1731, 1703, 1764, 1814, 1879, 1714, 1701, 1612, 1687, 1557, 1665, 1626, 1664, 1825, 1789, 1727, 1844, 1840, 1889, 1964, 1920, 1934, 1985, 2037, 2143, 2067, 2071, 2083, 2097, 2079, 2040, 2190, 2252, 2504, 2591, 2712, 2856, 2829, 2819, 2933, 3091, 3099, 3225, 3286, 3311, 3364, 3472, 3437, 3549, 3445, 3477, 3363, 3288, 3247, 3209, 3119, 2895, 2949, 2887, 2806, 2925, 2920, 2900, 2966, 2941, 2976, 2922, 2893, 2739, 2738, 2430, 2347, 2180, 2028, 1764, 1564, 1447, 1340, 1213, 1073, 916, 822, 711, 558, 562, 453, 444, 354, 330, 259, 219, 198, 146, 138, 88, 65, 56, 62, 52, 58, 1747, 6691, 959, 311, 387, 919, 7040, 27152, 35348, 19246, 4914, 1007, 223, 76, 49, 38, 38, 45, 34, 48, 32, 35, 30, 30, 42, 29, 28, 25, 32, 32, 33, 36, 28, 25, 27, 36, 30, 32, 21, 27, 27, 30, 31, 25, 21, 34, 33, 29, 26, 30, 35, 46, 47, 86, 143, 183, 292, 348, 418, 512, 601, 686, 792, 967, 1108, 1202, 1477, 1858, 2450, 3362, 4707, 6305, 8142, 10060, 10999, 11896, 12131, 11948, 11891, 11445, 11250, 10825, 10551, 9949, 9108, 8404, 7523, 6412, 5564, 4644, 3758, 3170, 2563, 2096, 1605, 1303, 1035, 842, 602, 485, 400, 375, 319, 278, 230, 210, 211, 177, 132, 136, 116, 120, 121, 119, 106, 120, 104, 121, 113, 93, 92, 78, 92, 81, 77, 94, 77, 86, 68, 83, 66, 68, 62, 48, 60, 40, 40, 32, 52, 33, 46, 38, 38, 45, 41, 36, 37, 34, 32, 34, 23, 23, 30, 29, 32, 26, 27, 28, 33, 44, 31, 22, 20, 18, 20, 26, 24, 19, 19, 16, 27, 30, 36, 38, 45, 51, 47, 49, 50, 31, 34, 38, 46, 26, 31, 33, 18, 26, 24, 15, 12, 21, 11, 9, 16, 17, 12, 12, 4, 12, 8, 10, 14, 9, 11, 6, 5, 5, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7294, 813, 256, 336, 1083, 3885, 12575, 33447, 29031, 10836, 3692, 1089, 369, 194, 128, 80, 73, 48, 56, 50, 56, 43, 52, 51, 37, 39, 57, 70, 89, 115, 181, 314, 531, 893, 1553, 2728, 4734, 7599, 11554, 15868, 20230, 23548, 24877, 23164, 20159, 16687, 13046, 9822, 7233, 5027, 3546, 2395, 1650, 1122, 788, 553, 433, 339, 283, 264, 193, 190, 155, 143, 145, 151, 136, 115, 121, 96, 100, 90, 105, 110, 96, 112, 112, 99, 81, 61, 58, 59, 53, 44, 39, 28, 33, 27, 25, 20, 21, 19, 19, 5, 7, 6, 3, 0, 1, 4, 3, 5, 3, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
+    ["test/images/04_test.tif", [3452, 1759, 108, 175, 317, 616, 4525, 19415, 34240, 24438, 7930, 2778, 1243, 534, 260, 174, 122, 103, 64, 65, 65, 46, 46, 53, 54, 43, 48, 36, 45, 48, 45, 51, 44, 46, 40, 46, 36, 38, 44, 45, 43, 33, 43, 38, 32, 40, 33, 27, 40, 49, 38, 30, 36, 45, 21, 32, 38, 38, 27, 36, 40, 19, 31, 38, 35, 31, 33, 33, 34, 34, 35, 27, 31, 34, 39, 29, 33, 37, 32, 32, 42, 51, 37, 48, 34, 25, 36, 45, 55, 45, 55, 49, 43, 58, 63, 65, 65, 96, 111, 109, 99, 141, 109, 118, 139, 168, 157, 184, 183, 187, 223, 222, 247, 266, 319, 300, 366, 332, 391, 431, 451, 460, 462, 549, 537, 533, 573, 567, 667, 667, 688, 796, 847, 869, 911, 978, 1001, 1047, 1047, 1072, 1129, 1213, 1338, 1366, 1443, 1535, 1555, 1563, 1549, 1510, 1556, 1569, 1561, 1540, 1522, 1445, 1427, 1416, 1376, 1350, 1382, 1381, 1362, 1319, 1335, 1322, 1371, 1351, 1422, 1480, 1454, 1531, 1571, 1538, 1634, 1653, 1821, 1778, 1790, 1979, 1972, 2154, 2135, 2216, 2381, 2522, 2571, 2771, 2757, 2768, 2738, 2743, 2639, 2637, 2608, 2504, 2472, 2351, 2234, 2331, 2227, 2275, 2217, 2225, 2194, 2156, 2159, 2066, 2140, 1965, 1930, 1863, 1796, 1743, 1606, 1649, 1510, 1514, 1521, 1418, 1449, 1417, 1388, 1272, 1276, 1214, 1229, 1213, 1196, 1165, 1199, 1123, 1205, 1118, 1207, 1190, 1228, 1272, 1232, 1221, 1180, 1288, 1205, 1194, 1230, 1232, 1205, 1198, 1201, 1071, 1046, 1084, 860, 833, 820, 16335, 5607, 1985, 306, 268, 808, 6529, 26058, 35469, 20433, 5545, 1076, 250, 93, 63, 45, 52, 33, 43, 38, 28, 39, 32, 38, 37, 28, 44, 31, 43, 32, 42, 23, 23, 34, 25, 34, 29, 35, 32, 27, 36, 36, 41, 56, 60, 62, 82, 74, 109, 113, 150, 169, 213, 245, 279, 343, 415, 513, 531, 631, 701, 837, 884, 924, 1073, 1166, 1315, 1413, 1618, 1889, 2159, 2512, 2764, 3135, 3461, 3807, 4056, 4305, 4429, 4635, 4836, 4929, 5035, 5362, 5459, 5780, 5868, 6070, 6234, 6234, 6127, 6132, 5984, 5647, 5222, 4868, 4629, 4227, 4062, 3853, 3625, 3385, 3139, 3017, 2774, 2594, 2459, 2286, 2288, 2128, 1977, 1862, 1761, 1639, 1638, 1433, 1406, 1284, 1126, 1056, 1088, 1075, 1053, 913, 835, 861, 811, 696, 691, 655, 663, 599, 604, 554, 546, 494, 460, 421, 383, 364, 344, 349, 327, 310, 277, 308, 243, 285, 222, 234, 216, 214, 192, 194, 175, 177, 183, 166, 184, 167, 168, 154, 144, 163, 151, 129, 166, 163, 138, 155, 108, 110, 112, 108, 94, 85, 92, 84, 81, 69, 65, 86, 81, 77, 75, 75, 69, 67, 52, 73, 63, 56, 59, 64, 61, 55, 31, 53, 66, 47, 44, 41, 40, 32, 49, 45, 47, 51, 54, 49, 44, 52, 29, 35, 39, 31, 19, 25, 23, 15, 15, 11, 14, 12, 12, 16, 11, 6, 17, 11, 13, 9, 6, 15, 12, 8, 14, 7, 10, 9, 8, 14, 13, 13, 12, 3, 12, 19, 14, 15, 22, 21, 19, 28, 20, 25, 395, 6114, 1819, 294, 387, 1130, 4336, 12491, 32552, 29547, 11312, 3620, 1070, 367, 172, 87, 72, 66, 64, 64, 54, 61, 56, 69, 73, 57, 66, 94, 89, 135, 145, 177, 257, 343, 422, 593, 773, 1006, 1302, 1588, 2002, 2408, 2994, 3457, 4074, 4957, 6023, 7237, 8570, 10020, 11278, 12293, 12879, 12618, 11645, 11154, 10031, 8991, 8139, 7756, 6985, 6118, 5340, 4390, 3694, 3119, 2694, 2204, 1939, 1694, 1470, 1290, 1161, 1030, 919, 796, 778, 669, 568, 562, 491, 468, 428, 357, 379, 318, 327, 335, 297, 256, 268, 291, 252, 284, 266, 224, 259, 245, 213, 238, 239, 226, 236, 216, 217, 188, 227, 189, 192, 176, 166, 157, 121, 116, 126, 137, 84, 83, 83, 60, 74, 54, 68, 65, 53, 43, 44, 55, 57, 67, 110, 51, 91, 46, 70, 55, 106, 89, 29, 80, 27, 66, 32, 42, 26, 15, 27, 16, 19, 10, 14, 11, 10, 6, 2, 7, 3, 5, 2, 2, 0, 1, 0, 0, 3, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
+    ["test/images/18_test.tif", [4576, 664, 46, 118, 342, 714, 5194, 18706, 31108, 24008, 9633, 3428, 1679, 833, 518, 290, 193, 105, 89, 59, 45, 42, 41, 46, 38, 44, 49, 28, 39, 38, 42, 40, 53, 49, 40, 42, 39, 39, 32, 41, 39, 37, 40, 40, 29, 39, 38, 22, 37, 43, 45, 14, 55, 45, 19, 47, 59, 55, 18, 39, 30, 32, 33, 29, 26, 19, 25, 26, 18, 20, 23, 24, 25, 28, 19, 17, 32, 22, 13, 29, 18, 15, 19, 22, 21, 10, 15, 19, 24, 18, 15, 17, 16, 20, 20, 13, 20, 14, 23, 18, 21, 27, 21, 17, 21, 18, 19, 13, 16, 25, 21, 9, 16, 21, 29, 20, 24, 13, 25, 21, 24, 22, 24, 17, 21, 22, 18, 20, 20, 25, 19, 23, 22, 31, 23, 22, 42, 49, 44, 70, 112, 116, 142, 141, 199, 229, 265, 379, 488, 595, 735, 924, 1102, 1241, 1337, 1452, 1545, 1585, 1591, 1576, 1664, 1666, 1615, 1695, 1646, 1677, 1701, 1614, 1805, 1807, 1909, 1816, 1723, 1783, 1653, 1639, 1573, 1548, 1571, 1590, 1562, 1564, 1613, 1704, 1669, 1690, 1710, 1671, 1687, 1693, 1820, 1726, 1773, 1881, 1928, 1973, 1879, 1861, 1910, 1939, 1931, 1886, 2030, 1993, 2110, 2146, 2144, 2090, 2072, 1995, 1998, 1985, 1950, 1949, 1884, 1936, 1778, 1761, 1845, 1799, 1711, 1884, 1883, 1871, 2047, 2169, 2211, 2187, 2188, 2048, 2081, 2162, 2139, 2106, 2153, 2244, 2322, 2275, 2355, 2480, 2547, 2520, 2613, 2677, 2683, 2632, 2522, 2630, 2463, 2431, 2485, 2325, 2279, 2224, 2076, 20661, 6731, 847, 298, 317, 793, 5294, 22003, 33566, 23468, 8060, 2043, 590, 175, 60, 43, 46, 31, 16, 31, 39, 22, 28, 26, 21, 21, 25, 21, 18, 30, 26, 28, 17, 26, 21, 18, 21, 17, 21, 20, 12, 22, 27, 16, 18, 19, 14, 14, 11, 18, 19, 16, 26, 23, 14, 13, 21, 21, 17, 13, 18, 22, 21, 15, 19, 16, 16, 24, 13, 22, 18, 15, 16, 29, 12, 21, 21, 20, 35, 28, 31, 43, 54, 59, 89, 122, 142, 185, 243, 300, 383, 455, 577, 724, 843, 1012, 1179, 1489, 1954, 2711, 3486, 4051, 4429, 4688, 4672, 5036, 5428, 5997, 7015, 7555, 8468, 9248, 9141, 9318, 9153, 8775, 8342, 7510, 7083, 6698, 6192, 6118, 5904, 5673, 5217, 4874, 4360, 4035, 3676, 3345, 2951, 2730, 2369, 2103, 1785, 1559, 1285, 1130, 978, 838, 739, 654, 614, 563, 466, 407, 376, 349, 298, 255, 255, 195, 183, 137, 132, 94, 102, 71, 66, 78, 61, 42, 42, 50, 44, 34, 30, 29, 35, 31, 24, 35, 17, 31, 24, 25, 24, 23, 31, 30, 21, 29, 18, 30, 26, 29, 21, 38, 33, 23, 25, 28, 38, 31, 35, 30, 34, 34, 21, 25, 23, 25, 31, 30, 43, 49, 42, 36, 43, 44, 35, 30, 27, 26, 23, 27, 16, 30, 26, 16, 20, 27, 20, 19, 20, 18, 24, 18, 17, 16, 18, 14, 20, 15, 15, 11, 13, 14, 16, 14, 7, 11, 6, 6, 9, 14, 11, 9, 10, 15, 12, 14, 17, 32, 12, 21, 75, 7708, 691, 248, 336, 1154, 4114, 12566, 30261, 29628, 12437, 3819, 1140, 492, 221, 131, 109, 58, 40, 35, 26, 24, 29, 32, 34, 42, 27, 35, 32, 29, 30, 34, 29, 22, 28, 33, 40, 32, 33, 36, 31, 31, 50, 54, 51, 44, 88, 86, 117, 186, 220, 297, 381, 497, 657, 1023, 1688, 2547, 4057, 5976, 8314, 10740, 13471, 15565, 16853, 17699, 17328, 16615, 15149, 13652, 11565, 9620, 7605, 6109, 4850, 3873, 2941, 2276, 1820, 1405, 1152, 892, 733, 592, 541, 417, 383, 305, 278, 250, 242, 235, 210, 167, 185, 159, 142, 157, 126, 124, 102, 106, 95, 76, 79, 89, 56, 66, 45, 38, 53, 45, 32, 32, 31, 30, 27, 26, 33, 40, 66, 55, 21, 34, 15, 17, 2, 10, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
+    ["test/images/03_test.tif", [5114, 388, 196, 307, 537, 880, 4723, 29573, 43048, 11759, 2181, 1027, 687, 399, 312, 239, 171, 127, 99, 67, 79, 63, 68, 64, 65, 67, 67, 61, 75, 68, 55, 74, 82, 58, 61, 55, 75, 48, 62, 73, 41, 56, 53, 50, 37, 44, 47, 41, 32, 37, 26, 40, 34, 38, 34, 29, 29, 19, 34, 36, 23, 36, 27, 30, 31, 34, 30, 30, 29, 23, 31, 23, 36, 26, 26, 30, 22, 20, 32, 29, 30, 27, 32, 42, 51, 72, 72, 93, 80, 107, 146, 150, 152, 171, 206, 281, 343, 409, 473, 570, 667, 800, 889, 1032, 1277, 1523, 1658, 1774, 1785, 1723, 1748, 1747, 1966, 2030, 1981, 1896, 1930, 1866, 1824, 1818, 1933, 1972, 2009, 1937, 1985, 1996, 2075, 1974, 2059, 1974, 2140, 2069, 2147, 2211, 2350, 2421, 2451, 2603, 2618, 2580, 2508, 2554, 2542, 2584, 2690, 2816, 2969, 2978, 3075, 3039, 3029, 3024, 3185, 3162, 3400, 3474, 3473, 3542, 3788, 3776, 3919, 3910, 3842, 3894, 3985, 4040, 4039, 4158, 4328, 4363, 4196, 4194, 3957, 3839, 3778, 3413, 3186, 2862, 2705, 2235, 2028, 1618, 1448, 1129, 823, 679, 523, 365, 262, 202, 144, 110, 103, 81, 59, 52, 66, 52, 47, 57, 43, 42, 43, 37, 24, 18, 10, 8, 2, 5, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1752, 1434, 4191, 429, 428, 757, 3975, 28757, 43933, 13881, 2773, 819, 390, 194, 98, 79, 68, 70, 36, 41, 23, 38, 29, 28, 36, 31, 30, 34, 20, 23, 31, 28, 31, 25, 24, 20, 35, 32, 27, 51, 68, 107, 152, 193, 247, 354, 473, 516, 576, 603, 707, 760, 934, 931, 1183, 1505, 1882, 2599, 3527, 4175, 4782, 5252, 5717, 6024, 6401, 6706, 7466, 8501, 9634, 10393, 11187, 11144, 11201, 10658, 10325, 9949, 9240, 8769, 8088, 7025, 6058, 5294, 4429, 3566, 2900, 2342, 1762, 1447, 1172, 951, 791, 673, 559, 453, 426, 374, 316, 219, 197, 164, 130, 98, 102, 88, 85, 71, 57, 69, 47, 43, 49, 33, 39, 32, 22, 31, 21, 34, 28, 25, 27, 19, 13, 12, 10, 5, 2, 5, 0, 2, 2, 1, 0, 0, 2, 0, 4, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8686, 513, 929, 2906, 7458, 29514, 41651, 9722, 1615, 645, 378, 311, 205, 181, 149, 152, 192, 313, 534, 1025, 1847, 3154, 5246, 8114, 11517, 14516, 17594, 19781, 21355, 21263, 20826, 18240, 15537, 12117, 9229, 6701, 4662, 3190, 2130, 1436, 983, 721, 478, 381, 294, 240, 184, 166, 143, 87, 95, 64, 69, 58, 50, 60, 43, 51, 45, 34, 23, 30, 24, 16, 17, 8, 9, 10, 8, 6, 8, 3, 6, 5, 0, 2, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
+    ["test/images/19_test.tif", [5037, 294, 99, 284, 422, 1464, 11240, 32946, 32191, 13237, 2960, 1033, 520, 257, 142, 102, 98, 63, 55, 71, 57, 69, 68, 59, 53, 61, 55, 59, 59, 61, 53, 57, 59, 45, 51, 52, 79, 57, 76, 89, 47, 68, 82, 60, 43, 55, 63, 34, 52, 42, 33, 27, 42, 38, 28, 25, 32, 23, 26, 19, 25, 27, 27, 31, 21, 22, 11, 36, 22, 40, 31, 24, 31, 25, 34, 36, 36, 21, 41, 38, 43, 43, 36, 47, 48, 41, 64, 64, 86, 122, 124, 156, 244, 254, 371, 417, 574, 702, 871, 1024, 1185, 1431, 1561, 1799, 1786, 1924, 1973, 2021, 2000, 2093, 2117, 2096, 2236, 2297, 2476, 2539, 2647, 2886, 2823, 2807, 2903, 3030, 3032, 3128, 3244, 3260, 3369, 3444, 3499, 3584, 3626, 3472, 3626, 3540, 3506, 3409, 3375, 3275, 3379, 3321, 3477, 3407, 3516, 3400, 3371, 3375, 3322, 3252, 3353, 3282, 3311, 3274, 3226, 3286, 3296, 3257, 3382, 3375, 3321, 3294, 3323, 3195, 3008, 2771, 2501, 2249, 2048, 1700, 1571, 1405, 1328, 1314, 1267, 1162, 1155, 1100, 981, 898, 921, 824, 759, 707, 627, 588, 508, 458, 401, 370, 316, 295, 263, 214, 207, 182, 165, 151, 118, 92, 75, 73, 71, 59, 60, 60, 38, 35, 30, 41, 33, 35, 31, 24, 24, 27, 33, 35, 22, 28, 33, 23, 29, 19, 33, 35, 27, 44, 30, 22, 22, 27, 35, 33, 28, 35, 40, 22, 25, 32, 24, 25, 26, 31, 32, 26, 30, 26, 25, 21, 23, 21, 11, 10, 15, 14, 14, 37, 6819, 415, 322, 324, 837, 5813, 23220, 38499, 22060, 4897, 812, 191, 74, 47, 45, 51, 41, 53, 48, 34, 31, 34, 28, 23, 43, 26, 40, 35, 35, 29, 38, 37, 39, 46, 41, 42, 50, 61, 80, 111, 104, 135, 166, 169, 232, 271, 297, 297, 415, 459, 560, 618, 725, 827, 1057, 1195, 1474, 1750, 2151, 2676, 3377, 4179, 4839, 5440, 6075, 6549, 7131, 7463, 7753, 7797, 7798, 7654, 7598, 7626, 7913, 8234, 8377, 8546, 8410, 8263, 7907, 7696, 6944, 6349, 5384, 4701, 4181, 3348, 3027, 2350, 1887, 1488, 1224, 993, 792, 654, 543, 449, 457, 392, 352, 348, 329, 288, 289, 256, 271, 225, 240, 222, 217, 190, 173, 159, 168, 162, 168, 143, 138, 110, 121, 111, 134, 83, 92, 116, 99, 78, 79, 78, 58, 69, 62, 56, 69, 49, 50, 43, 44, 45, 53, 41, 58, 50, 48, 43, 49, 41, 46, 49, 50, 44, 50, 33, 35, 38, 36, 36, 40, 30, 25, 28, 20, 19, 20, 18, 16, 13, 11, 15, 11, 13, 6, 3, 5, 6, 8, 3, 1, 9, 4, 4, 4, 1, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7655, 270, 323, 675, 3256, 11014, 19188, 33734, 20591, 5867, 1749, 534, 207, 116, 82, 80, 57, 73, 62, 58, 54, 60, 84, 82, 88, 105, 118, 116, 164, 199, 284, 332, 470, 606, 781, 1195, 1701, 2333, 3184, 4219, 5385, 7053, 8848, 10611, 12880, 14731, 16006, 16850, 16711, 15765, 14371, 12476, 10233, 8293, 6519, 4991, 3776, 2936, 2287, 1790, 1509, 1233, 1100, 971, 838, 786, 667, 607, 585, 530, 557, 482, 430, 414, 406, 371, 357, 358, 338, 331, 295, 273, 276, 208, 204, 184, 128, 121, 87, 95, 80, 67, 70, 54, 57, 47, 39, 48, 33, 47, 37, 24, 33, 33, 25, 16, 17, 22, 22, 21, 16, 13, 11, 11, 18, 13, 14, 10, 12, 6, 11, 2, 6, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
+  ]
+}
diff --git a/src/mednet/libs/segmentation/tests/test_drive.py b/src/mednet/libs/segmentation/tests/test_drive.py
new file mode 100644
index 00000000..a90f6318
--- /dev/null
+++ b/src/mednet/libs/segmentation/tests/test_drive.py
@@ -0,0 +1,142 @@
+# SPDX-FileCopyrightText: Copyright © 2024 Idiap Research Institute <contact@idiap.ch>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+"""Tests for drive dataset."""
+
+import importlib
+
+import pytest
+from click.testing import CliRunner
+
+
+def id_function(val):
+    if isinstance(val, dict):
+        return str(val)
+    return repr(val)
+
+
+@pytest.mark.parametrize(
+    "split,lengths",
+    [
+        ("default", dict(train=20, test=20)),
+    ],
+    ids=id_function,  # just changes how pytest prints it
+)
+def test_protocol_consistency(
+    database_checkers,
+    split: str,
+    lengths: dict[str, int],
+):
+    from mednet.libs.segmentation.config.data.drive.datamodule import (
+        make_split,
+    )
+
+    database_checkers.check_split(
+        make_split(f"{split}.json"),
+        lengths=lengths,
+    )
+
+
+@pytest.mark.skip_if_rc_var_not_set("datadir.drive")
+def test_database_check():
+    from mednet.libs.segmentation.scripts.database import check
+
+    runner = CliRunner()
+    result = runner.invoke(check, ["drive"])
+    assert (
+        result.exit_code == 0
+    ), f"Exit code {result.exit_code} != 0 -- Output:\n{result.output}"
+
+
+@pytest.mark.skip_if_rc_var_not_set("datadir.drive")
+@pytest.mark.parametrize(
+    "dataset",
+    [
+        "train",
+        "test",
+    ],
+)
+@pytest.mark.parametrize(
+    "name",
+    [
+        "default",
+    ],
+)
+def test_loading(database_checkers, name: str, dataset: str):
+    datamodule = importlib.import_module(
+        f".{name}",
+        "mednet.libs.segmentation.config.data.drive",
+    ).datamodule
+
+    datamodule.model_transforms = []  # should be done before setup()
+    datamodule.setup("predict")  # sets up all datasets
+
+    loader = datamodule.predict_dataloader()[dataset]
+
+    limit = 3  # limit load checking
+    for batch in loader:
+        if limit == 0:
+            break
+        database_checkers.check_loaded_batch(
+            batch,
+            batch_size=1,
+            color_planes=3,
+            expected_num_targets=1,
+        )
+        limit -= 1
+
+
+@pytest.mark.skip_if_rc_var_not_set("datadir.drive")
+def test_raw_transforms_image_quality(database_checkers, datadir):
+    reference_histogram_file = str(
+        datadir / "histograms/raw_data/histograms_drive_default.json",
+    )
+
+    datamodule = importlib.import_module(
+        ".default",
+        "mednet.libs.segmentation.config.data.drive",
+    ).datamodule
+
+    datamodule.model_transforms = []
+    datamodule.setup("predict")
+
+    database_checkers.check_image_quality(datamodule, reference_histogram_file)
+
+
+@pytest.mark.skip_if_rc_var_not_set("datadir.drive")
+@pytest.mark.parametrize(
+    "model_name",
+    ["lwnet"],
+)
+def test_model_transforms_image_quality(database_checkers, datadir, model_name):
+    # Densenet's model.name is "densenet-212" and does not correspond to its module name.
+    if model_name == "densenet":
+        reference_histogram_file = str(
+            datadir
+            / "histograms/models/histograms_densenet-121_drive_default.json",
+        )
+    else:
+        reference_histogram_file = str(
+            datadir
+            / f"histograms/models/histograms_{model_name}_drive_default.json",
+        )
+
+    datamodule = importlib.import_module(
+        ".default",
+        "mednet.libs.segmentation.config.data.drive",
+    ).datamodule
+
+    model = importlib.import_module(
+        f".{model_name}",
+        "mednet.libs.segmentation.config.models",
+    ).model
+
+    datamodule.model_transforms = model.model_transforms
+    datamodule.setup("predict")
+
+    database_checkers.check_image_quality(
+        datamodule,
+        reference_histogram_file,
+        compare_type="statistical",
+        pearson_coeff_threshold=0.005,
+    )
-- 
GitLab