In perl the function to get a single pixel is... Get()don wrote:Hi Anthony,
I see what you mean. With pixel.fcmp you can specify a pixel via the x/y and then see if it is whatever color(or nears the "fuzz" margin if specified). I can write a routine in my perl script that will pass the x/y on to a ruby script which performs the pixel.fcmp, and then returns true or false appropriately. Perl will keep querying the ruby script until it knows the borders of the north, south, east, and west points from the initial pixel that was specified. Then it will calculate the center pixel and size of each shape.
For example
Code: Select all
#!/usr/bin/perl
#
# You can grab and set pixels in PerlMagick, using methods like this.
#
use strict;
use Image::Magick;
# read image
my $im=Image::Magick->new();
$im->Read('logo:');
# get a single pixel
print "Skin Color = ", $im->Get('pixel[400,200]'), "\n";
# Or set a single pixel
$im->Set('pixel[0,0]'=>'0,0,0,0');
$im->Set('pixel[1,0]'=>'green');
$im->Set('pixel[2,0]'=>'rgb(255,0,255)');
# display the result (no save)
$im->Display();
As such the first 'Set()' will also be in that same range, and thus is IM dependant.
The other two 'Set()' examples are quality independent.
I just happened to have this script squirrelled away.
An alternative is also shown in "pixel_fx.pl" script that should be installed in the docs area with PerlMagick.