I'm trying to combine the RGB channels from 3 separate images using ImageMagick. The red channel from image01.png, blue channel from image02.png and the green channel from image03.png
Image01.png, Image02.png, Image03.png
The resulting image should look like this (left) but I'm getting this (right):
This is the command I'm running....
"C:/ImageMagick/magick.exe" convert "C:/images/image01.png" "C:/images/image02.png" "C:/images/image03.png" "-background" "#ff0000" "-channel" "red,green,blue" "-combine" "C:/images/combined.png"
Do I need to somehow save out the various channels of each image separating first and then combine the images?
In ImageMagick, -channel does not work to select channels from multiple images.
Furthermore and more importantly, white contains red, green and blue. So the red channel of the first image will have the red dot as white and the background white as white, leaving black for the green and blue lines. Similarly in the other images. So white needs to be made black in each image. Then the channels are separated and recombined. Then black needs to be made white again.
Unix syntax:
convert \
\( image01.png -fuzz 70% -fill black -opaque white \
-channel r -separate +channel \) \
\( image02.png -fuzz 70% -fill black -opaque white \
-channel g -separate +channel \) \
\( image03.png -fuzz 70% -fill black -opaque white \
-channel b -separate +channel \) \
-set colorspace sRGB -combine \
-fuzz 20% -fill white -opaque black \
result.png
convert.exe ^ ( image01.png -fuzz 70% -fill black -opaque white ^ -channel r -separate +channel ) ^ ( image02.png -fuzz 70% -fill black -opaque white ^ -channel g -separate +channel ) ^ ( image03.png -fuzz 70% -fill black -opaque white ^ -channel b -separate +channel ) ^ -set colorspace sRGB -combine ^ -fuzz 20% -fill white -opaque black ^ result.png
The -fuzz is needed to remove the anti-aliased colors that are near white around the edges of the colored regions.
You would be much better starting with the 3 input images that have a black background rather than white. Then all the fuzz and white to black and black back to white would not be needed.
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.