Segmenting a Double Array of Tags

Problem:

I have a large double (2d) array filled with various shortcuts. Each element (cell) in a double array contains a set of labels, and some elements in a double array may be empty. I need an algorithm to cluster elements in a double array into discrete segments. A segment is defined as a set of pixels that are adjacent within a double array, and one label that has all of these pixels in the segment. (Diagonal adjacency is not taken into account, and I do not cluster empty cells).

|-------|-------|-------|
| Jane  | Joe   |       |
| Jack  | Jane  |       |
|-------|-------|-------|
| Jane  | Jane  |       |
|       | Joe   |       |
|-------|-------|-------|
|       | Jack  | Jane  |
|       | Joe   |       |
|-------|-------|-------|

In the above arrangement of labels, distributed across nine elements, the largest cluster is the Jane cluster, which occupies the four upper left cells.

What I thought:

, , . , . / , .

, , . , , . - , .

:

, , : . , , , .

, , , . , , , , . , - , .

?

Edit:

- , . :

Segment 1 - Jane: (1,3), (2,3), (1,2), (2,2)
Segment 2 - Joe: (2,3), (2,2), (2,1)
+3
1

- , , , - ; .

, .

, , , . , , .

"", "".

, ,

for each pixel in the image
  for each label in the pixel
    1. remove the label
    2. mark the current pixel
    3. for each marked pixel, look in every adjacent pixel for the label
    4. remove any labels found
    5. if labels are found, clear marks, and mark the newly label-removed pixels
    6. if anything is marked, go back to 3
    7. report the set of points where you removed labels

, . ( , , , ).

+2

Source: https://habr.com/ru/post/1749866/


All Articles