如何用原始图像覆盖多个分割的蒙版图像

时间:2019-11-25 18:30:50

标签: python deep-learning cv2

我已分割图像和原始图像。如何将原始图像放置在分割图像的白色区域?

segmented image

colored image

orj-segmented image

我根据ksooklall的建议编写的代码是:

segmented_imgs=("D:/melanoma/train2/train/mask/1")
original_img=("D:/melanoma/train2/train/org/1")
masks=[]
original_imgs=[]
index=0
for index in range(1476):
   segmented_img=(segmented_imgs+ str(index) +"_mask.jpg"!=0)
   original_img=(original_img+ "/" + str(index) + ".jpg")
   mask = (segmented_img != 0)
   segmented_img[mask] = original_img[mask]

   index +=1

我收到错误:

File "D:/merge orjsegment.py", line 14, in <module>
    segmented_img=cv2.imread(segmented_img+ str(index) + "_mask.jpg"!=0)

TypeError: bad argument type for built-in operation

1 个答案:

答案 0 :(得分:0)

尝试:

mask = (segmented_img != 0)
segmented_img[mask] = original_img[mask]