Duck
Duck

Reputation: 36013

CIFilters values

Is there a cheat list showing all CIFilters and their respective range of values?

How can Apple get away writing a doc like this listing all filters without telling us the possible ranges?

C'mon Apple.

Upvotes: 2

Views: 1375

Answers (2)

ilkayaktas
ilkayaktas

Reputation: 188

You can find all filters and their attributes in this project. It's very useful to understand the detail of filters.

enter image description here

Upvotes: 0

user1118321
user1118321

Reputation: 26395

I've updated it to work correctly for what I was attempting to show you. I had forgotten that attributes are per filter, and each input key is the name of a key in the attributes dictionary. The values are themselves dictionaries containing the info we want.

Note however, that this doesn't do all the work. You will have to look up a few things if you want more info and do some work on your own. What this does is iterates through all parameters of all filters and prints out the name, min, and max of them, even if that doesn't make sense. (For example images don't have a min or max - in that case it prints "(null)".) Note that many parameters have no min or max. They can cover the entire floating point range. If you're trying to make a slider, use the kCIAttributeSliderMin and kCIAttributeSilderMax attributes instead of kCIAttributeMin and kCIAttributeMax.

You could also get the attribute type and class and print out the ranges for other types of values (if that makes sense). For example, some parameters are points, rectangles, etc.

// Insert code here to initialize your application
// Get the list of all filters
NSArray* allFilters = [CIFilter filterNamesInCategories:nil];

// Iterate over the filters
NSEnumerator* filterEnum = [allFilters objectEnumerator];
NSString* nextFilter = nil;
while ((nextFilter = [filterEnum nextObject]) != nil)
{
    NSLog (@"filter = %@", nextFilter);
    // Get all of the input parameters to this filter
    CIFilter *filter = [CIFilter filterWithName:nextFilter]; // 3
    NSDictionary* attribs = [filter attributes];
    NSArray* inputs = [filter inputKeys];

    // Iterate over the input keys
    NSEnumerator* inputEnum = [inputs objectEnumerator];
    NSString* nextInput = nil;
    while ((nextInput = [inputEnum nextObject]) != nil)
    {
        // Note that you'll have to do some work here because some
        // parameters return vectors instead of just numbers, but
        // this is the general idea
        NSDictionary*   paramAttrib = [attribs objectForKey:nextInput];
        NSString* name = [paramAttrib objectForKey:kCIAttributeDisplayName];
        NSNumber* min = [paramAttrib objectForKey:kCIAttributeMin];
        NSNumber* max = [paramAttrib objectForKey:kCIAttributeMax];
        NSLog (@"param: %@, min = %@, max = %@", name, min, max);
    }
}

Also, I was serious about filing bugs on the docs. If you don't file bugs, they certainly won't change them. I have filed bugs on documentation and they have gotten fixed.

Upvotes: 3

Related Questions