如何获取CIFilter类中的过滤器名称列表?

时间:2012-01-27 12:59:43

标签: macos cocoa

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

[CIFilter filterWithName: @"CIExposureAdjust"
                      keysAndValues: @"inputImage", [_imageView image], nil];

9 个答案:

答案 0 :(得分:26)

我写信给您之前发布的所有过滤器的帖子链接。我会重复:link to all filters

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

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

等等。

答案 1 :(得分:17)

您需要做的就是询问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;
    };
}

但大多数情况下,您可能只使用the docs

答案 2 :(得分:14)

我在CIFilter类中找到了名称列表,核心图像过滤器。这是链接names in CIFilter和过滤器列表。

过滤器

<强> CICategoryBlur
CIBoxBlur
CIDiscBlur
CIGaussianBlur
CIMaskedVariableBlur
CIMedianFilter
CIMotionBlur
CINoiseReduction

<强> CICategoryColorAdjustment
CIColorClamp
CIColorControls
CIColorMatrix
CIColorPolynomial
CIExposureAdjust
CIGammaAdjust
CIHueAdjust
CILinearToSRGBToneCurve
CISRGBToneCurveToLinear
CITemperatureAndTint
CIToneCurve
CIVibrance
CIWhitePointAdjust

<强> CICategoryColorEffect
CIColorCrossPolynomial
CIColorCube
CIColorCubeWithColorSpace
CIColorInvert
CIColorMap
CIColorMonochrome
CIColorPosterize
CIFalseColor
CIMaskToAlpha
CIMaximumComponent
CIMinimumComponent
CIPhotoEffectChrome
CIPhotoEffectFade
CIPhotoEffectInstant
CIPhotoEffectMono
CIPhotoEffectNoir
CIPhotoEffectProcess
CIPhotoEffectTonal
CIPhotoEffectTransfer
CISepiaTone
CIVignette
CIVignetteEffect

<强> CICategoryCompositeOperation
CIAdditionCompositing
CIColorBlendMode
CIColorBurnBlendMode
CIColorDodgeBlendMode
CIDarkenBlendMode
CIDifferenceBlendMode
CIDivideBlendMode
CIExclusionBlendMode
CIHardLightBlendMode
CIHueBlendMode
CILightenBlendMode
CILinearBurnBlendMode
CILinearDodgeBlendMode
CILuminosityBlendMode
CIMaximumCompositing
CIMinimumCompositing
CIMultiplyBlendMode
CIMultiplyCompositing
CIOverlayBlendMode
CIPinLightBlendMode
CISaturationBlendMode
CIScreenBlendMode
CISoftLightBlendMode
CISourceAtopCompositing
CISourceInCompositing
CISourceOutCompositing
CISourceOverCompositing
CISubtractBlendMode

<强> CICategoryDistortionEffect
CIBumpDistortion
CIBumpDistortionLinear
CICircleSplashDistortion
CICircularWrap
CIDroste
CIDisplacementDistortion
CIGlassDistortion
CIGlassLozenge
CIHoleDistortion
CILightTunnel
CIPinchDistortion
CIStretchCrop
CITorusLensDistortion
CITwirlDistortion
CIVortexDistortion

<强> CICategoryGenerator
CIAztecCodeGenerator
CICheckerboardGenerator
CICode128BarcodeGenerator
CIConstantColorGenerator
CILenticularHaloGenerator
CIPDF417BarcodeGenerator
CIQRCodeGenerator
CIRandomGenerator
CIStarShineGenerator
CIStripesGenerator
CISunbeamsGenerator

<强> CICategoryGeometryAdjustment
CIAffineTransform
CICrop
CILanczosScaleTransform
CIPerspectiveCorrection
CIPerspectiveTransform
CIPerspectiveTransformWithExtent
CIStraightenFilter

<强> CICategoryGradient
CIGaussianGradient
CILinearGradient
CIRadialGradient
CISmoothLinearGradient

<强> CICategoryHalftoneEffect
CICircularScreen
CICMYKHalftone
CIDotScreen
CIHatchedScreen
CILineScreen

<强> CICategoryReduction
CIAreaAverage
CIAreaHistogram
CIRowAverage
CIColumnAverage
CIHistogramDisplayFilter
CIAreaMaximum
CIAreaMinimum
CIAreaMaximumAlpha
CIAreaMinimumAlpha

