Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

review segmentation utils #2

Open
miguelgfierro opened this issue May 21, 2019 · 1 comment
Open

review segmentation utils #2

miguelgfierro opened this issue May 21, 2019 · 1 comment

Comments

@miguelgfierro
Copy link
Owner

def test_apply_mask_to_image(test_image):
    img = cv2.imread(test_image["lenna"])
    mask = cv2.imread(test_image["lenna_mask"], 0)
    masked = apply_mask_to_image(img, mask)

    assert np.count_nonzero(masked == 0) == 416754
    assert np.count_nonzero(masked != 0) == 369678

416754 and 369678 is too big for a mask, this looks a 3 channel matrix

@miguelgfierro
Copy link
Owner Author

def test_grabcut_mask(test_image):
    img = cv2.imread(test_image["lenna"])
    mask = cv2.imread(test_image["lenna_mask"], 0)
    img_result, mask = grabcut_mask(img, mask, iterations=1)

    assert np.count_nonzero(img_result == 0) == 416754
    assert np.count_nonzero(img_result != 0) == 369678
    assert np.count_nonzero(mask == 0) == 138918
    assert np.count_nonzero(mask == 255) == 123226

grabcut returns a mask between 0 and 1, instead of 0 and 255

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant