How to get the list of filter names in CIFilter class?

后端 未结 7 1795
感情败类
感情败类 2021-01-30 23:40

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.

         


        
7条回答
  •  北荒
    北荒 (楼主)
    2021-01-30 23:59

    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.

提交回复
热议问题