如何在CIFilter类中获得筛选器名称列表?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (18)

我使用以下代码进行曝光调整及其工作。我需要锐化,去噪,荧光,色温,阴影,模糊等的过滤器名称。

[CIFilter filterWithName: @"CIExposureAdjust"
                      keysAndValues: @"inputImage", [_imageView image], nil];
提问于
用户回答回答于

我会重复:链接到所有过滤器

例如你需要模糊效果。模糊是类别,并有7个过滤器:

  • CIBoxBlur
  • CIDiscBlur
  • CIGaussianBlur
  • CIMedianFilter
  • CIMotionBlur
  • CINoiseReduction
  • CIZoomBlur。

用户回答回答于

你只需要问CIFilter筛选器的名称。然后,可以向每个过滤器请求它的attributes,它返回描述过滤器接受的每个输入和输出参数的困。

NSArray* filters = [CIFilter filterNamesInCategories:nil];
for (NSString* filterName in filters)
{
    NSLog(@"Filter: %@", filterName);
    NSLog(@"Parameters: %@", [[CIFilter filterWithName:filterName] attributes]);
}

例如,这是上述代码的输出。CIZoomBlur过滤器:

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;
    };
}

扫码关注云+社区