# how to assign value to small region in a big image?

**URL:** <https://discourse.itk.org/t/how-to-assign-value-to-small-region-in-a-big-image/5950>\
**Category:** Beginner Questions\
**Created:** [May 17, 2023, 9:22am UTC](https://discourse.itk.org/t/how-to-assign-value-to-small-region-in-a-big-image/5950 "2023-05-17T09:22:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zx-lhb](https://discourse.itk.org/user_avatar/discourse.itk.org/zx-lhb/32/3082_2.png) [@zx-lhb](https://discourse.itk.org/u/zx-lhb)\
**Post date:** [May 17, 2023, 9:22am UTC](https://discourse.itk.org/t/how-to-assign-value-to-small-region-in-a-big-image/5950/1 "2023-05-17T09:22:10Z")

</div>

hi, i have a image buffer pointer, whose size is : [64,64,64], now I want to assign the buffer values to start [0,0,64] to end [63,63, 127] in a big image whose size is [256,256,103]. Is there any filter can do this? Thank you!

---

<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:** [May 17, 2023, 1:45pm UTC](https://discourse.itk.org/t/how-to-assign-value-to-small-region-in-a-big-image/5950/2 "2023-05-17T13:45:03Z")

</div>

That would be [PasteImageFilter](https://itk.org/Doxygen/html/classitk_1_1PasteImageFilter.html).

---

<div class="post-metadata">

**Author:** ![zx-lhb](https://discourse.itk.org/user_avatar/discourse.itk.org/zx-lhb/32/3082_2.png) [@zx-lhb](https://discourse.itk.org/u/zx-lhb)\
**Post date:** [May 18, 2023, 6:33am UTC](https://discourse.itk.org/t/how-to-assign-value-to-small-region-in-a-big-image/5950/3 "2023-05-18T06:33:42Z")

</div>

Thank you! it worked perfectly!

---

<div class="post-metadata">

**Author:** ![dchen](https://discourse.itk.org/user_avatar/discourse.itk.org/dchen/32/34_2.png) [@dchen](https://discourse.itk.org/u/dchen)\
**Post date:** [May 18, 2023, 6:32pm UTC](https://discourse.itk.org/t/how-to-assign-value-to-small-region-in-a-big-image/5950/4 "2023-05-18T18:32:37Z")

</div>

With SimpleITK you can set a sub-region like this:

```auto

import SimpleITK as sitk

img = sitk.Image(100,100,sitk.sitkUInt8)

img[20:40,20:40] = 255

```

That creates a black image, an then sets a square within it to white.

---

<div class="post-metadata">

**Author:** ![zx-lhb](https://discourse.itk.org/user_avatar/discourse.itk.org/zx-lhb/32/3082_2.png) [@zx-lhb](https://discourse.itk.org/u/zx-lhb)\
**Post date:** [May 19, 2023, 1:15am UTC](https://discourse.itk.org/t/how-to-assign-value-to-small-region-in-a-big-image/5950/5 "2023-05-19T01:15:17Z")

</div>

Thank you! And yes, numpy array makes it convient in python. I have solved my problem in c++, thank you anyway.
