霍森-科佩尔曼算法霍森–科佩尔曼算法基于联合-查找算法,用于标记占据-非占据网格团簇。[1] 此算法最早由霍森和科佩尔曼在1976年的文章《Percolation and Cluster Distribution. I. Cluster Multiple Labeling Technique and Critical Concentration Algorithm》中提出。[2] 逾渗理论逾渗理论研究格点上团簇的行为和统计性质。设在一个正方格子中每个元胞占据概率为
霍森–科佩尔曼算法查找、 标记团簇霍森-科佩尔曼算法的主要步骤是:扫描格点、查找占据元胞并将其用其所属团簇的序号标记。扫描格点时逐行扫描,一行结束后从下一行开头继续扫描。扫描每一个元胞时,若元胞被占据,则根据其相邻的已标记所属团簇的元胞将其标记,具体的操作要使用联合-查找算法。如果元胞没有任何相邻的、被标记的占据元胞,那么就用一个新的记号标记之。[3] 联合-查找算法联合-查找算法是一种计算等价类的方法。 定义函数 伪代码扫描网格时,每扫到一个占据元胞,就要查看其相邻的所有元胞。若某相邻元胞被占据且已被扫过,那么就执行 Raster Scan and Labeling on the Grid largest_label = 0; for x in 0 to n_columns { for y in 0 to n_rows { if occupied[x,y] then left = occupied[x-1,y]; above = occupied[x,y-1]; 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. */ label[x,y] = largest_label; else if (left != 0) and (above == 0) then /* One neighbor, to the left. */ label[x,y] = find(left); else if (left == 0) and (above != 0) then /* One neighbor, above. */ label[x,y] = find(above); else /* Neighbors BOTH to the left and above. */ union(left,above); /* Link the left and above clusters. */ label[x,y] = find(left); } } Union void union(int x, int y) { labels[find(x)] = find(y); } Find int find(int x) { int y = x; while (labels[y] != y) y = labels[y]; while (labels[x] != x) { int z = labels[x]; labels[x] = y; x = z; } return y; } 应用参见参考文献
|
Portal di Ensiklopedia Dunia