Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -71,7 +71,7 @@ F neighbours_tuple(x, y, image)
F transitions(neighbours)
V s = 0
L(i) 7
L(i) 0.<7
s += Int((neighbours[i], neighbours[i + 1]) == (0, 1))
R s + Int((neighbours[7], neighbours[0]) == (0, 1))

View file

@ -3,7 +3,7 @@ import system'routines;
import extensions;
import extensions'routines;
const string[] image = new string[]{
const string[] image = new []{
" ",
" ################# ############# ",
" ################## ################ ",
@ -50,7 +50,7 @@ extension zhangsuenOp : Matrix<CharValue>
if(self.numTransitions(r,c) != 1)
{ ^ false };
ifnot (self.atLeastOneIsWhite(r,c,firstStep.iif(0,1)))
if:not (self.atLeastOneIsWhite(r,c,firstStep.iif(0,1)))
{ ^ false };
toWhite.append(new { x = c; y = r; });
@ -100,7 +100,7 @@ extension zhangsuenOp : Matrix<CharValue>
var nbr := nbrs[group[i][j]];
if (self[r + nbr[1]][c + nbr[0]] == $32)
{ count := count + 1; $break; };
{ count := count + 1; :break; };
}
};
@ -136,17 +136,17 @@ extension zhangsuenOp : Matrix<CharValue>
{
var it := self.enumerator();
it.forEach::(ch){ console.print(ch," ") };
it.forEach::(ch){ Console.print(ch," ") };
while (it.next())
{
console.writeLine();
Console.writeLine();
it.forEach::(ch){ console.print(ch," ") }
it.forEach::(ch){ Console.print(ch," ") }
}
}
}
public program()
public Program()
{
Matrix<CharValue> grid := class Matrix<CharValue>.load(new
{
@ -162,5 +162,5 @@ public program()
grid.print();
console.readChar()
Console.readChar()
}

View file

@ -1,16 +1,36 @@
const pixelstring =
"00000000000000000000000000000000" *
"01111111110000000111111110000000" *
"01110001111000001111001111000000" *
"01110000111000001110000111000000" *
"01110001111000001110000000000000" *
"01111111110000001110000000000000" *
"01110111100000001110000111000000" *
"01110011110011101111001111011100" *
"01110001111011100111111110011100" *
"00000000000000000000000000000000"
const pixels = reshape([UInt8(c- 48) for c in pixelstring], (32,10))'
const rc01 = """
00000000000000000000000000000000
01111111110000000111111110000000
01110001111000001111001111000000
01110000111000001110000111000000
01110001111000001110000000000000
01111111110000001110000000000000
01110111100000001110000111000000
01110011110011101111001111011100
01110001111011100111111110011100
00000000000000000000000000000000"""
const pixels1 = map(c -> c == '1', stack([collect(line) for line in split(rc01, "\n") if !isempty(line)], dims = 1))
const rc02 = """
00000000000000000000000000000000000000000000000000000000000
01111111111111111100000000000000000001111111111111000000000
01111111111111111110000000000000001111111111111111000000000
01111111111111111111000000000000111111111111111111000000000
01111111100000111111100000000001111111111111111111000000000
00011111100000111111100000000011111110000000111111000000000
00011111100000111111100000000111111100000000000000000000000
00011111111111111111000000000111111100000000000000000000000
00011111111111111110000000000111111100000000000000000000000
00011111111111111111000000000111111100000000000000000000000
00011111100000111111100000000111111100000000000000000000000
00011111100000111111100000000111111100000000000000000000000
00011111100000111111100000000011111110000000111111000000000
01111111100000111111100000000001111111111111111111000000000
01111111100000111111101111110000111111111111111111011111100
01111111100000111111101111110000001111111111111111011111100
01111111100000111111101111110000000001111111111111011111100
00000000000000000000000000000000000000000000000000000000000"""
const pixels2 = map(c -> c == '1', stack([collect(line) for line in split(rc02, "\n") if !isempty(line)], dims = 1))
function surroundtesting(px, i, j, step)
if px[i,j] == 0
@ -20,7 +40,7 @@ function surroundtesting(px, i, j, step)
if i < 1 || j < 1 || i == isize || j == jsize # criteria 0.both
return false
end
s = Array{Int,1}(9)
s = zeros(Int, 9)
s[1] = s[9] = px[i-1,j]; s[2] = px[i-1,j+1]; s[3] = px[i,j+1]; s[4] = px[i+1,j+1]
s[5] = px[i+1,j]; s[6] = px[i+1,j-1]; s[7] = px[i,j-1]; s[8] = px[i-1,j-1]
b = sum(s[1:8])
@ -41,7 +61,7 @@ function surroundtesting(px, i, j, step)
end
function zsthinning(mat)
function zsthinning(mat; verbose = false)
retmat = copy(mat)
testmat = zeros(Int, size(mat))
isize, jsize = size(testmat)
@ -49,7 +69,7 @@ function zsthinning(mat)
loops = 0
while(needredo)
loops += 1
println("loop number $loops")
verbose && println("loop number $loops")
needredo = false
for n in 1:2
for i in 1:isize, j in 1:jsize
@ -73,5 +93,5 @@ function asciiprint(mat)
end
end
asciiprint(zsthinning(pixels))
asciiprint(zsthinning(pixels1, verbose = true))
asciiprint(zsthinning(pixels2))