[Solved] Combine RGB images problem

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
markmarques
Posts: 88
Joined: 2010-06-29T14:36:09-07:00
Authentication code: 8675308

[Solved] Combine RGB images problem

Post 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 ?
Last edited by markmarques on 2011-08-10T02:12:18-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Combine RGB images problem

Post 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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Combine RGB images problem

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
markmarques
Posts: 88
Joined: 2010-06-29T14:36:09-07:00
Authentication code: 8675308

Re: Combine RGB images problem

Post 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 ...
Post Reply