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


Python Image.LINEAR属性代码示例

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


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

示例1: test_correct_args

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import LINEAR [as 别名]
def test_correct_args(self):
        im = Image.new('RGB', (10, 10), 0)

        im.im.color_lut_3d('RGB', Image.LINEAR,
                           *self.generate_identity_table(3, 3))

        im.im.color_lut_3d('CMYK', Image.LINEAR,
                           *self.generate_identity_table(4, 3))

        im.im.color_lut_3d('RGB', Image.LINEAR,
                           *self.generate_identity_table(3, (2, 3, 3)))

        im.im.color_lut_3d('RGB', Image.LINEAR,
                           *self.generate_identity_table(3, (65, 3, 3)))

        im.im.color_lut_3d('RGB', Image.LINEAR,
                           *self.generate_identity_table(3, (3, 65, 3)))

        im.im.color_lut_3d('RGB', Image.LINEAR,
                           *self.generate_identity_table(3, (3, 3, 65))) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:22,代码来源:test_color_lut.py

示例2: test_wrong_mode

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import LINEAR [as 别名]
def test_wrong_mode(self):
        with self.assertRaisesRegex(ValueError, "wrong mode"):
            im = Image.new('L', (10, 10), 0)
            im.im.color_lut_3d('RGB', Image.LINEAR,
                               *self.generate_identity_table(3, 3))

        with self.assertRaisesRegex(ValueError, "wrong mode"):
            im = Image.new('RGB', (10, 10), 0)
            im.im.color_lut_3d('L', Image.LINEAR,
                               *self.generate_identity_table(3, 3))

        with self.assertRaisesRegex(ValueError, "wrong mode"):
            im = Image.new('L', (10, 10), 0)
            im.im.color_lut_3d('L', Image.LINEAR,
                               *self.generate_identity_table(3, 3))

        with self.assertRaisesRegex(ValueError, "wrong mode"):
            im = Image.new('RGB', (10, 10), 0)
            im.im.color_lut_3d('RGBA', Image.LINEAR,
                               *self.generate_identity_table(3, 3))

        with self.assertRaisesRegex(ValueError, "wrong mode"):
            im = Image.new('RGB', (10, 10), 0)
            im.im.color_lut_3d('RGB', Image.LINEAR,
                               *self.generate_identity_table(4, 3)) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:27,代码来源:test_color_lut.py

示例3: test_correct_mode

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import LINEAR [as 别名]
def test_correct_mode(self):
        im = Image.new('RGBA', (10, 10), 0)
        im.im.color_lut_3d('RGBA', Image.LINEAR,
                           *self.generate_identity_table(3, 3))

        im = Image.new('RGBA', (10, 10), 0)
        im.im.color_lut_3d('RGBA', Image.LINEAR,
                           *self.generate_identity_table(4, 3))

        im = Image.new('RGB', (10, 10), 0)
        im.im.color_lut_3d('HSV', Image.LINEAR,
                           *self.generate_identity_table(3, 3))

        im = Image.new('RGB', (10, 10), 0)
        im.im.color_lut_3d('RGBA', Image.LINEAR,
                           *self.generate_identity_table(4, 3)) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:18,代码来源:test_color_lut.py

