How to retouch (smart fill) photo image?
Here's a google drive link to the Notebook.
- Use "Mask tool" to select area to inpaint, copy as image, store somewhere.
- Do the same to select the area which should be used to probe texture from.
- Repeat for all environments.
Fold
Inpaint
.
A GIF animation of the masks (included here in order to make the post self-contained):
img = Import["http://i.stack.imgur.com/d3AXT.jpg"];
{waterMask, waterSource, headMask, headSource, shadowMask, shadowSource, edgeMask,
edgeSource, coatMask, coatSource} = Import["http://i.stack.imgur.com/x4v6b.gif"];
Fold[
Inpaint[#, First@#2,
Method -> {"TextureSynthesis", Masking -> Last@#2}] &,
img,
{
{waterMask, waterSource},
{headMask, headSource},
{shadowMask, shadowSource},
{edgeMask, edgeSource},
{coatMask, coatSource}
}
]
I have to polish a handrail but looks quite good.
Here is a way to do it, but it needs a lot 'artistic' touch.
First Import
the image.
img = Import["http://i.stack.imgur.com/d3AXT.jpg"];
Then create the Mask
using interface (thanks Kuba).
From orange Copy
choose Mask as ...
mask = (*Ctrl+v*)
Finally
Inpaint[img, mask]
I guess you have to do some fine tuning by hand. Try hard and you can make him completely disappear. I don't have that much talent or courage to mess with history.
If you want to do it with numbers then find the location of right person.
{x1, x2} = {545, 800};
{y1, y2} = {10, 500};
{l, h} = ImageDimensions[img];
i1 = ImageTake[img, {h - y2, h - y1}, {x1, x2}]
i2 = Graphics[{Inset[i1, {x1, y1}, {0, 0}, {x2 - x1, y2 - y1}]},
PlotRange -> {{1, l}, {1, h}}, ImageSize -> {l, h}];
mask = DeleteSmallComponents@FillingTransform@ChanVeseBinarize[i2,
"TargetColor" -> Darker[Gray]]