# Can we run itk in wasm without runPipeline?

**URL:** <https://discourse.itk.org/t/can-we-run-itk-in-wasm-without-runpipeline/6437>\
**Category:** Uncategorized\
**Tags:** itk\
**Created:** [February 12, 2024, 8:29pm UTC](https://discourse.itk.org/t/can-we-run-itk-in-wasm-without-runpipeline/6437 "2024-02-12T20:29:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sedghi](https://discourse.itk.org/user_avatar/discourse.itk.org/sedghi/32/317_2.png) [@sedghi](https://discourse.itk.org/u/sedghi)\
**Post date:** [February 12, 2024, 8:29pm UTC](https://discourse.itk.org/t/can-we-run-itk-in-wasm-without-runpipeline/6437/1 "2024-02-12T20:29:13Z")

</div>

My goal is to bring the [MorphologicalContourInterpolator](https://itk.org/Doxygen/html/classitk_1_1MorphologicalContourInterpolator.html) 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

---

<div class="post-metadata">

**Author:** ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)\
**Post date:** [February 15, 2024, 9:09pm UTC](https://discourse.itk.org/t/can-we-run-itk-in-wasm-without-runpipeline/6437/2 "2024-02-15T21:09:12Z")

</div>

Hi @sedghi ,

I went ahead and [created the wasm build](https://github.com/KitwareMedical/ITKMorphologicalContourInterpolation/pull/115).

- 👨‍💻 `Live API Demo` ✨
- 🕮 `Wasm Python Documentation` 📚
- 🕮 `JavaScript Documentation` 📚
- 📦 [`JavaScript Package`](https://www.npmjs.com/package/@itk-wasm/morphological-contour-interpolation)

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

```sh
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:

#### morphologicalContourInterpolation

_Interpolates contours between slices._

```ts
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. |

#### setPipelinesBaseUrl

_Set base URL for WebAssembly assets when vendored._

```ts
function setPipelinesBaseUrl(
  baseUrl: string | URL
) : void

```

---

<div class="post-metadata">

**Author:** ![sedghi](https://discourse.itk.org/user_avatar/discourse.itk.org/sedghi/32/317_2.png) [@sedghi](https://discourse.itk.org/u/sedghi)\
**Post date:** [February 16, 2024, 8:11pm UTC](https://discourse.itk.org/t/can-we-run-itk-in-wasm-without-runpipeline/6437/3 "2024-02-16T20:11:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![wayfarer3130](https://discourse.itk.org/user_avatar/discourse.itk.org/wayfarer3130/32/3942_2.png) [@wayfarer3130](https://discourse.itk.org/u/wayfarer3130)\
**Post date:** [March 11, 2024, 12:01pm UTC](https://discourse.itk.org/t/can-we-run-itk-in-wasm-without-runpipeline/6437/4 "2024-03-11T12:01:42Z")

</div>

Working with the interpolation library in Cornerstone. Was very easy to get running and start working with as soon as I figured out how to convert vtk images to itk (which fortunately I had an example for).
