Page 1 of 1

convert -modulate saturation behavior changed?

Posted: 2008-04-20T05:35:39-07:00
by remko
Hi,

I used to use 'convert -modulate 100,0' to remove saturation from
pictures. However, I recently upgraded my ImageMagick to 6.4.0 (no
idea what I was using before), and my resulting pictures are not what
I expected them to be:
  • Original icon: Image
  • Convert before: Image
  • Convert now: Image
When I remove saturation with any other graphics program, the result
is the one that I had before. Has something changed? Any suggestions
how I can get the original behavior?

Re: convert -modulate saturation behavior changed?

Posted: 2008-04-20T14:02:43-07:00
by fmw42
This is only a temporary workaround. I would suggest you report this to the Bugs forum as I believe you are correct. I checked on IM 6.4.0-3 with the same results from -modulate. Here is a work around.

If you are on Q16:
convert icon.png -colorspace HSL \
-channel G -threshold 65535 +channel \
-colorspace RGB icon_s0.png

If Q8, then replace 65535 with 255

Basically I am changing the Saturation channel to zero (black) without actually converting the image to HSL, as -threshold is a channel selective operator.

See similar processing of the luminance channel of the rose image at:
http://www.imagemagick.org/Usage/channe ... bine_other

This also works:

convert icon.png -colorspace HSL \
-fill black -colorize 0%,100%,0% +channel \
-colorspace RGB icon_s0.png

Re: convert -modulate saturation behavior changed?

Posted: 2008-05-20T17:45:41-07:00
by anthony
Other solutions, (zeroing the 'G' o saturation channel in HSL) which do not rely on a specific IM version include...

Code: Select all

   -channel G -threshold 101% +channel
   
   -channel G -negate -threshold -1 -negate +channel

   -channel G -evaluate set 0 +channel

   -gamma 1,0,1
That last is VERY tricky, and was in IM examples as a alternative method of channel seperation.

A more complex method is to -separate the image into channel images, delete the saturation channel the -combine just the two channels with a -background of black, though that is an awful lot of work for such a simple operation.