Skip to content

Rust API

lucem is a set of Rust crates. To get the library through one dependency, use lucem, which re-exports lucem-core, lucem-io, lucem-ops and lucem-ml as modules. The crates are not on crates.io, so the pages here stand in for docs.rs: each lists every public function, type and method with its exact signature and documentation, generated from the code.

[dependencies]
lucem = { git = "https://github.com/neuro-kitchen/lucem", features = ["wgpu"] }
Crate What it is
lucem-core Device arrays and memory, shapes, compute targets (runtimes), tiling
lucem-io Reading and writing images: TIFF, OME-Zarr, pyramids, projects
lucem-ops Image operations on the device: filters, thresholds, morphology, segmentation, measurements
lucem-pipeline Pipelines as data: the operation catalog, the executor, tables
lucem-hist Histology: tissue, cells, classifiers, densities, the analysis engine and sessions
lucem-ml The model-plugin protocol: discovery, client, messages
lucem-hub Verified downloads of published artifacts (model weights)
Need Module Start with
Smooth, sharpen, find edges filter gaussian_blur, median_filter, sobel, frangi
Turn an image into a mask threshold otsu, sauvola, hysteresis_threshold
Clean up masks morphology binary_open, remove_small_objects, remove_small_holes
Split touching objects segment watershed, slic, expand_labels
Measure objects measure label_components, region_features, pearson_r
Contrast and exposure intensity rescale_range, clahe, equalize_hist
Separate stains color unmix_stains
Remove background, denoise restore rolling_ball, tv_chambolle, bilateral
Find spots and features feature local_peaks, blobs_log, canny
Warp, resize, pyramids transform affine_warp, resize, gaussian_pyramid
Align images register phase_correlation
Compare results metric ssim, psnr, adapted_rand
Tables of measurements analytics regions_to_dataframe
  • A client first. Functions on the device take a CubeCL Client: ComputeTarget::from_env()?.client()? picks the runtime named by LUCEM_RUNTIME (wgpu, cpu, cuda, hip), or else the first one compiled in.
  • Data on the device. Images are DeviceArray<F> with a Shape ([y, x] or [z, y, x], row-major). DeviceArray::from_host uploads, to_host reads back; nothing moves between host and device unless a function says so.
  • Three forms of an operation. op returns a new array; op_into writes into an output you pass (no allocation, for loops and pipelines); op_device keeps a scalar result on the device (otsu_device) where op reads it back (otsu).
  • Errors are OpsResult<T> (lucem-ops), CoreResult<T> (lucem-core) and HistResult<T> (lucem-hist); shapes are checked before any kernel runs.
  • The same operations by name. A pipeline (lucem-pipeline), the app and lucem run call these functions through the operation catalog.