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


Python ImageChops.add方法代码示例

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


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

示例1: black_or_b

# 需要导入模块: from PIL import ImageChops [as 别名]
# 或者: from PIL.ImageChops import add [as 别名]
def black_or_b(diff_image, image, reference, opacity=0.85):
    """Copied from https://stackoverflow.com/a/30307875 """
    thresholded_diff = diff_image
    for _ in range(3):
        thresholded_diff = ImageChops.add(thresholded_diff, thresholded_diff)
    size = diff_image.size
    mask = new_gray(size, int(255 * (opacity)))
    shade = new_gray(size, 0)
    new = reference.copy()
    new.paste(shade, mask=mask)
    if image.size != new.size:
        image = image.resize(new.size)
    if image.size != thresholded_diff.size:
        thresholded_diff = thresholded_diff.resize(image.size)
    new.paste(image, mask=thresholded_diff)
    return new 
开发者ID:Qiskit,项目名称:qiskit-terra,代码行数:18,代码来源:results.py

示例2: _repr_html_

# 需要导入模块: from PIL import ImageChops [as 别名]
# 或者: from PIL.ImageChops import add [as 别名]
def _repr_html_(self):
        ret = self.summary()
        ret += "<div>"
        for name in self.names:
            fullpath_name = os.path.join(self.directory, name)
            fullpath_reference = os.path.join(self.directory, 'references', name)
            if os.path.exists(os.path.join(SWD, fullpath_reference)):
                if self.data[name]['ratio'] == 1:
                    ret += Results.passed_result_html(fullpath_name, fullpath_reference,
                                                      self.data[name]['diff_name'],
                                                      self.data[name]['title'])
                else:
                    ret += Results.failed_result_html(fullpath_name, fullpath_reference,
                                                      self.data[name]['diff_name'],
                                                      self.data[name]['title'])
            else:
                title = 'Download <a download="%s" href="%s">this image</a> to <tt>%s</tt>' \
                        ' and add/push to the repo</td>' % (name, fullpath_name, fullpath_reference)
                ret += Results.no_reference_html(fullpath_name, title)
        ret += "</div>"
        return ret 
开发者ID:Qiskit,项目名称:qiskit-terra,代码行数:23,代码来源:results.py

示例3: test_sanity

# 需要导入模块: from PIL import ImageChops [as 别名]
# 或者: from PIL.ImageChops import add [as 别名]
def test_sanity(self):

        im = hopper("L")

        ImageChops.constant(im, 128)
        ImageChops.duplicate(im)
        ImageChops.invert(im)
        ImageChops.lighter(im, im)
        ImageChops.darker(im, im)
        ImageChops.difference(im, im)
        ImageChops.multiply(im, im)
        ImageChops.screen(im, im)

        ImageChops.add(im, im)
        ImageChops.add(im, im, 2.0)
        ImageChops.add(im, im, 2.0, 128)
        ImageChops.subtract(im, im)
        ImageChops.subtract(im, im, 2.0)
        ImageChops.subtract(im, im, 2.0, 128)

        ImageChops.add_modulo(im, im)
        ImageChops.subtract_modulo(im, im)

        ImageChops.blend(im, im, 0.5)
        ImageChops.composite(im, im, im)

        ImageChops.offset(im, 10)
        ImageChops.offset(im, 10, 20) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:30,代码来源:test_imagechops.py

示例4: test_add

# 需要导入模块: from PIL import ImageChops [as 别名]
# 或者: from PIL.ImageChops import add [as 别名]
def test_add(self):
        # Arrange
        im1 = Image.open("Tests/images/imagedraw_ellipse_RGB.png")
        im2 = Image.open("Tests/images/imagedraw_floodfill_RGB.png")

        # Act
        new = ImageChops.add(im1, im2)

        # Assert
        self.assertEqual(new.getbbox(), (25, 25, 76, 76))
        self.assertEqual(new.getpixel((50, 50)), ORANGE) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:13,代码来源:test_imagechops.py

