I'm new to Python and need assistance. I am performing segmentation with my own medical data set. The test images in my folder are named like "1.0.2.34.56_1.png". I would like to remove the actual image extension and append the image names with "_mask.png". The current code throws an error.
def labelVisualize(num_class,color_dict,img):
img = img[:,:,0] if len(img.shape) == 3 else img
img_out = np.zeros(img.shape + (3,))
for i in range(num_class):
img_out[img == i,:] = color_dict[i]
return img_out / 255
def saveResult(save_path,npyfile,flag_multi_class = False,num_class = 2):
for i,item in enumerate(npyfile):
img = labelVisualize(num_class,COLOR_DICT,item) if flag_multi_class else item[:,:,0]
io.imsave(os.path.join(save_path,"%d_mask.png"%i),img)
saveResult("data/membrane/test/",results)