相当于复合立体声的魔杖
Wand equivalent of composite -stereo
我想编写 Wand 等价于:
composite -stereo 0 right.tif left.tif output.tif
我认为 0 是 x 轴偏移量,可能不相关。我从其他帖子中收集了一些零碎的东西,结果很好,但有点啰嗦。这是可以做到的最好的吗?
#! /usr/bin/python
from wand.image import Image
from wand.color import Color
# overlay left image with red
with Image(filename='picture1.tif') as image:
with Image(background=Color('red'), width=image.width, height=image.height) as screen:
image.composite_channel(channel='all_channels', image=screen, operator='multiply')
image.save(filename='picture1red.tif')
# overlay right image with cyan
with Image(filename='picture2.tif') as image:
with Image(background=Color('cyan'), width=image.width, height=image.height) as screen:
image.composite_channel(channel='all_channels', image=screen, operator='multiply')
image.save(filename='picture2cyan.tif')
# overlay left and right images
with Image(filename='picture1red.tif') as image:
with Image(filename='picture2cyan.tif') as screen:
image.composite_channel(channel='all_channels', image=screen, operator='add')
image.save(filename='3Dpicture.tif')
您使用正确的方法来创建具有红色(左)和青色(右)通道的新图像。但是,不需要 all_channels
上的 multiply
和 add
复合运算符。如果我们争论cyan = green + blue
;我们可以简化您的示例。
with Image(filename='picture1.tif') as left:
with Image(filename='picture2.tif') as right:
with Image(width=left.width, height=left.height) as new_image:
# Copy left image's red channel to new image
new_image.composite_channel('red', left, 'copy_red', 0, 0)
# Copy right image's green & blue channel to new image
new_image.composite_channel('green', right, 'copy_green', 0, 0)
new_image.composite_channel('blue', right, 'copy_blue', 0, 0)
new_image.save(filename='3Dpciture.tif'))
我想编写 Wand 等价于:
composite -stereo 0 right.tif left.tif output.tif
我认为 0 是 x 轴偏移量,可能不相关。我从其他帖子中收集了一些零碎的东西,结果很好,但有点啰嗦。这是可以做到的最好的吗?
#! /usr/bin/python
from wand.image import Image
from wand.color import Color
# overlay left image with red
with Image(filename='picture1.tif') as image:
with Image(background=Color('red'), width=image.width, height=image.height) as screen:
image.composite_channel(channel='all_channels', image=screen, operator='multiply')
image.save(filename='picture1red.tif')
# overlay right image with cyan
with Image(filename='picture2.tif') as image:
with Image(background=Color('cyan'), width=image.width, height=image.height) as screen:
image.composite_channel(channel='all_channels', image=screen, operator='multiply')
image.save(filename='picture2cyan.tif')
# overlay left and right images
with Image(filename='picture1red.tif') as image:
with Image(filename='picture2cyan.tif') as screen:
image.composite_channel(channel='all_channels', image=screen, operator='add')
image.save(filename='3Dpicture.tif')
您使用正确的方法来创建具有红色(左)和青色(右)通道的新图像。但是,不需要 all_channels
上的 multiply
和 add
复合运算符。如果我们争论cyan = green + blue
;我们可以简化您的示例。
with Image(filename='picture1.tif') as left:
with Image(filename='picture2.tif') as right:
with Image(width=left.width, height=left.height) as new_image:
# Copy left image's red channel to new image
new_image.composite_channel('red', left, 'copy_red', 0, 0)
# Copy right image's green & blue channel to new image
new_image.composite_channel('green', right, 'copy_green', 0, 0)
new_image.composite_channel('blue', right, 'copy_blue', 0, 0)
new_image.save(filename='3Dpciture.tif'))