Zhang-Suen thinning algorithm: Difference between revisions
Content added Content deleted
Line 697: | Line 697: | ||
end |
end |
||
</lang> |
</lang> |
||
zs may be used: See [[Zhang-Suen thinning algorithm/smallRC.csv]] for the input file contents. |
|||
<lang ruby> |
|||
s2.each{|row| row.each{|col| print(col==1? "#": " ")}; print("\n")} |
|||
while @r == 1 |
|||
@r = 0 |
|||
(1...s2.length-1).each{|n| (1...s2[0].length-1).each{|g| s1[n][g] = s2[n][g] - zs(s2[n-1..n+1].collect{|n| n[g-1..g+1]},0)}} |
|||
(1...s2.length-1).each{|n| (1...s2[0].length-1).each{|g| s2[n][g] = s1[n][g] - zs(s1[n-1..n+1].collect{|n| n[g-1..g+1]},1)}} |
|||
end |
|||
s2.each{|row| row.each{|col| print(col==1? "#": " ")}; print("\n")} |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
######### ######## |
|||
### #### #### #### |
|||
### ### ### ### |
|||
### #### ### |
|||
######### ### |
|||
### #### ### ### |
|||
### #### ### #### #### ### |
|||
### #### ### ######## ### |
|||
##### #### |
|||
# # # ## |
|||
# # # |
|||
# # # |
|||
#### # # |
|||
# ## # |
|||
# # # |
|||
# # ###### # |
|||
</pre> |
|||
To reproduce the output described in the task description it is necessary to call zs first with g=1 (though either way produces a valid thinned output): See [[Zhang-Suen thinning algorithm/bigRC.csv]] for the input file contents |
To reproduce the output described in the task description it is necessary to call zs first with g=1 (though either way produces a valid thinned output): See [[Zhang-Suen thinning algorithm/bigRC.csv]] for the input file contents |