示例4: test_channels_order

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import LINEAR [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

示例5: __init__

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import LINEAR [as 别名]
def __init__(self, interpolation):
        if Image is None:
            raise ImportError(
                'pillow backend for resize operation requires TensorFlow. Please install it before usage.'
            )
        self._supported_interpolations = {
            'NEAREST': Image.NEAREST,
            'NONE': Image.NONE,
            'BILINEAR': Image.BILINEAR,
            'LINEAR': Image.LINEAR,
            'BICUBIC': Image.BICUBIC,
            'CUBIC': Image.CUBIC,
            'ANTIALIAS': Image.ANTIALIAS,
        }
        try:
            optional_interpolations = {
                'BOX': Image.BOX,
                'LANCZOS': Image.LANCZOS,
                'HAMMING': Image.HAMMING,
            }
            self._supported_interpolations.update(optional_interpolations)
        except AttributeError:
            pass
        super().__init__(interpolation) 
开发者ID:opencv,项目名称:open_model_zoo,代码行数:26,代码来源:resize.py

示例6: supported_interpolations

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import LINEAR [as 别名]
def supported_interpolations(cls):
        if Image is None:
            return {}
        intrp = {
            'NEAREST': Image.NEAREST,
            'NONE': Image.NONE,
            'BILINEAR': Image.BILINEAR,
            'LINEAR': Image.LINEAR,
            'BICUBIC': Image.BICUBIC,
            'CUBIC': Image.CUBIC,
            'ANTIALIAS': Image.ANTIALIAS
        }
        try:
            optional_interpolations = {
                'BOX': Image.BOX,
                'LANCZOS': Image.LANCZOS,
                'HAMMING': Image.HAMMING,
            }
            intrp.update(optional_interpolations)
        except AttributeError:
            pass
        return intrp 
开发者ID:opencv,项目名称:open_model_zoo,代码行数:24,代码来源:resize.py

示例7: test_identities

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import LINEAR [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

示例8: test_copy_alpha_channel

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

示例9: test_overflow

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import LINEAR [as 别名]
def test_overflow(self):
        g = Image.linear_gradient('L')
        im = Image.merge('RGB', [g, g.transpose(Image.ROTATE_90),
                                 g.transpose(Image.ROTATE_180)])

        transformed = im._new(im.im.color_lut_3d('RGB', Image.LINEAR,
                              3, 2, 2, 2,
                              [
                                  -1, -1, -1,   2, -1, -1,
                                  -1,  2, -1,   2,  2, -1,

                                  -1, -1,  2,   2, -1,  2,
                                  -1,  2,  2,   2,  2,  2,
                              ])).load()
        self.assertEqual(transformed[0, 0], (0, 0, 255))
        self.assertEqual(transformed[50, 50], (0, 0, 255))
        self.assertEqual(transformed[255, 0], (0, 255, 255))
        self.assertEqual(transformed[205, 50], (0, 255, 255))
        self.assertEqual(transformed[0, 255], (255, 0, 0))
        self.assertEqual(transformed[50, 205], (255, 0, 0))
        self.assertEqual(transformed[255, 255], (255, 255, 0))
        self.assertEqual(transformed[205, 205], (255, 255, 0))

        transformed = im._new(im.im.color_lut_3d('RGB', Image.LINEAR,
                              3, 2, 2, 2,
                              [
                                  -3, -3, -3,   5, -3, -3,
                                  -3,  5, -3,   5,  5, -3,

                                  -3, -3,  5,   5, -3,  5,
                                  -3,  5,  5,   5,  5,  5,
                              ])).load()
        self.assertEqual(transformed[0, 0], (0, 0, 255))
        self.assertEqual(transformed[50, 50], (0, 0, 255))
        self.assertEqual(transformed[255, 0], (0, 255, 255))
        self.assertEqual(transformed[205, 50], (0, 255, 255))
        self.assertEqual(transformed[0, 255], (255, 0, 0))
        self.assertEqual(transformed[50, 205], (255, 0, 0))
        self.assertEqual(transformed[255, 255], (255, 255, 0))
        self.assertEqual(transformed[205, 205], (255, 255, 0)) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:42,代码来源:test_color_lut.py

示例10: resize_img

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import LINEAR [as 别名]
def resize_img(fname, targ, path, new_path):
    dest = os.path.join(path,new_path,str(targ),fname)
    if os.path.exists(dest): return
    im = Image.open(os.path.join(path, fname)).convert('RGB')
    r,c = im.size
    ratio = targ/min(r,c)
    sz = (scale_to(r, ratio, targ), scale_to(c, ratio, targ))
    os.makedirs(os.path.split(dest)[0], exist_ok=True)
    im.resize(sz, Image.LINEAR).save(dest) 
开发者ID:fastai,项目名称:imagenet-fast,代码行数:11,代码来源:resize_images.py

示例11: __init__

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import LINEAR [as 别名]
def __init__(self, src_rect, output_size, interp=Image.LINEAR, fill=0):
        """
        Args:
            src_rect (x0, y0, x1, y1): src coordinates
            output_size (h, w): dst image size
            interp: PIL interpolation methods
            fill: Fill color used when src_rect extends outside image
        """
        super().__init__()
        self._set_attributes(locals()) 
开发者ID:facebookresearch,项目名称:detectron2,代码行数:12,代码来源:transform.py

示例12: parameters

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import LINEAR [as 别名]
def parameters(cls):
        parameters = super().parameters()
        parameters.update({
            'size': NumberField(
                value_type=int, optional=True, min_value=1, description="Destination sizes for both dimensions."
            ),
            'dst_width': NumberField(
                value_type=int, optional=True, min_value=1, description="Destination width for image resizing."
            ),
            'dst_height': NumberField(
                value_type=int, optional=True, min_value=1, description="Destination height for image resizing."
            ),
            'aspect_ratio_scale': StringField(
                choices=ASPECT_RATIO_SCALE, optional=True,
                description="Allows save image aspect ratio using one of these ways: "
                            "{}".format(', '.join(ASPECT_RATIO_SCALE))
            ),
            'interpolation': StringField(
                choices=_Resizer.all_provided_interpolations(), optional=True, default='LINEAR',
                description="Specifies method that will be used."
            ),
            'use_pillow': BoolField(
                optional=True, default=False,
                description="Parameter specifies usage of Pillow library for resizing."
            ),
            'use_tensorflow': BoolField(
                optional=True,
                description="Specifies usage of TensorFlow Image for resizing. Requires TensorFlow installation."
            ),
            'resize_realization': StringField(
                optional=True, choices=_Resizer.providers,
                description="Parameter specifies functionality of which library will be used for resize: "
                            "{}".format(', '.join(_Resizer.providers))
            )
        })

        return parameters 
开发者ID:opencv,项目名称:open_model_zoo,代码行数:39,代码来源:resize.py

示例13: resize

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import LINEAR [as 别名]
def resize(img, size):
    if not isinstance(size, (list, tuple)):
        size = (size, size)
    if isinstance(img, np.ndarray):
        return cv2.resize(img, size)
    return img.resize(size, Image.LINEAR) 
开发者ID:sheqi,项目名称:GAN_Review,代码行数:8,代码来源:spatial_transforms.py

示例14: __init__

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import LINEAR [as 别名]
def __init__(self, size, scale_ratios, fix_crop=True, more_fix_crop=True, max_distort=1,
                 interpolation=Image.LINEAR):
        self.height = size[0]
        self.width = size[1]
        self.scale_ratios = scale_ratios
        self.fix_crop = fix_crop
        self.more_fix_crop = more_fix_crop
        self.max_distort = max_distort
        self.interpolation = interpolation

        self._crop_scale = None
        self._crop_offset = None
        self._num_scales = len(scale_ratios)
        self._num_offsets = 5 if not more_fix_crop else 13 
开发者ID:sheqi,项目名称:GAN_Review,代码行数:16,代码来源:spatial_transforms.py

示例15: test_wrong_args

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import LINEAR [as 别名]
def test_wrong_args(self):
        im = Image.new('RGB', (10, 10), 0)

        with self.assertRaisesRegex(ValueError, "filter"):
            im.im.color_lut_3d('RGB',
                               Image.CUBIC,
                               *self.generate_identity_table(3, 3))

        with self.assertRaisesRegex(ValueError, "image mode"):
            im.im.color_lut_3d('wrong',
                               Image.LINEAR,
                               *self.generate_identity_table(3, 3))

        with self.assertRaisesRegex(ValueError, "table_channels"):
            im.im.color_lut_3d('RGB',
                               Image.LINEAR,
                               *self.generate_identity_table(5, 3))

        with self.assertRaisesRegex(ValueError, "table_channels"):
            im.im.color_lut_3d('RGB',
                               Image.LINEAR,
                               *self.generate_identity_table(1, 3))

        with self.assertRaisesRegex(ValueError, "table_channels"):
            im.im.color_lut_3d('RGB',
                               Image.LINEAR,
                               *self.generate_identity_table(2, 3))

        with self.assertRaisesRegex(ValueError, "Table size"):
            im.im.color_lut_3d('RGB',
                               Image.LINEAR,
                               *self.generate_identity_table(3, (1, 3, 3)))

        with self.assertRaisesRegex(ValueError, "Table size"):
            im.im.color_lut_3d('RGB',
                               Image.LINEAR,
                               *self.generate_identity_table(3, (66, 3, 3)))

        with self.assertRaisesRegex(ValueError, r"size1D \* size2D \* size3D"):
            im.im.color_lut_3d('RGB',
                               Image.LINEAR,
                               3, 2, 2, 2, [0, 0, 0] * 7)

        with self.assertRaisesRegex(ValueError, r"size1D \* size2D \* size3D"):
            im.im.color_lut_3d('RGB',
                               Image.LINEAR,
                               3, 2, 2, 2, [0, 0, 0] * 9)

        with self.assertRaises(TypeError):
            im.im.color_lut_3d('RGB',
                               Image.LINEAR,
                               3, 2, 2, 2, [0, 0, "0"] * 8)

        with self.assertRaises(TypeError):
            im.im.color_lut_3d('RGB',
                               Image.LINEAR,
                               3, 2, 2, 2, 16) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:59,代码来源:test_color_lut.py


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