<强> CICategorySharpen
CISharpenLuminance
CIUnsharpMask

<强> CICategoryStylize
CIBlendWithAlphaMask
CIBlendWithMask
CIBloom
CIComicEffect
CIConvolution3X3
CIConvolution5X5
CIConvolution7X7
CIConvolution9Horizo​​ntal
CIConvolution9Vertical
CICrystallize
CIDepthOfField
CIEdges
CIEdgeWork
CIGloom
CIHeightFieldFromMask
CIHexagonalPixellate
CIHighlightShadowAdjust
CILineOverlay
CIPixellate
CIPointillize
CIShadedMaterial
CISpotColor
CISpotLight

<强> CICategoryTileEffect
CIAffineClamp
CIAffineTile
CIEightfoldReflectedTile
CIFourfoldReflectedTile
CIFourfoldRotatedTile
CIFourfoldTranslatedTile
CIGlideReflectedTile
CIKaleidoscope
CIOpTile
CIParallelogramTile
CIPerspectiveTile
CISixfoldReflectedTile
CISixfoldRotatedTile
CITriangleKaleidoscope
CITriangleTile
CITwelvefoldReflectedTile

<强> CICategoryTransition
CIAccordionFoldTransition
CIBarsSwipeTransition
CICopyMachineTransition
CIDisintegrateWithMaskTransition
CIDissolveTransition
CIFlashTransition
CIModTransition
CIPageCurlTransition
CIPageCurlWithShadowTransition
CIRippleTransition
CISwipeTransition

答案 3 :(得分:2)

可能您可以尝试以下CIFilter类的方法

+ (NSArray *)filterNamesInCategory:(NSString *)category

答案 4 :(得分:0)

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]);

答案 5 :(得分:0)

在Swift(撰写本文时为4.2)中,您可以使用此代码获取所有过滤器名称

对于指定类别中的过滤器:

CIFilter.filterNames(inCategory: "Name_of_the_category")

对于指定类别中的过滤器:

CIFilter.filterNames(inCategories: ["Name_of_the_category_1", "Name_of_the_category_2"])

对于所有类别中的过滤器,只需在inCategory或inCategories中传递nil:

CIFilter.filterNames(inCategory: nil)

CIFilter.filterNames(inCategories: nil)

以上所有功能均返回Array值中的String过滤器名称:

[ "CIAccordionFoldTransition", "CIAdditionCompositing", "CIAffineClamp", "CIAffineTile", "CIAffineTransform", "CIAreaAverage", "CIAreaHistogram"... ]

答案 6 :(得分:0)

iOS 14,Swift 5

必须承认它不容易阅读,但其答案与目标C上的第一个答案相当。

for filtername in filters {
  print("filter \(filtername)")
  print("attributes \(CIFilter.init(name: filtername)?.attributes.keys.description)")
}

产生这个...

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\"]")

因此,这些长字符串中包含信息,您只需要选择它即可:)

答案 7 :(得分:0)

Noah Gilmore 有一个非常方便的过滤器工具来演示和记录几乎所有的 cifilters 和过滤器参数.. 在应用商店“CIFilter.io”上查看。他在网站 https://cifilter.io

上也有同样的内容

答案 8 :(得分:0)

iOS 14、Swift 5

