Page 1 of 1

possible bug in -colorize in IM 6.4.1-8

Posted: 2008-06-20T09:56:45-07:00
by fmw42
Using IM 6.4.1-8 Q16 HDRI on Mac OSX Tiger

convert -size 100x100 gradient: -colorize 100,0,0 tmp.png

or

convert -size 100x100 gradient: -colorize 100%,0%,0% tmp.png


Produces a cyan gradient rather than the expected red gradient. Seems like colors are being complemented.

convert -size 100x100 gradient: -colorize 100 tmp.png

Produces an all black image.

Interestingly,

convert grad.png -colorize 0% tmp.png

produces a red gradient. Again looking like some kind of complement of the values is being used.

A simple-minded solution is to complement the user supplied values before feeding to -colorize, namely, red->(QuantumRange - red), green->(QuantumRange - green), blue->(QuantumRange - blue). But it is not likely that simple.

The documenation for -colorize does not specify whether the values are raw (0 to QuantumRange), percent, but I get the same results either way. Perhaps once this is resolved, the documentation could be more specific about this.

Re: possible bug in -colorize in IM 6.4.1-8

Posted: 2008-06-20T10:29:42-07:00
by magick
The problem you reported is fixed in the subversion repository.

Re: possible bug in -colorize in IM 6.4.1-8

Posted: 2008-06-20T10:42:49-07:00
by fmw42
Sorry, what is the subversion repository?

It is not urgent for me. I can wait until the next release or if you want me to test, I can test in the next beta.

Fred

Re: possible bug in -colorize in IM 6.4.1-8

Posted: 2008-06-20T10:46:30-07:00
by magick
The patch will require more thought. Take a look at http://www.imagemagick.org/Usage/color/. Any patch I add ends up breaking this section of the usage examples, suggesting -colorize may be behaving properly. Why not run it by Anthony and see what he says about it.

Re: possible bug in -colorize in IM 6.4.1-8

Posted: 2008-06-20T16:43:12-07:00
by fmw42
OK, I just sent him email.

Thanks.

Re: possible bug in -colorize in IM 6.4.1-8

Posted: 2008-06-22T18:26:54-07:00
by anthony
You have NOT specified the 'fill' color to colorize with!!!!!
Default fill color is 'black'. colorizing with black removed color from the image!!!

As you limit it to just the red channel you effectivally remove all 'red' from the image, giving 'cyan'.

That is white, with red channel overlayed with black -> cyan

Try this instead....

Code: Select all

convert -size 100x100 gradient: -fill white -colorize 100%,0%,0% result.png
the result is a white-red gradient, and you are only adding a red channel color turning black to red. white remains white as you only making the red channel of white reder and it is already at maximum.

Colorize is working correct. You are just not using it correctly!

Re: possible bug in -colorize in IM 6.4.1-8

Posted: 2008-06-22T19:23:48-07:00
by fmw42
I was afraid that might be the case. But I completely missed the part about the fill color. I guess I need to read more carefully. I will try some more tests. Sorry for the oversight. Thanks.