~ubuntu-branches/ubuntu/oneiric/imagemagick/oneiric-updates

« back to all changes in this revision

Viewing changes to magick/compare.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2011-06-15 11:05:28 UTC
  • mfrom: (6.2.11 sid)
  • Revision ID: james.westby@ubuntu.com-20110615110528-08jgo07a4846xh8d
Tags: 8:6.6.0.4-3ubuntu1
* Resynchronise with Debian (LP: #797595).  Remaining changes:
  - Make ufraw-batch (universe) a suggestion instead of a recommendation.
  - Make debian/rules install target depend on check; they cannot reliably
    be run in parallel.
  - Don't set MAKEFLAGS in debian/rules; just pass it to the build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
129
129
    *difference_image,
130
130
    *highlight_image;
131
131
 
132
 
  ssize_t
 
132
  long
133
133
    y;
134
134
 
135
135
  MagickBooleanType
200
200
#if defined(MAGICKCORE_OPENMP_SUPPORT)
201
201
  #pragma omp parallel for schedule(dynamic,4) shared(status)
202
202
#endif
203
 
  for (y=0; y < (ssize_t) image->rows; y++)
 
203
  for (y=0; y < (long) image->rows; y++)
204
204
  {
205
205
    MagickBooleanType
206
206
      sync;
220
220
    register IndexPacket
221
221
      *restrict highlight_indexes;
222
222
 
223
 
    register ssize_t
 
223
    register long
224
224
      x;
225
225
 
226
226
    register PixelPacket
244
244
    highlight_indexes=GetCacheViewAuthenticIndexQueue(highlight_view);
245
245
    pixel=zero;
246
246
    reconstruct_pixel=zero;
247
 
    for (x=0; x < (ssize_t) image->columns; x++)
 
247
    for (x=0; x < (long) image->columns; x++)
248
248
    {
249
249
      MagickStatusType
250
250
        difference;
353
353
    *image_view,
354
354
    *reconstruct_view;
355
355
 
356
 
  ssize_t
 
356
  long
357
357
    y;
358
358
 
359
359
  MagickBooleanType
372
372
#if defined(MAGICKCORE_OPENMP_SUPPORT)
373
373
  #pragma omp parallel for schedule(dynamic,4) shared(status)
374
374
#endif
375
 
  for (y=0; y < (ssize_t) image->rows; y++)
 
375
  for (y=0; y < (long) image->rows; y++)
376
376
  {
377
377
    double
378
378
      channel_distortion[AllChannels+1];
389
389
      *restrict p,
390
390
      *restrict q;
391
391
 
392
 
    register ssize_t
 
392
    register long
393
393
      i,
394
394
      x;
395
395
 
408
408
    pixel=zero;
409
409
    reconstruct_pixel=pixel;
410
410
    (void) ResetMagickMemory(channel_distortion,0,sizeof(channel_distortion));
411
 
    for (x=0; x < (ssize_t) image->columns; x++)
 
411
    for (x=0; x < (long) image->columns; x++)
412
412
    {
413
413
      SetMagickPixelPacket(image,p,indexes+x,&pixel);
414
414
      SetMagickPixelPacket(reconstruct_image,q,reconstruct_indexes+x,
435
435
#if defined(MAGICKCORE_OPENMP_SUPPORT)
436
436
  #pragma omp critical (MagickCore_GetAbsoluteError)
437
437
#endif
438
 
    for (i=0; i <= (ssize_t) AllChannels; i++)
 
438
    for (i=0; i <= (long) AllChannels; i++)
439
439
      distortion[i]+=channel_distortion[i];
440
440
  }
441
441
  reconstruct_view=DestroyCacheView(reconstruct_view);
443
443
  return(status);
444
444
}
445
445
 
446
 
static size_t GetNumberChannels(const Image *image,
 
446
static unsigned long GetNumberChannels(const Image *image,
447
447
  const ChannelType channel)
448
448
{
449
 
  size_t
 
449
  unsigned long
450
450
    channels;
451
451
 
452
452
  channels=0;
473
473
    *image_view,
474
474
    *reconstruct_view;
475
475
 
476
 
  ssize_t
 
476
  long
477
477
    y;
478
478
 
479
479
  MagickBooleanType
480
480
    status;
481
481
 
482
 
  register ssize_t
 
482
  register long
483
483
    i;
484
484
 
485
485
  status=MagickTrue;
488
488
#if defined(MAGICKCORE_OPENMP_SUPPORT)
489
489
  #pragma omp parallel for schedule(dynamic,4) shared(status)
490
490
#endif
491
 
  for (y=0; y < (ssize_t) image->rows; y++)
 
491
  for (y=0; y < (long) image->rows; y++)
492
492
  {
493
493
    double
494
494
      channel_distortion[AllChannels+1];
501
501
      *restrict p,
502
502
      *restrict q;
503
503
 
504
 
    register ssize_t
 
504
    register long
505
505
      i,
506
506
      x;
507
507
 
518
518
    indexes=GetCacheViewVirtualIndexQueue(image_view);
519
519
    reconstruct_indexes=GetCacheViewVirtualIndexQueue(reconstruct_view);
520
520
    (void) ResetMagickMemory(channel_distortion,0,sizeof(channel_distortion));
521
 
    for (x=0; x < (ssize_t) image->columns; x++)
 
521
    for (x=0; x < (long) image->columns; x++)
522
522
    {
523
523
      MagickRealType
524
524
        distance;
562
562
#if defined(MAGICKCORE_OPENMP_SUPPORT)
563
563
  #pragma omp critical (MagickCore_GetMeanAbsoluteError)
564
564
#endif
565
 
    for (i=0; i <= (ssize_t) AllChannels; i++)
 
565
    for (i=0; i <= (long) AllChannels; i++)
566
566
      distortion[i]+=channel_distortion[i];
567
567
  }
568
568
  reconstruct_view=DestroyCacheView(reconstruct_view);
569
569
  image_view=DestroyCacheView(image_view);
570
 
  for (i=0; i <= (ssize_t) AllChannels; i++)
 
570
  for (i=0; i <= (long) AllChannels; i++)
571
571
    distortion[i]/=((double) image->columns*image->rows);
572
572
  distortion[AllChannels]/=(double) GetNumberChannels(image,channel);
573
573
  return(status);
581
581
    *image_view,
582
582
    *reconstruct_view;
583
583
 
584
 
  ssize_t
 
584
  long
585
585
    y;
586
586
 
587
587
  MagickBooleanType
602
602
  mean_error=0.0;
603
603
  image_view=AcquireCacheView(image);
604
604
  reconstruct_view=AcquireCacheView(reconstruct_image);
605
 
  for (y=0; y < (ssize_t) image->rows; y++)
 
605
  for (y=0; y < (long) image->rows; y++)
606
606
  {
607
607
    register const IndexPacket
608
608
      *restrict indexes,
612
612
      *restrict p,
613
613
      *restrict q;
614
614
 
615
 
    register ssize_t
 
615
    register long
616
616
      x;
617
617
 
618
618
    p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
625
625
      }
626
626
    indexes=GetCacheViewVirtualIndexQueue(image_view);
627
627
    reconstruct_indexes=GetCacheViewVirtualIndexQueue(reconstruct_view);
628
 
    for (x=0; x < (ssize_t) image->columns; x++)
 
628
    for (x=0; x < (long) image->columns; x++)
629
629
    {
630
630
      MagickRealType
631
631
        distance;
710
710
    *image_view,
711
711
    *reconstruct_view;
712
712
 
713
 
  ssize_t
 
713
  long
714
714
    y;
715
715
 
716
716
  MagickBooleanType
717
717
    status;
718
718
 
719
 
  register ssize_t
 
719
  register long
720
720
    i;
721
721
 
722
722
  status=MagickTrue;
725
725
#if defined(MAGICKCORE_OPENMP_SUPPORT)
726
726
  #pragma omp parallel for schedule(dynamic,4) shared(status)
727
727
#endif
728
 
  for (y=0; y < (ssize_t) image->rows; y++)
 
728
  for (y=0; y < (long) image->rows; y++)
729
729
  {
730
730
    double
731
731
      channel_distortion[AllChannels+1];
738
738
      *restrict p,
739
739
      *restrict q;
740
740
 
741
 
    register ssize_t
 
741
    register long
742
742
      i,
743
743
      x;
744
744
 
755
755
    indexes=GetCacheViewVirtualIndexQueue(image_view);
756
756
    reconstruct_indexes=GetCacheViewVirtualIndexQueue(reconstruct_view);
757
757
    (void) ResetMagickMemory(channel_distortion,0,sizeof(channel_distortion));
758
 
    for (x=0; x < (ssize_t) image->columns; x++)
 
758
    for (x=0; x < (long) image->columns; x++)
759
759
    {
760
760
      MagickRealType
761
761
        distance;
800
800
#if defined(MAGICKCORE_OPENMP_SUPPORT)
801
801
  #pragma omp critical (MagickCore_GetMeanSquaredError)
802
802
#endif
803
 
    for (i=0; i <= (ssize_t) AllChannels; i++)
 
803
    for (i=0; i <= (long) AllChannels; i++)
804
804
      distortion[i]+=channel_distortion[i];
805
805
  }
806
806
  reconstruct_view=DestroyCacheView(reconstruct_view);
807
807
  image_view=DestroyCacheView(image_view);
808
 
  for (i=0; i <= (ssize_t) AllChannels; i++)
 
808
  for (i=0; i <= (long) AllChannels; i++)
809
809
    distortion[i]/=((double) image->columns*image->rows);
810
810
  distortion[AllChannels]/=(double) GetNumberChannels(image,channel);
811
811
  return(status);
819
819
    *image_view,
820
820
    *reconstruct_view;
821
821
 
822
 
  ssize_t
 
822
  long
823
823
    y;
824
824
 
825
825
  MagickBooleanType
831
831
#if defined(MAGICKCORE_OPENMP_SUPPORT)
832
832
  #pragma omp parallel for schedule(dynamic,4) shared(status)
833
833
#endif
834
 
  for (y=0; y < (ssize_t) image->rows; y++)
 
834
  for (y=0; y < (long) image->rows; y++)
835
835
  {
836
836
    double
837
837
      channel_distortion[AllChannels+1];
844
844
      *restrict p,
845
845
      *restrict q;
846
846
 
847
 
    register ssize_t
 
847
    register long
848
848
      i,
849
849
      x;
850
850
 
861
861
    indexes=GetCacheViewVirtualIndexQueue(image_view);
862
862
    reconstruct_indexes=GetCacheViewVirtualIndexQueue(reconstruct_view);
863
863
    (void) ResetMagickMemory(channel_distortion,0,sizeof(channel_distortion));
864
 
    for (x=0; x < (ssize_t) image->columns; x++)
 
864
    for (x=0; x < (long) image->columns; x++)
865
865
    {
866
866
      MagickRealType
867
867
        distance;
916
916
#if defined(MAGICKCORE_OPENMP_SUPPORT)
917
917
  #pragma omp critical (MagickCore_GetPeakAbsoluteError)
918
918
#endif
919
 
    for (i=0; i <= (ssize_t) AllChannels; i++)
 
919
    for (i=0; i <= (long) AllChannels; i++)
920
920
      if (channel_distortion[i] > distortion[i])
921
921
        distortion[i]=channel_distortion[i];
922
922
  }
1244
1244
  ExceptionInfo
1245
1245
    *exception;
1246
1246
 
1247
 
  ssize_t
 
1247
  long
1248
1248
    y;
1249
1249
 
1250
1250
  MagickBooleanType
1270
1270
  exception=(&image->exception);
1271
1271
  image_view=AcquireCacheView(image);
1272
1272
  reconstruct_view=AcquireCacheView(reconstruct_image);
1273
 
  for (y=0; y < (ssize_t) image->rows; y++)
 
1273
  for (y=0; y < (long) image->rows; y++)
1274
1274
  {
1275
1275
    register const IndexPacket
1276
1276
      *restrict indexes,
1280
1280
      *restrict p,
1281
1281
      *restrict q;
1282
1282
 
1283
 
    register ssize_t
 
1283
    register long
1284
1284
      x;
1285
1285
 
1286
1286
    p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
1290
1290
      break;
1291
1291
    indexes=GetCacheViewVirtualIndexQueue(image_view);
1292
1292
    reconstruct_indexes=GetCacheViewVirtualIndexQueue(reconstruct_view);
1293
 
    for (x=0; x < (ssize_t) image->columns; x++)
 
1293
    for (x=0; x < (long) image->columns; x++)
1294
1294
    {
1295
1295
      MagickRealType
1296
1296
        distance;
1382
1382
*/
1383
1383
 
1384
1384
static double GetSimilarityMetric(const Image *image,const Image *reference,
1385
 
  const ssize_t x_offset,const ssize_t y_offset,ExceptionInfo *exception)
 
1385
  const long x_offset,const long y_offset,ExceptionInfo *exception)
1386
1386
{
1387
1387
  CacheView
1388
1388
    *image_view,
1391
1391
  double
1392
1392
    similarity;
1393
1393
 
1394
 
  ssize_t
 
1394
  long
1395
1395
    y;
1396
1396
 
1397
1397
  MagickBooleanType
1407
1407
#if defined(MAGICKCORE_OPENMP_SUPPORT)
1408
1408
  #pragma omp parallel for schedule(dynamic,4) shared(status)
1409
1409
#endif
1410
 
  for (y=0; y < (ssize_t) reference->rows; y++)
 
1410
  for (y=0; y < (long) reference->rows; y++)
1411
1411
  {
1412
1412
    register const IndexPacket
1413
1413
      *restrict indexes,
1417
1417
      *restrict p,
1418
1418
      *restrict q;
1419
1419
 
1420
 
    register ssize_t
 
1420
    register long
1421
1421
      x;
1422
1422
 
1423
1423
    if (status == MagickFalse)
1433
1433
      }
1434
1434
    indexes=GetCacheViewVirtualIndexQueue(image_view);
1435
1435
    reference_indexes=GetCacheViewVirtualIndexQueue(reference_view);
1436
 
    for (x=0; x < (ssize_t) reference->columns; x++)
 
1436
    for (x=0; x < (long) reference->columns; x++)
1437
1437
    {
1438
1438
      double
1439
1439
        thread_similarity;
1485
1485
  CacheView
1486
1486
    *similarity_view;
1487
1487
 
 
1488
  long
 
1489
    progress,
 
1490
    y;
 
1491
 
1488
1492
  Image
1489
1493
    *similarity_image;
1490
1494
 
1491
1495
  MagickBooleanType
1492
1496
    status;
1493
1497
 
1494
 
  MagickOffsetType
1495
 
    progress;
1496
 
 
1497
 
  ssize_t
1498
 
    y;
1499
 
 
1500
1498
  assert(image != (const Image *) NULL);
1501
1499
  assert(image->signature == MagickSignature);
1502
1500
  if (image->debug != MagickFalse)
1528
1526
#if defined(MAGICKCORE_OPENMP_SUPPORT)
1529
1527
  #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
1530
1528
#endif
1531
 
  for (y=0; y < (ssize_t) (image->rows-reference->rows+1); y++)
 
1529
  for (y=0; y < (long) (image->rows-reference->rows+1); y++)
1532
1530
  {
1533
1531
    double
1534
1532
      similarity;
1535
1533
 
1536
 
    register ssize_t
 
1534
    register long
1537
1535
      x;
1538
1536
 
1539
1537
    register PixelPacket
1548
1546
        status=MagickFalse;
1549
1547
        continue;
1550
1548
      }
1551
 
    for (x=0; x < (ssize_t) (image->columns-reference->columns+1); x++)
 
1549
    for (x=0; x < (long) (image->columns-reference->columns+1); x++)
1552
1550
    {
1553
1551
      similarity=GetSimilarityMetric(image,reference,x,y,exception);
1554
1552
#if defined(MAGICKCORE_OPENMP_SUPPORT)