Zhang-Suen thinning algorithm: Difference between revisions
Content added Content deleted
(Dialects of BASIC moved to the BASIC section.) |
imported>Arakov |
||
Line 1,684: | Line 1,684: | ||
=={{header|Elena}}== |
=={{header|Elena}}== |
||
ELENA |
ELENA 6.x : |
||
{{trans|Java}} |
{{trans|Java}} |
||
<syntaxhighlight lang="elena">import system'collections; |
<syntaxhighlight lang="elena">import system'collections; |
||
Line 1,711: | Line 1,711: | ||
" "}; |
" "}; |
||
int[][] nbrs = new int[][] |
static int[][] nbrs = new int[][] |
||
{ |
{ |
||
new int[]{0, -1}, new int[]{1, -1}, new int[]{1, 0}, new int[]{1, 1}, new int[]{0, 1}, |
new int[]{0, -1}, new int[]{1, -1}, new int[]{1, 0}, new int[]{1, 1}, new int[]{0, 1}, |
||
Line 1,717: | Line 1,717: | ||
}; |
}; |
||
int[][][] nbrGroups = new int[][][] |
static int[][][] nbrGroups = new int[][][] |
||
{ |
{ |
||
new int[][]{new int[]{0, 2, 4}, new int[]{2, 4, 6}}, |
new int[][]{new int[]{0, 2, 4}, new int[]{2, 4, 6}}, |
||
Line 1,750: | Line 1,750: | ||
int count := 0; |
int count := 0; |
||
for (int i := 0, i < nbrs.Length, i += 1) |
for (int i := 0, i < nbrs.Length - 1, i += 1) |
||
{ |
{ |
||
if (self[r + nbrs[i][1]][c + nbrs[i][0]] == $35) |
if (self[r + nbrs[i][1]][c + nbrs[i + 1][0]] == $35) |
||
{ count += 1 } |
{ count += 1 } |
||
}; |
}; |
||
Line 1,763: | Line 1,763: | ||
int count := 0; |
int count := 0; |
||
for (int i := 0, i < nbrs.Length, i += 1) |
for (int i := 0, i < nbrs.Length - 1, i += 1) |
||
{ |
{ |
||
if (self[r + nbrs[i][1]][c + nbrs[i][0]] == $32) |
if (self[r + nbrs[i][1]][c + nbrs[i][0]] == $32) |
||
Line 1,781: | Line 1,781: | ||
int count := 0; |
int count := 0; |
||
var group := nbrGroups[step]; |
var group := nbrGroups[step]; |
||
for(int i := 0, i < |
for(int i := 0, i < 2, i += 1) |
||
{ |
{ |
||
for(int j := 0, j < group[i].Length, j += 1) |
for(int j := 0, j < group[i].Length, j += 1) |
||
Line 1,788: | Line 1,788: | ||
if (self[r + nbr[1]][c + nbr[0]] == $32) |
if (self[r + nbr[1]][c + nbr[0]] == $32) |
||
{ count := count + 1; |
{ count := count + 1; $break; }; |
||
^ false |
|||
} |
} |
||
}; |
}; |
||
Line 1,808: | Line 1,806: | ||
firstStep := firstStep.Inverted; |
firstStep := firstStep.Inverted; |
||
for(int r := 1, r < self.Rows, r += 1) |
for(int r := 1, r < self.Rows - 1, r += 1) |
||
{ |
{ |
||
for(int c := 1, c < self.Columns, c += 1) |
for(int c := 1, c < self.Columns - 1, c += 1) |
||
{ |
{ |
||
if(self.proceed(r,c,toWhite,firstStep)) |
if(self.proceed(r,c,toWhite,firstStep)) |
||
Line 1,858: | Line 1,856: | ||
# # # # # # # # # # # # # # # # # # # |
|||
# # |
# # # # # # # # |
||
# # # # |
# # # # |
||
⚫ | |||
# # # |
# # # |
||
# |
# # # # # |
||
# |
# # # # # # # # # # # |
||
# # # |
|||
⚫ | |||
# # # |
# # # |
||
# # # |
# # # |
||
# # # |
# # # |
||
# # # |
# # # |
||
# # # # # # # # # # # # |
|||
# # # # # # |
# # # # # # |
||