I create an image with PIL:
I need to fill in the empty space (depicted as black). I coul
You can also create the mask with the function CreateImage()
, for instance:
inpaint_mask = cv.CreateImage(cv.GetSize(im), 8, 1)
Depending on how you're deploying this application, another option might be to use the Gimp's python interface to do the image manipulation.
The doc page I linked to is oriented more towards writing GIMP plugins in python, rather than interacting with a background gimp instance from a python app, but I'm pretty sure that's also possible (it's been a while since I played with the gimp/python interface, I'm a little hazy).
A method with nice results is the Navier-Stokes Image Restoration. I know OpenCV has it, don't know about PIL.
Your example:
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.