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


Python Image.HAMMING属性代码示例

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


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

示例1: dominant_screen_color

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import HAMMING [as 别名]
def dominant_screen_color(initial_color, func_bounds=lambda: None):
    """
    https://stackoverflow.com/questions/50899692/most-dominant-color-in-rgb-image-opencv-numpy-python
    """
    monitor = get_monitor_bounds(func_bounds)
    if "full" in monitor:
        screenshot = getScreenAsImage()
    else:
        screenshot = getRectAsImage(str2list(monitor, int))

    downscale_width, downscale_height = screenshot.width // 4, screenshot.height // 4
    screenshot = screenshot.resize((downscale_width, downscale_height), Image.HAMMING)

    a = np.array(screenshot)
    a2D = a.reshape(-1, a.shape[-1])
    col_range = (256, 256, 256)  # generically : a2D.max(0)+1
    eval_params = {'a0': a2D[:, 0], 'a1': a2D[:, 1], 'a2': a2D[:, 2],
                   's0': col_range[0], 's1': col_range[1]}
    a1D = ne.evaluate('a0*s0*s1+a1*s0+a2', eval_params)
    color = np.unravel_index(np.bincount(a1D).argmax(), col_range)

    color_hsbk = list(utils.RGBtoHSBK(color, temperature=initial_color[3]))
    # color_hsbk[2] = initial_color[2]  # TODO Decide this
    return color_hsbk 
开发者ID:samclane,项目名称:LIFX-Control-Panel,代码行数:26,代码来源:color_thread.py

示例2: __init__

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import HAMMING [as 别名]
def __init__(self, size, maintain_aspect_ratio=False, resample='bicubic'):
        self.size = size
        self.maintain_aspect_ratio = maintain_aspect_ratio
        resampling_mapping = {
            'nearest': Image.NEAREST,
            'bilinear': Image.BILINEAR,
            'bicubic': Image.BICUBIC,
            'lanczos': Image.LANCZOS,
            'box': Image.BOX,
            'hamming': Image.HAMMING,
        }
        if resample.lower() not in resampling_mapping.keys():
            raise ValueError(
                "Unknown resampling method '{}'. Allowed values are '{}'"
                .format(resample, "', '".join(resampling_mapping.keys())))
        self.resample = resampling_mapping[resample]
        super().__init__() 
开发者ID:tyarkoni,项目名称:pliers,代码行数:19,代码来源:image.py

示例3: _load_icons

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import HAMMING [as 别名]
def _load_icons():
        """ Scan the icons cache folder and load the icons into :attr:`icons` for retrieval
        throughout the GUI.

        Returns
        -------
        dict:
            The icons formatted as described in :attr:`icons`

        """
        size = get_config().user_config_dict.get("icon_size", 16)
        size = int(round(size * get_config().scaling_factor))
        icons = dict()
        pathicons = os.path.join(PATHCACHE, "icons")
        for fname in os.listdir(pathicons):
            name, ext = os.path.splitext(fname)
            if ext != ".png":
                continue
            img = Image.open(os.path.join(pathicons, fname))
            img = ImageTk.PhotoImage(img.resize((size, size), resample=Image.HAMMING))
            icons[name] = img
        logger.debug(icons)
        return icons 
开发者ID:deepfakes,项目名称:faceswap,代码行数:25,代码来源:utils.py

示例4: __init__

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

示例5: supported_interpolations

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

示例6: _pil_interp

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import HAMMING [as 别名]
def _pil_interp(method):
    if method == 'bicubic':
        return Image.BICUBIC
    elif method == 'lanczos':
        return Image.LANCZOS
    elif method == 'hamming':
        return Image.HAMMING
    else:
        # default bilinear, do we want to allow nearest?
        return Image.BILINEAR 
开发者ID:rwightman,项目名称:gen-efficientnet-pytorch,代码行数:12,代码来源:transforms.py

示例7: avg_screen_color

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import HAMMING [as 别名]
def avg_screen_color(initial_color, func_bounds=lambda: None):
    """ Capture an image of the monitor defined by func_bounds, then get the average color of the image in HSBK"""
    monitor = get_monitor_bounds(func_bounds)
    if "full" in monitor:
        screenshot = getScreenAsImage()
    else:
        screenshot = getRectAsImage(str2list(monitor, int))
    # Resizing the image to 1x1 pixel will give us the average for the whole image (via HAMMING interpolation)
    color = screenshot.resize((1, 1), Image.HAMMING).getpixel((0, 0))
    color_hsbk = list(utils.RGBtoHSBK(color, temperature=initial_color[3]))
    return color_hsbk 
开发者ID:samclane,项目名称:LIFX-Control-Panel,代码行数:13,代码来源:color_thread.py

示例8: test_reduce_hamming

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import HAMMING [as 别名]
def test_reduce_hamming(self):
        for mode in ['RGBX', 'RGB', 'La', 'L']:
            case = self.make_case(mode, (8, 8), 0xe1)
            case = case.resize((4, 4), Image.HAMMING)
            data = ('e1 da'
                    'da d3')
            for channel in case.split():
                self.check_case(channel, self.make_sample(data, (4, 4))) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:10,代码来源:test_image_resample.py

