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


Python BandMerger.add_ops方法代码示例

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


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

示例1: test_rgb_merge_missing

# 需要导入模块: from mapproxy.image.merge import BandMerger [as 别名]
# 或者: from mapproxy.image.merge.BandMerger import add_ops [as 别名]
    def test_rgb_merge_missing(self):
        """
        Check missing band is set to 0
        """
        merger = BandMerger(mode='RGB')

        merger.add_ops(dst_band=0, src_img=2, src_band=1)
        merger.add_ops(dst_band=2, src_img=1, src_band=2)

        img_opts = ImageOptions('RGB')
        result = merger.merge([self.img0, self.img1, self.img2, self.img3], img_opts)
        img = result.as_image()

        eq_(img.getpixel((0, 0)), (210, 0, 120))
开发者ID:tjay,项目名称:mapproxy,代码行数:16,代码来源:test_image.py

示例2: test_l_merge

# 需要导入模块: from mapproxy.image.merge import BandMerger [as 别名]
# 或者: from mapproxy.image.merge.BandMerger import add_ops [as 别名]
    def test_l_merge(self):
        """
        Check merge bands to grayscale image
        """
        merger = BandMerger(mode='L')

        merger.add_ops(dst_band=0, src_img=0, src_band=2, factor=0.2)
        merger.add_ops(dst_band=0, src_img=2, src_band=1, factor=0.3)
        merger.add_ops(dst_band=0, src_img=3, src_band=1, factor=0.5)

        img_opts = ImageOptions('L')
        result = merger.merge([self.img0, self.img1, self.img2, self.img3], img_opts)
        img = result.as_image()

        eq_(img.getpixel((0, 0)), int(20*0.2) + int(210*0.3) + int(255*0.5))
开发者ID:tjay,项目名称:mapproxy,代码行数:17,代码来源:test_image.py

示例3: test_rgba_merge_missing_a

# 需要导入模块: from mapproxy.image.merge import BandMerger [as 别名]
# 或者: from mapproxy.image.merge.BandMerger import add_ops [as 别名]
    def test_rgba_merge_missing_a(self):
        """
        Check that missing alpha band defaults to opaque
        """
        merger = BandMerger(mode='RGBA')

        merger.add_ops(dst_band=1, src_img=0, src_band=0, factor=0.5)
        merger.add_ops(dst_band=1, src_img=3, src_band=1, factor=0.5)
        merger.add_ops(dst_band=0, src_img=2, src_band=1)
        merger.add_ops(dst_band=2, src_img=1, src_band=2)

        img_opts = ImageOptions('RGBA')
        result = merger.merge([self.img0, self.img1, self.img2, self.img3], img_opts)
        img = result.as_image()

        eq_(img.getpixel((0, 0)), (210, 127, 120, 255))
开发者ID:tjay,项目名称:mapproxy,代码行数:18,代码来源:test_image.py

示例4: test_rgb_merge

# 需要导入模块: from mapproxy.image.merge import BandMerger [as 别名]
# 或者: from mapproxy.image.merge.BandMerger import add_ops [as 别名]
    def test_rgb_merge(self):
        """
        Check merge of RGB bands
        """
        merger = BandMerger(mode='RGB')

        merger.add_ops(dst_band=1, src_img=0, src_band=0, factor=0.5)
        merger.add_ops(dst_band=1, src_img=3, src_band=1, factor=0.5)
        merger.add_ops(dst_band=0, src_img=2, src_band=1)
        merger.add_ops(dst_band=2, src_img=1, src_band=2)

        img_opts = ImageOptions('RGB')
        result = merger.merge([self.img0, self.img1, self.img2, self.img3], img_opts)
        img = result.as_image()

        eq_(img.getpixel((0, 0)), (210, 127, 120))
开发者ID:tjay,项目名称:mapproxy,代码行数:18,代码来源:test_image.py

示例5: test_from_mixed_merge

# 需要导入模块: from mapproxy.image.merge import BandMerger [as 别名]
# 或者: from mapproxy.image.merge.BandMerger import add_ops [as 别名]
    def test_from_mixed_merge(self):
        """
        Check merge RGBA bands from image without alpha (mixed)
        """
        merger = BandMerger(mode='RGBA')

        merger.add_ops(dst_band=0, src_img=0, src_band=2)
        merger.add_ops(dst_band=1, src_img=0, src_band=1)
        merger.add_ops(dst_band=2, src_img=0, src_band=0)
        merger.add_ops(dst_band=3, src_img=0, src_band=3)

        img = Image.new('RGB', (10, 10), (0, 100, 200))
        src_img = ImageSource(img)

        img_opts = ImageOptions('RGBA')
        result = merger.merge([src_img], img_opts)

        img = result.as_image()
        eq_(img.mode, 'RGBA')
        eq_(img.getpixel((0, 0)), (200, 100, 0, 255))
开发者ID:tjay,项目名称:mapproxy,代码行数:22,代码来源:test_image.py

示例6: test_p_merge

# 需要导入模块: from mapproxy.image.merge import BandMerger [as 别名]
# 或者: from mapproxy.image.merge.BandMerger import add_ops [as 别名]
    def test_p_merge(self):
        """
        Check merge bands to paletted image
        """
        merger = BandMerger(mode='RGB')

        merger.add_ops(dst_band=1, src_img=0, src_band=0, factor=0.5)
        merger.add_ops(dst_band=1, src_img=3, src_band=1, factor=0.5)
        merger.add_ops(dst_band=0, src_img=2, src_band=1)
        merger.add_ops(dst_band=2, src_img=1, src_band=2)

        img_opts = ImageOptions('P', format='image/png', encoding_options={'quantizer': 'mediancut'})
        result = merger.merge([self.img0, self.img1, self.img2, self.img3], img_opts)

        # need to encode to get conversion to P
        img = Image.open(result.as_buffer())

        eq_(img.mode, 'P')
        img = img.convert('RGB')
        eq_(img.getpixel((0, 0)), (210, 127, 120))
开发者ID:tjay,项目名称:mapproxy,代码行数:22,代码来源:test_image.py

示例7: test_from_p_merge

# 需要导入模块: from mapproxy.image.merge import BandMerger [as 别名]
# 或者: from mapproxy.image.merge.BandMerger import add_ops [as 别名]
    def test_from_p_merge(self):
        """
        Check merge bands from paletted image
        """
        merger = BandMerger(mode='RGB')

        merger.add_ops(dst_band=0, src_img=0, src_band=2)
        merger.add_ops(dst_band=1, src_img=0, src_band=1)
        merger.add_ops(dst_band=2, src_img=0, src_band=0)

        img = Image.new('RGB', (10, 10), (0, 100, 200)).quantize(256)
        eq_(img.mode, 'P')
        # src img is P but we can still access RGB bands
        src_img = ImageSource(img)

        img_opts = ImageOptions('RGB')
        result = merger.merge([src_img], img_opts)

        img = result.as_image()
        eq_(img.mode, 'RGB')
        eq_(img.getpixel((0, 0)), (200, 100, 0))
开发者ID:tjay,项目名称:mapproxy,代码行数:23,代码来源:test_image.py


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