本文整理匯總了Python中PIL.Image.ROTATE_180屬性的典型用法代碼示例。如果您正苦於以下問題:Python Image.ROTATE_180屬性的具體用法?Python Image.ROTATE_180怎麽用?Python Image.ROTATE_180使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類PIL.Image
的用法示例。
在下文中一共展示了Image.ROTATE_180屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_channels_order
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_180 [as 別名]
def test_channels_order(self):
g = Image.linear_gradient('L')
im = Image.merge('RGB', [g, g.transpose(Image.ROTATE_90),
g.transpose(Image.ROTATE_180)])
# Reverse channels by splitting and using table
self.assert_image_equal(
Image.merge('RGB', im.split()[::-1]),
im._new(im.im.color_lut_3d('RGB', Image.LINEAR,
3, 2, 2, 2, [
0, 0, 0, 0, 0, 1,
0, 1, 0, 0, 1, 1,
1, 0, 0, 1, 0, 1,
1, 1, 0, 1, 1, 1,
])))
示例2: response
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_180 [as 別名]
def response(self, response, request, data):
try:
isImage = getattr(request, 'isImage')
except AttributeError:
isImage = False
if isImage:
try:
#For some reason more images get parsed using the parser
#rather than a file...PIL still needs some work I guess
p = ImageFile.Parser()
p.feed(data)
im = p.close()
im = im.transpose(Image.ROTATE_180)
output = StringIO()
im.save(output, format=self.imageType)
data = output.getvalue()
output.close()
self.clientlog.info("Flipped image", extra=request.clientInfo)
except Exception as e:
self.clientlog.info("Error: {}".format(e), extra=request.clientInfo)
return {'response': response, 'request': request, 'data': data}
示例3: __init__
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_180 [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')]
示例4: get_tta_patterns
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_180 [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]]
示例5: eval_angle
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_180 [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
示例6: __init__
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_180 [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]
示例7: rotate
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_180 [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
示例8: rotate
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_180 [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
示例9: test_rotate_180_deg
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_180 [as 別名]
def test_rotate_180_deg(self):
self._test_rotate(180, Image.ROTATE_180)
示例10: test_identities
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_180 [as 別名]
def test_identities(self):
g = Image.linear_gradient('L')
im = Image.merge('RGB', [g, g.transpose(Image.ROTATE_90),
g.transpose(Image.ROTATE_180)])
# Fast test with small cubes
for size in [2, 3, 5, 7, 11, 16, 17]:
self.assert_image_equal(im, im._new(
im.im.color_lut_3d('RGB', Image.LINEAR,
*self.generate_identity_table(3, size))))
# Not so fast
self.assert_image_equal(im, im._new(
im.im.color_lut_3d('RGB', Image.LINEAR,
*self.generate_identity_table(3, (2, 2, 65)))))
示例11: test_identities_4_channels
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_180 [as 別名]
def test_identities_4_channels(self):
g = Image.linear_gradient('L')
im = Image.merge('RGB', [g, g.transpose(Image.ROTATE_90),
g.transpose(Image.ROTATE_180)])
# Red channel copied to alpha
self.assert_image_equal(
Image.merge('RGBA', (im.split()*2)[:4]),
im._new(im.im.color_lut_3d('RGBA', Image.LINEAR,
*self.generate_identity_table(4, 17))))
示例12: test_copy_alpha_channel
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_180 [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))))
示例13: test_numpy_formats
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_180 [as 別名]
def test_numpy_formats(self):
g = Image.linear_gradient('L')
im = Image.merge('RGB', [g, g.transpose(Image.ROTATE_90),
g.transpose(Image.ROTATE_180)])
lut = ImageFilter.Color3DLUT.generate((7, 9, 11),
lambda r, g, b: (r, g, b))
lut.table = numpy.array(lut.table, dtype=numpy.float32)[:-1]
with self.assertRaisesRegex(ValueError, "should have table_channels"):
im.filter(lut)
lut = ImageFilter.Color3DLUT.generate((7, 9, 11),
lambda r, g, b: (r, g, b))
lut.table = (numpy.array(lut.table, dtype=numpy.float32)
.reshape((7 * 9 * 11), 3))
with self.assertRaisesRegex(ValueError, "should have table_channels"):
im.filter(lut)
lut = ImageFilter.Color3DLUT.generate((7, 9, 11),
lambda r, g, b: (r, g, b))
lut.table = numpy.array(lut.table, dtype=numpy.float16)
self.assert_image_equal(im, im.filter(lut))
lut = ImageFilter.Color3DLUT.generate((7, 9, 11),
lambda r, g, b: (r, g, b))
lut.table = numpy.array(lut.table, dtype=numpy.float32)
self.assert_image_equal(im, im.filter(lut))
lut = ImageFilter.Color3DLUT.generate((7, 9, 11),
lambda r, g, b: (r, g, b))
lut.table = numpy.array(lut.table, dtype=numpy.float64)
self.assert_image_equal(im, im.filter(lut))
lut = ImageFilter.Color3DLUT.generate((7, 9, 11),
lambda r, g, b: (r, g, b))
lut.table = numpy.array(lut.table, dtype=numpy.int32)
im.filter(lut)
lut.table = numpy.array(lut.table, dtype=numpy.int8)
im.filter(lut)
示例14: test_apply
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_180 [as 別名]
def test_apply(self):
lut = ImageFilter.Color3DLUT.generate(5, lambda r, g, b: (r, g, b))
g = Image.linear_gradient('L')
im = Image.merge('RGB', [g, g.transpose(Image.ROTATE_90),
g.transpose(Image.ROTATE_180)])
self.assertEqual(im, im.filter(lut))
示例15: gradient_RGB
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_180 [as 別名]
def gradient_RGB(self):
return Image.merge('RGB', [
self.gradient_L,
self.gradient_L.transpose(Image.ROTATE_90),
self.gradient_L.transpose(Image.ROTATE_180),
])