Zhang-Suen thinning algorithm: Difference between revisions

m
Line 171:
R intmatrix.map(row -> row.map(p -> (I p {‘#’} E ‘.’)).join(‘’)).join("\n")
 
F neighbours_arrneighbours_array(x, y, image)
‘Return 8-neighbours of point p1 of picture, in order’
V i = image
Line 196:
L(y) 1 .< image.len - 1
L(x) 1 .< image[0].len - 1
V n = neighbours_arrneighbours_array(x, y, image)
V (P2, P3, P4, P5, P6, P7, P8, P9) = neighbours_tuple(x, y, image)
I (image[y][x] == 1 & P4 * P6 * P8 == 0 & P2 * P4 * P6 == 0 & transitions(n) == 1 & sum(n) C 2..6)
Line 205:
L(y) 1 .< image.len - 1
L(x) 1 .< image[0].len - 1
V n = neighbours_arrneighbours_array(x, y, image)
V (P2, P3, P4, P5, P6, P7, P8, P9) = neighbours_tuple(x, y, image)
I (image[y][x] == 1 & P2 * P6 * P8 == 0 & P2 * P4 * P8 == 0 & transitions(n) == 1 & sum(n) C 2..6)
1,480

edits