Zhang-Suen thinning algorithm: Difference between revisions
Content deleted Content added
→{{header|J}}: Improve clarity of phrasing |
→{{header|J}}: separate out explicit version |
||
Line 339: | Line 339: | ||
c13=: 0 e. 1 5 7&getPx |
c13=: 0 e. 1 5 7&getPx |
||
c14=: 0 e. 5 7 3&getPx |
c14=: 0 e. 5 7 3&getPx |
||
c23=: 0 e. 1 5 3&getPx NB. step2, condition 3 |
c23=: 0 e. 1 5 3&getPx NB. step2, condition 3 |
||
c24=: 0 e. 1 7 3&getPx |
c24=: 0 e. 1 7 3&getPx |
||
Line 347: | Line 346: | ||
whiten=: [ * -.@:*. NB. make black pixels white |
whiten=: [ * -.@:*. NB. make black pixels white |
||
zhangSuen=: [: toImage [: (whiten frameImg@(step2 neighbrs))@(whiten frameImg@(step1 neighbrs))^:_ isBlackPx |
zhangSuen=: [: toImage [: (whiten frameImg@(step2 neighbrs))@(whiten frameImg@(step1 neighbrs))^:_ isBlackPx</lang> |
||
'''Alternative, explicit representation of last verb above''' |
|||
zhangSuenX=: verb define |
<lang j>zhangSuenX=: verb define |
||
img=. isBlackPx y |
img=. isBlackPx y |
||
whilst. 0 < +/ , msk1 +.&-. msk2 do. |
whilst. 0 < +/ , msk1 +.&-. msk2 do. |
||
Line 358: | Line 357: | ||
end. |
end. |
||
toImage img |
toImage img |
||
⚫ | |||
) |
|||
⚫ | |||
'''Example Use:''' |
'''Example Use:''' |
||
<lang j>toASCII=: ' #' {~ '1'&=;._2 NB. convert to ASCII representation |
<lang j>toASCII=: ' #' {~ '1'&=;._2 NB. convert to ASCII representation |