def load_train_image(self, train_id, scale=1, border=0, mask=False):
"""Return image as numpy array.
Args:
border (int): Add a black border of this width around image
mask (bool): If true copy masks from corresponding dotted image
Returns:
uint8 numpy array
"""
img = self._load_image('train', train_id, scale, border)
if mask:
# The masked areas are not uniformly black, presumable due to
# jpeg compression artifacts
MASK_MAX = 40
dot_img = self.load_dotted_image(train_id, scale, border).astype(np.uint16).sum(axis=-1)
img = np.copy(img)
img[dot_img < MASK_MAX] = 0
return img
评论列表
文章目录