It is currently Thu Jul 25, 2024 9:19 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 49 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: Is there any G'MIC filter for foreground/background extraction?
PostPosted: Mon Jul 15, 2013 4:19 am  (#21) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
Very cool filter garagecoder. Maybe I have some suggestions to improve it :

- Force foreground image to be output with an alpha-channel. I've tested with RGB images, and the segmented objects appear on a black background instead of a transparent one.
- It would be maybe more simple to use if color strokes were white (foreground) and black (background), since these are the default foreground/background colors in GIMP, and selecting these colors can be done very quickly (one button to press instead of selecting a color in the color selector).
I understand that drawing black strokes is maybe not the best choice when dealing with dark backgrounds, but maybe you could consider that the brightest color always select the foreground objects, and the darkest, the background, so we could use for instance white/red as colors for the strokes.

Anyway, very nice filter, and it works quite well on the images on which I've tested the process.


Top
 Post subject: Re: Is there any G'MIC filter for foreground/background extraction?
PostPosted: Mon Jul 15, 2013 4:44 am  (#22) 
Offline
GimpChat Member

Joined: Sep 24, 2012
Posts: 275
Location: Scotland
Thanks, only possible due to the amazing work of you and your students of course ;)

Good suggestions, I'll use those - by the way if you add an alpha channel to the input image it will use it (i.e. the outputs will also have alpha). I left it that way in case somebody didn't particularly want the alpha but maybe it just confuses people (I could at least add that to the instructions at the top).

Maybe you can help me with a strange problem I'm having with it too - see post on G'MIC flickr forum (if you have time :) )!


Top
 Post subject: Re: Is there any G'MIC filter for foreground/background extraction?
