# How to retouch (smart fill) photo image?

Can the program proposed by Alexei Boulbitch at the post of Custom arrow shaft be adapted to retouch an image in setting a mask arround the part one desires to disapear? This is only a suggestion, there may be a more straightforward way to do it.

In the famous following picture

Nicolas Yehzov has been edited out. The original picture was the following

I was wondering if It could be done in Mathematica, in the same way one can extract a part of an image. The reason for which I refer to the Custom arrow shaft post is that I think the mechanism must be similar.

Sorry not to have been enough precise. Here is how i can operate under LaTeX + PsTricks

I can construct a mask by hand, point to point --- which is particularly borying --- and erase one of the mass killers. It's there that I was thinking of Alexei's Code. After that either I can mask the part under the clipping path or I can add negatively for the rest of the image. The whith the help of the various graphic commands I can reconstruct the missing part. For instance it should not been too difficult to rebuild the wall and the water.

Perhaps with today technology can we do a better job than the one of the past where you see the effect of pencil drawing. Of course, here is not my intension but I give always to my students some pictures to anchor them in reality.

In all the case I am particularly gratefull to all your answer even if the questions are not always clear. I am particularly impress by your skills and by this incredible tool I have had for nearly 30 years without realizing how it could be such a great tool.

• Error corrected Sorry – cyrille.piatecki Jul 12 '16 at 6:56
• Please add so much information as to make the question self-contained. At the moment your goal is unclear to me. You have asked over 25 questions by now, so you should have a good idea on how to pose interesting and relevant questions. – Yves Klett Jul 12 '16 at 7:07
• Sorry Yves I was thinking that clipping was a clear operation. I will add some elements in the question. – cyrille.piatecki Jul 12 '16 at 7:50
• I have no idea how it is related to those arrows but you may be interested in Inpaint. – Kuba Jul 12 '16 at 10:34
• About the edit, click on the photo, below a photo editor toolbar should appear, use masking tool, draw lines, copy mask as image, save. Etc. – Kuba Jul 12 '16 at 14:06

1. Use "Mask tool" to select area to inpaint, copy as image, store somewhere.
2. Do the same to select the area which should be used to probe texture from.
3. Repeat for all environments.
4. 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"];

Fold[
Inpaint[#, First@#2,
Method -> {"TextureSynthesis", Masking -> Last@#2}] &,
img,
{
}
]


I have to polish a handrail but looks quite good.

• Thanks for the accept but it is always good to hold on a day or two. Let's not discourage others. There are image magicians around. – Kuba Jul 12 '16 at 16:15
• @Kuba I have edited your answer in order to make it self-contained. Great answer and wonderful sense of humor! You made my day! – Alexey Popkov Jul 12 '16 at 20:59
• Looks way much better than the two other pictures. – J. M. is in limbo Jul 13 '16 at 0:57
• @AlexeyPopkov Thanks for the edit and an appreciattion :) – Kuba Jul 13 '16 at 5:33
• Historical justice is served by Mathematica :) – István Zachar Jul 13 '16 at 8:54

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}];

• Cannot try hard. Information::notfound: Symbol hard not found. >>. "Try hard" is not very programmatic. – István Zachar Jul 12 '16 at 13:26
• I agree @IstvánZachar, it is not, by Definition. And that is why I am unable to do it ;-) – Sumit Jul 12 '16 at 14:06
• @Rahul, a big rectangle is not doing any good. Dividing the region into small boxes and using Inpaint iteratively may give some better result. – Sumit Jul 12 '16 at 14:09