在这里您还可以找到协议支持的 CIFilter 函数数组。

                      CIFilter.hueSaturationValueGradient(),
                      CIFilter.linearGradient(),
                      CIFilter.radialGradient(),
                      CIFilter.smoothLinearGradient(),
                      CIFilter.sharpenLuminance(),
                      CIFilter.unsharpMask(),
                      CIFilter.dotScreen(),
                      CIFilter.hatchedScreen(),
                      CIFilter.lineScreen(),
                      CIFilter.bicubicScaleTransform(),
                      CIFilter.edgePreserveUpsample(),
                      CIFilter.keystoneCorrectionCombined(),
                      CIFilter.keystoneCorrectionHorizontal(),
                      CIFilter.keystoneCorrectionVertical(),
                      CIFilter.lanczosScaleTransform(),
                      CIFilter.perspectiveCorrection(),
                      CIFilter.perspectiveRotate(),
                      CIFilter.perspectiveTransform(),
                      CIFilter.perspectiveTransformWithExtent(),
                      CIFilter.straighten(),
                      CIFilter.accordionFoldTransition(),
                      CIFilter.barsSwipeTransition(),
                      CIFilter.copyMachineTransition(),
                      CIFilter.disintegrateWithMaskTransition(),
                      CIFilter.dissolveTransition(),
                      CIFilter.flashTransition(),
                      CIFilter.modTransition(),
                      CIFilter.pageCurlTransition(),
                      CIFilter.pageCurlWithShadowTransition(),
                      CIFilter.rippleTransition(),
                      CIFilter.swipeTransition(),
                      CIFilter.additionCompositing(),
                      CIFilter.colorBlendMode(),
                      CIFilter.colorBurnBlendMode(),
                      CIFilter.colorDodgeBlendMode(),
                      CIFilter.darkenBlendMode(),
                      CIFilter.differenceBlendMode(),
                      CIFilter.divideBlendMode(),
                      CIFilter.exclusionBlendMode(),
                      CIFilter.hardLightBlendMode(),
                      CIFilter.hueBlendMode(),
                      CIFilter.lightenBlendMode(),
                      CIFilter.linearBurnBlendMode(),
                      CIFilter.linearDodgeBlendMode(),
                      CIFilter.luminosityBlendMode(),
                      CIFilter.maximumCompositing(),
                      CIFilter.minimumCompositing(),
                      CIFilter.multiplyBlendMode(),
                      CIFilter.multiplyCompositing(),
                      CIFilter.overlayBlendMode(),
                      CIFilter.pinLightBlendMode(),
                      CIFilter.saturationBlendMode(),
                      CIFilter.screenBlendMode(),
                      CIFilter.softLightBlendMode(),
                      CIFilter.sourceAtopCompositing(),
                      CIFilter.sourceInCompositing(),
                      CIFilter.sourceOutCompositing(),
                      CIFilter.sourceOverCompositing(),
                      CIFilter.subtractBlendMode(),
                      CIFilter.colorAbsoluteDifference(),
                      CIFilter.colorClamp(),
                      CIFilter.colorControls(),
                      CIFilter.colorMatrix(),
                      CIFilter.colorPolynomial(),
                      CIFilter.colorThreshold(),
                      CIFilter.colorThresholdOtsu(),
                      CIFilter.depthToDisparity(),
                      CIFilter.disparityToDepth(),
                      CIFilter.exposureAdjust(),
                      CIFilter.gammaAdjust(),
                      CIFilter.hueAdjust(),
                      CIFilter.linearToSRGBToneCurve(),
                      CIFilter.sRGBToneCurveToLinear(),
                      CIFilter.temperatureAndTint(),
                      CIFilter.toneCurve(),
                      CIFilter.vibrance(),
                      CIFilter.whitePointAdjust(),
                      CIFilter.colorCrossPolynomial(),
                      CIFilter.colorCube(),
                      CIFilter.colorCubesMixedWithMask(),
                      CIFilter.colorCubeWithColorSpace(),
                      CIFilter.colorCurves(),
                      CIFilter.colorInvert(),
                      CIFilter.colorMap(),
                      CIFilter.colorMonochrome(),
                      CIFilter.colorPosterize(),
                      CIFilter.dither(),
                      CIFilter.documentEnhancer(),
                      CIFilter.falseColor(),
                      CIFilter.labDeltaE(),
                      CIFilter.maskToAlpha(),
                      CIFilter.maximumComponent(),
                      CIFilter.minimumComponent(),
                      CIFilter.paletteCentroid(),
                      CIFilter.palettize(),
                      CIFilter.photoEffectChrome(),
                      CIFilter.photoEffectFade(),
                      CIFilter.photoEffectInstant(),
                      CIFilter.photoEffectMono(),
                      CIFilter.photoEffectNoir(),
                      CIFilter.photoEffectProcess(),
                      CIFilter.photoEffectTonal(),
                      CIFilter.photoEffectTransfer(),
                      CIFilter.sepiaTone(),
                      CIFilter.thermal(),
                      CIFilter.vignette(),
                      CIFilter.vignetteEffect(),
                      CIFilter.xRay(),
                      CIFilter.bumpDistortion(),
                      CIFilter.bumpDistortionLinear(),
                      CIFilter.circleSplashDistortion(),
                      CIFilter.circularWrap(),
                      CIFilter.displacementDistortion(),
                      CIFilter.droste(),
                      CIFilter.glassDistortion(),
                      CIFilter.glassLozenge(),
                      CIFilter.holeDistortion(),
                      CIFilter.lightTunnel(),
                      CIFilter.ninePartStretched(),
                      CIFilter.ninePartTiled(),
                      CIFilter.pinchDistortion(),
                      CIFilter.stretchCrop(),
                      CIFilter.torusLensDistortion(),
                      CIFilter.twirlDistortion(),
                      CIFilter.vortexDistortion(),
                      CIFilter.affineClamp(),
                      CIFilter.affineTile(),
                      CIFilter.eightfoldReflectedTile(),
                      CIFilter.fourfoldReflectedTile(),
                      CIFilter.fourfoldRotatedTile(),
                      CIFilter.fourfoldTranslatedTile(),
                      CIFilter.glideReflectedTile(),
                      CIFilter.kaleidoscope(),
                      CIFilter.opTile(),
                      CIFilter.parallelogramTile(),
                      CIFilter.perspectiveTile(),
                      CIFilter.sixfoldReflectedTile(),
                      CIFilter.sixfoldRotatedTile(),
                      CIFilter.triangleKaleidoscope(),
                      CIFilter.triangleTile(),
                      CIFilter.twelvefoldReflectedTile(),
                      CIFilter.attributedTextImageGenerator(),
                      CIFilter.aztecCodeGenerator(),
                      CIFilter.barcodeGenerator(),
                      CIFilter.checkerboardGenerator(),
                      CIFilter.code128BarcodeGenerator(),
                      CIFilter.lenticularHaloGenerator(),
                      CIFilter.meshGenerator(),
                      CIFilter.pdf417BarcodeGenerator(),
                      CIFilter.qrCodeGenerator(),
                      CIFilter.randomGenerator(),
                      CIFilter.roundedRectangleGenerator(),
                      CIFilter.starShineGenerator(),
                      CIFilter.stripesGenerator(),
                      CIFilter.sunbeamsGenerator(),
                      CIFilter.textImageGenerator(),
                      CIFilter.blendWithAlphaMask(),
                      CIFilter.blendWithBlueMask(),
                      CIFilter.blendWithMask(),
                      CIFilter.blendWithRedMask(),
                      CIFilter.bloom(),
                      CIFilter.comicEffect(),
                      CIFilter.convolution3X3(),
                      CIFilter.convolution5X5(),
                      CIFilter.convolution7X7(),
                      CIFilter.convolution9Horizontal(),
                      CIFilter.convolution9Vertical(),
                      CIFilter.coreMLModel(),
                      CIFilter.crystallize(),
                      CIFilter.depthOfField(),
                      CIFilter.edges(),
                      CIFilter.edgeWork(),
                      CIFilter.gaborGradients(),
                      CIFilter.gloom(),
                      CIFilter.heightFieldFromMask(),
                      CIFilter.hexagonalPixellate(),
                      CIFilter.highlightShadowAdjust(),
                      CIFilter.lineOverlay(),
                      CIFilter.mix(),
                      CIFilter.pixellate(),
                      CIFilter.pointillize(),
                      CIFilter.saliencyMap(),
                      CIFilter.shadedMaterial(),
                      CIFilter.spotColor(),
                      CIFilter.spotLight(),
                      CIFilter.bokehBlur(),
                      CIFilter.boxBlur(),
                      CIFilter.discBlur(),
                      CIFilter.gaussianBlur(),
                      CIFilter.maskedVariableBlur(),
                      CIFilter.median(),
                      CIFilter.morphologyGradient(),
                      CIFilter.morphologyMaximum(),
                      CIFilter.morphologyMinimum(),
                      CIFilter.morphologyRectangleMaximum(),
                      CIFilter.morphologyRectangleMinimum(),
                      CIFilter.motionBlur(),
                      CIFilter.noiseReduction(),
                      CIFilter.zoomBlur] as [AnyObject]