def load_label(self, idx):
"""
Load binary mask and preprocess:
- resize
- convert to greyscale
- cast to integer
- binarize
"""
idx = self.indices_label[idx]
idx=idx.split()[0]
im = io.imread('{}/{}'.format(self.data_dir, idx))
im = Image.fromarray(im)
im=im.resize((self.width, self.height), Image.NEAREST) # resize
im=im.convert('L') # convert to greyscale
im=np.array(im, dtype=(np.int32)) # cast to integer
label=im
label[label>0]=1 # convert to binary
label=np.array(label,np.uint8)
label = label[np.newaxis, ...]
return label
评论列表
文章目录