I was wondering if anyone can help me. My ultimate aim is to take an image like the one shown and draw line between the white and black blobs that show a direction and output the coordinates in the image. However, blobs should only be connected if they are on the adjacent vertex and blobs on the same vertex should not be connected i.e. a white blob should only connect to a black blob on its nearest neighbour.
Currently, I have been able to draw lines between blobs and give them a colour depending on their direction. I have also been able to exclude diagonal lines.
My current problem is my code is still drawing vertical and horizontal lines across the same vertex. I cannot use a distance limit as some of the nearest neighbour blobs are the same distance away as the ones on the same vertex.
I have managed to map the coordinates of the vertices using mouse clicks and store those in a list and I also have a list for the centre point between two blobs so I was hoping I'd be able to say - if the centre point of the line is too close to the vertex coordinate then don't draw a line.
for dark in keypoints_dark: xd = int(dark.pt) #assigns x and y values and puts them as a coordinate yd = int(dark.pt) cd = (xd,yd) for light in keypoints_light: xl = int(light.pt) yl = int(light.pt) cl = (xl,yl) xa, ya = (xd+xl)/2, (yd+yl)/2 for vertices in C: point_1 = geometry.Point(xa,ya) vertex = geometry.Point(vertices,vertices)
In the code, light and dark are the lists for all the light and dark blobs, C is a list with all of the vertex coordinates so I'm running through all of the dark and light coordinate pairs, calculating the centre point between the two and I'm then trying to compare the centre coordinates to all of the vertex coordinates however I can't seem to figure out a way to say if the centre matches any one of the vertex, then end the loop.
Thanks in advance for any help!
Currently what I'm getting for the first image is this. Some of the blobs arent being recognised but I can sort that. The issue is, for example, on the left vertical edge there are two blue lines going over two of the vertices which I don't want.