示例9: test_enlarge_hamming

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import HAMMING [as 别名]
def test_enlarge_hamming(self):
        for mode in ['RGBX', 'RGB', 'La', 'L']:
            case = self.make_case(mode, (2, 2), 0xe1)
            case = case.resize((4, 4), Image.HAMMING)
            data = ('e1 d2'
                    'd2 c5')
            for channel in case.split():
                self.check_case(channel, self.make_sample(data, (4, 4))) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:10,代码来源:test_image_resample.py

示例10: test_levels_rgba

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import HAMMING [as 别名]
def test_levels_rgba(self):
        case = self.make_levels_case('RGBA')
        self.run_levels_case(case.resize((512, 32), Image.BOX))
        self.run_levels_case(case.resize((512, 32), Image.BILINEAR))
        self.run_levels_case(case.resize((512, 32), Image.HAMMING))
        self.run_levels_case(case.resize((512, 32), Image.BICUBIC))
        self.run_levels_case(case.resize((512, 32), Image.LANCZOS)) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:9,代码来源:test_image_resample.py

示例11: test_levels_la

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import HAMMING [as 别名]
def test_levels_la(self):
        case = self.make_levels_case('LA')
        self.run_levels_case(case.resize((512, 32), Image.BOX))
        self.run_levels_case(case.resize((512, 32), Image.BILINEAR))
        self.run_levels_case(case.resize((512, 32), Image.HAMMING))
        self.run_levels_case(case.resize((512, 32), Image.BICUBIC))
        self.run_levels_case(case.resize((512, 32), Image.LANCZOS)) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:9,代码来源:test_image_resample.py

示例12: test_dirty_pixels_rgba

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import HAMMING [as 别名]
def test_dirty_pixels_rgba(self):
        case = self.make_dirty_case('RGBA', (255, 255, 0, 128), (0, 0, 255, 0))
        self.run_dirty_case(case.resize((20, 20), Image.BOX), (255, 255, 0))
        self.run_dirty_case(case.resize((20, 20), Image.BILINEAR),
                            (255, 255, 0))
        self.run_dirty_case(case.resize((20, 20), Image.HAMMING),
                            (255, 255, 0))
        self.run_dirty_case(case.resize((20, 20), Image.BICUBIC),
                            (255, 255, 0))
        self.run_dirty_case(case.resize((20, 20), Image.LANCZOS),
                            (255, 255, 0)) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:13,代码来源:test_image_resample.py

示例13: test_wrong_arguments

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import HAMMING [as 别名]
def test_wrong_arguments(self):
        im = hopper()
        for resample in (Image.NEAREST, Image.BOX, Image.BILINEAR,
                         Image.HAMMING, Image.BICUBIC, Image.LANCZOS):
            im.resize((32, 32), resample, (0, 0, im.width, im.height))
            im.resize((32, 32), resample, (20, 20, im.width, im.height))
            im.resize((32, 32), resample, (20, 20, 20, 100))
            im.resize((32, 32), resample, (20, 20, 100, 20))

            with self.assertRaisesRegex(TypeError,
                                        "must be sequence of length 4"):
                im.resize((32, 32), resample, (im.width, im.height))

            with self.assertRaisesRegex(ValueError, "can't be negative"):
                im.resize((32, 32), resample, (-20, 20, 100, 100))
            with self.assertRaisesRegex(ValueError, "can't be negative"):
                im.resize((32, 32), resample, (20, -20, 100, 100))

            with self.assertRaisesRegex(ValueError, "can't be empty"):
                im.resize((32, 32), resample, (20.1, 20, 20, 100))
            with self.assertRaisesRegex(ValueError, "can't be empty"):
                im.resize((32, 32), resample, (20, 20.1, 100, 20))
            with self.assertRaisesRegex(ValueError, "can't be empty"):
                im.resize((32, 32), resample, (20.1, 20.1, 20, 20))

            with self.assertRaisesRegex(ValueError, "can't exceed"):
                im.resize((32, 32), resample, (0, 0, im.width + 1, im.height))
            with self.assertRaisesRegex(ValueError, "can't exceed"):
                im.resize((32, 32), resample, (0, 0, im.width, im.height + 1)) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:31,代码来源:test_image_resample.py

示例14: test_reduce_filters

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import HAMMING [as 别名]
def test_reduce_filters(self):
        for f in [Image.NEAREST, Image.BOX, Image.BILINEAR,
                  Image.HAMMING, Image.BICUBIC, Image.LANCZOS]:
            r = self.resize(hopper("RGB"), (15, 12), f)
            self.assertEqual(r.mode, "RGB")
            self.assertEqual(r.size, (15, 12)) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:8,代码来源:test_image_resize.py

示例15: test_enlarge_filters

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import HAMMING [as 别名]
def test_enlarge_filters(self):
        for f in [Image.NEAREST, Image.BOX, Image.BILINEAR,
                  Image.HAMMING, Image.BICUBIC, Image.LANCZOS]:
            r = self.resize(hopper("RGB"), (212, 195), f)
            self.assertEqual(r.mode, "RGB")
            self.assertEqual(r.size, (212, 195)) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:8,代码来源:test_image_resize.py


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