Ejemplo n.º 1
0
    def test_circle_with_params(self, image, boolean):
        if not boolean:
            image_ref = np.array([[0, 1, 0], [1, 0, 1], [0, 1, 0]])
        else:
            image_ref = np.array([[0, 0, 0], [0, 0, 0], [1, 0, 1]])

        result = cut_image_circle(image,
                                  center=(2, 4),
                                  radius=1,
                                  inverse=boolean)

        assert result.shape == image_ref.shape
        assert (result == image_ref).all()
Ejemplo n.º 2
0
    def test_cut_circle(self, image, boolean):
        image_ref = image.copy()
        if not boolean:
            image_ref[0:2] = 0
            image_ref[1][4] = 1
            image_ref[-1] = 0
            image_ref[:, 0] = 0
            image_ref[:, -1] = 0
        else:
            image_ref[0:-1, 2:7] = 0
            image_ref[2:7, 1:-1] = 0

        result = cut_image_circle(image, inverse=boolean)

        assert result.shape == image_ref.shape
        assert (result == image_ref).all()
Ejemplo n.º 3
0
def get_plate_images(image, plate_coordinates, edge_cut = 100):
    """
    Split image into lattice subimages and delete background

    :param img: a black and white image as a numpy array
    :param plate_coordinates: a list of centers and radii
    :param edge_cut: a radius, in pixels, to remove from the outer edge of the plate
    :returns: a list of plate images
    """
    plates = []

    for coordinate in plate_coordinates:
        center, radius = coordinate
        plates.append(imaging.cut_image_circle(image, center, radius - edge_cut))

    return plates
Ejemplo n.º 4
0
 def test_exceed_bounds(self, image):
     with pytest.raises(ValueError):
         cut_image_circle(image, center=(2, 4), radius=3)
Ejemplo n.º 5
0
 def test_exceed_shape(self, image):
     with pytest.raises(ValueError):
         image_radius = image.shape[0] // 2
         cut_image_circle(image, radius=image_radius + 1)