Extracting a saturation map with SVG filters ?
I can't figure how I could extract a saturation map (as a greyscale image) with SVG filters. My idea is using it to replace any hue of an image with only one like it's done with cyan in the joined png created with Xara Xtreme Linux Edition. I am searching for a long time already but without success. Perhaps not possible.
In Xara I only put a cyan rectangle above the image and apply the "Hue" transparency type. I was able to synthezize all Xara's color effects but this one.
ivan
Ivan Louette wrote:
I can't figure how I could extract a saturation map (as a greyscale image) with SVG filters. My idea is using it to replace any hue of an image with only one like it's done with cyan in the joined png created with Xara Xtreme Linux Edition. I am searching for a long time already but without success. Perhaps not possible.
My guess would be that it should be possible to at least compute a rough approximation of the operation by simply trying to approximate the function(s) involved. I've done such things to simulate conical gradients, and it can work reasonably well (although the quality of the approximation is often dependent on the renderer): http://wiki.inkscape.org/wiki/index.php/Advanced_Gradients
In Xara I only put a cyan rectangle above the image and apply the "Hue" transparency type. I was able to synthezize all Xara's color effects but this one.
I'm afraid I'm too busy at the moment to give it a go myself, but I hope you'll succeed :) I think it's quite interesting what can be done within the confines of SVG filters, and I really hope the possibilities will be improved in later versions of the standard (and that the renderers catch up).
Thanks !
Actually approximating is what I am doing a lot ;) I will continue to try !
About the standard of course I would suggest one of two things. Unfortunately I am unable to go to SVG Open next fall to add my modest contribution into this game, but at a smaller scale I will be present and possibly fairly active at next LGM in Brussels.
ivan
________________________________ De : Jasper van de Gronde <th.v.d.gronde@...528...> À : Inkscape-devel@lists.sourceforge.net Envoyé le : Samedi, 1 Août 2009, 11h23mn 47s Objet : Re: [Inkscape-devel] Extracting a saturation map with SVG filters ?
Ivan Louette wrote:
I can't figure how I could extract a saturation map (as a greyscale image) with SVG filters. My idea is using it to replace any hue of an image with only one like it's done with cyan in the joined png created with Xara Xtreme Linux Edition. I am searching for a long time already but without success. Perhaps not possible.
My guess would be that it should be possible to at least compute a rough approximation of the operation by simply trying to approximate the function(s) involved. I've done such things to simulate conical gradients, and it can work reasonably well (although the quality of the approximation is often dependent on the renderer): http://wiki.inkscape.org/wiki/index.php/Advanced_Gradients
In Xara I only put a cyan rectangle above the image and apply the "Hue" transparency type. I was able to synthezize all Xara's color effects but this one.
I'm afraid I'm too busy at the moment to give it a go myself, but I hope you'll succeed :) I think it's quite interesting what can be done within the confines of SVG filters, and I really hope the possibilities will be improved in later versions of the standard (and that the renderers catch up).
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
I couldn't help myself and had a look at HSL on Wikipedia (http://en.wikipedia.org/wiki/HSL_and_HSV). I think it shouldn't be too hard:
First of all, let's assume tR, tG and tB (collectively called tC) are given (if only the target hue is given you could still compute them yourself with a little effort).
Now note what happens if you collapse the conversion from RGB to HSL and from HSL back to RGB:
l = (max+min)/2 if l<.5 s = (max-min)/2l q = l*(1+s) = l + (max-min)/2 = max/2 + min/2 + max/2 - min/2 = max else s = (max-min)/(2-2l) q = l + s - l*s = l + s*(1-l) = l + (max-min)/2 = max p = 2*l - q = max + min - max = min
Clearly, if we can compute the minimum and maximum of the RGB values the only thing left is to correctly combine these values using tC. Computing the minimum and maximum can be done using feBlend with darken/lighten if you first create three images with the original red, green and blue channels all in the same color(!) component (alpha set to 1?). You may want to make sure the values are replicated in all three color channels either beforehand or afterwards. (feColorMatrix is very useful for these kinds of operations)
This only leaves the question of computing the final color values. I would be inclined to use feFlood to get the tC values at every pixel and then use feComponentTransfer to determine the right coefficient for combining p/min and q/max (you could even flood with the hue and skip computing the tC values altogether). For the final blend you could use any number of methods to combine p and q. The nicest method would probably be if you would be able to directly get the coefficient into the alpha channel of q and then use simple alpha compositing (feBlend normal for example).
The main problem with all of the above is that it doesn't preserve the alpha channel. This is mainly because of having to compute the minimum and maximum, which uses normal alpha compositing for the alpha channel, making it quite inconvenient to use any alpha value other than 1 (and which definitely does NOT preserve the original alpha value). I think the easiest way out would probably be to post-multiply (using feComposite) the output with an image that has the alpha channel of the original image and all ones in the color channels (again feColorMatrix could come in handy).
I started creating something in Inkscape itself, but found that there is apparently a (at least one) bug in setting the blend mode. You should be able to create a file manually though.
Ivan Louette wrote:
Thanks !
Actually approximating is what I am doing a lot ;) I will continue to try !
About the standard of course I would suggest one of two things. Unfortunately I am unable to go to SVG Open next fall to add my modest contribution into this game, but at a smaller scale I will be present and possibly fairly active at next LGM in Brussels.
ivan
participants (2)
-
Ivan Louette
-
Jasper van de Gronde