Код: Выделить всё
from PIL import Image
def get_pair(image_path, mask_path):
image = np.array(Image.open(image_path).convert('RGB'))
mask = np.array(Image.open(mask_path).convert('L'), dtype = np.float32) # Mask should be Grayscale so each value is either 0 or 255
mask[mask == 255.0] = 1.0 # whereever there is 255, convert it to 1: (1 == 255 == White)
return image, mask
Код: Выделить всё
image, mask = data[0]
image = image / 255
mask = np.stack((mask,)*3, axis=-1)
blended = image * mask
plt.imshow(blended)
Ниже приведены два изображения


и я хочу отобразить эти 3 как:

Подробнее здесь: https://stackoverflow.com/questions/714 ... tplotlib-o