本文整理汇总了Python中Image.Image.reshape_to_linear方法的典型用法代码示例。如果您正苦于以下问题:Python Image.reshape_to_linear方法的具体用法?Python Image.reshape_to_linear怎么用?Python Image.reshape_to_linear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image.Image
的用法示例。
在下文中一共展示了Image.reshape_to_linear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
# 需要导入模块: from Image import Image [as 别名]
# 或者: from Image.Image import reshape_to_linear [as 别名]
def load(self):
""" Load the image and return an :class:`Image` instance. """
bits_per_pixel = self.get_bits_per_sample()
height = self.get_image_length()
samples_per_pixel = self.get_sample_per_pixel()
width = self.get_image_width()
photometric = self.get_photometric()
planar_config = self.get_planar_config()
is_planar = planar_config == Tiff.PLANARCONFIG_SEPARATE
# Tiff.PLANARCONFIG_CONTIG = 1 = Chunky format
# Tiff.PLANARCONFIG_SEPARATE = 2 = Planar format
if samples_per_pixel == 1 and bits_per_pixel == 16 and photometric == Tiff.PHOTOMETRIC_MINISBLACK:
format_ = 'gray16'
elif samples_per_pixel == 3 and bits_per_pixel == 8 and photometric == Tiff.PHOTOMETRIC_RGB:
format_ = 'rgb8'
else:
raise NameError('Image format of %s is not supported' % (self.file_name))
image = Image(format_, width, height, is_planar)
image.reshape_to_linear()
if format_ == 'gray16':
Tiff.read_scanline_gray16(self.tif, image.buffer)
elif format_ == 'rgb8':
Tiff.read_scanline_rgb8(self.tif, image.buffer)
else:
raise NotImplementedError
image.reshape()
return image