I'm working on something which would give results much faster if I could include automatic intersection detection. In short, what I want is to make a function which would recieve an image as an argument and would return (x, y) location(s) of the intersections. To make it a bit simpler, this image would consist only of lines and black&white pixels. The way of storing the coordinates data is not relevant, I'm just looking for a way of getting the yes/no answer if a pixels is an intersection or not.
Here's an example of a typical image that I would use:
What I'm asking you is to give me an advice, is there a good library which would do that for me or should I write this from scratch? If the answer is the latter, I'd like you to give me an idea or suggest me a way of thinking when approaching a problem like this, if you know what I mean.
Use the pixel values, either by thresholding or by counting (neighbour) blackness to determine hotspots. Clean the list of found points from coordinates very close to each other. Either implement that yourself or check out the example below which extracts the 6 intersections from the image you provided.
Yeah. Depending on the images, thresholding might work (like with the provided image) or a little more work would be required by actually counting pixels or pixel values for more robust results. But the basic concept is the same, finding hotspots based on (surrounding) color. Below an even shorter hack (it checks closeness before adding to the list) that still works on the provided image.