Skip to content
Snippets Groups Projects
Commit a22929bf authored by Mahmoud Ahmed Ali's avatar Mahmoud Ahmed Ali
Browse files

Add instance mask file

parent 73734334
No related branches found
No related tags found
No related merge requests found
from matplotlib import pyplot as plt
import cv2
def instance(im, id):
im = im * 255
im[im == id] = 255
im[im < 255] = 0
im = im / 255
# plt.imshow(im, cmap='gray')
# plt.show()
return im
def generate_instance_mask(data_name):
ids = {"Banana": 108, "Orange": 117, "Pear": 121}
for i in range(4995):
for key in ids.keys():
id = ids[key]
img = plt.imread(f"{data_name}/Mask/{i}.png")
instance_img = instance(img, id)
cv2.imwrite(f"{data_name}/Instance_Mask/{key}/{i}.png", instance_img)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment