Zhang-Suen thinning algorithm: Difference between revisions

→‎{{header|Python}}: FIx inverted Vertical axis in calculation of neighbours and add dots in toTxt().
(Improved D entry)
(→‎{{header|Python}}: FIx inverted Vertical axis in calculation of neighbours and add dots in toTxt().)
Line 401:
 
def toTxt(intmatrix):
'''Change a 2d list of lists of 1/0 ints into lines of '#' and ' .' chars'''
return '\n'.join(''.join(('#' if p else ' .') for p in row) for row in intmatrix)
 
def neighbours(x, y, image):
'''Return 8-neighbours of point p1 of picture, in order'''
i = image
x1, y1, x_1, y_1 = x+1, y+-1, x-1, y-+1
#print ((x,y))
return [i[y1][x], i[y1][x1], i[y][x1], i[y_1][x1], # P2,P3,P4,P5
Anonymous user