4

I need to make a black and white mask for seamless clone, I have a png image, I need to convert it like these photos.

I didn’t find the cut photo, just imagine that there is a transparent background behind, it needs to be filled in black, and the girl in white

enter image description here enter image description here

1 Answer 1

6

Assuming your background is 100% transparent, the following example gives you a single channel mask with the dimensions of the image. Replaced 'girl.png' with the filename of your image.

import cv2
im = cv2.imread("girl.png", cv2.IMREAD_UNCHANGED)
ret, mask = cv2.threshold(im[:, :, 3], 0, 255, cv2.THRESH_BINARY)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.