I want to extract the blue dress from this image however it is not working.
https://www.revolve.com/sau-lee-preston-dress-in-egyptian-blue/dp/SLEE-WD174/?d=Womens&vn=true&page=1&lc=3&itrownum=1&itcurrpage=1&itview=05
At first, I tried removing colors similar to her skin shade (e.g., #e1965e) from the image using the HSV color space. However, this method didn’t give satisfactory results, as it didn’t effectively remove the model from the dress image while preserving the original color.
Then, I attempted to isolate only the blue color in the image by defining a range of blue colors in the HSV color space. Unfortunately, this approach also fell short of expectations, as it couldn’t accurately separate the model from the dress.
I refined the approach by utilizing a mask based on the HSV color space to isolate the blue color. Despite this adjustment, the desired outcome was still not achieved, as the model removal process remained inadequate.
I simplified the task by converting the image to grayscale and applying thresholding to create a binary mask of the white background. Subsequently, I inverted this mask and applied it to the original image to effectively remove the model.
Is this doomed to be a manual process?
import cv2
import numpy as np
def remove_model(image_path):
# Read the image
image = cv2.imread(image_path)
# Convert the image to grayscale
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# Threshold the image to create a binary mask of the white background
_, mask = cv2.threshold(gray, 240, 255, cv2.THRESH_BINARY)
# Invert the mask
mask = cv2.bitwise_not(mask)
# Apply the mask to the original image
result = cv2.bitwise_and(image, image, mask=mask)
return result
File path and name
file_path = “/Users/prabhjotchadha/prabbiecode/Nike/dress.png”
Remove model from image
output_image = remove_model(file_path)
Save the output image
cv2.imwrite(“output_image.png”, output_image)
user24705162 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.