GPUImage翻译三:内置滤镜(图片处理)

图片处理 (Image processing)

  • GPUImageTransformFilter: This applies an arbitrary 2-D or 3-D transformation to an image

    • affineTransform: This takes in a CGAffineTransform to adjust an image in 2-D
    • transform3D: This takes in a CATransform3D to manipulate an image in 3-D
    • ignoreAspectRatio: By default, the aspect ratio of the transformed image is maintained, but this can be set to YES to make the transformation independent of aspect ratio
  • GPUImageCropFilter: This crops an image to a specific region, then passes only that region on to the next stage in the filter

    • cropRegion: A rectangular area to crop out of the image, normalized to coordinates from 0.0 - 1.0. The (0.0, 0.0) position is in the upper left of the image.
  • GPUImageLanczosResamplingFilter: This lets you up- or downsample an image using Lanczos resampling, which results in noticeably better quality than the standard linear or trilinear interpolation. Simply use -forceProcessingAtSize: to set the target output resolution for the filter, and the image will be resampled for that new size.

  • GPUImageSharpenFilter: Sharpens the image

    • sharpness: The sharpness adjustment to apply (-4.0 - 4.0, with 0.0 as the default)
  • GPUImageUnsharpMaskFilter: Applies an unsharp mask

    • blurRadiusInPixels: The blur radius of the underlying Gaussian blur. The default is 4.0.
    • intensity: The strength of the sharpening, from 0.0 on up, with a default of 1.0
  • GPUImageGaussianBlurFilter: 硬件优化的、半径可变的高斯模糊(Gaussian blur)。

    • texelSpacingMultiplier: 纹理元素间距的乘数(A multiplier for the spacing between texels), 范围从0开始,默认是1.0。提高该参数会增加模糊强度,但会在结果中引入伪影(artifacts)。 强烈建议接触该参数前,先使用其他参数。
    • blurRadiusInPixels: 用于模糊的半径(以像素为单位),默认值为2.0。这会调整高斯分布函数(distribution function)中的sigma变量。
    • blurRadiusAsFractionOfImageWidth:
    • blurRadiusAsFractionOfImageHeight: 设置这些属性将允许模糊半径随图像的大小缩放。 这些属性是互斥的(mutually exclusive); 设置其中任意一个将会使另一个置为0。(Setting these properties will allow the blur radius to scale with the size of the image.)
    • blurPasses: 模糊次数。 值越大,过滤器(filter)越慢。
  • GPUImageBoxBlurFilter: 硬件优化的、半径可变的方框模糊(box blur)。

    • texelSpacingMultiplier: A multiplier for the spacing between texels, ranging from 0.0 on up, with a default of 1.0. Adjusting this may slightly increase the blur strength, but will introduce artifacts in the result. Highly recommend using other parameters first, before touching this one.
    • blurRadiusInPixels:用于模糊半径(以像素为单位),默认值为2.0。这会调整高斯分布函数(distribution function)中的sigma变量。
    • blurRadiusAsFractionOfImageWidth:
    • blurRadiusAsFractionOfImageHeight: Setting these properties will allow the blur radius to scale with the size of the image
    • blurPasses: 模糊次数。值越大,模糊的越慢。
  • GPUImageSingleComponentGaussianBlurFilter: 基于GPUImageGaussianBlurFilter的修改,仅对红色组件进行操作。

    • texelSpacingMultiplier: A multiplier for the spacing between texels, ranging from 0.0 on up, with a default of 1.0. Adjusting this may slightly increase the blur strength, but will introduce artifacts in the result. Highly recommend using other parameters first, before touching this one.
    • blurRadiusInPixels: 用于模糊半径(以像素为单位),默认值为2.0。这会调整高斯分布函数(distribution function)中的sigma变量。
    • blurRadiusAsFractionOfImageWidth:
    • blurRadiusAsFractionOfImageHeight: Setting these properties will allow the blur radius to scale with the size of the image
    • blurPasses: 模糊次数。值越大,模糊的越慢。
  • GPUImageGaussianSelectiveBlurFilter: 高斯模糊,将焦点保留在一个圆形区域内。

    • blurRadiusInPixels: 用于模糊半径(以像素为单位),默认值为5.0。这会调整高斯分布函数(distribution function)中的sigma变量。
    • excludeCircleRadius: 未模糊的圆形区域的半径,范围(0, 1)
    • excludeCirclePoint: 未模糊的圆形区域的中心点,范围(0, 1),都是以图片大小为基点。
    • excludeBlurSize: 模糊区域和未模糊的圆形区域之间的区域的宽,大小范围(0, 1)
    • aspectRatio: 图像的宽高比,用于调整对焦区域的椭圆度。 默认等于图像宽高比,但您可以修改此值。
  • GPUImageGaussianBlurPositionFilter: 基于GPUImageGaussianSelectiveBlurFilter做的修改, 仅对某个确定的圆形区域进行模糊。

    • blurSize: A multiplier for the size of the blur (模糊区域的size), 从0开始增加, 默认为 1
    • blurCenter: 模糊的中心点, 默认(0.5, 0.5)
    • blurRadius: 模糊半径, 默认1.0
  • GPUImageiOSBlurFilter: iOS系统风格的模糊,像iOS控制中心的模糊一样。

    • blurRadiusInPixels: 用于模糊半径(以像素为单位),默认值为12。这会调整高斯分布函数(distribution function)中的sigma变量。
    • saturation: 饱和度,范围从0 (fully desaturated) 到2.0 (max saturation), 正常值为0.8
    • downsampling: The degree to which to downsample, then upsample the incoming image to minimize computations within the Gaussian blur, with a default of 4.0.
  • GPUImageMedianFilter: 采用三个颜色分量的中值,超过3x3区域。(Takes the median value of the three color components, over a 3x3 area)

  • GPUImageBilateralFilter: 双边滤波模糊 (可用于磨皮),模糊相似的颜色值,同时保留锐边。(A bilateral blur, which tries to blur similar color values while preserving sharp edges)

    • texelSpacingMultiplier: A multiplier for the spacing between texel reads, ranging from 0.0 on up, with a default of 4.0
    • distanceNormalizationFactor: A normalization factor for the distance between central color and sample color, with a default of 8.0.
  • GPUImageTiltShiftFilter: A simulated tilt shift lens effect

    • blurRadiusInPixels: The radius of the underlying blur, in pixels. This is 7.0 by default.
    • topFocusLevel: The normalized location of the top of the in-focus area in the image, this value should be lower than bottomFocusLevel, default 0.4
    • bottomFocusLevel: The normalized location of the bottom of the in-focus area in the image, this value should be higher than topFocusLevel, default 0.6
    • focusFallOffRate: The rate at which the image gets blurry away from the in-focus region, default 0.2
  • GPUImage3x3ConvolutionFilter: Runs a 3x3 convolution kernel against the image

    • convolutionKernel: The convolution kernel is a 3x3 matrix of values to apply to the pixel and its 8 surrounding pixels. The matrix is specified in row-major order, with the top left pixel being one.one and the bottom right three.three. If the values in the matrix don't add up to 1.0, the image could be brightened or darkened.
  • GPUImageSobelEdgeDetectionFilter: Sobel edge detection, with edges highlighted in white

    • texelWidth:
    • texelHeight: These parameters affect the visibility of the detected edges
    • edgeStrength: Adjusts the dynamic range of the filter. Higher values lead to stronger edges, but can saturate the intensity colorspace. Default is 1.0.
  • GPUImagePrewittEdgeDetectionFilter: Prewitt edge detection, with edges highlighted in white

    • texelWidth:
    • texelHeight: These parameters affect the visibility of the detected edges
    • edgeStrength: Adjusts the dynamic range of the filter. Higher values lead to stronger edges, but can saturate the intensity colorspace. Default is 1.0.
  • GPUImageThresholdEdgeDetectionFilter: Performs Sobel edge detection, but applies a threshold instead of giving gradual strength values

    • texelWidth:
    • texelHeight: These parameters affect the visibility of the detected edges
    • edgeStrength: Adjusts the dynamic range of the filter. Higher values lead to stronger edges, but can saturate the intensity colorspace. Default is 1.0.
    • threshold: Any edge above this threshold will be black, and anything below white. Ranges from 0.0 to 1.0, with 0.8 as the default
  • GPUImageCannyEdgeDetectionFilter: This uses the full Canny process to highlight one-pixel-wide edges

    • texelWidth:
    • texelHeight: These parameters affect the visibility of the detected edges
    • blurRadiusInPixels: The underlying blur radius for the Gaussian blur. Default is 2.0.
    • blurTexelSpacingMultiplier: The underlying blur texel spacing multiplier. Default is 1.0.
    • upperThreshold: Any edge with a gradient magnitude above this threshold will pass and show up in the final result. Default is 0.4.
    • lowerThreshold: Any edge with a gradient magnitude below this threshold will fail and be removed from the final result. Default is 0.1.
  • GPUImageHarrisCornerDetectionFilter: Runs the Harris corner detection algorithm on an input image, and produces an image with those corner points as white pixels and everything else black. The cornersDetectedBlock can be set, and you will be provided with a list of corners (in normalized 0..1 X, Y coordinates) within that callback for whatever additional operations you want to perform.

    • blurRadiusInPixels: The radius of the underlying Gaussian blur. The default is 2.0.
    • sensitivity: An internal scaling factor applied to adjust the dynamic range of the cornerness maps generated in the filter. The default is 5.0.
    • threshold: The threshold at which a point is detected as a corner. This can vary significantly based on the size, lighting conditions, and iOS device camera type, so it might take a little experimentation to get right for your cases. Default is 0.20.
  • GPUImageNobleCornerDetectionFilter: Runs the Noble variant on the Harris corner detector. It behaves as described above for the Harris detector.

    • blurRadiusInPixels: The radius of the underlying Gaussian blur. The default is 2.0.
    • sensitivity: An internal scaling factor applied to adjust the dynamic range of the cornerness maps generated in the filter. The default is 5.0.
    • threshold: The threshold at which a point is detected as a corner. This can vary significantly based on the size, lighting conditions, and iOS device camera type, so it might take a little experimentation to get right for your cases. Default is 0.2.
  • GPUImageShiTomasiCornerDetectionFilter: Runs the Shi-Tomasi feature detector. It behaves as described above for the Harris detector.

    • blurRadiusInPixels: The radius of the underlying Gaussian blur. The default is 2.0.
    • sensitivity: An internal scaling factor applied to adjust the dynamic range of the cornerness maps generated in the filter. The default is 1.5.
    • threshold: The threshold at which a point is detected as a corner. This can vary significantly based on the size, lighting conditions, and iOS device camera type, so it might take a little experimentation to get right for your cases. Default is 0.2.
  • GPUImageNonMaximumSuppressionFilter: Currently used only as part of the Harris corner detection filter, this will sample a 1-pixel box around each pixel and determine if the center pixel's red channel is the maximum in that area. If it is, it stays. If not, it is set to 0 for all color components.

  • GPUImageXYDerivativeFilter: An internal component within the Harris corner detection filter, this calculates the squared difference between the pixels to the left and right of this one, the squared difference of the pixels above and below this one, and the product of those two differences.

  • GPUImageCrosshairGenerator: This draws a series of crosshairs on an image, most often used for identifying machine vision features. It does not take in a standard image like other filters, but a series of points in its -renderCrosshairsFromArray:count: method, which does the actual drawing. You will need to force this filter to render at the particular output size you need.

    • crosshairWidth: The width, in pixels, of the crosshairs to be drawn onscreen.
  • GPUImageDilationFilter: This performs an image dilation operation, where the maximum intensity of the red channel in a rectangular neighborhood is used for the intensity of this pixel. The radius of the rectangular area to sample over is specified on initialization, with a range of 1-4 pixels. This is intended for use with grayscale images, and it expands bright regions.

  • GPUImageRGBDilationFilter: This is the same as the GPUImageDilationFilter, except that this acts on all color channels, not just the red channel.

  • GPUImageErosionFilter: This performs an image erosion operation, where the minimum intensity of the red channel in a rectangular neighborhood is used for the intensity of this pixel. The radius of the rectangular area to sample over is specified on initialization, with a range of 1-4 pixels. This is intended for use with grayscale images, and it expands dark regions.

  • GPUImageRGBErosionFilter: This is the same as the GPUImageErosionFilter, except that this acts on all color channels, not just the red channel.

  • GPUImageOpeningFilter: This performs an erosion on the red channel of an image, followed by a dilation of the same radius. The radius is set on initialization, with a range of 1-4 pixels. This filters out smaller bright regions.

  • GPUImageRGBOpeningFilter: This is the same as the GPUImageOpeningFilter, except that this acts on all color channels, not just the red channel.

  • GPUImageClosingFilter: This performs a dilation on the red channel of an image, followed by an erosion of the same radius. The radius is set on initialization, with a range of 1-4 pixels. This filters out smaller dark regions.

  • GPUImageRGBClosingFilter: This is the same as the GPUImageClosingFilter, except that this acts on all color channels, not just the red channel.

  • GPUImageLocalBinaryPatternFilter: This performs a comparison of intensity of the red channel of the 8 surrounding pixels and that of the central one, encoding the comparison results in a bit string that becomes this pixel intensity. The least-significant bit is the top-right comparison, going counterclockwise to end at the right comparison as the most significant bit.

  • GPUImageLowPassFilter: This applies a low pass filter to incoming video frames. This basically accumulates a weighted rolling average of previous frames with the current ones as they come in. This can be used to denoise video, add motion blur, or be used to create a high pass filter.

    • filterStrength: This controls the degree by which the previous accumulated frames are blended with the current one. This ranges from 0.0 to 1.0, with a default of 0.5.
  • GPUImageHighPassFilter: This applies a high pass filter to incoming video frames. This is the inverse of the low pass filter, showing the difference between the current frame and the weighted rolling average of previous ones. This is most useful for motion detection.

    • filterStrength: This controls the degree by which the previous accumulated frames are blended and then subtracted from the current one. This ranges from 0.0 to 1.0, with a default of 0.5.
  • GPUImageMotionDetector: This is a motion detector based on a high-pass filter. You set the motionDetectionBlock and on every incoming frame it will give you the centroid of any detected movement in the scene (in normalized X,Y coordinates) as well as an intensity of motion for the scene.

    • lowPassFilterStrength: This controls the strength of the low pass filter used behind the scenes to establish the baseline that incoming frames are compared with. This ranges from 0.0 to 1.0, with a default of 0.5.
  • GPUImageHoughTransformLineDetector: Detects lines in the image using a Hough transform into parallel coordinate space. This approach is based entirely on the PC lines process developed by the Graph@FIT research group at the Brno University of Technology and described in their publications: M. Dubská, J. Havel, and A. Herout. Real-Time Detection of Lines using Parallel Coordinates and OpenGL. Proceedings of SCCG 2011, Bratislava, SK, p. 7 (http://medusa.fit.vutbr.cz/public/data/papers/2011-SCCG-Dubska-Real-Time-Line-Detection-Using-PC-and-OpenGL.pdf) and M. Dubská, J. Havel, and A. Herout. PClines — Line detection using parallel coordinates. 2011 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), p. 1489- 1494 (http://medusa.fit.vutbr.cz/public/data/papers/2011-CVPR-Dubska-PClines.pdf).

    • edgeThreshold: A threshold value for which a point is detected as belonging to an edge for determining lines. Default is 0.9.
    • lineDetectionThreshold: A threshold value for which a local maximum is detected as belonging to a line in parallel coordinate space. Default is 0.20.
    • linesDetectedBlock: This block is called on the detection of lines, usually on every processed frame. A C array containing normalized slopes and intercepts in m, b pairs (y=mx+b) is passed in, along with a count of the number of lines detected and the current timestamp of the video frame.
  • GPUImageLineGenerator: A helper class that generates lines which can overlay the scene. The color of these lines can be adjusted using -setLineColorRed:green:blue:

    • lineWidth: The width of the lines, in pixels, with a default of 1.0.
  • GPUImageMotionBlurFilter: Applies a directional motion blur to an image

    • blurSize: A multiplier for the blur size, ranging from 0.0 on up, with a default of 1.0
    • blurAngle: The angular direction of the blur, in degrees. 0 degrees by default.
  • GPUImageZoomBlurFilter: Applies a directional motion blur to an image

    • blurSize: A multiplier for the blur size, ranging from 0.0 on up, with a default of 1.0
    • blurCenter: The normalized center of the blur. (0.5, 0.5) by default
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,744评论 6 502
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,505评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 163,105评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,242评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,269评论 6 389
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,215评论 1 299
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,096评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,939评论 0 274
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,354评论 1 311
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,573评论 2 333
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,745评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,448评论 5 344
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,048评论 3 327
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,683评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,838评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,776评论 2 369
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,652评论 2 354

推荐阅读更多精彩内容