1 | initial version |
Write a method that works like Breadth-first search and does the following: It starts on a position in the image. Put that position in a list. Then in a loop, do the following: Get and remove the point at the beginning of the list and make it black in the current image so it won't be added again. Put that point in another list (this is the list that you want). Look at every point around your position and if it is not black, add it to the beginning of the list. Then start the loop again.
Of course, when using this you have to make your junction point, otherwise it will traverse every point in the image. So you start the method on every point around your junction and get three lists.