Finding intercepts between colored segments


I have a bit of a compelx/odd request and I am not sure even where to begin. I have some images, each with two sets of colored segments, red-oranges and purples. For every orange segment I’d like to do the following:

  • find the RGB value of the segment
  • find the nearest segment in the purple set
  • draw a line between their respective centers of mass
  • find the angle between this line and the x-axis
  • find the x,y coordinate where this line crosses the border of the orange segment
  • print the RGB, angle, x, and y data into a .csv

Here’s an example:

Any help with this would be greatly appreciated. Thanks in advance!

  • AhD