Walter Perry on  wrote...
| Mr. Thyssen,
| 
| I am looking for the correct syntax to use in PerlMagick to compare two 
| images.  Out of all my search requests on Google you were the only 
| person who had an example on the proper use of the compare command in 
| PerlMagick.  I have the command working correctly in ImageMagick but I 
| am stumped on how to get it to work correctly in PerlMagick.  Below is 
| the command I am wanting to work in PerlMagick (which I got also from 
| your post on ImageMagick) - I want to get a numerical result back.
| 
| compare -Metric MAE image1.jpg image2.jpg null
| 
| I know the PerlMagick command would be something like this but where do 
| you put the Metirc MAE ???
| 
| $result = $image1->Compare(image=>$image2);
| 
| Any help you can provide would be greatly appreciated.
| 
I think you want   "null:"   not  "null"  in the above :-)
The former junks the image generated, the later saves it in some image
format.

Note unless the two images are copies of exactly the same image file
(in which case the image files md5sum will also match up), JPEG images
will never match exactly, though they will be close enough not to worry
too much about it.

I have included probably the simplist PerlMagick script for direct
comparision of any two images.  The images are resized (without aspect
ratio preservation) to 100x00 pixels before hand to simplify comparing
images of different sizes.

Error I believe 'peak' or PAE metric while mean-error is MAE metric

It is reasonable, but not a good way for finding matching images from a
very large collection.  For that you are better off generating a metric
such as a color matrix, to locate posible matches for closer
examination.

See IM Examples, Comparing, Color Matrix
  http://www.cit.gu.edu.au/~anthony/compare/#metric_color_matrix

Also look at Sorting images "Greyscale vs Color"
  http://www.cit.gu.edu.au/~anthony/compare/#type_general

This is my current 'find simular images' method, and involves about a
half-a-dozen scripts and a image metric caching system.  From there
something like the comparision script given can be used to match images
even closer.

Warning. Greyscale (or linear color) images use a much lower threshold
than full color images when comparing, due to the lower number of
dimensional variation involved.  Sorting the images by these types is
a very good starting point.

And please let me know how it all goes, what you find, what works for
you, and what doesn't.   Too few people report anything about this type
of thing, and yet so many are interested.


  Anthony Thyssen ( Graphics Enthusiast )    <[EMAIL PROTECTED]>
 -----------------------------------------------------------------------------
  At 300 dpi you can tell she's wearing a swimsuit.
  At 600 dpi you can tell it's wet.
  At 1200 dpi you can tell it's painted on.
  I suppose at 2400 dpi you can tell if the paint is giving her a rash.
                                                      -- Joshua R. Poulson
 -----------------------------------------------------------------------------
         IM Examples               http://www.imagemagick.org/Usage/
#!/usr/bin/perl
=head1 NAME

image_cmp_thumbs_two --  two image thumbnails - simply

=head1 SYNOPSIS

  image_compare  image  image

=head1 DESCRIPTION

Just compare two images and only two images.

=head1 AUTHOR

  Anthony Thyssen  21 January 2003  anthony_AT_griffith.edu.au

=cut
# -----------------------------------------------------------------------
use Image::Magick;

$i1 = Image::Magick->new;
$i2 = Image::Magick->new;

$w = $i1->Read( filename=> shift );       # read in images
warn("$w")  if $w;
exit  if $w =~ /^Exception/;

$w = $i2->Read( filename=> shift );
warn("$w")  if $w;
exit  if $w =~ /^Exception/;

$i1->Scale(width=>100, height=>100); # scale without preserving aspect ratio
$i2->Scale(width=>100, height=>100);

$w = $i1->Compare(image=>$i2);       # compare
die "$w" if $w;

printf "Errors is %f\n",     $i1->Get('error');
printf "Mean Error is %f\n", $i1->Get('mean-error');

_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to