Page 1 of 1

[Solved] Combine RGB images problem

Posted: 2011-08-09T07:29:40-07:00
by markmarques
Hi,
I am trying to change the gamma of each image channel from an initial image but what I get is a strange yellow image ..

Although if I split and save each individual image it works correctly ...

So if do something like this I get the correct colored final image:

convert -monitor image1.jpg -depth 32 -auto-level -set colorspace RGB ^
-channel R -separate -gamma 3 -blur 0x2 PNG:image1_red.png

convert -monitor image1 -depth 32 -auto-level -set colorspace RGB ^
-channel g -separate -gamma 0.9 PNG:image1_green.png

convert -monitor image1 -depth 32 -auto-level -set colorspace RGB ^
-channel b -separate -gamma 0.85 PNG:image1_blue.png

convert -monitor image1_red.png image1_green.png image1_blue.png -colorspace RGB -quality 98 -combine JPG:image1_final.jpg
----------------------------------------------------------------------------------------------------------------------------

But if I try this :
convert -monitor image1 -depth 32 -auto-level -set colorspace RGB
( -clone 0 -channel R -separate -gamma 3 -blur 0x2 )
( -clone 0 -channel G -separate -gamma 0.95 )
( -clone 0 -channel B -separate -gamma 0.85 )
-delete 0 -colorspace RGB -quality 98 -combine JPG:iamge1_finala.jpg

I only get a full yellow image ....

What am I doing wrong ?
I even tried swaping the channels but still same problem this time with a resulting black image...


any ideas ?

Re: Combine RGB images problem

Posted: 2011-08-09T09:42:32-07:00
by fmw42
You need to escape the new line with ^ and add +channel or -channel rgb at the end of each paren or possible use -respect-parenthesis in your first line


try either:

convert -monitor image1 -depth 32 -auto-level -set colorspace RGB ^
( -clone 0 -channel R -separate -gamma 3 -blur 0x2 +channel ) ^
( -clone 0 -channel G -separate -gamma 0.95 +channel ) ^
( -clone 0 -channel B -separate -gamma 0.85 +channel ) ^
-delete 0 -colorspace RGB -quality 98 -combine JPG:iamge1_finala.jpg

or

convert -monitor image1 -depth 32 -auto-level -set colorspace RGB -respect-parenthesis ^
( -clone 0 -channel R -separate -gamma 3 -blur 0x2 ) ^
( -clone 0 -channel G -separate -gamma 0.95 ) ^
( -clone 0 -channel B -separate -gamma 0.85 ) ^
-delete 0 -colorspace RGB -quality 98 -combine JPG:iamge1_finala.jpg

Re: Combine RGB images problem

Posted: 2011-08-09T23:50:48-07:00
by anthony
The -gamma operator allows you to specify a different gamma for each channel directly...

Code: Select all

convert -monitor image1 -depth 32 -auto-level  ^
       -gamma 3,0.95,0.85 ^
       -quality 98 JPG:iamge1_finala.jpg 
See IM Examples...
http://www.imagemagick.org/Usage/color_mods/#gamma

to blur just the red channel only add the line...

Code: Select all

  -channel R -blur 0x2 +channel ^
afetr the gamma operator line. -blur understands -channel setting.

Re: Combine RGB images problem

Posted: 2011-08-10T02:11:56-07:00
by markmarques
I have tried the -gamma option previously but I need to change and add more things in each of the channels ... :)

Although it worked flawlessly with the "-respect-parenthesis" option ...

But I would never figured it out alone... :)
Thanks for the fast answer ...