Esempio n. 1
0
def test_dilate_erode_wrong_parameters_4():
    image = numpy.zeros((25, 25), dtype=numpy.uint8)
    mask = numpy.zeros((25, 25, 3), dtype=numpy.uint8)
    try:
        phm_img.dilate_erode(image, mask=mask)
    except Exception, e:
        assert type(e) == ValueError
Esempio n. 2
0
def test_dilate_erode_wrong_parameters_1():
    try:
        phm_img.dilate_erode(None)
    except Exception as e:
        assert type(e) == TypeError
    else:
        assert False
Esempio n. 3
0
def test_dilate_erode_wrong_parameters_2():
    image = numpy.zeros((25, 25, 3), dtype=numpy.uint8)
    try:
        phm_img.dilate_erode(image)
    except Exception as e:
        assert type(e) == ValueError
    else:
        assert False
Esempio n. 4
0
def test_dilate_erode_wrong_parameters_3():
    image = numpy.zeros((25, 25), dtype=numpy.uint8)
    mask = 42
    try:
        phm_img.dilate_erode(image, mask=mask)
    except Exception as e:
        assert type(e) == TypeError
    else:
        assert False
Esempio n. 5
0
def test_dilate_erode_2():
    image = numpy.zeros((25, 25), dtype=numpy.uint8)

    image_cleaning = phm_img.dilate_erode(image)

    assert isinstance(image_cleaning, numpy.ndarray)
    assert image_cleaning.ndim == 2
def routine_top_binarization(image):
    hsv_min = (42, 75, 28)
    hsv_max = (80, 250, 134)
    median_blur_size=9
    iterations=5
    
    # Convert image on HSV representation
    hsv_image = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
    # Apply a median blur on the image
    hsv_image = cv2.medianBlur(hsv_image, ksize=median_blur_size)

    # Threshold the image with HSV min and max value
    bin_img = phm_img.threshold_hsv(hsv_image, hsv_min, hsv_max)
    # dilate and erode the image to remove possible noise
    bin_img = phm_img.dilate_erode(bin_img, kernel_shape=(3, 3),iterations=iterations)

    return bin_img