本文整理汇总了Python中PIL.Image.ROTATE_270属性的典型用法代码示例。如果您正苦于以下问题:Python Image.ROTATE_270属性的具体用法?Python Image.ROTATE_270怎么用?Python Image.ROTATE_270使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类PIL.Image
的用法示例。
在下文中一共展示了Image.ROTATE_270属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_270 [as 别名]
def __init__(self, config, comm, CameraModule):
super().__init__()
self._comm = comm
self._cfg = config
self._cam = CameraModule
self._cap = None
self._pic_dims = None
self._is_preview = self._cfg.getBool('Photobooth', 'show_preview')
self._is_keep_pictures = self._cfg.getBool('Storage', 'keep_pictures')
rot_vals = {0: None, 90: Image.ROTATE_90, 180: Image.ROTATE_180,
270: Image.ROTATE_270}
self._rotation = rot_vals[self._cfg.getInt('Camera', 'rotation')]
示例2: to_column_format
# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_270 [as 别名]
def to_column_format(self, high_density_vertical=True):
"""
Extract slices of an image as equal-sized blobs of column-format data.
:param high_density_vertical: Printed line height in dots
"""
im = self._im.transpose(Image.ROTATE_270).transpose(Image.FLIP_LEFT_RIGHT)
line_height = 24 if high_density_vertical else 8
width_pixels, height_pixels = im.size
top = 0
left = 0
while left < width_pixels:
box = (left, top, left + line_height, top + height_pixels)
im_slice = im.transform((line_height, height_pixels), Image.EXTENT, box)
im_bytes = im_slice.tobytes()
yield(im_bytes)
left += line_height
示例3: image
# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_270 [as 别名]
def image(self, im):
for p in range(8):
pr = self.im.crop((0,8*p,128,8*p+8)).transpose(Image.ROTATE_270)
bb = im.crop((0,8*p,128,8*p+8)).transpose(Image.ROTATE_270)
diff = ImageChops.difference(pr, bb)
di = diff.getbbox()
if di is not None:
(x0, y0, x1, y1) = di
self.command(COLUMNADDR)
self.command(y0)
self.command(y1 - 1)
self.command(PAGEADDR)
self.command(p)
self.command(p + 1)
self.i2.start(self.a, 0)
self.i2.write([0x40])
self.i2.write(bb.tobytes()[y0:y1])
self.i2.stop()
self.im = im
self.command(DISPLAYON)
示例4: rotate_image
# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_270 [as 别名]
def rotate_image(imagedata, clockwise = True):
"""
Rotate an image.
clockwise: Rotate 90 degrees clockwise, if false rotates anticlockwise
"""
try:
inputd = asm3.utils.bytesio(imagedata)
im = Image.open(inputd)
if clockwise:
im = im.transpose(Image.ROTATE_270)
else:
im = im.transpose(Image.ROTATE_90)
output = asm3.utils.bytesio()
im.save(output, "JPEG")
rotated_data = output.getvalue()
output.close()
return rotated_data
except Exception as err:
asm3.al.error("failed rotating image: %s" % str(err), "media.rotate_image")
return imagedata
示例5: get_tta_patterns
# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_270 [as 别名]
def get_tta_patterns(src, n):
src_lr = src.transpose(Image.FLIP_LEFT_RIGHT)
patterns = [
[src, None],
[src.transpose(Image.ROTATE_90), inv(-90)],
[src.transpose(Image.ROTATE_180), inv(-180)],
[src.transpose(Image.ROTATE_270), inv(-270)],
[src_lr, inv(0, True)],
[src_lr.transpose(Image.ROTATE_90), inv(-90, True)],
[src_lr.transpose(Image.ROTATE_180), inv(-180, True)],
[src_lr.transpose(Image.ROTATE_270), inv(-270, True)],
]
if n == 2:
return [patterns[0], patterns[4]]
elif n == 4:
return [patterns[0], patterns[2], patterns[4], patterns[6]]
elif n == 8:
return patterns
return [patterns[0]]
示例6: eval_angle
# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_270 [as 别名]
def eval_angle(im,detectAngle=False):
"""
估计图片偏移角度
@@param:im
@@param:detectAngle 是否检测文字朝向
"""
angle = 0
img = np.array(im)
if detectAngle:
angle = angle_detect(img=np.copy(img))##文字朝向检测
if angle==90:
im = Image.fromarray(im).transpose(Image.ROTATE_90)
elif angle==180:
im = Image.fromarray(im).transpose(Image.ROTATE_180)
elif angle==270:
im = Image.fromarray(im).transpose(Image.ROTATE_270)
img = np.array(im)
return angle,img
示例7: __init__
# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_270 [as 别名]
def __init__(self, p, degree):
"""Creates an `JointRandomRotation` instance.
Args:
p: the probability for rotating.
"""
self.p = p
methods = {90: Image.ROTATE_90, 180: Image.ROTATE_180, 270: Image.ROTATE_270}
if degree not in methods.keys():
raise NotImplementedError("We only support multiple of 90 degree rotations for now")
self.method = methods[degree]
示例8: rotate
# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_270 [as 别名]
def rotate(self, image, target, link, contour, angle):
if angle == 0:
if link is None:
return image, target, contour
return image, target, link, contour
elif angle == 90:
image = image.transpose(Image.ROTATE_90)
target = target.transpose(Image.ROTATE_90)
link = np.rot90(link)
contour_f = self.contour_rotate(contour, 90, image.size[0], image.size[1])
elif angle == 180:
image = image.transpose(Image.ROTATE_180)
target = target.transpose(Image.ROTATE_180)
link = np.rot90(np.rot90(link))
contour_f = self.contour_rotate(contour, 180, image.size[1], image.size[0])
elif angle == 270:
image = image.transpose(Image.ROTATE_270)
target = target.transpose(Image.ROTATE_270)
link = np.rot90(np.rot90(np.rot90(link)))
contour_f = self.contour_rotate(contour, 270, image.size[0], image.size[1])
if link is None:
return image, target, contour_f
return image, target, link, contour_f
示例9: rotate
# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_270 [as 别名]
def rotate(self, img, rot):
if rot == 0:
img_rt = img
elif rot == 90:
img_rt = img.transpose(Image.ROTATE_90)
elif rot == 180:
img_rt = img.transpose(Image.ROTATE_180)
elif rot == 270:
img_rt = img.transpose(Image.ROTATE_270)
else:
raise ValueError('Rotation angles should be in [0, 90, 180, 270]')
return img_rt
示例10: test_rotate_270_deg
# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_270 [as 别名]
def test_rotate_270_deg(self):
self._test_rotate(270, Image.ROTATE_270)
示例11: test_copy_alpha_channel
# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_270 [as 别名]
def test_copy_alpha_channel(self):
g = Image.linear_gradient('L')
im = Image.merge('RGBA', [g, g.transpose(Image.ROTATE_90),
g.transpose(Image.ROTATE_180),
g.transpose(Image.ROTATE_270)])
self.assert_image_equal(im, im._new(
im.im.color_lut_3d('RGBA', Image.LINEAR,
*self.generate_identity_table(3, 17))))
示例12: mask_L
# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_270 [as 别名]
def mask_L(self):
return self.gradient_L.transpose(Image.ROTATE_270)
示例13: gradient_RGBA
# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_270 [as 别名]
def gradient_RGBA(self):
return Image.merge('RGBA', [
self.gradient_L,
self.gradient_L.transpose(Image.ROTATE_90),
self.gradient_L.transpose(Image.ROTATE_180),
self.gradient_L.transpose(Image.ROTATE_270),
])
示例14: gradient_RGBa
# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_270 [as 别名]
def gradient_RGBa(self):
return Image.merge('RGBa', [
self.gradient_L,
self.gradient_L.transpose(Image.ROTATE_90),
self.gradient_L.transpose(Image.ROTATE_180),
self.gradient_L.transpose(Image.ROTATE_270),
])
示例15: __init__
# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_270 [as 别名]
def __init__(self, fps=16, skip_frames=2, scale_factor=1, rotate=0, rawrgb_path=None, **kwargs):
"""
:param fps: Frames per seconds (default: 16)
:param skip_frames: Number of frames to be skipped on sensor initialization/warmup (default: 2)
:param scale_factor: The camera outputs 24x32 pixels artifacts. Use scale_factor to scale them up to a larger
image (default: 1)
:param rotate: Rotation angle in degrees (default: 0)
:param rawrgb_path: Specify it if the rawrgb executable compiled from
https://github.com/pimoroni/mlx90640-library is in another folder than
`<directory of this file>/lib/examples`.
"""
from PIL import Image
super().__init__(**kwargs)
self._rotate_values = {
90: Image.ROTATE_90,
180: Image.ROTATE_180,
270: Image.ROTATE_270,
}
if not rawrgb_path:
rawrgb_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'lib', 'examples', 'rawrgb')
rawrgb_path = os.path.abspath(os.path.expanduser(rawrgb_path))
assert fps > 0
assert skip_frames >= 0
assert os.path.isfile(rawrgb_path)
self.fps = fps
self.rotate = rotate
self.skip_frames = skip_frames
self.scale_factor = scale_factor
self.rawrgb_path = rawrgb_path
self._capture_proc = None