Message Boards Message Boards

2
|
5222 Views
|
4 Replies
|
9 Total Likes
View groups...
Share
Share this post:

Removal of Complex Background from Image

Posted 9 years ago

Hello,

What I want to do is to remove complex background from an image attached and only highlight or draw polygons around trees. I have tried and tried to highlight green color of trees to separate from the background and none was successful. I also attached a target image of what I roughly want to achieve. I really appreciate some inputs. Thank you very much.

TreeImage TargeImage: Image I want to achieve

POSTED BY: Eiji Matsuzaki
4 Replies
Posted 9 years ago

Hi Marco and Henrik,

Both approaches are fantastic to me! I really want to study both of your codings.

Again, thank you very much!

Eiji

POSTED BY: Eiji Matsuzaki

Dear Henrik,

that is a fantastic solution! A great and clean separation which captures all details. Very nice. I see that, should Inever have an image processing problem, I should ask you!

Thanks for sharing,

M.

POSTED BY: Marco Thiel

Hi all,

removing a complex background can be a difficult task; therefore Marco's nice solution can hardly be shorter. If one concentrates on the fact that due to snow the background is basically gray and the trees stay (at least a little bit) green, things get much easier (though I am not sure that this approach answers the original question):

greenQ[p : {r_, g_, b_}] := With[{mean = Mean[p]}, If[g > 1.03 mean, 1, 0]]
mask = Erosion[Dilation[ImageApply[greenQ, img], 4], 4]

this gives a "mask" for green trees. Lets check:

enter image description here

Regards -- Henrik

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

Group Abstract Group Abstract