duncan_cowan Posted June 23, 2009 Share Posted June 23, 2009 Hi,I was wondering if there is a way to find what area, of an image map, a given pixel is in?ThanksDuncan Link to comment Share on other sites More sharing options...
Ingolme Posted June 23, 2009 Share Posted June 23, 2009 If you use <input type="image"> you can get the X and Y position of the clicked pixel on the server-side, if that's any help. Link to comment Share on other sites More sharing options...
duncan_cowan Posted June 23, 2009 Author Share Posted June 23, 2009 Thanks for the reply but Im afraid that doesnt help ... Link to comment Share on other sites More sharing options...
Ingolme Posted June 23, 2009 Share Posted June 23, 2009 Can you give a clearer idea of what you want to do? Link to comment Share on other sites More sharing options...
duncan_cowan Posted June 23, 2009 Author Share Posted June 23, 2009 I have a map of the world and each country is an area on an image map.The user will select a start location and an end location and the script will cycle through each pixel in a direct line from the start to the end and i want to find out what country the pixel is in or if it is over sea. Link to comment Share on other sites More sharing options...
Ingolme Posted June 23, 2009 Share Posted June 23, 2009 You'd have to define which pixels are what country somewhere or another. Link to comment Share on other sites More sharing options...
duncan_cowan Posted June 23, 2009 Author Share Posted June 23, 2009 You mean every pixel, there is no way to find out what pixels are within a polygon area?? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 23, 2009 Share Posted June 23, 2009 Correct, there's not a built-in way to do that. You would need to have a Javascript array or something similar where you define the regions and what pixels they cover that you can use to cross-reference a pixel with a region. Link to comment Share on other sites More sharing options...
duncan_cowan Posted June 23, 2009 Author Share Posted June 23, 2009 that would take a very long time as the polygon is very large.ahh well i will have to think of some alternative method.Thanks very much anyway Link to comment Share on other sites More sharing options...
justsomeguy Posted June 23, 2009 Share Posted June 23, 2009 From the basic details it sounds like Flash might be an option. Link to comment Share on other sites More sharing options...
Ingolme Posted June 23, 2009 Share Posted June 23, 2009 You could devise an algorithm and mathematical formula to find out which pixels are in the area by the coordinates. I'm not going to tell you how to do that, though. I'd need to do some research myself, it's not something simple because it requires geometry. Link to comment Share on other sites More sharing options...
justsomeguy Posted June 24, 2009 Share Posted June 24, 2009 That would involve dividing the region into specific polygons like triangles and squares, and then computing the area of the parts. The formulas for computing the area of a triangle or square are well-known. Link to comment Share on other sites More sharing options...
duncan_cowan Posted June 24, 2009 Author Share Posted June 24, 2009 hmmm, sounds complicated.May look into finding the pixels that lie along the lines of the edge of the polygon and finding if the path crosses one of these lines.Thanks for the posts. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.