in reply to Re: Can i Compare two images in perl ?
in thread Can i Compare two images in perl ?
This is one of those internet myths that just persists.
According to your formula, this image and this one ought to approach 2.0. They are to all intents and purposes identical.
The actual result:
C:\test>jimagezipcmp.pl adding: 1.png (160 bytes security) (deflated 90%) adding: 2.png (160 bytes security) (deflated 89%) adding: 1.png (160 bytes security) (deflated 90%) adding: 2.png (160 bytes security) (deflated 89%) 1.0272952853598
Try it yourself:
#! perl -slw use strict; use GD; sub rgb2n { unpack 'N', pack 'CCCC', 0, @_ } for my $n ( 1, 2 ) { my $im1 = GD::Image->new( 600, 400, 1 ); $im1->filledRectangle( 0, 0, 600, 400, rgb2n( 255, 255, 255 ) ); $im1->filledRectangle( 100, 100, 500, 300, rgb2n( 255 - $n, 0, 0 ) + ); open O, '>:raw', $n . '.png' or die $!; print O $im1->png; close O; } system q[zip 1.zip 1.png]; system q[zip 2.zip 2.png]; system q[zip 3.zip 1.png 2.png]; my $size1 = -s '1.zip'; my $size2 = -s '2.zip'; my $size3 = -s '3.zip'; print +( $size1 + $size2 ) / $size3;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Can i Compare two images in perl ? (It's a myth!)
by Anonymous Monk on May 31, 2011 at 13:08 UTC | |
by BrowserUk (Patriarch) on May 31, 2011 at 13:43 UTC | |
by SuicideJunkie (Vicar) on May 31, 2011 at 15:34 UTC | |
by BrowserUk (Patriarch) on May 31, 2011 at 15:39 UTC |