@@ -166,9 +166,6 @@ MagickExport Image *CompareImageChannels(Image *image,
166
166
const char
167
167
* artifact ;
168
168
169
- double
170
- fuzz ;
171
-
172
169
Image
173
170
* clone_image ,
174
171
* difference_image ,
@@ -245,7 +242,6 @@ MagickExport Image *CompareImageChannels(Image *image,
245
242
/*
246
243
Generate difference image.
247
244
*/
248
- fuzz = image -> fuzz * reconstruct_image -> fuzz ;
249
245
GetMagickPixelPacket (image ,& zero );
250
246
image_view = AcquireVirtualCacheView (image ,exception );
251
247
reconstruct_view = AcquireVirtualCacheView (reconstruct_image ,exception );
@@ -298,70 +294,11 @@ MagickExport Image *CompareImageChannels(Image *image,
298
294
reconstruct_pixel = zero ;
299
295
for (x = 0 ; x < (ssize_t ) columns ; x ++ )
300
296
{
301
- MagickStatusType
302
- difference ;
303
-
304
297
SetMagickPixelPacket (image ,p ,indexes == (IndexPacket * ) NULL ? NULL :
305
298
indexes + x ,& pixel );
306
299
SetMagickPixelPacket (reconstruct_image ,q ,reconstruct_indexes ==
307
300
(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 )
365
302
SetPixelPacket (highlight_image ,& highlight ,r ,highlight_indexes ==
366
303
(IndexPacket * ) NULL ? NULL : highlight_indexes + x );
367
304
else
@@ -459,7 +396,8 @@ static MagickBooleanType GetAESimilarity(const Image *image,
459
396
/*
460
397
Compute the absolute difference in pixels between two images.
461
398
*/
462
- fuzz = image -> fuzz * reconstruct_image -> fuzz ;
399
+ fuzz = 0.5 * (image -> fuzz ,reconstruct_image -> fuzz );
400
+ fuzz *=fuzz ;
463
401
SetImageCompareBounds (image ,reconstruct_image ,& columns ,& rows );
464
402
image_view = AcquireVirtualCacheView (image ,exception );
465
403
reconstruct_view = AcquireVirtualCacheView (reconstruct_image ,exception );
@@ -604,7 +542,8 @@ static MagickBooleanType GetFUZZSimilarity(const Image *image,
604
542
i ,
605
543
y ;
606
544
607
- fuzz = image -> fuzz * reconstruct_image -> fuzz ;
545
+ fuzz = 0.5 * (image -> fuzz ,reconstruct_image -> fuzz );
546
+ fuzz *=fuzz ;
608
547
SetImageCompareBounds (image ,reconstruct_image ,& columns ,& rows );
609
548
image_view = AcquireVirtualCacheView (image ,exception );
610
549
reconstruct_view = AcquireVirtualCacheView (reconstruct_image ,exception );
0 commit comments