# FastMarchingImageFilter for multiple-labels?

**URL:** <https://discourse.itk.org/t/fastmarchingimagefilter-for-multiple-labels/1446>\
**Category:** Algorithms\
**Created:** [November 29, 2018, 9:41am UTC](https://discourse.itk.org/t/fastmarchingimagefilter-for-multiple-labels/1446 "2018-11-29T09:41:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yannick\_s](https://discourse.itk.org/letter_avatar_proxy/v4/letter/y/f14d63/32.png) [@yannick\_s](https://discourse.itk.org/u/yannick_s)\
**Post date:** [November 29, 2018, 9:41am UTC](https://discourse.itk.org/t/fastmarchingimagefilter-for-multiple-labels/1446/1 "2018-11-29T09:41:15Z")

</div>

Dear all,

I would like to refine/vary a given multi-label segmentation with the multi-label fast marching algorithm. For a single label, I was able to use the FastMarchingImageFilter in python ITK.  
Is it possible to use this filter to a multi-label task? I could process the labels separately, but would like to enforce mutually exclusive labels.

For a single label I use:

```
NodeType = itk.LevelSetNode.F3
NodeContainer = itk.VectorContainer[itk.UI, NodeType]
container = NodeContainer.New()
container.Initialize()
for i,p in enumerate(seed4):
    node = NodeType()
    node.SetIndex(p.tolist())
    node.SetValue(0.0)
    container.InsertElement(i, node)

fm_filter = itk.FastMarchingImageFilter.IF3IF3.New(t1c, TrialPoints=container)

```

Best and thanks,  
Yannick

---

<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:** [December 3, 2018, 3:18pm UTC](https://discourse.itk.org/t/fastmarchingimagefilter-for-multiple-labels/1446/2 "2018-12-03T15:18:11Z")

</div>

Hi Yannick,

> I could process the labels separately, but would like to enforce mutually exclusive labels

One possible approach is to process the labels separately, then use [label voting](https://itk.org/Doxygen/html/group__ITKLabelVoting.html) on the result.

HTH,  
Matt

---

<div class="post-metadata">

**Author:** ![grothausmann.roman](https://discourse.itk.org/user_avatar/discourse.itk.org/grothausmann.roman/32/582_2.png) [@grothausmann.roman](https://discourse.itk.org/u/grothausmann.roman)\
**Post date:** [January 9, 2019, 11:57am UTC](https://discourse.itk.org/t/fastmarchingimagefilter-for-multiple-labels/1446/3 "2019-01-09T11:57:32Z")

</div>

Depending on your problem, you could make the multi labels binary, run FM once and then the morphological watershed on the FM map with the original labels as seeds. Would that work for you?
