Group Abstract Group Abstract

Message Boards Message Boards

Removal of Complex Background and Separation of overlapping objects

Posted 10 years ago
POSTED BY: Eiji Matsuzaki
4 Replies

Hi Eiji,

counting those trees appears not to be an easy task - even if one tries it by hand. So I guess an approximation is the best one can expect. Here is what I tried:

  • I separated the trees by its color - as before;
  • then I applied a SkeletonTransform, which I blured;
  • finally WatershedComponents seems to do the trick.

My result looks like:

enter image description here

I think one can see here at least a not unreasonable separation of single trees. My code:

ClearAll["Global`*"]
img = "your original image";
greenQ[p : {r_, g_, b_}] := With[{mean = Mean[p]}, If[g > 1.05 mean, 1, 0]]
mask = Dilation[Erosion[ImageApply[greenQ, img], 6], 4];
maskData = ImageData[mask];
img0 = ImageMultiply[mask, img]
img1 = Dilation[ImageAdjust@SkeletonTransform[mask], 1]
img2 = Blur[img1, 30] // ImageAdjust
wscData = WatershedComponents@ColorNegate[img2];
colorTrees = ImageMultiply[Colorize[wscData], mask]
Manipulate[Blend[{img, colorTrees}, p], {p, 0, 1}]

What is left for you to do (in case you find this meaningful at all) is to count occurrend colors (except black) down to some minimal patch size. Maybe this might be an approach.

Regards -- Henrik

POSTED BY: Henrik Schachner

Dear Henrik,

very (!) impressive indeed. I always enjoy your posts.

Cheers,

Marco

POSTED BY: Marco Thiel
Posted 10 years ago

Dear Marco,

thank you very much for your heartening words! Although I do not regard the above as a very robust solution. Maybe somebody is coming up really with a clever idea ...

Best greetings from Germany -- Henrik

POSTED BY: Eiji Matsuzaki

Dear Marco,

thank you very much for your heartening words! Although I do not regard the above as a very robust solution. Maybe somebody is coming up really with a clever idea ...

Best greetings from Germany -- Henrik

POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard