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


Python merge.BandMerger类代码示例

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


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

示例1: test_merge_noops

    def test_merge_noops(self):
        """
        Check that black image is returned for no ops.
        """
        merger = BandMerger(mode='RGB')

        img_opts = ImageOptions('RGB')
        result = merger.merge([self.img0], img_opts)
        img = result.as_image()
        eq_(img.size, (10, 10))
        eq_(img.getpixel((0, 0)), (0, 0, 0))
开发者ID:tjay,项目名称:mapproxy,代码行数:11,代码来源:test_image.py

示例2: test_rgb_merge_missing

    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,代码行数:14,代码来源:test_image.py

示例3: test_rgba_merge

    def test_rgba_merge(self):
        """
        Check merge of RGBA bands
        """
        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)
        merger.add_ops(dst_band=3, src_img=1, src_band=1)

        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, 110))
开发者ID:tjay,项目名称:mapproxy,代码行数:17,代码来源:test_image.py

示例4: test_l_merge

    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,代码行数:15,代码来源:test_image.py

示例5: test_rgba_merge_missing_a

    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,代码行数:16,代码来源:test_image.py

示例6: test_from_mixed_merge

    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,代码行数:20,代码来源:test_image.py

示例7: test_p_merge

    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,代码行数:20,代码来源:test_image.py

示例8: test_from_p_merge

    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,代码行数:21,代码来源:test_image.py


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