From: cristy Date: Thu, 9 Dec 2010 14:27:51 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~8411 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8954bf39b5f20c669ee14e7a7faafeef0e13e7f0;p=imagemagick --- diff --git a/magick/color.c b/magick/color.c index 332bd84d9..18d33b3a3 100644 --- a/magick/color.c +++ b/magick/color.c @@ -1577,7 +1577,7 @@ MagickExport MagickBooleanType IsColorSimilar(const Image *image, scale=(QuantumScale*GetAlphaPixelComponent(p)); if (image->matte != MagickFalse) scale*=(QuantumScale*GetAlphaPixelComponent(q)); - if (scale < MagickEpsilon) + if (scale <= MagickEpsilon) return(MagickTrue); } @@ -1756,6 +1756,23 @@ MagickExport MagickBooleanType IsImageSimilar(const Image *image, % This method is used by ColorFloodFill() and other algorithms which % compare two colors. % +% This implements the equivelent of... +% fuzz < sqrt( color_distance^2 * u.a*v.a + alpha_distance^2 ) +% +% Which produces a multi-dimentional cone for that colorspace along the +% transpaency vector +% +% For example for an RGB +% color_distance^2 = ( (u.r-v.r)^2 + (u.g-v.g)^2 + (u.b-v.b)^2 ) / 3 +% +% See http://www.imagemagick.org/Usage/bugs/fuzz_distance/ +% +% Hue colorspace distances need more work. Hue is not a distance, it is an +% angle! +% +% A check that q is in the same color space as p should be made and the +% appropriate mapping made. -- Anthony Thyssen 8 December 2010 +% % The format of the IsMagickColorSimilar method is: % % MagickBooleanType IsMagickColorSimilar(const MagickPixelPacket *p, @@ -1768,26 +1785,6 @@ MagickExport MagickBooleanType IsImageSimilar(const Image *image, % o q: Pixel q. % */ -/* - This implements the equivelent of... - fuzz < sqrt( color_distance^2 * u.a*v.a + alpha_distance^2 ) - - Which produces a multi-dimentional cone for that colorspace - along the transpaency vector - - For example for an RGB - color_distance^2 = ( (u.r-v.r)^2 + (u.g-v.g)^2 + (u.b-v.b)^2 ) / 3 - - See http://www.imagemagick.org/Usage/bugs/fuzz_distance/ - - Hue colorspace distances need more work. - Hue is not a distance, it is an angle! - - A check that q is in the same color space as p should be made! - and the appropriate mapping made. - - -- Anthony Thyssen 8 December 2010 -*/ MagickExport MagickBooleanType IsMagickColorSimilar(const MagickPixelPacket *p, const MagickPixelPacket *q) { @@ -1799,7 +1796,6 @@ MagickExport MagickBooleanType IsMagickColorSimilar(const MagickPixelPacket *p, scale, distance; - if ((p->fuzz == 0.0) && (q->fuzz == 0.0)) return(IsMagickColorEqual(p,q)); if (p->fuzz == 0.0) @@ -1827,7 +1823,7 @@ MagickExport MagickBooleanType IsMagickColorSimilar(const MagickPixelPacket *p, scale=(QuantumScale*GetAlphaPixelComponent(p)); if (q->matte != MagickFalse) scale*=(QuantumScale*GetAlphaPixelComponent(q)); - if ( scale < MagickEpsilon ) + if ( scale <= MagickEpsilon ) return(MagickTrue); } @@ -1848,8 +1844,7 @@ MagickExport MagickBooleanType IsMagickColorSimilar(const MagickPixelPacket *p, fuzz*=3.0; pixel=p->red-q->red; - if ((p->colorspace == HSLColorspace) || - (p->colorspace == HSBColorspace) || + if ((p->colorspace == HSLColorspace) || (p->colorspace == HSBColorspace) || (p->colorspace == HWBColorspace)) { /* This calculates a arc distance for hue