[Magick-bugs] Quantizing an image with alpha introduces black areas
Peter Pimley
Peter.Pimley at zoemode.com
Fri Aug 3 08:29:55 PDT 2007
Hello IM Bugs,
<backstory>
I have encountered a problem with ImageMagick's color reduction system.
I believe it only occurs when quantizing images with transparency (i.e.
when not all the pixels are opaque)
Ealier on this week, I described on the user's list some troubles I was
having with quantizing images to 256 colors (Thread subject: "-colors
with more colors than the image has"). I'm running a command (convert
$in -colors 256 $out) on a large set of images, and a small number of
them were getting a black 'splodge' drawn across them. By 'a small
number', I mean about six images from a set of about a thousand.
I suspected that it was because they all already had <256 colors. That
is the point when I mailed the user list. Later on I noticed the same
effect happening on an image with > 256 colors, so that was a dead end.
>From my entire set of input images, practically all of them have an
alpha channel, and somewhere in the order of 50% of each image is fully
transparent. The images I've encountered the error with are unusual in
this set in two ways. Firstly, very few of their pixels are completely
transparent. Secondly, none of their pixels are fully opaque. I'm not
sure if this is part of the problem, but it's certainly worth noting.
</backstory>
I've found a good way to reproduce this problem, and I think it's a
severe enough artifact to be considered a bug:
convert -size 256x256 gradient:blue-none -colors 256 problem.png
On my machine (WinXP, IM 6.3.5 07/28/07 Q16, downloaded yesterday) I
get a one pixel high black horizontal bar about a quarter of the way
down the image. Other sizes seem to work too, that's not an important
factor. From the horizontal alignment of the bar and the dithering
effect, it looks like the pixels that are getting turned to black would
normally all be the same color.
I've been creating and quantizing a number of test images, trying to
prove various theories but I can't seem to be able to put my finger on
exactly when the problem does occur and when it does not. In one case I
changed just the alpha channel, and the problem went away. I can email
these test images to anyone who is interested.
>From what I have observed with my images (and of course that does not
cover all possibilities), ImageMagick will always put a color in the
quantized image that has zero R, G and B channels. If you're lucky, the
alpha component of this color is zero too, and transparent parts of the
image (and no others) get changed to it. If you're unlucky, then the
alpha component is non-zero, and pixels that should be some other color
get changed to this black. I've just not been able to determine what
defines 'lucky'!
I'm happy to supply any other material or information to anybody
interseted in this problem.
Peter Pimley
__________________________________________________________________________________________________________________________________________
Information contained in this e-mail is intended for the use of the addressee only, and is confidential and may be the subject of Legal Professional Privilege. Any dissemination, distribution, copying or use of this communication without prior permission of the addressee is strictly prohibited.The views of the author may not necessarily constitute the views of Kuju Entertainment Ltd. Nothing in this email shall bind Kuju Entertainment Ltd in any contract or obligation.
The contents of an attachment to this e-mail may contain software viruses which could damage your own computer system. While Kuju Entertainment has taken every reasonable precaution to minimise this risk, we cannot accept liability for any damage which you sustain as a result of software viruses. You should carry out your own virus checks before opening the attachment.
Kuju Entertainment Ltd trading as Zoe Mode
Registered Office : 10 Woodside Park, Catteshall Lane, Godalming, Surrey, UK, GU7 1LG. Company Number : 3481384. Company Registered in England.
__________________________________________________________________________________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
_________________________________________________________________________________________________________________________________________
More information about the Magick-bugs
mailing list