Suppose you have an arbitrary black and white image, consider the following ones as an example:
........... ...........
........... ...........
........... ...........
.OOO...O... ...........
X...O.O.OOY XOOO...OOOY
.....O..... ...........
........... ...........
........... ...........
........... ...........
Where "."
represent black pixels, "O"
, "X"
, "Y"
represent white pixels
The left picture's X
and Y
pixels are interconnected between themselves along the path of O
's (in terms of Moore's neighbourhood). While on the right picture X
and Y
pixels are disconnected. By having an arbitrary black and white image, I need highly performant algorithm that will answer the question whether some group of pixels is connected to another group of pixels. I'm pretty sure that there has to be well-developed solution to this problem, since the problem looks common, but I can't seem to find one that would suite me. And by the way I'm aware of Flood Fill algorithm but currently I'm not considering it, since it does more job than it is required to answer the initial question.
I would appreciate reference to any info in subject direction,
P.S.
Just in case you have the answer the original question, maybe you might have answer to the following:
...........
...........
...........
.OOO...O...
X...O.O.OOY
.....O.....
..........Z
..........U
..........V
It would be also great (but not required) could answer the initial question in the following form:
Pixel X
is connected to pixel Y
,
Pixel X
is not connected to pixel Z
,
Pixel X
is not connected to pixel U
,
Pixel X
is not connected to pixel V
,
Thank you in advance!