09
Mar
10

Apply Core Image Kernel To Area Of Image

I always knew this was possible. Never got an answer from anyone ‘in the know’ on how to do it though, so eventually worked it out on my own.

/*
	Apply effect to area of image.
	
	toneburst 2010
*/

function __image main(__image image) {
	
	// Define rect (x-pos, y-pos, width, height)
	var rect = new Vec(100,100,100,200);
	
	// Apply effect to area of image defined by rect
	var inverted = fx.apply(rect, null, image);
	
	// Composite processed area on top of original image and return result
	return Filter.CISourceOverCompositing(inverted, image);
}

This snipped of JavaScript in a Core Image Filter (with ‘Edit filter function’ turned on) will apply the kernel function ‘fx’ in the top panel to the area of the image defined by the variable ‘rect’. Then I return the result of compositing the processed area on top of the original image.

I have a use for this, actually. Not sure anyone else out there will, mind you…

UPDATE:
Added demo QTZ to the Box.net widget
‘tb_CIFilter_wipe_demo.qtz’

Advertisements

5 Responses to “Apply Core Image Kernel To Area Of Image”


  1. March 10, 2010 at 1:03 am

    just crashed out whilst re-editing and adumbrating your newly discovered CI JS 🙂

  2. 2 alx
    March 10, 2010 at 9:33 am

    Hmm…doesn’t surprise me. It crashed several time on me while I was making it, too. There’s something a bit flaky about the whole Edit Filter Function thing, I think. I have a funny feeling I’m the only person who ever uses it, too, so I don’t think it’s had much testing, historically. I may be wrong, of course.

    a|x

  3. 3 alx
    March 10, 2010 at 9:36 am

    ‘adumbrating’??

    😉

  4. March 10, 2010 at 4:14 pm

    I dont think you are the only one using the filter functions 😛

  5. 5 alx
    March 10, 2010 at 4:50 pm

    Glad to be proved wrong. Maybe the QC team will make it a bit less crash-prone, in that case.

    a|x


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Twitter

March 2010
M T W T F S S
« Feb   Nov »
1234567
891011121314
15161718192021
22232425262728
293031  

Links

Blog Stats

  • 472,043 hits

%d bloggers like this: