def __init__(self, annotation, nrows=512, ncols=None):
super(SingleLayerLabels, self).__init__()
self.annotation = annotation
assert annotation.imagesize.nrows is not None, "Must know the image size first (see update_image_size)"
self.aspect = annotation.imagesize.ncols/float(annotation.imagesize.nrows)
self.y_scale = nrows / float(annotation.imagesize.nrows)
self.nrows = nrows
if ncols is None:
self.x_scale = self.y_scale
self.ncols = int(self.x_scale*annotation.imagesize.ncols)
else:
self.x_scale = ncols / float(annotation.imagesize.ncols)
self.ncols = ncols
self.image = Image.new('L', (self.ncols, self.nrows), LABEL_NEGATIVE)
self.artist = ImageDraw.Draw(self.image)
评论列表
文章目录