# Interpolate ITK image data at missing / masked pixels (CUDA / C++)

**URL:** https://discourse.itk.org/t/interpolate-itk-image-data-at-missing-masked-pixels-cuda-c/4363
**Category:** Algorithms
**Created:** [August 25, 2021, 2:29pm UTC](https://discourse.itk.org/t/interpolate-itk-image-data-at-missing-masked-pixels-cuda-c/4363 "2021-08-25T14:29:31Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Thibault\_Pelletier](https://discourse.itk.org/user_avatar/discourse.itk.org/thibault_pelletier/32/2235_2.png) [@Thibault\_Pelletier](https://discourse.itk.org/u/Thibault_Pelletier)
#### Post date: [August 25, 2021, 2:29pm UTC](https://discourse.itk.org/t/interpolate-itk-image-data-at-missing-masked-pixels-cuda-c/4363/1 "2021-08-25T14:29:31Z")

</div>

Hi everyone,

I would like to know if there are any algorithms in ITK which would allow me to interpolate linearily missing pixels of a 2D image data (preferably with a CUDA implementation)?

To detail a little more my question, I have an image which looks something like the following :

```auto
0 0 0 0 0 
0 ma 0 ma 0
0 ma ma 0 0
0 0 0 0 0 

```

I want to linearly interpolate the pixel values at the masked coordinates using the surrounding unmasked pixels.

In python, using SciPy, the equivalent code would be something like this :

```auto
slice_2d[masked_pos] = griddata(unmasked_pos, slice_2d[unmasked_pos], masked_pos, method="linear")

```

Thanks in advance,  
Thibault

---

<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: [August 25, 2021, 3:21pm UTC](https://discourse.itk.org/t/interpolate-itk-image-data-at-missing-masked-pixels-cuda-c/4363/2 "2021-08-25T15:21:45Z")

</div>

Hello @Thibault_Pelletier,

As far as I’m aware, this functionality isn’t available in ITK. What you are describing is a very basic form of [inpainting](https://en.wikipedia.org/wiki/Inpainting).

An ITK based implementation is described in this [kitware blog entry](https://blog.kitware.com/a-greedy-patch-based-image-inpainting-framework/). Given the age, 9+ years, not sure if the code still works (the GitHub repository is still there).

---

<div class="post-metadata">

### Author: ![Thibault\_Pelletier](https://discourse.itk.org/user_avatar/discourse.itk.org/thibault_pelletier/32/2235_2.png) [@Thibault\_Pelletier](https://discourse.itk.org/u/Thibault_Pelletier)
#### Post date: [August 26, 2021, 7:47am UTC](https://discourse.itk.org/t/interpolate-itk-image-data-at-missing-masked-pixels-cuda-c/4363/3 "2021-08-26T07:47:59Z")

</div>

Hi @zivy,

Thank you for your input.  
I will take a look at the repository and the blog entry and have a go at it!

Thanks!
