Elia Mazzawi on  wrote...
| Hello,
| 
| I have 100's of PNG files, that may or may not contain a smaller image 
| that I have in another smaller PNG file.
| I want to write a program to test if the sub Image exists in the larger 
| Image, and at what location if it does.
| 
| I think that since these are PNG not JPEGs there is no fuzzy logic 
| matching needed.
| 
| i've been trying to get the pixels out of both images ( using getPixels 
| ) and comparing the binary.
| 
| but I'm not sure what parameters i should give getPixels(). or if there 
| is a better way to do this.
| 
| any help is appreciated.
| 

There was a library routine added to the IM library, which was for
locating sub-images like this. As well as a seperate C program for
testing it.

Hmmmm....

here it is, an old email on the IM users mailing list...

=======8<--------CUT HERE----------axes/crowbars permitted---------------
Subject: Re: [magick-users] How to locate (x, y) coordinates of one sub-image 
within another?
From: [EMAIL PROTECTED]
Date: Fri, 7 Jul 2006 07:07:16 -0700 (Sat 00:07 EST)
To: [EMAIL PROTECTED], [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED], [email protected],
        [EMAIL PROTECTED]

We added IsImageSimilar() to ImageMagick 6.2.8-4 Beta if anyone wants to
take a look at the solution to locating coordinates of a sub-image within
another image.  It works in all colorspaces and accounts for image masks.
Below a test program for IsImageSimilar().  Compile with:

  cc `Magick-config --cflags --cppflags` -o similar similar.c \
    `Magick-config --ldflags --libs`

  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
  #include <time.h>
  #include <magick/MagickCore.h>
  
  int main(int argc,char **argv)
  {
    ExceptionInfo
      *exception;
  
    Image
      *crop_image,
      *image;
  
    ImageInfo
      *image_info;
  
    long
      x,
      y;
  
    RectangleInfo
      region;
  
    if (argc != 2)
      {
        (void) fprintf(stdout,"Usage: %s image\n",argv[0]);
        exit(0);
      }
    InitializeMagick(*argv);
    exception=AcquireExceptionInfo();
    image_info=CloneImageInfo((ImageInfo *) NULL);
    (void) strcpy(image_info->filename,argv[1]);
    image=ReadImage(image_info,exception);
    if (exception->severity != UndefinedException)
      CatchException(exception);
    if (image == (Image *) NULL)
      exit(1);
    region.width=100;
    region.height=100;
    region.x=100;
    region.y=100;
    crop_image=CropImage(image,&region,exception);
    x=0;
    y=0;
    IsImageSimilar(image,crop_image,&x,&y,exception);
    printf("%ld %ld\n",x,y);
    image=DestroyImageList(image);
    image_info=DestroyImageInfo(image_info);
    exception=DestroyExceptionInfo(exception);
    DestroyMagick();
    return(0);
  }

=======8<--------CUT HERE----------axes/crowbars permitted---------------

If you have any success, or lack of it, please report.
I have not looked at it since it came out.

  Anthony Thyssen ( System Programmer )    <[EMAIL PROTECTED]>
 -----------------------------------------------------------------------------
        ``Sorry 'bout that Chief!''
        ``Missed it, by that much!''          -- Get Smart
 -----------------------------------------------------------------------------
     Anthony's Home is his Castle     http://www.cit.gu.edu.au/~anthony/
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to