当前位置: 首页>>代码示例>>Python>>正文


Python Image.ROTATE_90属性代码示例

本文整理汇总了Python中PIL.Image.ROTATE_90属性的典型用法代码示例。如果您正苦于以下问题:Python Image.ROTATE_90属性的具体用法?Python Image.ROTATE_90怎么用?Python Image.ROTATE_90使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在PIL.Image的用法示例。


在下文中一共展示了Image.ROTATE_90属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_channels_order

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_90 [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,
                    ]))) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:18,代码来源:test_color_lut.py

示例2: test_g4_write

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_90 [as 别名]
def test_g4_write(self):
        """Checking to see that the saved image is the same as what we wrote"""
        test_file = "Tests/images/hopper_g4_500.tif"
        orig = Image.open(test_file)

        out = self.tempfile("temp.tif")
        rot = orig.transpose(Image.ROTATE_90)
        self.assertEqual(rot.size, (500, 500))
        rot.save(out)

        reread = Image.open(out)
        self.assertEqual(reread.size, (500, 500))
        self._assert_noerr(reread)
        self.assert_image_equal(reread, rot)
        self.assertEqual(reread.info['compression'], 'group4')

        self.assertEqual(reread.info['compression'], orig.info['compression'])

        self.assertNotEqual(orig.tobytes(), reread.tobytes()) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:21,代码来源:test_file_libtiff.py

示例3: __init__

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_90 [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')] 
开发者ID:reuterbal,项目名称:photobooth,代码行数:19,代码来源:__init__.py

示例4: rotate_image

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_90 [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 
开发者ID:bobintetley,项目名称:asm3,代码行数:22,代码来源:media.py

示例5: get_tta_patterns

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_90 [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]] 
开发者ID:tsurumeso,项目名称:waifu2x-chainer,代码行数:21,代码来源:reconstruct.py

示例6: eval_angle

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_90 [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 
开发者ID:bing1zhi2,项目名称:chinese_ocr,代码行数:21,代码来源:model.py

示例7: __init__

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_90 [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] 
开发者ID:mapbox,项目名称:robosat,代码行数:17,代码来源:transforms.py

示例8: rotate

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_90 [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 
开发者ID:mayank-git-hub,项目名称:Text-Recognition,代码行数:33,代码来源:dete_loader.py

示例9: rotate

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_90 [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 
开发者ID:Jiaolong,项目名称:self-supervised-da,代码行数:14,代码来源:rotate_dataset.py

示例10: rotate_image

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_90 [as 别名]
def rotate_image(self):
        if self.model.current_image is not None:
            rotated_image = self.model.current_image.transpose(Image.ROTATE_90)
            self.model.current_image.close()
            self.model.current_image = None
            self.display_image_on_canvas(rotated_image) 
开发者ID:weclaw1,项目名称:inbac,代码行数:8,代码来源:controller.py

示例11: __init__

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_90 [as 别名]
def __init__(self, width, height, text, xtext=6, ytext=6, chars=14, font_file=None):
    image = Image.new('1', (width, height), WHITE)
    if font_file == None:
      font_file = FONT_DEFAULT
    font = ImageFont.truetype(FONT_PATH + font_file, FONT_SIZE)

    draw = ImageDraw.Draw(image)
    w = textwrap.TextWrapper(width=chars, break_long_words=False) #, replace_whitespace=False)
    for line in text.splitlines(): 
      for frag in w.wrap(line):
        #print("Line: '%s'" % frag)
        width, height = font.getsize(frag)
        draw.text((xtext, ytext), frag, font=font, fill=BLACK)
        ytext += height
    self._image = image.transpose(Image.FLIP_LEFT_RIGHT).transpose(Image.ROTATE_90) 
开发者ID:oprema,项目名称:Waveshare-E-Ink,代码行数:17,代码来源:text.py

示例12: __init__

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_90 [as 别名]
def __init__(self, image, icon_file, xstart=14, ystart=14):
    icon = Image.open(icon_file).convert('RGBA')
    icon = icon.transpose(Image.FLIP_LEFT_RIGHT).transpose(Image.ROTATE_90)

    self._name = icon_file
    self._image = image
    self._width, self._height = icon.size
    self._image.paste(icon, (xstart, ystart, xstart+self._width, ystart+self._height), mask=icon) 
开发者ID:oprema,项目名称:Waveshare-E-Ink,代码行数:10,代码来源:icon.py

示例13: test_rotate_90_deg

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_90 [as 别名]
def test_rotate_90_deg(self):
        self._test_rotate(90, Image.ROTATE_90) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:4,代码来源:test_image_transform.py

示例14: test_identities

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_90 [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))))) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:17,代码来源:test_color_lut.py

示例15: test_identities_4_channels

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import ROTATE_90 [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)))) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:12,代码来源:test_color_lut.py


注:本文中的PIL.Image.ROTATE_90属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。