# Filter to get data around a point

**URL:** https://discourse.itk.org/t/filter-to-get-data-around-a-point/3141
**Category:** Beginner Questions
**Tags:** simpleitk
**Created:** [June 2, 2020, 2:58pm UTC](https://discourse.itk.org/t/filter-to-get-data-around-a-point/3141 "2020-06-02T14:58:55Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![flaviu2](https://discourse.itk.org/letter_avatar_proxy/v4/letter/f/74df32/32.png) [@flaviu2](https://discourse.itk.org/u/flaviu2)
#### Post date: [June 2, 2020, 2:58pm UTC](https://discourse.itk.org/t/filter-to-get-data-around-a-point/3141/1 "2020-06-02T14:58:55Z")

</div>

Which **ITK/SimpleITK** filter can cut down a bit of volume and let the rest as it is ? To be more specific: user choose a point, 3d point. And I am intend to use this point into a filter that will make a hole around that point plus minus, let say, 20 pixels. Is there any filter that can do that ?

I read all SimpleITK filter: [https://simpleitk.readthedocs.io/en/master/filters.html](https://simpleitk.readthedocs.io/en/master/filters.html)

but I don’t know what filter does like this. Can you guide me a little bit ?

---

<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 2, 2020, 4:01pm UTC](https://discourse.itk.org/t/filter-to-get-data-around-a-point/3141/2 "2020-06-02T16:01:51Z")

</div>

It is unclear what “make a hole around that point…” means. Do you just want to set the pixels/voxels around that voxel to 0, or -1000 (HU value for air)? Why do you need a filter to do this, instead of directly assigning the values as shown below?

```auto
import SimpleITK as sitk

img = sitk.Image([256,256,30], sitk.sitkInt16)
index = [40,30,20]
print(img[index])
img[index] = -1000
print(img[index])

```

---

<div class="post-metadata">

### Author: ![flaviu2](https://discourse.itk.org/letter_avatar_proxy/v4/letter/f/74df32/32.png) [@flaviu2](https://discourse.itk.org/u/flaviu2)
#### Post date: [June 2, 2020, 4:36pm UTC](https://discourse.itk.org/t/filter-to-get-data-around-a-point/3141/3 "2020-06-02T16:36:57Z")

</div>

It’s a starting point tough …

> [@zivy](#):
>
> `40,30,20`

So, if I go around that 3d point with 20 pixels, and setup Image values to 0, is kind of what I need (for the moment) … but as long I don’t know Python, can you tell me how to access _img[40,30,20]_ in C++ ? I didn’t saw any operator here: [SimpleITK: sitkImageOperators.h Source File](https://simpleitk.org/doxygen/latest/html/sitkImageOperators_8h_source.html)

---

<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: [June 2, 2020, 5:34pm UTC](https://discourse.itk.org/t/filter-to-get-data-around-a-point/3141/4 "2020-06-02T17:34:24Z")

</div>

[Using an iterator](https://itk.org/ITKExamples/src/Core/Common/IterateRegionWithWriteAccess/Documentation.html) is the way to go for what you want. For setting value of just one pixel in C++: `img->SetPixel(index,-1000);`

---

<div class="post-metadata">

### Author: ![flaviu2](https://discourse.itk.org/letter_avatar_proxy/v4/letter/f/74df32/32.png) [@flaviu2](https://discourse.itk.org/u/flaviu2)
#### Post date: [June 2, 2020, 6:30pm UTC](https://discourse.itk.org/t/filter-to-get-data-around-a-point/3141/5 "2020-06-02T18:30:21Z")

</div>

In order to avoid translating _SimpleITK to ITK_, is there any way to use an iterator in _SimpleITK only_ ? Or, a way to access that _img[40, 30, 20]_ in _SimpleITK_ ?

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [June 2, 2020, 6:40pm UTC](https://discourse.itk.org/t/filter-to-get-data-around-a-point/3141/6 "2020-06-02T18:40:22Z")

</div>

[https://simpleitk.org/doxygen/latest/html/classitk\_1\_1simple\_1\_1Image.html](https://simpleitk.org/doxygen/latest/html/classitk_1_1simple_1_1Image.html)

---

<div class="post-metadata">

### Author: ![flaviu2](https://discourse.itk.org/letter_avatar_proxy/v4/letter/f/74df32/32.png) [@flaviu2](https://discourse.itk.org/u/flaviu2)
#### Post date: [June 3, 2020, 6:57am UTC](https://discourse.itk.org/t/filter-to-get-data-around-a-point/3141/7 "2020-06-03T06:57:09Z")

</div>

Ahh, is obvious. Thank you.
