-combine colormix

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?".
droiddk
Posts: 12
Joined: 2015-10-15T12:05:24-07:00
Authentication code: 1151

-combine colormix

Post by droiddk »

Hello

I use this command for creating an RGB-image from three (grey) images:
convert c:\img\red.jpg c:\img\green.jpg c:\img\blue.jpg \ -set colorspace RGB -combine -set colorspace sRGB c:\img\rgb.jpg

I would like to do a colormix, like the one I can do in Photoshop so I get something like this: Red + 34%, green +23% and blue +12%

Is this possible? Cannot find anything about it in the documentation :/

Kind Regards
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -combine colormix

Post by fmw42 »

Red + 34%, green +23% and blue +12%
Do you mean you want 34% red and 23% green and 12% blue? If so, they do not add up to 100%.

Do you mean you want to add 34% graylevel to red and 23% graylevel to green and 12% graylevel to blue?

Note sure why you are setting the color channels to linear RGB before combining. That does not make sense to me, unless your input images are linear RGB and you want to then convert the result to non-linear sRGB. If you input images are non-linear sRGB, then the following should do that (unless you are on an older version of IM where RGB and sRGB were backwards)

Unix syntax for the former

Code: Select all

convert \
\( image1 -evaluate multiply 0.34 \) \
\( image2 -evaluate multiply 0.23 \) \
\( image3 -evaluate multiply 0.12 \) \
-set colorspace sRGB -combine result
Unix syntax for the latter

Code: Select all

convert \
\( image1 -evaluate add 34% \) \
\( image2 -evaluate add 23% \) \
\( image3 -evaluate add 12% \) \
-set colorspace sRGB -combine result
droiddk
Posts: 12
Joined: 2015-10-15T12:05:24-07:00
Authentication code: 1151

Re: -combine colormix

Post by droiddk »

Thank you very much for your help.

What I really want is something like this:

Image

Please note that right after the making of the RGB the red-channel is +100% so I have actually decreased this.

Images says more than.. :-)

Kind Regards
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -combine colormix

Post by fmw42 »

IM can easily adjust the red for the red channel, the green for the green channel and the blue for the blue channel. It cannot easily mix green or blue directly in the red channel nor similarly with the other channels. I am not sure what PS is doing for that. PS 100% is like no change in IM. And PS 0 is like all black. I think PS -100% is negated.

So if you want to change channel values in IM that correspond to PS between 0 and 100% on each channel separately and use the default constant of -10%

That would be

Code: Select all

convert \
\( image1 -evaluate multiply 0.34 -evaluate subtract 10% \) \
\( image2 -evaluate multiply 0.23 -evaluate subtract 10% \) \
\( image3 -evaluate multiply 0.12 -evaluate subtract 10% \) \
-set colorspace sRGB -combine result
droiddk
Posts: 12
Joined: 2015-10-15T12:05:24-07:00
Authentication code: 1151

Re: -combine colormix

Post by droiddk »

Thanks

I have tried but it does not give me the same result as PS :/

Kind Regards
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -combine colormix

Post by fmw42 »

For the PS equivalent of my commands you must only change in PS the red with the red channel, the green with the green channel and the blue with the blue channel. No mixing of blue or green in the red channel.

I think what you may want is the -color-matrix function. See http://www.imagemagick.org/script/comma ... lor-matrix. The values are fractions, not percent. So divide you percents by 100 and use those values for -color-matrix.
droiddk
Posts: 12
Joined: 2015-10-15T12:05:24-07:00
Authentication code: 1151

Re: -combine colormix

Post by droiddk »

Hello fmw42

Thanks but I think that this is out of my reach - I have never worked with IM before and I don't know very much about colormix - I can tweak the faders in PS and that's all :)

Kind Regards
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: -combine colormix

Post by snibgo »

Adding 34% is (or should be) equivalent to multiplying by 1.34, so perhaps "-evaluate Multiply 1.34" is needed.
snibgo's IM pages: im.snibgo.com
droiddk
Posts: 12
Joined: 2015-10-15T12:05:24-07:00
Authentication code: 1151

Re: -combine colormix

Post by droiddk »

I've also tried that.

Kind Regards
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: -combine colormix

Post by snibgo »

Googling "Photoshop Channel Mixer" finds http://www.dummies.com/how-to/content/h ... p-cs6.html , which strongly suggests the IM equivalent is "-color-matrix". For example:

Code: Select all

convert rose: -color-matrix "0,1,0 1,0,0 0,0,1" r.png
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -combine colormix

Post by fmw42 »

snibgo wrote:Adding 34% is (or should be) equivalent to multiplying by 1.34, so perhaps "-evaluate Multiply 1.34" is needed.
Photoshop does not add percents it uses them as multipliers, so that 100% is no change and 0 is black.

I agree that color-matrix is the right thing.

If the use provides the image and the settings for each of the r,g,b channels, I can provide the -color-matrix equivalent (or at least see if that compares properly).
droiddk
Posts: 12
Joined: 2015-10-15T12:05:24-07:00
Authentication code: 1151

Re: -combine colormix

Post by droiddk »

Hi fmw42 and snibgo

Thank you for your reply's.

I may not have been clear about what I wanted to do, or I did not actually know what PS was doing.

What I really want (I think) is this:

Red: 55% red from this channel, but also 50% blue, and 33% green from this channel.
Blue: 100%
Green: 100%

I think that is what PS is doing - in the atached image.
Does it makes sense?

Maybe the color-matrix is the right for me.

Kind Regards
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -combine colormix

Post by fmw42 »

-color-matrix is I think what PS is doing. You are only changing one channel

Code: Select all

-color-matrix "0.55 0.5 0.33    0 1 0    0 0 1"
is what I think you are asking for.
droiddk
Posts: 12
Joined: 2015-10-15T12:05:24-07:00
Authentication code: 1151

Re: -combine colormix

Post by droiddk »

I think you are right, I will try that right away :)

Thanks.

Kind Regards
droiddk
Posts: 12
Joined: 2015-10-15T12:05:24-07:00
Authentication code: 1151

Re: -combine colormix

Post by droiddk »

Yeeees!

It works.

Thank you very much.

Kind Regards
Post Reply