Making inpainting more reliable

I have a bad relationship with inpainting commands. When they work, they are great, when they don’t, well…

The above may not be the best example but it summarizes the problems I have with inpainting. You could imagine why I am hesitant when it comes to incorporating inpainting into any of my commands. One bad parameter setting, or input image or mask, and craziness ensues.

1 Sometimes it spills over to other regions.

2 Usually it has a ripple effect (due to jagged, convex or brightness varying edges seeding these variations?).


I’m sure you know all the limitations of inpainting so won’t go into that :slight_smile:

Specific to gmic script, the commands expect a mask where regions p \ge 1 will be inpainted. In general the better the mask, the better the inpaint. With the above you really want to get to a binary single channel mask narrowed right down to the small scratches. Will do an example shortly…

gmic img618.jpg +median. 5 sub. .. norm. gt. 5% dilate. 3 inpaint.. .,0,0

I would say in this case the trouble isn’t the inpaint - it’s getting a really good mask out of such a noisy image.

1 Like