I currently have loaded a simple image onto a canvas.
Its just a white circle with a black background.
What I'm trying to do is convert that white area into a shape. This shape will then be used for boundary detection.
I'm assuming that I need to loop through the image data pixel by pixel? I've done this before for color manipulation, but I'm not sure how I would go about saving this information into "in bounds" and / or "out of bounds".
Other images used will be a bit more complex:
Thanks!
Here's how to use context.getImageData to test if the pixel under the mouse is black or white:
The key is to get the image pixel array and test if any of the red, green or blue components are near 255 (==white if all rgb equal 255)
Example code and a Demo: http://jsfiddle.net/m1erickson/Uw3A4/
Boundary detection with circles is much easier than that. Just use the distance formula to determine if an object is within the radius of the circle.
d = sqrt((x2 - x1)^2 + (y2-y1)^2)