- From: Ian Hickson <ian@hixie.ch>
- Date: Wed, 16 Jan 2008 02:48:39 +0000 (UTC)
On Sun, 20 May 2007, ddailey wrote: > > 1. Is there a way, using filters, to take an image A and produce its > photographic negative A', such that 255-C(A)=C(A') for each channel C in > {R,G,B)? I've fooled a bit with the filter "feComponentTransfer" with > some hints of success, but it seems like so natural a thing that there > must be a straightforward way that I'm just missing. Here is an approach > that comes close using <feComponentTransfer> together with <feComposite > operator="arithmetic">. > http://srufaculty.sru.edu/david.dailey/svg/ComponentTransferComposite.svg. > It produces an image which looks like a spectrum-equalized version of > the negative. There is no way to do this using <canvas> globalCompositeOperation (1-A is not a PorterDuff operator), but you could do it manually using the getImageData()/putImageData() methods. > 2. On a related theme, <feBlend/> has modes including "screen", > "multiply" etc. Is there a way to create the "difference" between two > images (as with the Photoshop difference filter) in SVG? Here's the best > I have figured out so far: > http://srufaculty.sru.edu/david.dailey/svg/ImageDiffer.svg . The ability > to calculate differences between images comes in quite handy, for > example, in explaining image compression to students, in scientific > image processing, and I believe in forensics as well. You could use the <canvas> globalCompositeOperation "xor", does that do what you want? > Another question arises in my mind in this context: is there any reason > that any of the treatments of these effects (like the Porter-Duff > operators, darken, saturate etc.) should be any different than they are > in the SVG spec? So many things that I see in the treatment of canvas > remind me of something so similar to what is in SVG that it makes me > wonder why not just reference say http://www.w3.org/TR/SVG/filters.html > ? The <canvas> globalCompositeOperation is just defined in terms of PorterDuff, which far predates SVG. > If indeed, my suspicion that 1 and 2, above, are not possible in current > approaches within SVG, then that would certainly justify a reopening and > augmentation of that treatment, but having come late to the discussions > about <canvas> and having not been involved in the discussions about the > SVG filters, I am a bit baffled by some of this. (Not that my state of > bafflement is anyone's problem but mine, mind you: I am well prepared to > deal with what I fear is a rather persistent condition.) A future version may introduce new operators, but at this point it's probably best if we stabalise on the well-known PorterDuff operators. Cheers, -- Ian Hickson U+1047E )\._.,--....,'``. fL http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,. Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
Received on Tuesday, 15 January 2008 18:48:39 UTC