All examplesImages Install Aner
Read and write typed image files
Inspect image headers and round trip an explicitly supported numeric format without overwriting files.
// Run in a fresh writable directory: native image saving refuses an existing path.
import aner.image
import aner.tensor
let work = image.context(workers: 1, memory_mb: 32)
let samples: Tensor = [[0.0, 1024.0, 60000.0], [7.0, 500.0, 65535.0]]
let source = image.from_tensor(work, samples, dtype: "UInt16")
source.save("image-roundtrip.pgm")
let info = image.inspect(work, "image-roundtrip.pgm")
print(info.width())
print(info.height())
print(info.dtype())
print(info.pages())
let restored = image.load(work, "image-roundtrip.pgm")
print(restored.sample(2, 1))
let region = image.load_region(work, "image-roundtrip.pgm", x: 1, y: 0, width: 2, height: 2)
print(region.sample(0, 0))
print(image.available("png"))
print(image.capabilities())
Make it your experiment.
Use Aner 0.1.0 or newer. Save this program as examples/image_files.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.
aner check examples/image_files.aner
aner run examples/image_files.anerThe aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.
Requires Aner 0.1.0 or newer. CPU image analysis and binary PNM work without optional image codecs. PNG, JPEG and TIFF require their compiled capabilities. Use a fresh writable directory for outputs.
aner check examples/image_files.aner
aner run examples/image_files.anerBundled datasets retain their own source attribution and license notices. Example outcomes are not comparative benchmarks or evidence of clinical validity.
Dataset sources & attribution