Pfft, this is easy. Never send a person to do a computer’s job. =)
#!/usr/bin/perl -w
#
# Finds identical figures in image at [Link]
# Requires PNG input, or other GD-supported format; suggest gif2png.
# Output coordinates are standard Euclidean: origin at lower left,
# images are on points of ZxZ, so the bottom-left is (1, 1).
use GD;
use strict;
use vars qw($theImage %seenat); # easiest when global
$theImage = GD::Image->new($ARGV[0] || "matchmaker.cgi.png")
or die "Couldn't open image: $@, $!";
OUTERLOOP:
for (my $i = 0; $i [0]+1,
10-$seenat{$hashval}->[1],
$i+1,
10-$j);
last OUTERLOOP;
}
}
}
# The grunt work: $theImage is to be considered as 100 39x39 blocks, two
# of which are identical. The best way to handle this is to have a hash
# function that works on a block, and keep a simple lookup table.
# This function takes an offset (from top left) and computes such a hash value.
sub imHash
{
my ($xoff, $yoff) = @_;
my $hval = 0;
for (my $i = 0; $i getPixel($i + 39*$xoff,
$j + 39*$yoff);
$hval += ((39*$i)+$j)*$ctIdx; # or something
}
}
return $hval;
}
EVIL!!!!!!!!!!!!!!
No likie. Will die if I look.
*pop*
Zhaneel
No Way!! No Way!!
You cant make!…..You cant Make!
Noooooo! Nevah!!!
I’m not showing this to Simpsone. Nofe Air! Nofe Air!
Yet another thing I can ‘blame’ on you for introducing me to….not that I’m complaining, mind you…
Pfft, this is easy. Never send a person to do a computer’s job. =)
#!/usr/bin/perl -w
#
# Finds identical figures in image at [Link]
# Requires PNG input, or other GD-supported format; suggest gif2png.
# Output coordinates are standard Euclidean: origin at lower left,
# images are on points of ZxZ, so the bottom-left is (1, 1).
use GD;
use strict;
use vars qw($theImage %seenat); # easiest when global
$theImage = GD::Image->new($ARGV[0] || "matchmaker.cgi.png")
or die "Couldn't open image: $@, $!";
OUTERLOOP:
for (my $i = 0; $i [0]+1,
10-$seenat{$hashval}->[1],
$i+1,
10-$j);
last OUTERLOOP;
}
}
}
# The grunt work: $theImage is to be considered as 100 39x39 blocks, two
# of which are identical. The best way to handle this is to have a hash
# function that works on a block, and keep a simple lookup table.
# This function takes an offset (from top left) and computes such a hash value.
sub imHash
{
my ($xoff, $yoff) = @_;
my $hval = 0;
for (my $i = 0; $i getPixel($i + 39*$xoff,
$j + 39*$yoff);
$hval += ((39*$i)+$j)*$ctIdx; # or something
}
}
return $hval;
}
Cheater.
Zhaneel