Using PIL to fill empty image space with nearby colors (aka inpainting)

前端 未结 3 1491
一个人的身影
一个人的身影 2021-02-02 02:25

I create an image with PIL:

\"example

I need to fill in the empty space (depicted as black). I coul

3条回答
  •  爱一瞬间的悲伤
    2021-02-02 03:00

    A method with nice results is the Navier-Stokes Image Restoration. I know OpenCV has it, don't know about PIL.

    Your example:

    enter image description here enter image description here

    I did it with Mathematica.

    Edit

    As per your reuquest, the code is:

    i = Import["http://i.stack.imgur.com/uEPqc.png"];
    Inpaint[i, ColorNegate@Binarize@i, Method -> "NavierStokes"]
    

    The ColorNegate@ ... part creates the replacement mask. The filling is done with just the Inpaint[] command.

提交回复
热议问题