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