示例5: test_add_scale_offset

# 需要导入模块: from PIL import ImageChops [as 别名]
# 或者: from PIL.ImageChops import add [as 别名]
def test_add_scale_offset(self):
        # Arrange
        im1 = Image.open("Tests/images/imagedraw_ellipse_RGB.png")
        im2 = Image.open("Tests/images/imagedraw_floodfill_RGB.png")

        # Act
        new = ImageChops.add(im1, im2, scale=2.5, offset=100)

        # Assert
        self.assertEqual(new.getbbox(), (0, 0, 100, 100))
        self.assertEqual(new.getpixel((50, 50)), (202, 151, 100)) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:13,代码来源:test_imagechops.py

示例6: test_add_clip

# 需要导入模块: from PIL import ImageChops [as 别名]
# 或者: from PIL.ImageChops import add [as 别名]
def test_add_clip(self):
        # Arrange
        im = hopper()

        # Act
        new = ImageChops.add(im, im)

        # Assert
        self.assertEqual(new.getpixel((50, 50)), (255, 255, 254)) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:11,代码来源:test_imagechops.py

示例7: load_image

# 需要导入模块: from PIL import ImageChops [as 别名]
# 或者: from PIL.ImageChops import add [as 别名]
def load_image(filename):
    """Load an image from the given filename.

    Loads an image into a variable of type PImage. Four types of
    images may be loaded. 

    In most cases, load all images in setup() or outside the draw()
    call to preload them at the start of the program. Loading images
    inside draw() will reduce the speed of a program. 

    :param filename: Filename (or path)of the given image. The
        file-extennsion is automatically inferred.
    :type filename: str

    :returns: An :class:`p5.PImage` instance with the given image data
    :rtype: :class:`p5.PImage`

    """
    # todo: add support for loading images from URLs -- abhikpal
    # (2018-08-14)
    img = Image.open(filename)
    w, h = img.size
    pimg = PImage(w, h)
    pimg._img = img

    return pimg 
开发者ID:p5py,项目名称:p5,代码行数:28,代码来源:image.py

示例8: do_add

# 需要导入模块: from PIL import ImageChops [as 别名]
# 或者: from PIL.ImageChops import add [as 别名]
def do_add(self):
        """usage: add <image:pic1> <image:pic2> <int:offset> <float:scale>

        Pop the two top images, produce the scaled sum with offset.
        """
        from PIL import ImageChops
        image1 = self.do_pop()
        image2 = self.do_pop()
        scale = float(self.do_pop())
        offset = int(self.do_pop())
        self.push(ImageChops.add(image1, image2, scale, offset)) 
开发者ID:awslabs,项目名称:mxnet-lambda,代码行数:13,代码来源:pildriver.py

示例9: _trim

# 需要导入模块: from PIL import ImageChops [as 别名]
# 或者: from PIL.ImageChops import add [as 别名]
def _trim(self, img):
        bg = Image.new(img.mode, img.size, img.getpixel((0,0)))
        diff = ImageChops.difference(img, bg)
        diff = ImageChops.add(diff, diff, 2.0, -100)
        return img.crop(diff.getbbox()) 
开发者ID:budach,项目名称:pysster,代码行数:7,代码来源:Motif.py

示例10: trim

# 需要导入模块: from PIL import ImageChops [as 别名]
# 或者: from PIL.ImageChops import add [as 别名]
def trim(image):
    bg = Image.new(image.mode, image.size, image.getpixel((0, 0)))
    diff = ImageChops.difference(image, bg)
    diff = ImageChops.add(diff, diff, 2.0, -100)
    bbox = diff.getbbox()
    if bbox:
        return image.crop(bbox) 
开发者ID:mewforest,项目名称:google-art-downloader,代码行数:9,代码来源:GoogleArtDownloader.py


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