# Multiprocessing LabelMap

**URL:** https://discourse.itk.org/t/multiprocessing-labelmap/6339
**Category:** Beginner Questions
**Tags:** threads, multiprocessing
**Created:** [December 5, 2023, 6:39pm UTC](https://discourse.itk.org/t/multiprocessing-labelmap/6339 "2023-12-05T18:39:50Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![chlee](https://discourse.itk.org/user_avatar/discourse.itk.org/chlee/32/3788_2.png) [@chlee](https://discourse.itk.org/u/chlee)
#### Post date: [December 5, 2023, 6:39pm UTC](https://discourse.itk.org/t/multiprocessing-labelmap/6339/1 "2023-12-05T18:39:50Z")

</div>

Dear ITK community,

I am dealing with LabelMap, where for each label (and corresponding main image) I want to do image operations, say otsu-thresholding and subsequent filtering to obtain a blob (in itself a label - there can be multiple labels). I have made a code which iterates over each label objects to do this, but my image has thousands of labels and with a single thread it takes too long time to be feasible. I wonder whether multi-threading this by distributing labelled objects to separate threads could significantly make it faster. Is there any example that I can refer to build a code that processes individual labelled objects? Or any suggestions what the best way to deal such situation welcome. Thank you for your help.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [December 5, 2023, 9:39pm UTC](https://discourse.itk.org/t/multiprocessing-labelmap/6339/2 "2023-12-05T21:39:20Z")

</div>

You could take a look at [instances of ParallelizeArray](https://github.com/search?q=repo%3AInsightSoftwareConsortium%2FITK%20parallelizearray&type=code) to see how it is invoked. You could also deep dive into one particular refactoring e.g. [this one](https://github.com/InsightSoftwareConsortium/ITK/commit/b1ffefe79a13fa72e457c0193367af8a036d001c).
