Can we run itk in wasm without runPipeline?

My goal is to bring the MorphologicalContourInterpolator to wasm/web

  1. Is there a docker image available for itk that we can use to bring itk filters as WASM to the web? The kitware/vtk-wasm docker appears to be quite straightforward for vtk side. is there similar thing available for ITK?

  2. All the itk-wasm examples I’ve found rely on itk.runPipeline . In theory, a JavaScript bridge to WASM should be sufficient for executing WASM code. Are there ways to work with ITK-WASM filters without this dependency?

Any help is appreciated

Hi @sedghi ,

I went ahead and created the wasm build.

I am refining the tooling so the generation of a project is simply:

pnpm create itk-wasm
# answer a few questions
# add your C++ logic code
pnpm install
pnpm build
pnpm test

and there is:

  • C++ easily developed and debugged with native binary tools
  • Emscripten and WASI builds based on docker images
  • Shared C++ and WASI CTest testing
  • TypeScript / JavaScript binding
  • TypeScript / JavaScript packages
  • TypeScript / JavaScript documentation
  • JavaScript ESM bundles for no-code / low-code development
  • Python bindings
  • Python packages
  • Python documentation
  • Test drivers

Testing of this will be appreciated. More documentation updates are in progress.

We generate idiomatic JavaScript and Python. Here is the JavaScript interface:


Interpolates contours between slices.

async function morphologicalContourInterpolation(
  inputImage: Image,
  options: MorphologicalContourInterpolationOptions = {}
) : Promise<MorphologicalContourInterpolationResult>
Parameter Type Description
inputImage Image The input image

MorphologicalContourInterpolationOptions interface:

Property Type Description
label number The label to interpolate. Interpolates all labels if set to 0 (default).
axis number Interpolate only along this axis. Interpolates along all axes if set to -1 (default).
noHeuristicAlignment boolean Heuristic alignment of regions for interpolation is faster than optimal alignment.
noUseDistanceTransform boolean Using distance transform instead of repeated dilations to calculate the median contour is slightly faster, but produces lower quality interpolations.
useCustomSlicePositions boolean Use custom slice positions (not slice auto-detection).
noUseExtrapolation boolean Perform extrapolation for branch extremities. Branch extremities are defined as regions having no overlap with any region in the next slice. Extrapolation helps generate smooth surface closings.
useBallStructuringElement boolean Use ball instead of default cross structuring element for repeated dilations.
labeledSliceIndicesAxis number Axis along which the labeled slice indices are defined. Default is -1 (that is, auto-detection).
labeledSliceIndicesLabel number Label of the slice indices. Default is 1.
labeledSliceIndices number[] List of labeled slice indices. Default is empty.
webWorker null or Worker or boolean WebWorker for computation. Set to null to create a new worker. Or, pass an existing worker. Or, set to false to run in the current thread / worker.
noCopy boolean When SharedArrayBuffer’s are not available, do not copy inputs.

MorphologicalContourInterpolationResult interface:

Property Type Description
outputImage Image The output image
webWorker Worker WebWorker used for computation.


Set base URL for WebAssembly assets when vendored.

function setPipelinesBaseUrl(
  baseUrl: string | URL
) : void

This is awesome!
Thanks a lot. I will test it out.

1 Like