Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Image - Image unit question




On 13 May 2005, at 14:12, Darrin Cardani wrote:

At 8:25 AM +0100 5/13/05, James Weatherley wrote:

My question is can these filters be re-written in terms of Core Image? The reason I ask is that the simple examples I've seen so far are of the 'Apply this algorithm to each pixel in the image' variety. I want something a bit different: an ordered dither for example. To do an ordered dither I need to divide the image into squares (4x4 say); count how many pixels in a square are above a threshold; set pixels within the square depending on how many were above the threshold.


In general, you cannot pass any information from one pixel to another. So the usual algorithm for, say, a Floyd-Stienberg dither can't be done in Core Image.


There may be some way to work around the limitation, though. For example, for each pixel in the output, sample the surrounding input pixels that would normally be 0 in the Floyd-Stienberg kernel, dither each one to figure out the error propogated from each one, add those values together, add them to the current pixel, and round it off as appropriate. It means you'll be sampling a bunch of times more than you would with the traditional algorithm, so it might not be very fast. And I can't verify that my method will give identical results. :-) But it's worth a try.

<sound of sucking teeth> Not sure about that - you'll be losing some of the errors! (Normally losing errors sounds like a good idea, but not here).


Anyway, straight ordered dither, unlike Floyd Steinberg doesn't require passing information from pixel to pixel and can be done by only looking at a single pixel at a time so you should be able to do it in Core Image. The difficulty may be in passing in the dither matrix. I've not looked at Core Image for some months now, so I may be making this up, but you could pass a 4x4 dither matrix in easily enough using vec4s, say. For larger matrices, you may have to do something like make the matrix into an image and use a sampler.

Jerry

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartz-dev/email@hidden

This email sent to email@hidden
References: 
 >Core Image - Image unit question (From: James Weatherley <email@hidden>)
 >Re: Core Image - Image unit question (From: Darrin Cardani <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.