I am using the following code for exposure adjustment and its working. I need the filter names for sharpen, denoise, highlighs, color temperature, shadows, blur, etc.
May be you can try following method of CIFilter class
+ (NSArray *)filterNamesInCategory:(NSString *)category
All you need to do is ask CIFilter
for the filter names. You can then ask each filter for its attributes
, which returns a dictionary that describes each input and output parameter that the filter accepts.
NSArray* filters = [CIFilter filterNamesInCategories:nil];
for (NSString* filterName in filters)
{
NSLog(@"Filter: %@", filterName);
NSLog(@"Parameters: %@", [[CIFilter filterWithName:filterName] attributes]);
}
For example, this is the output of the above code for the CIZoomBlur
filter:
Filter: CIZoomBlur
Parameters: {
CIAttributeDescription = "Simulates the effect of zooming the camera while capturing the image.";
CIAttributeFilterCategories = (
CICategoryBlur,
CICategoryVideo,
CICategoryStillImage,
CICategoryBuiltIn
);
CIAttributeFilterDisplayName = "Zoom Blur";
CIAttributeFilterName = CIZoomBlur;
CIAttributeReferenceDocumentation = "http://developer.apple.com/cgi-bin/apple_ref.cgi?apple_ref=//apple_ref/doc/filter/ci/CIZoomBlur";
inputAmount = {
CIAttributeClass = NSNumber;
CIAttributeDefault = 20;
CIAttributeDescription = "The zoom-in amount. Larger values result in more zooming in.";
CIAttributeDisplayName = Amount;
CIAttributeIdentity = 0;
CIAttributeMin = 0;
CIAttributeSliderMax = 200;
CIAttributeSliderMin = 0;
CIAttributeType = CIAttributeTypeDistance;
CIUIParameterSet = CIUISetBasic;
};
inputCenter = {
CIAttributeClass = CIVector;
CIAttributeDefault = "[150 150]";
CIAttributeDescription = "The x and y position to use as the center of the effect.";
CIAttributeDisplayName = Center;
CIAttributeType = CIAttributeTypePosition;
CIUIParameterSet = CIUISetBasic;
};
inputImage = {
CIAttributeClass = CIImage;
CIAttributeDescription = "The image to use as an input image. For filters that also use a background image, this is the foreground image.";
CIAttributeDisplayName = Image;
CIUIParameterSet = CIUISetBasic;
};
outputImage = {
CIAttributeClass = CIImage;
};
}
Most of the time, though, you'll probably just use the docs.
iOS 14, Swift 5
Must confess not easy to read, but an answer that is comparable to the first one on Objective C.
for filtername in filters {
print("filter \(filtername)")
print("attributes \(CIFilter.init(name: filtername)?.attributes.keys.description)")
}
Produces this ...
filter CIAccordionFoldTransition
attributes Optional("[\"inputImage\", \"CIAttributeFilterDisplayName\", \"inputTargetImage\", \"CIAttributeFilterAvailable_iOS\", \"CIAttributeFilterAvailable_Mac\", \"inputNumberOfFolds\", \"inputFoldShadowAmount\", \"inputBottomHeight\", \"CIAttributeReferenceDocumentation\", \"inputTime\", \"CIAttributeFilterCategories\", \"CIAttributeFilterName\"]")
filter CIAdditionCompositing
attributes Optional("[\"CIAttributeFilterCategories\", \"CIAttributeFilterName\", \"CIAttributeFilterDisplayName\", \"inputImage\", \"CIAttributeReferenceDocumentation\", \"CIAttributeFilterAvailable_iOS\", \"CIAttributeFilterAvailable_Mac\", \"inputBackgroundImage\"]")
So the info is there in these long strings, you just need to pick it out :)
I was writing to your earlier post link to all filters. I will repeat: link to all filters.
And for example You need Blur effect. Blur is category and have 7 filters:
And etc..
NSLog(@"Distortion: %@", [CIFilter filterNamesInCategory:kCICategoryDistortionEffect]);
NSLog(@"Blurs: %@", [CIFilter filterNamesInCategory:kCICategoryBlur]);
NSLog(@"Color effects: %@", [CIFilter filterNamesInCategory:kCICategoryColorEffect]);
NSLog(@"Color adjustment: %@", [CIFilter filterNamesInCategory:kCICategoryColorAdjustment]);
NSLog(@"Built-in effects: %@", [CIFilter filterNamesInCategory:kCICategoryBuiltIn]);
In Swift (4.2, at the time of writing this), you can use this code to get all filter names:
For filters in a specified category:
CIFilter.filterNames(inCategory: "Name_of_the_category")
For filters in specified categories:
CIFilter.filterNames(inCategories: ["Name_of_the_category_1", "Name_of_the_category_2"])
For filters in all categories, just pass nil either in inCategory or inCategories:
CIFilter.filterNames(inCategory: nil)
or
CIFilter.filterNames(inCategories: nil)
All the functions above returns an Array
of the filter names in String
values:
[
"CIAccordionFoldTransition",
"CIAdditionCompositing",
"CIAffineClamp",
"CIAffineTile",
"CIAffineTransform",
"CIAreaAverage",
"CIAreaHistogram"...
]