Skip to main content
. 2024 Mar 19;9(3):185. doi: 10.3390/biomimetics9030185
Algorithm 2. ColorStep algorithm
Inputs: mapColor, mapData, clusterN, point, color; eps, s
Outputs: mapColor
i ← point.i
j ← point.j
e ← mapData.mainDirection(i, j)
e → direction: {[0, 1]; [1, 0]; [1, 1]; [−1, 1]}
tangent ← map(direction): {[1, 0]; [0, 1]; [−1, 1]; [1, 1]}
diag ← map(direction): {[1, 1] and [−1, 1]; [1, 0] and [0, 1]}
ptemp ← size (mapColor == s and mapData.cluster = color(clusterN))
ptemp ← ptemp/size(mapColor and mapData.cluster = color(clusterN))
β ← mapData.ellipticity(i, j)
p ← mapData. cluster(clusterN).meanPorosity
If |p(cluster) − ptemp|/ptemp > eps
        break
end if
If mapColor [(i,j) ± direction] ≠ s and mapData.cluster = color(clusterN) then
mapColor [(i,j) ± direction] += 1
else
        colorStep(mapColor, (i,j) ± direction, β, e, s)
end if
If mapColor [(i,j) ± tangent] ≠ s and mapData.cluster = color(clusterN) then
mapColor [(i,j) ± tangent] += β
else  break
        colorStep(mapColor, (i,j) ± tangent, β, e, s)
end if
If mapColor [(i,j) ± diag] ≠ s and mapData.cluster = color(clusterN) then
mapColor [(i,j) ± diag] += sqrt(2β2/(β2 + 1))
else
        colorStep(mapColor, (i,j) ± diag, β, e, s)
end if