Phann
Phann

Reputation: 1327

Build-in function for interpolating single pixels and small blobs

Problem

Is there a build-in function for interpolating single pixels? Given a normal image as Mat and a Point, e.g. an anomaly of the sensor or an outlier, is their some function to repair this Point? Furthermore, if I have more than one Point connected (let's say a blob with area smaller 10x10) is there a possibility to fix them too?

Trys but not really solutions

It seems that interpolation is implemented in the geometric transformations including resizing images and to extrapolate pixels outside of the image with borderInterpolate, but I haven't found a possibility for single pixels or small clusters of pixels.

A solution with medianBlur like suggested here does not seem appropriate as it changes the whole image.

Alternative

If there isn't a build-in function, my idea would be to look at all 8-connected surrounding pixels which are not part of the blob and calculate the mean or weighted mean. If doing this iteratively, all missing or erroneous pixel should be filled. But this method would be dependent of the applied order to correct each pixel. Are there other suggestions?

Update

Here is an image to illustrate the problem. Left the original image with a contour marking the pixels to fix. Right side shows the fixed pixels. I hope to find some sophisticated algorithms to fix the pixel.

Left: Original image with contour with pixels to fix. Right: pixels fixed

Upvotes: 1

Views: 1420

Answers (1)

Phann
Phann

Reputation: 1327

The build-in function inpaint of OpenCV does the desired interpolation of chosen pixels. Simply create a mask with all pixels to be repaired.

See the documentation here: OpenCV 3.2. Description: inpaint and Function: inpaint

Upvotes: 1

Related Questions