# Texture for all objects with labeled images

**URL:** https://discourse.itk.org/t/texture-for-all-objects-with-labeled-images/4554
**Category:** Uncategorized
**Created:** [November 5, 2021, 2:54pm UTC](https://discourse.itk.org/t/texture-for-all-objects-with-labeled-images/4554 "2021-11-05T14:54:30Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![emmenlau](https://discourse.itk.org/letter_avatar_proxy/v4/letter/e/8c91f0/32.png) [@emmenlau](https://discourse.itk.org/u/emmenlau)
#### Post date: [November 5, 2021, 2:54pm UTC](https://discourse.itk.org/t/texture-for-all-objects-with-labeled-images/4554/1 "2021-11-05T14:54:30Z")

</div>

I would like to compute texture statistics on a gray value image, but separately for image regions that are given in a separate label image. Basically the same as `itk::LabelStatisticsImageFilter<RawImage, LabelImage>` does, but for texture.

Does that exist? Or is there a typical workflow how to do that in ITK? I could not find a ready-made module that would take a `LabelImage`. The `itk::Statistics::ScalarImageToTextureFeaturesFilter` seems useful but takes only a mask, not a label image. Are there other ways to achieve that, without having to iterate over all the labels individually?

---

<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: [November 5, 2021, 3:50pm UTC](https://discourse.itk.org/t/texture-for-all-objects-with-labeled-images/4554/2 "2021-11-05T15:50:01Z")

</div>

> [@emmenlau](#):
>
> without having to iterate over all the labels individually?

I highly doubt that. Iterating over labels sounds like your best bet.

---

<div class="post-metadata">

### Author: ![emmenlau](https://discourse.itk.org/letter_avatar_proxy/v4/letter/e/8c91f0/32.png) [@emmenlau](https://discourse.itk.org/u/emmenlau)
#### Post date: [November 7, 2021, 6:46pm UTC](https://discourse.itk.org/t/texture-for-all-objects-with-labeled-images/4554/3 "2021-11-07T18:46:34Z")

</div>

Thanks @dzenanz for the quick response! I’ll implement it with iteration over the objects then.

I guess its not too likely that someone would implement this with a single pass over the image? I understand that this comes with the problem that it may consume excessive memory for the many 2D histograms…

---

<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: [November 8, 2021, 2:41pm UTC](https://discourse.itk.org/t/texture-for-all-objects-with-labeled-images/4554/4 "2021-11-08T14:41:52Z")

</div>

I think that texture computation is demanding, and doing labels in parallel would not bring much, if any, improvement.

---

<div class="post-metadata">

### Author: ![emmenlau](https://discourse.itk.org/letter_avatar_proxy/v4/letter/e/8c91f0/32.png) [@emmenlau](https://discourse.itk.org/u/emmenlau)
#### Post date: [November 8, 2021, 2:56pm UTC](https://discourse.itk.org/t/texture-for-all-objects-with-labeled-images/4554/5 "2021-11-08T14:56:08Z")

</div>

Thanks again @dzenanz for the quick response!

My use case is that I have hundreds if not thousands of small segmented objects in an image. To create the textures I currently iterate the image thousands of times, every time creating a single texture. The simple iteration over the image adds up to a lot of runtime.

So I do not mean that ITK should create the texture measurements in parallel like in “multi-threaded parallel”. I mean it would already help a lot if a single pass over the image would be sufficient, even if internally ITK processes object after object sequentially.

Would something like that be possible, for example by extracting a temporary internal representation of the object intensities for each object?

---

<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: [November 8, 2021, 4:20pm UTC](https://discourse.itk.org/t/texture-for-all-objects-with-labeled-images/4554/6 "2021-11-08T16:20:29Z")

</div>

Does [CoocurrenceTextureFeaturesImageFilter](https://github.com/InsightSoftwareConsortium/ITKTextureFeatures/blob/master/include/itkCoocurrenceTextureFeaturesImageFilter.h) help you?

Could you compute the texture features for all of your object in one pass, then use `LabelStatisticsImageFilter` on that?

---

<div class="post-metadata">

### Author: ![emmenlau](https://discourse.itk.org/letter_avatar_proxy/v4/letter/e/8c91f0/32.png) [@emmenlau](https://discourse.itk.org/u/emmenlau)
#### Post date: [November 9, 2021, 9:53am UTC](https://discourse.itk.org/t/texture-for-all-objects-with-labeled-images/4554/7 "2021-11-09T09:53:54Z")

</div>

I will take a look at that! Its quite cool, maybe this is what I need. Thanks!
