14
$\begingroup$

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

enter image description here

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

enter image description here

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.

Added this afternoon

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

enter image description here

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.

$\endgroup$
8
  • 1
    $\begingroup$ Error corrected Sorry $\endgroup$ Jul 12, 2016 at 6:56
  • 2
    $\begingroup$ 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. $\endgroup$
    – Yves Klett
    Jul 12, 2016 at 7:07
  • $\begingroup$ Sorry Yves I was thinking that clipping was a clear operation. I will add some elements in the question. $\endgroup$ Jul 12, 2016 at 7:50
  • 5
    $\begingroup$ I have no idea how it is related to those arrows but you may be interested in Inpaint. $\endgroup$
    – Kuba
    Jul 12, 2016 at 10:34
  • 1
    $\begingroup$ 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. $\endgroup$
    – Kuba
    Jul 12, 2016 at 14:06

2 Answers 2

21
$\begingroup$

Here's a google drive link to the Notebook.

  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.

enter image description here

enter image description here

A GIF animation of the masks (included here in order to make the post self-contained):

masks

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

enter image description here

I have to polish a handrail but looks quite good.

$\endgroup$
6
  • $\begingroup$ 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. $\endgroup$
    – Kuba
    Jul 12, 2016 at 16:15
  • 1
    $\begingroup$ @Kuba I have edited your answer in order to make it self-contained. Great answer and wonderful sense of humor! You made my day! $\endgroup$ Jul 12, 2016 at 20:59
  • 2
    $\begingroup$ Looks way much better than the two other pictures. $\endgroup$ Jul 13, 2016 at 0:57
  • $\begingroup$ @AlexeyPopkov Thanks for the edit and an appreciattion :) $\endgroup$
    – Kuba
    Jul 13, 2016 at 5:33
  • 2
    $\begingroup$ Historical justice is served by Mathematica :) $\endgroup$ Jul 13, 2016 at 8:54
5
$\begingroup$

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).

enter image description here

From orange Copy choose Mask as ...

mask = (*Ctrl+v*)

enter image description here

Finally

Inpaint[img, mask] 

enter image description here

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]]
$\endgroup$
5
  • 3
    $\begingroup$ Cannot try hard. Information::notfound: Symbol hard not found. >>. "Try hard" is not very programmatic. $\endgroup$ Jul 12, 2016 at 13:26
  • $\begingroup$ What happens if you just make the whole rectangle be the mask? $\endgroup$
    – user484
    Jul 12, 2016 at 13:44
  • 2
    $\begingroup$ I agree @IstvánZachar, it is not, by Definition. And that is why I am unable to do it ;-) $\endgroup$
    – Sumit
    Jul 12, 2016 at 14:06
  • $\begingroup$ @Rahul, a big rectangle is not doing any good. Dividing the region into small boxes and using Inpaint iteratively may give some better result. $\endgroup$
    – Sumit
    Jul 12, 2016 at 14:09
  • $\begingroup$ Dear Kuba, you play against history but the russian would have been certainly happier if one of the greatest monster in the human history --- I heard that Mao ZeDong was a greater killer than Stalin --- would have been erased really twenty years before his death. $\endgroup$ Jul 12, 2016 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.