-2

I'm trying to change a specific area of the image after instance segmentation as I'm new to computer vision field so a help would be appreciated.

for example I want to replace the brown color area with another image in a segmented image below:

Image segmented using pixellib

Thanks.

  • 1
    do not **EVER** save label masks as jpg images - only PNG/TIFF or BMP. – Shai Oct 06 '21 at 12:04
  • **first** work through the **basic tutorials of OpenCV**. then return to your question and see if you can't answer it yourself. – Christoph Rackwitz Oct 06 '21 at 13:51
  • @ChristophRackwitz any link or something if it's a simple task ? – Umer Qaisar Oct 06 '21 at 14:13
  • this is an operation with "masks". I can only reiterate: use the learning materials that are available to you. this site isn't for individual tutoring. it is for problems that aren't solved by reading introductory materials. – Christoph Rackwitz Oct 06 '21 at 21:57

1 Answers1

0

This was a very easy problem, here are the steps I took to solve it using numpy operation.

#Loading Masks available    
x = np.loadtxt(maskPath, delimiter=",", dtype=np.uint8)

#Selecting an specific mask
onlyfloor = (x==3)

#Creating mask with 3rd image.
maskedfloor = cv2.bitwise_and(ThirdImage, ThirdImage, mask=onlyfloor.astype(np.uint8))

#Replacing Original Image Pixels with target image pixels.
originalImage[np.where(onlyfloor == 1)] = maskedfloor[np.where(onlyfloor == 1)]

Hope this will help other readers.

Credits: Combine 2 images with mask