// One selected executor and context are reused across native stages and runs.
import aner.image
import aner.parallel
import aner.tensor

let execution = parallel.local(workers: 1)
let work = image.context_with(execution: execution, memory_mb: 32)
let samples: Tensor = [[0.0, 0.0, 0.0, 0.0, 0.0],
    [0.0, 6.0, 6.0, 6.0, 0.0], [0.0, 6.0, 6.0, 6.0, 0.0],
    [0.0, 6.0, 6.0, 6.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0]]
let source = image.from_tensor(work, samples)
let analysis = image.pipeline(work).channel(0)
    .gaussian(sigma: 0.5).otsu().components(connectivity: 4)
let result = analysis.run(source)
let regions = result.regions(source)
print(result.labels().count())
print(regions.count())
print(regions.intensity_mean(0))
print(analysis.run(source).labels().count())
print(work.workers())
print(work.peak_bytes())
