possible bug in -colorize in IM 6.4.1-8

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

possible bug in -colorize in IM 6.4.1-8

Post 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.
Last edited by fmw42 on 2008-06-20T21:24:31-07:00, edited 4 times in total.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

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

Post by magick »

The problem you reported is fixed in the subversion repository.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

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

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post by fmw42 »

OK, I just sent him email.

Thanks.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post 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!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

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