Skip to main content
Question

RasterInpainter


FME Hub user dmitribagh just uploaded a new transformer to the FME Hub.

The transformer uses OpenCV’s inpainting functionality to fill in missing or damaged parts of a raster image. This transformer is useful for tasks such as repairing damaged images, or filling in Nodata values in aerial/satellite imagery. "Inpainting" is a term used in image processing to fill in missing or damaged parts of an image by interpolating the surrounding pixel information.

Installing OpenCV Python library

The transformer needs OpenCV Python library installed. Use the following syntax to install the library:

On Windows:

<your_FME_install_path>/fme.exe python -m pip install opencv-python

On Mac/Linux:

<your FME install path>/fme python -m pip install opencv-python

Input

The raster image(s) to be inpainted. The transformer will try to inpaint black pixels only, that is those having the RGB value set to 0,0,0, interpolating the new values based on the surrounding pixels.

The transformer works with RGB24, RGBA32, RGB48, RGBA64, UINT8, UINT16, and some other interpretations, however, it will fail on Real32, Real64, UInt 32, UInt64 interpretations. Use RasterInterpretationCoercer to transform the input raster to one of the supported interpretations.

Output

The inpainted raster images. Their interpretation will be set to RGB24. Use RasterInterpretationCoercer to set the necessary interpretation.

Parameters

Inpaint Radius

The radius of the circular neighborhood used for inpainting. The available range is 1 to 50.

Inpaint Algorithm

The inpainting algorithm to use. Options are TELEA (fast, good for small defects) and NS (Navier-Stokes, good for large defects).

Usage Notes

Ensure that the input raster has areas marked for inpainting - the algorithm will inpaint black pixels only (RGB 0,0,0).

The TELEA algorithm is generally faster and works well for small defects, while the NS algorithm is more suitable for larger defects but is slower.

Make sure the source raster does not use lossy compression, which usually generates values slightly different from the required RGB value of 0,0,0 along the hole edges. Such values will participate in filling the holes and destroy the effect. Use RasterExpressionEvaluator to make sure the holes are fully black.



Would you like to know more? Click here to find out more details!
This post has been closed for comments