# Is it possible to extract an array of the image intensities in Sitk?

**URL:** https://discourse.itk.org/t/is-it-possible-to-extract-an-array-of-the-image-intensities-in-sitk/5147
**Category:** Uncategorized
**Created:** [June 30, 2022, 2:36pm UTC](https://discourse.itk.org/t/is-it-possible-to-extract-an-array-of-the-image-intensities-in-sitk/5147 "2022-06-30T14:36:54Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![DushiFdo](https://discourse.itk.org/letter_avatar_proxy/v4/letter/d/c68b51/32.png) [@DushiFdo](https://discourse.itk.org/u/DushiFdo)
#### Post date: [June 30, 2022, 2:36pm UTC](https://discourse.itk.org/t/is-it-possible-to-extract-an-array-of-the-image-intensities-in-sitk/5147/1 "2022-06-30T14:36:54Z")

</div>

I am working with 3D images(300) of size (128x128x128). I want to extract the image area/an array of the image intensities (remove the background), do some transformation, and plug the transformed image intensities back on the original image (so that it has the same shape as before 128x128x128). Is it possible to do this with sitk?

---

<div class="post-metadata">

### Author: ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)
#### Post date: [June 30, 2022, 3:44pm UTC](https://discourse.itk.org/t/is-it-possible-to-extract-an-array-of-the-image-intensities-in-sitk/5147/2 "2022-06-30T15:44:32Z")

</div>

Generally speaking, yes. As always, this depends on what exactly you want to do.

Example below adds 100 to all foreground pixels (foreground obtained via Otsu thresholding):

```auto
import SimpleITK as sitk

file_name = "training_001_ct.mha"
image = sitk.ReadImage(file_name)
mask = sitk.Cast(sitk.OtsuThreshold(image, 0, 1), image.GetPixelID())

sitk.Show(image, "original")
sitk.Show(image + mask*100, "adding 100 to foreground")

```