PostPosted: Mon Jul 15, 2013 7:53 am  (#23) 
Offline
GimpChat Member
User avatar

Joined: Nov 09, 2011
Posts: 726
Hair and particularly in this image:
Image
is the most difficult with other automatic methods that I've used. Your code works pretty well:
Image

Advantages over other automatic methods:
* Easy and fast
* Preview
* Interactive
* All the benefits of G'MIC
Really good!

My only doubt is whether the filter name indicates well for what it does. Maybe "foreground/background extractor" or something like that would be better. Anyway that's the least important.

_________________
Image
Be patient, English is not my language.


Top
 Post subject: Re: Is there any G'MIC filter for foreground/background extraction?
PostPosted: Mon Jul 15, 2013 8:19 am  (#24) 
Offline
GimpChat Member

Joined: Sep 24, 2012
Posts: 275
Location: Scotland
@YAFU

Thanks for the comments, I'll probably rename it when I move it to the main filters tree to make it more obvious what it can do. I have some ideas to improve fine detail inclusion at the edges but not sure when I'll be working on that.


Top
 Post subject: Re: Is there any G'MIC filter for foreground/background extraction?
PostPosted: Mon Jul 15, 2013 10:28 am  (#25) 
Offline
Global Moderator
User avatar

Joined: Apr 01, 2012
Posts: 7763
Location: On the other side of this screen
Looks like a great script garagecoder. I will have to try it out.

_________________


Top
 Post subject: Re: Is there any G'MIC filter for foreground/background extraction?
PostPosted: Mon Jul 15, 2013 3:52 pm  (#26) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14730
Location: USA
Any way to have the code capture partially transparent pixels?

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: Is there any G'MIC filter for foreground/background extraction?
PostPosted: Mon Jul 15, 2013 4:55 pm  (#27) 
Offline
GimpChat Member

Joined: Sep 24, 2012
Posts: 275
Location: Scotland
@Rod

Can you give me some kind of example? Most things are possible, it's just a case of how difficult it is :D


Top
 Post subject: Re: Is there any G'MIC filter for foreground/background extraction?
PostPosted: Mon Jul 15, 2013 5:42 pm  (#28) 
Offline
GimpChat Member
User avatar

Joined: Jul 17, 2012
Posts: 2770
garagecoder: thank you for this excellent filter !

im normally skeptical when it comes to these automated processes and i didnt find the examples very convincing...
BUT i have tried it now with several pictures and got GREAT results !!

as the curious guy i am, could we get a few explanations what all the options mean and do ?!

Alpha Minimum, Edge Flow, Median
and Inpainting


Top
 Post subject: Re: Is there any G'MIC filter for foreground/background extraction?
PostPosted: Mon Jul 15, 2013 6:05 pm  (#29) 
Offline
GimpChat Member

Joined: Sep 24, 2012
Posts: 275
Location: Scotland
@Esper

Yep sure, it's something like this:

Alpha Min: Set a minimum threshold based on the alpha channel. Any pixels with an opacity less than this will be filled solid black (only during edge detection). Useful for controlling edge detection of objects on a transparent background.

Edge flow: Apply a pde flow algorithm before finding edges - basically smooth the image along contours, can help close gaps in edges. This controls how much to apply.

Median: Straightforward median blur filter. Helps reduce the image into it's main chunks by smoothing out fine detail areas while keeping edges. Again controls how much - only used for the edge detection.

Grow alpha: Expand/contract the edges of detected objects or background, roughly equivalent to growing a selection.

Blur alpha: Blur the edges of the selection, helps create a smooth gradient from the edges to the background.

Inpainting: Intelligently fill in portions of the image that are transparent. Most useful when "Swap layers" is checked, to fill in foreground objects to look like they aren't there. Low to Ultra controls how visually accurate the filling will look and therefore how much time it takes to compute (can be incredibly slow especially with large areas/ultra accuracy so beware).


There is more to come, but as always it's a question of when I get around to it ;)


Top
 Post subject: Re: Is there any G'MIC filter for foreground/background extraction?
PostPosted: Mon Jul 15, 2013 6:38 pm  (#30) 
Offline
GimpChat Member
User avatar

Joined: Jul 17, 2012
Posts: 2770
thank you garagecoder, very helpful !


Top
 Post subject: Re: Is there any G'MIC filter for foreground/background extraction?
PostPosted: Mon Jul 15, 2013 6:59 pm  (#31) 
Offline
GimpChat Member
User avatar

Joined: Nov 09, 2011
Posts: 726
Esper wrote:
im normally skeptical when it comes to these automated processes and i didnt find the examples very convincing...

Sorry if I'm giving bad publicity to the filter with my examples :)
But you try with the girl photo using another automated methods, and you will see that the garagecoder filter is easier and faster, and gets the similar or better result.
Maybe you get better results with hair using the RGGJAN/Onkel Hatti version, but I think in the central areas of the image this G'MIC filter works a little better.

_________________
Image
Be patient, English is not my language.


Top
 Post subject: Re: Is there any G'MIC filter for foreground/background extraction?
PostPosted: Mon Jul 15, 2013 8:32 pm  (#32) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14730
Location: USA
garagecoder wrote:
@Rod

Can you give me some kind of example? Most things are possible, it's just a case of how difficult it is :D

Sure (i hope) :P
It seems to me a good foreground or background selection tool will also grab colors you draw on that are of a close color similarity and also have some transparency.
For instance i open an image that has a woman with flowing hair and i want to catch those pixels that are the hair color but also contain transparency to the background colors. Just seems like this would capture more of the strands of hair that have mixed bg and fg colors.
Of course this will only work if the bg color is almost or is a solid color. The setting would keep those stray pixels of fg color and discard the bg colors thus rendering a fg color with some transparency.

Sort of like peeling the fg color off the bg color. In a sense. :)

I hope you get what i mean. :)

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: Is there any G'MIC filter for foreground/background extraction?
PostPosted: Mon Jul 15, 2013 11:11 pm  (#33) 
Offline
GimpChat Member
User avatar

Joined: Jul 17, 2012
Posts: 2770
YAFU wrote:
Sorry if I'm giving bad publicity to the filter with my examples :)

its not like that Yafu and it was not meant as an offence to you

i see in general the wish of the gimpcrowd for getting a script or filter for everything

i think there are several problems with that
one is, that i think a lot of stuff can be done in a superior way by doing it by hand
i see it with texteffects all the time
and a lot of stuff just cant be duplicated with a script

i tried your horses image, with a simple invert/levels layermask technique and i found the result much better
the image is very easy to render with that method because of the contrast
and it didnt take long either

but people like to use a filter instead, because it seems easier and quicker
but often: not better, imo

i didnt find the hair image convincing either, because hair is always hard to render and there are some very complex techniques around for doing it the "proper" way
yes the result was pretty good, but then again you have to ask: for what job ?
if you want to have really well rendered hair for a classy piece of art, then the result the filter provided will not be good enough

i do think a filter/script has its place for some uses
sometimes a quick and dirty result is good enough
and as i just said, this script is excellent

still im sure there will be a lot of cases where doing it the manual way will be better
on the other hand, you can have the best of both worlds by using garagecoders filter, then alphaselecting the foreground-object and applying a layermask from selection to the original
then you can fine-tune the layermask by hand


Top
 Post subject: Re: Is there any G'MIC filter for foreground/background extraction?
PostPosted: Tue Jul 16, 2013 1:34 am  (#34) 
Offline
GimpChat Member

Joined: Feb 13, 2013
Posts: 86
Here is a quick filter that uses garagecoder's filter but adds some more bits to get better edges. It requires two layers, the top layer is filled with either red,green,or blue. red for parts to remove, green for parts to keep and blue for edges to be calculated by the filter.

Image


#@gimp objectmask: objectmask, objectmask
#@gimp : edge max = float (255,0,255)
#@gimp : edge min = float (0,0,255)
#@gimp : erode = int(3,3,19)
objectmask:
-remove_opacity[1]
-split[0] c
--l[1,2,-1]
-add[0,1] #create inpaint mask
-inpaint[1] [0] # inpaint
-keep[1]
-endl

-sub[-1] [-2] -abs[-1] # difference between the inpainted image and the original

-l[0,1,2,3,-1] # use gcd_splitobj on the difference image
-reverse[2,3]
-fill[2] 0
-negative[3]
-append[0,1,2,3] c
--gcd_splitobj[0,1] 50,3,3,0,0,0,0
-endl


-l[1,2]

-l[0] # create greyscale mask
-split c
-max
-endl

-split_opacity[1]
-erode[-1] $3 # adjust gcd calculated mask
-apply_curve[0] 0,-1,0,$2,0,$1,255,256,255 # apply curve to difference image to adjust transparency
-add[0] [2] # add gcd mask and difference image
-c 0,255
-endl

-keep[1,5]
-reverse
-append c


Top
 Post subject: Re: Is there any G'MIC filter for foreground/background extraction?
PostPosted: Tue Jul 16, 2013 2:35 am  (#35) 
Offline
GimpChat Member

Joined: Sep 24, 2012
Posts: 275
Location: Scotland
@Iain

That looks remarkably similar to the idea I had in my head! I assume the red/green/blue mask is hand drawn? However you've done it, I'm sure there are bits of that script I can steal ;)

@Rod

I think I maybe misinterpreted what you suggested first of all about a threshold - is what you mean like Iain's example where it picks up fine detail? If so I can probably remove or re-use the "Alpha min" control.


Top
 Post subject: Re: Is there any G'MIC filter for foreground/background extraction?
PostPosted: Tue Jul 16, 2013 3:11 am  (#36) 
Offline
GimpChat Member

Joined: Feb 13, 2013
Posts: 86
garagecoder wrote:
@Iain

That looks remarkably similar to the idea I had in my head! I assume the red/green/blue mask is hand drawn? However you've done it, I'm sure there are bits of that script I can steal ;)


Yep. Hand drawn.

The filter is a bit rough. I'm sure if you will be able to make something better.


Top
 Post subject: Re: Is there any G'MIC filter for foreground/background extraction?
PostPosted: Tue Jul 16, 2013 6:47 am  (#37) 
Offline
GimpChat Member
User avatar

Joined: Jan 10, 2013
Posts: 863
Rod wrote:
(...) i want to catch those pixels that are the hair color but also contain transparency to the background colors. Just seems like this would capture more of the strands of hair that have mixed bg and fg colors.(...)

That is the greatest difficulty in hair clippings. Even getting a few strands cut correctly, they keep the tone of the background. And fix it ever too much work. :gaah

_________________
bbbbbbbbbbbImage
bbbbbbbbbbb Be patient, English is not my language.


Top
 Post subject: Re: Is there any G'MIC filter for foreground/background extraction?
PostPosted: Tue Jul 16, 2013 7:22 am  (#38) 
Offline
GimpChat Member
User avatar

Joined: Nov 09, 2011
Posts: 726
Esper wrote:
YAFU wrote:
Sorry if I'm giving bad publicity to the filter with my examples :)

its not like that Yafu and it was not meant as an offence to you

I know, Esper :)
I agree that there are many not automated methods to do a better job. But this is about automatic methods, usually for someone who wants to do something quickly or for those who don't have an advanced level of knowledge in other techniques.
So an automatic filter has to be fast and easy to use, and get a decent result (regarding automatic filters). If with the filter you have to spend a lot of time carefully drawing by hand and filling large areas, I think the filter is no longer useful. If you have to do as much work with an automatic filter, is better to do the job by hand. That is why I think this filter is a good automatic filter.

_________________
Image
Be patient, English is not my language.


Top
 Post subject: Re: Is there any G'MIC filter for foreground/background extraction?
PostPosted: Tue Jul 16, 2013 9:42 am  (#39) 
Offline
GimpChat Member

Joined: Jul 11, 2010
Posts: 349
Rod wrote:
Any way to have the code capture partially transparent pixels?


@garagecoder to see this effect, try using the RGGJAN/Onkel Hatti version. It does a great job on many pics, but can be annoying to use, and doesn't do similar colers that well. Although you filter with the Iain mod looks very interesting!


Top
 Post subject: Re: Is there any G'MIC filter for foreground/background extraction?
PostPosted: Wed Jul 24, 2013 7:39 pm  (#40) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14730
Location: USA
Quote:
@Rod

I think I maybe misinterpreted what you suggested first of all about a threshold - is what you mean like Iain's example where it picks up fine detail? If so I can probably remove or re-use the "Alpha min" control.


Yes. A way to find fine detail such as Ian's filter does. :)

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
Post new topic Reply to topic  [ 49 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) background and foreground: discussion of a little GIMPWork with b/w

5

No new posts Change foreground and background color

2

No new posts Change Foreground Colour

0

No new posts Gimp always "not responding" when I use the foreground select tool.

1

No new posts Attachment(s) cli345's cartoon filter as a native GEGL Filter.

10



* Login  



Powered by phpBB3 © phpBB Group