【问题标题】:How to get RGB channel using Wand?如何使用 Wand 获得 RGB 通道?
【发布时间】:2021-09-25 06:02:57
【问题描述】:

我想在 Python 中使用 Wand 从图像中获取通道(例如红色)。

我已经知道如何获取频道 using ImageMagick itself,但我想这样做,但使用 Wand

在我看来它没有在 Wand 中实现,或者我错过了什么?

【问题讨论】:

    标签: python wand


    【解决方案1】:

    在我看来它没有在 Wand 中实现,或者我错过了什么?

    这是在 Wand 0.3.0 版中实现的,但没有很好的文档记录。

    from wand.image import Image
    
    with Image(filename='wizard:') as img:
        with img.channel_image['red'] as red_channel:
            red_channel.save(filename='red_channel.png')
    

    【讨论】:

      【解决方案2】:

      使用color_matrix 找到了解决方法:

      img.color_matrix([
          [1, 0, 0],
          [1, 0, 0],
          [1, 0, 0],
      ])
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-03-15
        • 1970-01-01
        • 2018-12-12
        • 2023-03-13
        • 1970-01-01
        • 2022-12-06
        • 1970-01-01
        • 2015-06-10
        相关资源
        最近更新 更多