Beispiel #1
0
    def test_vessel_number(self):
        self.image.reshape_for_landmarks(2)
        self.image.threshold_image()
        threshold = self.image.get_uint_image()
        self.image.skeletonization()
        skeleton = self.image.get_uint_image()
        self.image.bin_to_bgr()
        skeleton_rgb = self.image.get_uint_image()
        landmarks, segments = l.potential_landmarks(skeleton, 3)
        widths = l.vessel_width(threshold, landmarks)
        vessels = l.finding_landmark_vessels(widths, landmarks, skeleton,
                                             skeleton_rgb)
        marked_skeleton, final_landmarks = l.vessel_number(
            vessels, landmarks, skeleton_rgb)
        result_skeleton = np.genfromtxt(self._test_path +
                                        "vessel_number_skeleton_test.csv",
                                        delimiter=',')
        result_landmarks = np.genfromtxt(self._test_path +
                                         "vessel_number_filter_test.csv",
                                         delimiter=',')

        assert_array_equal(result_skeleton, marked_skeleton[20, :],
                           "Vessel skeleton does not match")
        assert_array_equal(result_landmarks, final_landmarks,
                           "Vessel final landmarks does not match")
Beispiel #2
0
    def test_principal_boxes(self):
        self.image.reshape_for_landmarks(2)
        self.image.threshold_image()
        threshold = self.image.get_uint_image()
        self.image.skeletonization()
        skeleton = self.image.get_uint_image()
        self.image.bin_to_bgr()
        skeleton_rgb = self.image.get_uint_image()
        landmarks, segments = l.potential_landmarks(skeleton, 3)
        widths = l.vessel_width(threshold, landmarks)
        vessels = l.finding_landmark_vessels(widths, landmarks, skeleton,
                                             skeleton_rgb)
        marked_skeleton, final_landmarks = l.vessel_number(
            vessels, landmarks, skeleton_rgb)
        bifurcations, crossings = l.principal_boxes(marked_skeleton,
                                                    final_landmarks, 2)
        result = np.genfromtxt(self._test_path + "boxes_bifurcations_test.csv",
                               delimiter=',')
        result2 = np.genfromtxt(self._test_path + "boxes_crossings_test.csv",
                                delimiter=',')

        assert_array_equal(result, bifurcations[0],
                           "Bifurcation points does not match")
        assert_array_equal(result2, crossings[0],
                           "Crossing points does not match")
Beispiel #3
0
    def test_vessel_width(self):
        self.image.reshape_for_landmarks(2)
        self.image.threshold_image()
        threshold = self.image.get_uint_image()
        self.image.skeletonization()
        skeleton = self.image.get_uint_image()
        landmarks, segments = l.potential_landmarks(skeleton, 3)
        widths = l.vessel_width(threshold, landmarks)
        result = np.genfromtxt(self._test_path + "vessel_widths_test.csv",
                               delimiter=',')

        assert_array_equal(result, widths, "Vessel widths does not match")
def _average_width(connected_matrix: np.ndarray, connected: list,
                   thr_img: np.ndarray, final_image: np.ndarray):
    connected_avg = []
    for c in connected:
        formatted_indexes = _normalize_indexes(connected_matrix, c)
        label_widths = l.vessel_width(thr_img, formatted_indexes)
        index = int(len(formatted_indexes) / 2)
        connected_avg.extend([
            _average(label_widths), final_image[formatted_indexes[index][0],
                                                formatted_indexes[index][1]]
        ])
    return connected_avg
Beispiel #5
0
    def test_finding_landmark_vessels(self):
        self.image.reshape_for_landmarks(2)
        self.image.threshold_image()
        threshold = self.image.get_uint_image()
        self.image.skeletonization()
        skeleton = self.image.get_uint_image()
        self.image.bin_to_bgr()
        skeleton_rgb = self.image.get_uint_image()
        landmarks, segments = l.potential_landmarks(skeleton, 3)
        widths = l.vessel_width(threshold, landmarks)
        vessels = l.finding_landmark_vessels(widths, landmarks, skeleton,
                                             skeleton_rgb)
        result = np.genfromtxt(self._test_path +
                               "finding_landmark_vessels_test.csv",
                               delimiter=',')

        assert_array_equal(result, vessels[0],
                           "Landmark vessels does not match")