Hoshen–Kopelman algorithm: Difference between revisions

Content deleted Content added
No edit summary
Changed "occupied" to "label", added clarification on on the "labels" array, different from the "label" array, which is the resulting array.
Line 30:
'''Raster Scan and Labeling on the Grid'''
largest_label = 0;
label = zeros[n_columns, n_rows]
labels = [0:n_columns*n_rows] /* Array containing integers from 0 to the size of the image. */
for x in 0 to n_columns {
for y in 0 to n_rows {
if occupied[x, y] then
left = occupiedlabel[x-1, y]; # Shouldn't this be label[x-1, y]
above = occupiedlabel[x, y-1]; # Same here?
if (left == 0) and (above == 0) then /* Neither a label above nor to the left. */
largest_label = largest_label + 1; /* Make a new, as-yet-unused cluster label. */