swap colors/channels
swap colors/channels
hello, how can i swap, for example ALPHA channel and BLUE channel, or BLUE channel and GREEN channel?
can't find the solution, but it should be simle i'm sure!
can't find the solution, but it should be simle i'm sure!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: swap colors/channels
see http://www.imagemagick.org/Usage/basics/#swap
convert image -separate -swap 0,1 -combine result
this will swap the red and green channels
convert image -separate -swap 0,1 -combine result
this will swap the red and green channels
Re: swap colors/channels
ha, i know that, i just thought that i can use other technic than this
but i don't understand why all channel (rgb) became so dark after combining?
but i don't understand why all channel (rgb) became so dark after combining?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: swap colors/channels
What version of IM are you using?
After IM 6.7.8.2, separate (grayscale) channels are linear rather than non-linear. To keep them non-linear add -set colorspace RGB before -separate
try
convert image -set colorspace RGB -separate -swap 0,1 -combine result
or just convert back to sRGB after the combine
convert image -separate -swap 0,1 -combine -colorspace sRGB result
see
viewtopic.php?f=4&t=21269
After IM 6.7.8.2, separate (grayscale) channels are linear rather than non-linear. To keep them non-linear add -set colorspace RGB before -separate
try
convert image -set colorspace RGB -separate -swap 0,1 -combine result
or just convert back to sRGB after the combine
convert image -separate -swap 0,1 -combine -colorspace sRGB result
see
viewtopic.php?f=4&t=21269
Last edited by fmw42 on 2012-09-11T20:17:07-07:00, edited 1 time in total.
Re: swap colors/channels
i'm useing latest 6.7.9-4 version
and now everything works brilliant, thank you very much!
will use this technic for all my needs
and now everything works brilliant, thank you very much!
will use this technic for all my needs
Re: swap colors/channels
oh, thank u, very usefull infofmw42 wrote:see
viewtopic.php?f=4&t=21269
Re: swap colors/channels
strange, i can't swap ALPHA channel with other RGB channel for some reason
strings: -separate +swap 0,2 -combine -colorspace sRGB
snd
-separate -swap 1,3 -combine -colorspace sRGB
please help me
strings: -separate +swap 0,2 -combine -colorspace sRGB
snd
-separate -swap 1,3 -combine -colorspace sRGB
please help me
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: swap colors/channels
add -channel rgba -alpha on before the -separate. not sure if -alpha on is needed, but it won't hurt
Note r=0, g=1, b=2 and a=3 in terms of channels in -swap
Note r=0, g=1, b=2 and a=3 in terms of channels in -swap
Re: swap colors/channels
oh, thank you, i will try this
Re: swap colors/channels
hm, strange, it actual copying but copied channel looks strange:
i used this commands:
-channel rgba -alpha on -separate -swap 1,3 -combine -fill "#ffffff" -colorize 0,0,100 -alpha off -colorspace sRGB
i used this commands:
-channel rgba -alpha on -separate -swap 1,3 -combine -fill "#ffffff" -colorize 0,0,100 -alpha off -colorspace sRGB
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: swap colors/channels
Perhaps you should post a link to your original image and explain why you are doing that and why the result looks wrong.
Re: swap colors/channels
you rightfmw42 wrote:Perhaps you should post a link to your original image and explain why you are doing that and why the result looks wrong.
here is original image
https://dl.dropbox.com/u/9919707/tempor ... 0807_4.dds
i'm trying to swap green and alpha channels, fill blue channel with blue and kill alpha channel
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: swap colors/channels
try this, seems to work for me
# enable rgba, separate channels, swap g and alpha, delete new alpha, combine
# select channel b and make uniform white, reenable rgb channels
# convert to sRGB
convert Tex_0807_4.dds \
-channel rgba -separate +channel -swap 1,3 +delete -combine \
-channel B -evaluate set 100% +channel \
-colorspace sRGB Tex_0807_4_swap.png
# enable rgba, separate channels, swap g and alpha, delete new alpha, combine
# select channel b and make uniform white, reenable rgb channels
# convert to sRGB
convert Tex_0807_4.dds \
-channel rgba -separate +channel -swap 1,3 +delete -combine \
-channel B -evaluate set 100% +channel \
-colorspace sRGB Tex_0807_4_swap.png
Last edited by fmw42 on 2012-09-22T10:34:51-07:00, edited 1 time in total.
Re: swap colors/channels
thank you, but i keep getting those artifacts