本文整理汇总了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))
示例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))
示例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))
示例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))
示例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))
示例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))
示例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))
示例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))
示例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))