JPERKS1985
asked on
Use ImageColorAt to map out pixel locations.
I need to know how to use ImageColorAt to map out pixels in a png image. Then echo the results like this,
Point 1 : X - 1, Y - 19
Point 2 : X - 4, Y - 36
Point 3 : X - 6, Y - 11
It will be a loop, I know that much. Thanks
Point 1 : X - 1, Y - 19
Point 2 : X - 4, Y - 36
Point 3 : X - 6, Y - 11
It will be a loop, I know that much. Thanks
ASKER
didn't work :(. It should output it in x and y.
Building on NickVd's code, just add another loop to print it.
for($x=1 ; $x<=$imgWidth ; $x++) {
for($y=1 ; $y<=$imgHeight ; $y++) {
echo "X=$x Y=$y Color=" . ImageColorAt($img, $x, $y);
}
}
for($x=1 ; $x<=$imgWidth ; $x++) {
for($y=1 ; $y<=$imgHeight ; $y++) {
echo "X=$x Y=$y Color=" . ImageColorAt($img, $x, $y);
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
didn't work/
ASKER
"After separating all the characters, it time to get the individual pixel point (x, y) of each pixel (1px width x height) in a character and store them for later comparison. The function we will be using is the "ImageColorAt", which basically gets the index of the color of a pixel. Using a loop to go through every single pixel, you would be able to filter out the white pixels apart from the pixels that forms the character (Table 1.0). Do this for the rest of the different characters and you should have a completed pixel index library for this kind of image. (Table 2.0) show the complete pixel index librar.."
<?php
$img = ImageCreateFromPng("<YOURI
$imgWidth = imagesx($img);
$imgHeight = imagesy($img);
for($x=1 ; $x<=$imgWidth ; $x++) {
for($y=1 ; $y<=$imgHeight ; $y++) {
$rgbValues[$x][$y] = ImageColorAt($img, $x, $y);
}
}
?>
Hope this helps!