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?".

Hello, how can I reproduce operations that I do in Photoshop for changing HUE/Saturation (for green and yellow) using the IM commandline? Seems that IM and PS use different gradation of values and work in a different way... maybe somebody can help me?

My conversion above was for all channels (using -modulate). I don't know anything about changing HSL values for a given channel. The PS panel allows one to select any channel R,G,B,Y,C,M. But I am not sure what they are doing.

The GIMP coloration tool and my coloration script both convert the image to grayscale and then color appropriately according to H,S,L values. GIMP's H,S,L tool is similar to PS in that it allows one to select a channel.

Perhaps it is a blending of colorizing the one channel and the original image.

Selecting "Master", the HLS sliders have the expected effect. The Overlap slider does nothing.

Selecting colours Yellow, Green or Cyan: no sliders do anything.

Selecting colours Red, Magenta or Blue: the appropriate third of my source image is effected. When Overlap==0, there is a sharp transition between the effect and no-effect; the transition is at the selected colour plus or minus 20 degrees. When Overlap==100, the transition is gradual.

So my step (2) above isn't what Gimp does. A closer version is:

2a. Suppose the selected colour, as an angle in degrees, is S. Suppose the image pixel has colour P. The absolute difference D = abs(P-S).

1) takes a color (R,G,B,M,Y,C) and modulates that color2) creates a mask (possibly from some threshold on the difference between the image colors at a pixel and this modulated color). Something like what snibgo suggested. The overlap my a be some kind of blurring or ramping of the mask3) uses the mask to -compose over (or possibly blend) -composite the modified color with the original image.

Next color selected works on the result of the previous changed image.

If we take the central transition to be at D==30 degrees, so there is no slope discontinuity in the transition and we can do the job with one "-level" instead of two, this Windows script gives results very close to those from Gimp:

I'm not keen on the way Gimp does this job, so I probably won't refine the emulation further.

But I like the concept so here is my variation, more in line with what I initially thought Gimp did. I find the distance in any colorspace between a pixel and the chosen colour. (Gimp apparently compares only the hue; I compare all three channels.) I then transition the effect down from maximum at pixels that match exactly, to zero effect at a distance MAXDIST from the exact match, where typically 0 <= MAXDIST <= 100, but higher values gives results closer to conventional "-modulate". The effect never goes negative. Distance measurement is in the specified colourspace.

I don't read your windows scripts very well, but from what I can tell you are modulating the image. When I look at what is going on in the GIMP panel when one color is selected, I see that the controls change the color patch. This would suggest to me that the modulation perhaps should be on the selected color and that compared with the image for the distance test and mask. But this is only a guess on my part and you may be on the more correct path. I did notice also that in GIMP that it appeared that they only compared hue.

I have not tried to experiment with any bash scripting. I did not like that effect too well (especially at the extremes) and did not think it was worth the effort to try to figure it out.

The Windows-specific parts of my scripts do nothing interesting, and can easily be replicated in another language.

The Gimp (v2.8 ) patches show what would happen to any pure red, magenta etc pixels with the current settings.

There are many ways to skin a cat. My method modulates the image then composes that over the original, with a mask. The complexity is in the mask. Both scripts use gray masks. The first uses the difference in hues, and the level uses the "overlap" parameter (which my script mis-spells as "overlay") to restrict the transition. The second script uses the diagonal distance in the 3-D colour cube between the selected colour and each pixel. It also uses level to restrict the transition, but in a different way.

I tried to see if there was a way to modulate an image of a constant colour and use that to modify the image, along the lines of your previous post. I couldn't see a way of doing that, but it might exist, of course, and be better than my method.

I should mention that Gimp can apply seven transformations, whereas my scripts can do only one -- but could be run multiple times.

OOPS: in my second script, I left in a debugging line: "-write mask_mbc.png ^". This can be removed.

Delphir wrote:so there is no a regular command-style solution for that?

I don't know of one. The simple solution is to use a hald color look-up. This would let you apply your color modification to one or many images. The down side is that a color look-up file must be created by hand using PS for each set of parameters you use. Alternatively, snibgo's clever script could be simplified if your needs are narrower that supporting the entire PS dialog.