Zhang-Suen thinning algorithm: Difference between revisions

→‎{{header|Ruby}}: added comment pointing to incorrect line
(→‎{{header|Ruby}}: Marked incorrect)
(→‎{{header|Ruby}}: added comment pointing to incorrect line)
Line 694:
 
def zs(ng,g)
# The following line cannot be correct; each of the 4 directions must be ignored in
# one of the triples, and [1][2], [0][1], [2][1], and [1][0] are never ignored.
return 0 if ng[1][1] == 0 or (ng[1][2] + ng[0][1] + ng[1+g][g]) == 3 or (ng[g][1+g] + ng[2][1] + ng[1][0]) == 3
t = -1; ng.each{|n| n.each{|g| t+=g}}; return 0 unless (2 <= t and t <= 6)
Anonymous user