當前位置: 首頁>>代碼示例>>Python>>正文


Python BandMerger.merge方法代碼示例

本文整理匯總了Python中mapproxy.image.merge.BandMerger.merge方法的典型用法代碼示例。如果您正苦於以下問題:Python BandMerger.merge方法的具體用法?Python BandMerger.merge怎麽用?Python BandMerger.merge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mapproxy.image.merge.BandMerger的用法示例。


在下文中一共展示了BandMerger.merge方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_merge_noops

# 需要導入模塊: from mapproxy.image.merge import BandMerger [as 別名]
# 或者: from mapproxy.image.merge.BandMerger import merge [as 別名]
    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,代碼行數:13,代碼來源:test_image.py

示例2: test_merge_missing_source

# 需要導入模塊: from mapproxy.image.merge import BandMerger [as 別名]
# 或者: from mapproxy.image.merge.BandMerger import merge [as 別名]
    def test_merge_missing_source(self):
        """
        Check that empty source list or source list with missing images
        returns BlankImageSource.
        """
        merger = BandMerger(mode='RGB')
        merger.add_ops(dst_band=0, src_img=0, src_band=0)
        merger.add_ops(dst_band=1, src_img=1, src_band=0)
        merger.add_ops(dst_band=2, src_img=2, src_band=0)

        img_opts = ImageOptions('RGBA', transparent=True)
        result = merger.merge([], img_opts, size=(10, 10))
        img = result.as_image()

        eq_(img.size, (10, 10))
        eq_(img.getpixel((0, 0)), (255, 255, 255, 0))

        result = merger.merge([self.img0, self.img1], img_opts, size=(10, 10))
        img = result.as_image()

        eq_(img.size, (10, 10))
        eq_(img.getpixel((0, 0)), (255, 255, 255, 0))
開發者ID:tjay,項目名稱:mapproxy,代碼行數:24,代碼來源:test_image.py

示例3: test_rgb_merge_missing

# 需要導入模塊: from mapproxy.image.merge import BandMerger [as 別名]
# 或者: from mapproxy.image.merge.BandMerger import merge [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

示例4: test_l_merge

# 需要導入模塊: from mapproxy.image.merge import BandMerger [as 別名]
# 或者: from mapproxy.image.merge.BandMerger import merge [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

示例5: test_rgba_merge_missing_a

# 需要導入模塊: from mapproxy.image.merge import BandMerger [as 別名]
# 或者: from mapproxy.image.merge.BandMerger import merge [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

示例6: test_rgb_merge

# 需要導入模塊: from mapproxy.image.merge import BandMerger [as 別名]
# 或者: from mapproxy.image.merge.BandMerger import merge [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

示例7: test_from_mixed_merge

# 需要導入模塊: from mapproxy.image.merge import BandMerger [as 別名]
# 或者: from mapproxy.image.merge.BandMerger import merge [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

示例8: test_p_merge

# 需要導入模塊: from mapproxy.image.merge import BandMerger [as 別名]
# 或者: from mapproxy.image.merge.BandMerger import merge [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

示例9: test_from_p_merge

# 需要導入模塊: from mapproxy.image.merge import BandMerger [as 別名]
# 或者: from mapproxy.image.merge.BandMerger import merge [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.merge方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。