Let's say I have some bitmap data (in black) over which some lines have been hand drawn in vector format (in green). The lines roughly follow the shape of the bitmap data. In some places, the lines intersect.
So what I'm trying to do is, knowing the position of the green lines intersection, how I can find the position of A, B, C and D?
See below for some examples:
I'm not sure how to approach this problem given the random positioning of the lines and sometime they are not even inside the black shape. However, I guess there must be some way. Any suggestion?
Simplest approach I can think of is this:
Filter the image to remove the green line. A simple approach would be to use some sort of thinning that fills with the background color of the neighboring pixel(s).
Now you should have an image which consists of only black (broad) lines and white background.
Filter the image again using a corner detection algorithm, such as the Harris detector. This will give you the four corners.
Notes:
Depending on the input data, you might get more than four corners. In any case it is a good idea to verify that the four corners you extracted are indeed possible corners of the intersection.
Again, this is a quite rough approach, but if the input data is as clean as in your example pictures, and the distance between the green lines and the black lines is not too big, I think it might work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With