图像合成结果使用python魔杖不正确 [英] image composite result incorrect using python wand
问题描述
我需要将3张图像合成在一起,但是结果剂量与AfterEffect合成的原始结果不同.在AfterEffect中,我需要使用32位图像深度来进行某种合成,我已经尝试了ImageMagick,结果是正确的,我可以在批处理命令中完成它,但是我需要做大的图层并且处理时间很长,然后我在python魔杖中做到了,我认为我可以加快时间,但是我坚持了这一点,复合计算看起来将所有负值都钳位了.
I have 3 images need to composite together, but the result dose not same as original result from AfterEffect compositing. In AfterEffect , i need to use 32 bit image depth to do some composite , i have try the ImageMagick, the result is correct, i can do it in batch command but i have large layer need to do and the process time is quite long, then i do it in python Wand think i can speed up the time, but i stuck on this, the composite calculation look clamp all negative value.
如何使用魔杖或其他库获得正确的结果?我也尝试使用PythonMagick和pgmagick,但结果也是如此.谢谢
How can i get the right result using wand or other library? I also try PythonMagick and pgmagick but the result also like that. Thanks
我使用的是Wand 0.5.1,ImageMagick的版本是ImageMagick-7.0.8-Q16-HDRI(64bit),
I'm using Wand 0.5.1 and ImageMagick version is ImageMagick-7.0.8-Q16-HDRI(64bit) ,
这是我的代码和示例:
from wand import image as wi
from wand import api
img = wi.Image()
img.read(filename='D:\\0225_red.jpg')
img.convert('TIFF')
img.depth=24
api.library.MagickSetOption(img.wand,'quantum:format','floating-point')
api.library.MagickSetOption(img.wand,'compose:clamp','off')
img2=wi.Image()
img2.read(filename='D:\\0225_pink.jpg')
img2.convert('TIFF')
img2.depth=24
api.library.MagickSetOption(img2.wand,'quantum:format','floating-point')
api.library.MagickSetOption(img2.wand,'compose:clamp','off')
img3=wi.Image()
img3.read(filename='D:\\0225_blue.jpg')
img3.depth=24
api.library.MagickSetOption(img3.wand,'quantum:format','floating-point')
api.library.MagickSetOption(img3.wand,'compose:clamp','off')
img.composite_channel('all_channels',img2 , 'minus_src')
img.composite_channel('all_channels',img3 , 'plus')
img.format = 'TIFF'
img.save(filename='D:\\0225_test.tif')
AE的结果:
我的代码的结果:
推荐答案
我怀疑问题与操作顺序有关.尝试以下操作...
I would suspect the issue is related to the order of operations. Try the following...
from wand.image import Image
with Image(filename='D:\\0225_red.jpg') as img:
img.options['quantum:format'] = 'floating-point'
img.options['compose:clamp'] = 'off'
with Image(filename='D:\\0225_blue.jpg') as blue:
img.composite_channel('all_channels', blue, 'plus')
with Image(filename='D:\\0225_pink.jpg') as pink:
img.composite_channel('all_channels', pink, 'minus_src')
img.save(filename='D:\\0225_test.tif')
这篇关于图像合成结果使用python魔杖不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!