How to remove spider from "spider web"?

enter image description here

there is good example in documentation center

enter image description here

but how to make black marker of spider?

  • $\begingroup$ You will need the mask first. Do you have the mask? $\endgroup$ – Kattern Apr 20 '16 at 9:26

This is a fast and quite good way to create the mask of the spider:

i = Import["http://i.stack.imgur.com/2Lz0A.jpg"];
mask = Dilation[
  DeleteSmallComponents@ ColorNegate@ DeleteSmallComponents@
    MorphologicalBinarize[i, .25], 


Then, you can use Inpaint with the generated mask:

Inpaint[i, mask]


You will have to adjust the MorphologicalBinarize threshold value to achieve good results for other images.


You should first generate the mask, then you can apply Inpaint. Following is a demo, it can be further enhanced.

flt = ColorNegate@MorphologicalBinarize[img, {0.4, 0.9}];
Inpaint[img, flt];

enter image description here


Your Answer

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