예제 #1
0
 def test_median_filter(self):
     self.image.median_filter(3)
     original_image = retina_grayscale.Retina_grayscale(
         None, _image_path, 1)
     assert_array_equal(
         self.image.np_image,
         cv2.medianBlur(original_image.np_image.astype(np.uint8), 3))
예제 #2
0
 def test_opening(self):
     self.image.opening(3)
     original_image = retina_grayscale.Retina_grayscale(
         None, _image_path, 1)
     assert_array_equal(
         self.image.np_image,
         ndimage.grey_opening(original_image.np_image, size=(3, 3)))
예제 #3
0
 def test_gaussian_filter(self):
     self.image.gaussian_filter(17, 1.82)
     original_image = retina_grayscale.Retina_grayscale(
         None, _image_path, 1)
     assert_array_equal(
         self.image.np_image,
         cv2.GaussianBlur(original_image.np_image, (17, 17), 1.82))
 def test_equalize_histogram(self):
     self.image.equalize_histogram()
     original_image = retina_grayscale.Retina_grayscale(None, _image_path, 1)
     clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(3, 3))
     original_image.np_image = clahe.apply(original_image.np_image)
     original_image.restore_mask()
     assert_array_equal(self.image.np_image, original_image.np_image)
 def test_restore_mask(self):
     self.image.np_image[self.image.mask == 0] = 5
     self.image.restore_mask()
     original_image = retina_grayscale.Retina_grayscale(None, _image_path, 1)
     original_image.np_image[original_image.mask == 0] = 5
     original_image.restore_mask()
     assert_array_equal(self.image.np_image, original_image.np_image)
 def test_top_hat(self):
     self.image.top_hat(3)
     original_image = retina_grayscale.Retina_grayscale(None, _image_path, 1)
     assert_array_equal(self.image.np_image,
                        cv2.morphologyEx(original_image.np_image, cv2.MORPH_TOPHAT,
                                         cv2.getStructuringElement(cv2.MORPH_RECT, (
                                             3, 3))))
예제 #7
0
 def test_calculate_roc(self):
     double_segmentation = self.image.normal_vessels_segmentation()
     original_image = retina_grayscale.Retina_grayscale(
         None, _manual_result_path, 1)
     self.image.calculate_roc(double_segmentation / 255,
                              original_image.np_image / 255)
     np.testing.assert_allclose(self.image.roc,
                                [[425., 304., 423., 299., 1451.]], 1e-2)
예제 #8
0
def post_segmentation_double_segmentation():
    data = {"success": False} # pragma: no cover

    if flask.request.method == "POST": # pragma: no cover
        json = flask.request.get_json(silent=True)
        if json is not None:  # pragma: no cover
            image = base64.b64decode(json["image"])
            image = Image.open(io.BytesIO(image))
            retina = retina_grayscale.Retina_grayscale(np.array(image), None)
            data = {"segmentation": retina.double_segmentation()}
    return flask.jsonify(data) # pragma: no cover
예제 #9
0
 def test_constructor_image_no_type_2(self):
     """Test the constructor with an existing image"""
     image = io.imread(_image_path_2)
     none_constructor_image = retina_grayscale.Retina_grayscale(
         image, _image_file_name)
예제 #10
0
 def setUp(self):
     self.image = retina_grayscale.Retina_grayscale(None, _image_path, 1)
예제 #11
0
 def test_double_vessels_segmentation(self):
     double_segmentation = self.image.double_segmentation()
     other_segmentation = retina_grayscale.Retina_grayscale(
         None, _image_path, 1).double_segmentation()
     assert_array_equal(double_segmentation, other_segmentation)
예제 #12
0
 def test_mean_filter(self):
     self.image.mean_filter(3)
     original_image = retina_grayscale.Retina_grayscale(
         None, _image_path, 1)
     assert_array_equal(self.image.np_image,
                        cv2.blur(original_image.np_image, (3, 3)))