简体   繁体   中英

How to get RGB channel using Wand?

I want to get a channel (Red, for example) from an Image using Wand in Python.

I already know how to get channel using ImageMagick itself but I want to do the same but using Wand

It seems to me that it is not implemented in Wand, or I miss something?

It seems to me that it is not implemented in Wand, or I miss something?

This was implemented in Wand version 0.3.0, but not well documented.

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')

red_channel

Found a workaround using color_matrix :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM