Page 1 of 3

swap colors/channels

Posted: 2012-09-11T18:57:45-07:00
by Tosyk
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! :)

Re: swap colors/channels

Posted: 2012-09-11T19:14:09-07:00
by fmw42
see http://www.imagemagick.org/Usage/basics/#swap

convert image -separate -swap 0,1 -combine result

this will swap the red and green channels

Re: swap colors/channels

Posted: 2012-09-11T19:29:47-07:00
by Tosyk
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?

Re: swap colors/channels

Posted: 2012-09-11T20:10:21-07:00
by fmw42
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

Re: swap colors/channels

Posted: 2012-09-11T20:16:59-07:00
by Tosyk
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 :D

Re: swap colors/channels

Posted: 2012-09-11T20:17:47-07:00
by fmw42

Re: swap colors/channels

Posted: 2012-09-11T20:20:44-07:00
by Tosyk
oh, thank u, very usefull info

Re: swap colors/channels

Posted: 2012-09-21T08:38:49-07:00
by Tosyk
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

Re: swap colors/channels

Posted: 2012-09-21T09:50:12-07:00
by fmw42
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

Re: swap colors/channels

Posted: 2012-09-21T18:42:18-07:00
by Tosyk
oh, thank you, i will try this :)

Re: swap colors/channels

Posted: 2012-09-21T20:03:47-07:00
by Tosyk
hm, strange, it actual copying but copied channel looks strange:

Image

i used this commands:
-channel rgba -alpha on -separate -swap 1,3 -combine -fill "#ffffff" -colorize 0,0,100 -alpha off -colorspace sRGB

Re: swap colors/channels

Posted: 2012-09-21T20:38:06-07:00
by fmw42
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

Posted: 2012-09-21T20:51:47-07:00
by Tosyk
fmw42 wrote:Perhaps you should post a link to your original image and explain why you are doing that and why the result looks wrong.
you right
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

Re: swap colors/channels

Posted: 2012-09-21T21:22:56-07:00
by fmw42
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

Image

Re: swap colors/channels

Posted: 2012-09-22T03:41:02-07:00
by Tosyk
thank you, but i keep getting those artifacts :?