@@ -166,9 +166,6 @@ MagickExport Image *CompareImageChannels(Image *image,
166166 const char
167167 * artifact ;
168168
169- double
170- fuzz ;
171-
172169 Image
173170 * clone_image ,
174171 * difference_image ,
@@ -245,7 +242,6 @@ MagickExport Image *CompareImageChannels(Image *image,
245242 /*
246243 Generate difference image.
247244 */
248- fuzz = image -> fuzz * reconstruct_image -> fuzz ;
249245 GetMagickPixelPacket (image ,& zero );
250246 image_view = AcquireVirtualCacheView (image ,exception );
251247 reconstruct_view = AcquireVirtualCacheView (reconstruct_image ,exception );
@@ -298,70 +294,11 @@ MagickExport Image *CompareImageChannels(Image *image,
298294 reconstruct_pixel = zero ;
299295 for (x = 0 ; x < (ssize_t ) columns ; x ++ )
300296 {
301- MagickStatusType
302- difference ;
303-
304297 SetMagickPixelPacket (image ,p ,indexes == (IndexPacket * ) NULL ? NULL :
305298 indexes + x ,& pixel );
306299 SetMagickPixelPacket (reconstruct_image ,q ,reconstruct_indexes ==
307300 (IndexPacket * ) NULL ? NULL : reconstruct_indexes + x ,& reconstruct_pixel );
308- difference = MagickFalse ;
309- if (channel == CompositeChannels )
310- {
311- if (IsMagickColorSimilar (& pixel ,& reconstruct_pixel ) == MagickFalse )
312- difference = MagickTrue ;
313- }
314- else
315- {
316- double
317- Da ,
318- distance ,
319- pixel ,
320- Sa ;
321-
322- Sa = QuantumScale * (image -> matte != MagickFalse ? (double )
323- GetPixelAlpha (p ) : ((double ) QuantumRange - (double ) OpaqueOpacity ));
324- Da = QuantumScale * (image -> matte != MagickFalse ? (double )
325- GetPixelAlpha (q ) : ((double ) QuantumRange - (double ) OpaqueOpacity ));
326- if ((channel & RedChannel ) != 0 )
327- {
328- pixel = Sa * (double ) GetPixelRed (p )- Da * (double ) GetPixelRed (q );
329- distance = pixel * pixel ;
330- if (distance > fuzz )
331- difference = MagickTrue ;
332- }
333- if ((channel & GreenChannel ) != 0 )
334- {
335- pixel = Sa * (double ) GetPixelGreen (p )- Da * (double ) GetPixelGreen (q );
336- distance = pixel * pixel ;
337- if (distance > fuzz )
338- difference = MagickTrue ;
339- }
340- if ((channel & BlueChannel ) != 0 )
341- {
342- pixel = Sa * (double ) GetPixelBlue (p )- Da * (double ) GetPixelBlue (q );
343- distance = pixel * pixel ;
344- if (distance > fuzz )
345- difference = MagickTrue ;
346- }
347- if (((channel & OpacityChannel ) != 0 ) &&
348- (image -> matte != MagickFalse ))
349- {
350- pixel = (double ) GetPixelOpacity (p )- (double ) GetPixelOpacity (q );
351- distance = pixel * pixel ;
352- if (distance > fuzz )
353- difference = MagickTrue ;
354- }
355- if (((channel & IndexChannel ) != 0 ) &&
356- (image -> colorspace == CMYKColorspace ))
357- {
358- pixel = Sa * (double ) indexes [x ]- Da * (double ) reconstruct_indexes [x ];
359- distance = pixel * pixel ;
360- if (distance > fuzz )
361- difference = MagickTrue ;
362- }
363- }
364- if (difference != MagickFalse )
301+ if (IsMagickColorSimilar (& pixel ,& reconstruct_pixel ) == MagickFalse )
365302 SetPixelPacket (highlight_image ,& highlight ,r ,highlight_indexes ==
366303 (IndexPacket * ) NULL ? NULL : highlight_indexes + x );
367304 else
@@ -459,7 +396,8 @@ static MagickBooleanType GetAESimilarity(const Image *image,
459396 /*
460397 Compute the absolute difference in pixels between two images.
461398 */
462- fuzz = image -> fuzz * reconstruct_image -> fuzz ;
399+ fuzz = 0.5 * (image -> fuzz ,reconstruct_image -> fuzz );
400+ fuzz *=fuzz ;
463401 SetImageCompareBounds (image ,reconstruct_image ,& columns ,& rows );
464402 image_view = AcquireVirtualCacheView (image ,exception );
465403 reconstruct_view = AcquireVirtualCacheView (reconstruct_image ,exception );
@@ -604,7 +542,8 @@ static MagickBooleanType GetFUZZSimilarity(const Image *image,
604542 i ,
605543 y ;
606544
607- fuzz = image -> fuzz * reconstruct_image -> fuzz ;
545+ fuzz = 0.5 * (image -> fuzz ,reconstruct_image -> fuzz );
546+ fuzz *=fuzz ;
608547 SetImageCompareBounds (image ,reconstruct_image ,& columns ,& rows );
609548 image_view = AcquireVirtualCacheView (image ,exception );
610549 reconstruct_view = AcquireVirtualCacheView (reconstruct_image ,exception );
0 commit comments