Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

As an example of what can be achieved without "image processing".

This simple script compares two images and produces a single xx.xxx% similarity figure:

#! perl -slw use strict; use GD; GD::Image->trueColor( 1 ); my $im1 = GD::Image->new( $ARGV[ 0 ] ); my $im2 = GD::Image->new( $ARGV[ 1 ] ); my $raw1 = $im1->gd; my $raw2 = $im2->gd; my $xored = $raw1 ^ $raw2; my( $all, $diff ) = (0)x2; $all += 255, $diff += ord substr $xored, $_, 1 for 0 .. length( $xored + ) - 1; print $all, ' ', $diff; printf "The simlarity is %.3f%%\n", ( $all - $diff ) / $all * 100;

And here are the results of applying that to my previous 'problem' examples.

  • The 'spot-the-differences' ballons A & B:
    C:\test\xx>..\907337 ballons1.jpg ballons2.jpg 672410265 62443267 The simlarity is 90.714%
  • The 'identical except slight color fade' ballons; A & A':
    C:\test\xx>..\907337 ballons1.jpg ballons1a.jpg 672410265 92011553 The simlarity is 86.316%
  • The two BrowserUk late period variations of "Red rectangle on white background"; X & Y:
    C:\test\xx>..\907337 1.png 2.png 244802805 241803 The simlarity is 99.901%
  • And perhaps a more poignant example. MicroArray1 & MicroArray2:
    C:\test\xx>..\907337 microarray1.jpg microarray2.jpg 340764405 41409302 The simlarity is 87.848%

    In this example, the second microarray is just a mirror image of the first for test purposes as I couldn't find two similarly size examples. The reflection means that the registration is probably not as good as you'd expect from a true comparison, but it serves its purpose to highlight the possibilities and downsides of the technique.

The technique could be much improved with good examples and a clearer statement of requirements.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: Can i Compare two images in perl ? by BrowserUk
in thread Can i Compare two images in perl ? by deep3101

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (2)
    As of 2017-12-14 03:11 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      What programming language do you hate the most?




















      Results (384 votes). Check out past polls.

      Notices?