I know photoshop has this algo. Is it available in GIMP or another open source tool?
Just to clarify, this will be the tool where you highlight what you want in green and what you don't want in red with a little space in between. Then the tool will trace a little yellow line around what you want, and you can adjust.