Initial commit
This commit is contained in:
commit
d5c932d8e1
710 changed files with 50282 additions and 0 deletions
23
.tmp_axprobe/band.swift
Executable file
23
.tmp_axprobe/band.swift
Executable file
|
|
@ -0,0 +1,23 @@
|
|||
import Foundation
|
||||
let data = try! Data(contentsOf: URL(fileURLWithPath: "shot.bmp"))
|
||||
let pixOff = data.withUnsafeBytes { $0.load(fromByteOffset: 10, as: UInt32.self) }
|
||||
let w = Int(data.withUnsafeBytes { $0.load(fromByteOffset: 18, as: Int32.self) })
|
||||
let hRaw = Int(data.withUnsafeBytes { $0.load(fromByteOffset: 22, as: Int32.self) }); let h = abs(hRaw)
|
||||
let B = Int(data.withUnsafeBytes { $0.load(fromByteOffset: 28, as: UInt16.self) })/8
|
||||
let rowBytes = (B * w + 3) & ~3
|
||||
var cols: [Int] = Array(repeating: 0, count: w)
|
||||
for y in 365...400 {
|
||||
let rowStart = Int(pixOff) + (hRaw > 0 ? (h-1-y) : y) * rowBytes
|
||||
for x in 0..<w {
|
||||
let i = rowStart + x * B
|
||||
let b = Int(data[i]), g = Int(data[i+1]), r = Int(data[i+2])
|
||||
if b > 120 && b > r + 30 && b > g + 15 && r < 160 { cols[x] += 1 }
|
||||
}
|
||||
}
|
||||
var runs: [(Int,Int)] = []
|
||||
var s = -1
|
||||
for x in 0..<w {
|
||||
if cols[x] > 3 && s < 0 { s = x }
|
||||
if (cols[x] <= 3 || x == w-1) && s >= 0 { runs.append((s,x)); s = -1 }
|
||||
}
|
||||
for r in runs { print("blue run x=\(r.0)-\(r.1) width=\(r.1-r.0) center=\((r.0+r.1)/2)") }
|
||||
Loading…
Reference in a new issue