Search code examples
pythonimage-processinginterpolationmaskastronomy

How do i fill "holes" in an image?


I have photo images of galaxies. There are some unwanted data on these images (like stars or aeroplane streaks) that are masked out. I don't just want to fill the masked areas with some mean value, but to interpolate them according to surrounding data. How do i do that in python?

We've tried various functions in SciPy.interpolate package: RectBivariateSpline, interp2d, splrep/splev, map_coordinates, but all of them seem to work in finding new pixels between existing pixels, we were unable to make them fill arbitrary "hole" in data.


Solution

  • What you want is called Inpainting.
    OpenCV has an inpaint() function that does what you want.