Skip to content Skip to sidebar Skip to footer

How To Put An Image On A T-shirt Using Python OpenCV

I'm trying to put any custom image on a blank t-shirt as done below I'm using Python's CV2. Any idea how that could be done? I'm thinking cv2.inRange could point me to the white t

Solution 1:

you want to "blend" the overlay onto the image. open an image editor and explore the blend modes it has for layers. I would suggest trying the "multiply" and "overlay" modes.

OpenCV has some limited support for blending but I would suggest formulating the calculation yourself. the Wikipedia article should help. for a multiply, I would convert both pictures to CV_32F, scale them by 1/255 (so the range is 0.0 .. 1.0), then just multiply them elementwise.

getting a mask for the t-shirt is a useful step. that will let you place the overlay only on the t-shirt, not on the background or skin of the model.

multiply blend using SO logo with white background on a picture from pxhere.com

edge detection is not at all applicable here.


Post a Comment for "How To Put An Image On A T-shirt Using Python OpenCV"