4
$\begingroup$

I 'm trying to get a code that can delete what I wrote with a pen on my hand.

enter image description here

I created a mask to delimit the area where I wanted to change the colors.

This was my first attempt :

i = Import["C:\\Users\\Leandro\\Desktop\\Hand.jpg"]; mask = Graphics[{Black, Rectangle[{0, 0}, {2176, 1624}], White,Rectangle[{709, 575}, {1345, 854}]}]; bbb = ColorReplace[i, mask -> Blue]; ChanVeseBinarize[bbb];

This was my second attempt :

mask2 = Graphics[{Black, Rectangle[{0, 0}, {2176, 1624}], White, Rectangle[{753.112, 638.37}, {757.227, 642.485}]}]; ColorReplace[i, mask2 -> Black]

I could highlight the word , but I can not treat it so that it disappears from the original image.

$\endgroup$
1
8
$\begingroup$

This is a first pass without refinement. Note: after deleting small components there were 4 components. The last 3 were the letters. It is ugly but a start:

i = Import["http://i.stack.imgur.com/NgJUB.jpg"];
cs = ColorSeparate[i];
is = DeleteSmallComponents[
  b = ColorNegate[Binarize[ImageSubtract[cs[[1]], cs[[3]]]]]]; 
m =DeleteSmallComponents[ImageSubtract[b, is]];
cc = ComponentMeasurements[m, "Mask"];
MatrixPlot[m = Total[Range[2, 4] /. cc]]
mask = Dilation[Image[m], 10];
Inpaint[i, mask]

enter image description here

$\endgroup$
7
$\begingroup$

The procedure you are looking for is called "inpainting" and there is an implementation in Mathematica called 'Inpaint'. Using your mask:

i = Import["http://i.stack.imgur.com/NgJUB.jpg"]; 
mask = Graphics[{Black, Rectangle[{0, 0}, {2176, 1624}], White, 
   Rectangle[{709, 575}, {1345, 854}]}]; 
Inpaint[i, mask]

enter image description here

$\endgroup$

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.