'How to remove cloth from a person using python
My Input Image is this.
I need only the face and hair from that image and others will convert to white background including cloth. I used mediapipe's SelfiSegmentation to remove background and it gives me a promising result. The code is given below,
import cv2
import numpy as np
import cvzone
from cvzone.SelfiSegmentationModule import SelfiSegmentation
import os
from PIL import Image, ImageOps
img = cv2.imread('face.png')
segmentor = SelfiSegmentation()
img = segmentor.removeBG(img,(255,255,255))
cv2.imwrite("whitebg.png", img)
The output is given below..
All I need to remove is the cloth right now and make it a white pixel. Don't just change the black pixel to white. The cloth color may vary from person to person. Is there any way to do that with just image processing?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|