Esempio n. 1
0
    def test_homogenize(self):
        features, segments, thr, predictions = vc._loading_model(self.original, self.manual.np_image, self.av, 38)
        acc, rgb, network, original = vc._validating_model(features, segments, self.original, predictions, 38, 1)
        connected_components = cv2.connectedComponentsWithStats(segments.astype(np.uint8), 4, cv2.CV_32S)
        final_img, rgb_img = vc._homogenize(connected_components, network, rgb, original)

        result = np.genfromtxt(self._test_path + "homogenize_test.csv", delimiter=',')
        assert_array_equal(result, rgb_img[:, 20], "Homogenized image does not match")
Esempio n. 2
0
    def test_postprocessing(self):
        bifurcations, crossings = l.classification(self.manual.np_image, 0)
        features, segments, thr, predictions = vc._loading_model(self.original, self.manual.np_image, self.av, 38)
        acc, rgb, network, original = vc._validating_model(features, segments, self.original, predictions, 38, 1)
        connected_components = cv2.connectedComponentsWithStats(segments.astype(np.uint8), 4, cv2.CV_32S)
        final_img, rgb_img = vc._homogenize(connected_components, network, rgb, original)
        post_img = vc._postprocessing(connected_components, thr, bifurcations, rgb_img)

        result = np.genfromtxt(self._test_path + "postprocessing_test.csv", delimiter=',')
        assert_array_equal(result, post_img[:, 20], "Post image does not match")
Esempio n. 3
0
    def test_coloring(self):
        features, segments, thr, predictions = vc._loading_model(self.original, self.manual.np_image, self.av, 38)
        connected_components = cv2.connectedComponentsWithStats(segments.astype(np.uint8), 4, cv2.CV_32S)
        bifurcations, crossings = l.classification(self.manual.np_image, 0)
        connected_vessels = vc._box_labels(bifurcations, connected_components)
        acc, rgb, network, original = vc._validating_model(features, segments, self.original, predictions, 38, 1)
        final_img, rgb_img = vc._homogenize(connected_components, network, rgb, original)
        rgb = vc._coloring(connected_components, connected_vessels[0], [0, 0, 255], rgb_img)

        assert_array_equal([0, 0, 255], rgb, "Coloring does not match")
Esempio n. 4
0
    def test_accuracy(self):
        bifurcations, crossings = l.classification(self.manual.np_image, 0)
        features, segments, thr, predictions = vc._loading_model(self.original, self.manual.np_image, self.av, 38)
        acc, rgb, network, original = vc._validating_model(features, segments, self.original, predictions, 38, 1)
        connected_components = cv2.connectedComponentsWithStats(segments.astype(np.uint8), 4, cv2.CV_32S)
        final_img, rgb_img = vc._homogenize(connected_components, network, rgb, original)

        post_img = vc._postprocessing(connected_components, thr, bifurcations, rgb_img)
        acc = vc._accuracy(post_img, segments, self.av)

        assert_array_equal([0.8447412353923205, 0.7686274509803922, 0.9011627906976745], acc, "Accuracy does not match")
Esempio n. 5
0
    def test_average_width(self):
        features, segments, thr, predictions = vc._loading_model(self.original, self.manual.np_image, self.av, 38)
        connected_components = cv2.connectedComponentsWithStats(segments.astype(np.uint8), 4, cv2.CV_32S)
        bifurcations, crossings = l.classification(self.manual.np_image, 0)
        connected_vessels = vc._box_labels(bifurcations, connected_components)
        acc, rgb, network, original = vc._validating_model(features, segments, self.original, predictions, 38, 1)
        final_img, rgb_img = vc._homogenize(connected_components, network, rgb, original)
        widths_colors = vc._average_width(connected_components, connected_vessels[0], thr, rgb_img)
        wc = [widths_colors[2]]
        wc.extend(widths_colors[3])

        result = np.genfromtxt(self._test_path + "average_width_test.csv", delimiter=',')
        assert_array_equal(result, wc, "Width and color do not match")