GPUImage翻译二:内置滤镜(颜色调整)

内置滤镜 (Built-in filters

本框架内置了125种滤镜,分为以下几类:

颜色调整(Color adjustments

  • GPUImageBrightnessFilter:亮度。
    brightness: 默认为0.0,范围[-1.0, 1.0]

  • GPUImageExposureFilter: 曝光度。
    exposure: 默认为0.0, 范围[-10.0, 10.0]

  • GPUImageContrastFilter: 对比度。
    contrast: 默认1.0,范围[0.0, 4.0]

  • GPUImageSaturationFilter: 饱和度
    saturation: 饱和度和去饱和度,默认为1.0,范围[0.0, 2.0]

  • GPUImageGammaFilter: 伽马值(Gamma)。
    gamma: 默认为1.0,范围[0.0, 3.0]

  • GPUImageLevelsFilter:类似Photoshop中的色阶(levels)。 参数 min, max, minOutmaxOut 都是 float 类型,范围 [0, 1]。 Photoshop获取的参数值是从[0, 255],需要转换成[0, 1]。参数 gamma/mid 也是 float >= 0\,这个值跟Photoshop一致。 If you want to apply levels to RGB as well as individual channels you need to use this filter twice - first for the individual channels and then for all channels.

  • GPUImageColorMatrixFilter: Transforms the colors of an image by applying a matrix to them通过矩阵(matrix)转换图片颜色。
    colorMatrix:一个4x4的矩阵应用于图片的每种颜色
    intensity:每个像素新转换的颜色替换原始颜色的一个度数。

  • GPUImageRGBFilter: RGB值。
    red: Normalized values by which each color channel is multiplied. 默认为1.0, 范围[0.0, 1.0].
    green
    blue

  • GPUImageHueFilter: 色相(Hue值)。
    hue: hue 角(angle), 以度(degrees)为单位。默认是90度。

  • GPUImageVibranceFilter:自然饱和度(vibrance)。
    vibrance: 默认为0.0。建议范围为[-1.2, 1.2]

  • GPUImageWhiteBalanceFilter: 白平衡。
    temperature: temperature(温度)属性以ºK为单位。默认为50004000时偏冷,7000时偏暖。注意,4000-5000的尺度视觉上跟5000-7000的尺度视觉上一样重要(Note that the scale between 4000 and 5000 is nearly as visually significant as that between 5000 and 7000).
    tint: 色彩值为 -200时 偏绿 , 200时偏粉(pink),默认为0。

  • GPUImageToneCurveFilter: 根据每个颜色通道的样条曲线(spline curves)调整图片的颜色。
    redControlPoints:
    greenControlPoints:
    blueControlPoints:
    rgbCompositeControlPoints: 色调曲线(tone curve)接受一系列的控制点,来为每种颜色元素定义样条曲线(spline curve)。 它们以CGPoints的形式用NSValue包装并保存在NSArray中,其中X、Y坐标都是从[0, 1]。 默认是 (0,0), (0.5,0.5), (1,1).

  • GPUImageHighlightShadowFilter: 阴影和高亮。
    shadows: 值越大阴影越淡,默认是0.0,范围[0.0, 1.0]
    highlights: 值越小高亮效果越深,默认为1.0,范围[1.0, 0.0]

  • GPUImageHighlightShadowTintFilter: 通过颜色和亮度(intensity)对图片的阴影和高亮(hightlights)着色。
    shadowTintColor: Shadow tint RGB color (GPUVector4). 默认: {1.0f, 0.0f, 0.0f, 1.0f} (red).
    highlightTintColor: Highlight tint RGB color (GPUVector4). 默认: {0.0f, 0.0f, 1.0f, 1.0f} (blue).
    shadowTintIntensity: Shadow tint intensity, 范围[0, 1]. 默认0。
    highlightTintIntensity: Highlight tint intensity, 范围[0, 1], 默认0。

  • GPUImageLookupFilter: 使用RGB查找(lookup)图片,重新绘制图中的颜色。首先,用你最喜欢的图片编辑工具给工程中的lookup.png图片加一个滤镜。 要想准确,每种像素颜色必须不能依赖其他像素(如,模糊效果就不会起作用)。如果需要更复杂的滤镜,可以根据需要创建查找表(lookup tables)。准备好之后,用新生成的lookup.png文件作为GPUImageLookupFilter的第二个input。

  • GPUImageAmatorkaFilter: 基于Photoshop中的 Amatorka 动作的图片滤镜。要用这个效果,必须添加lookup_amatorka.png文件到程序bundle中。

  • GPUImageMissEtikateFilter: 基于Photoshop中的 Miss Etikate 动作的图片滤镜。要用这个效果,必须添加lookup_miss_etikate.png文件到程序bundle中。

  • GPUImageSoftEleganceFilter: Another lookup-based color remapping(重映射、重测绘) filter。要用这个效果,必须添加lookup_soft_elegance_1.pnglookup_soft_elegance_2.png文件到程序bundle中。

  • GPUImageSkinToneFilter: 肤色调整滤镜,影响的范围一个独特的浅肤色( light skin-tone colors)的范围,调整粉色/绿色( pink/green)或者粉色/橘黄色(pink/orange)范围。 默认是针对白种人的肤色(fair caucasian skin),不过可根据需要调整。
    skinToneAdjust: 调整皮肤色调(Amount to adjust skin tone)。默认: 0.0, 建议范围 [-0.3, 0.3]
    skinHue: 被检测的皮肤色相(Skin hue to be detected)。 默认: 0.05 (白种人肤色偏红/fair caucasian to reddish skin).
    skinHueThreshold: Amount of variance(变化、方差) in skin hue. 默认: 40.0.
    maxHueShift: 允许最大的色相移动量(Maximum amount of hue shifting allowed). 默认: 0.25.
    maxSaturationShift =要移动的最大饱和度(当使用橘黄色时)= Maximum amount of saturation to be shifted (when using orange). 默认: 0.4.
    upperSkinToneColor = GPUImageSkinToneUpperColorGreenGPUImageSkinToneUpperColorOrange

  • GPUImageColorInvertFilter: 反转颜色。

  • GPUImageGrayscaleFilter: 将图片转为灰阶(grayscale)(略快的实现饱和度滤镜,但不能改变颜色的贡献 a slightly faster implementation of the saturation filter, without the ability to vary the color contribution

  • GPUImageMonochromeFilter: 根据每个像素的亮度(luminance)将图片转为单色版本。
    intensity: 亮度/强度。某种具体的颜色替代正常图片颜色的度。[0, 1],默认为1。
    color: 该效果的基础色, 默认(0.6, 0.45, 0.3, 1.0)

  • GPUImageFalseColorFilter: 在用户指定的两种颜色之间,使用亮度(luminance)来混合。
    firstColor: 两种颜色分别指定了哪些颜色分别代替图像的暗区和亮区。 默认(0.0, 0.0, 0.5)amd (1.0, 0.0, 0.0)
    secondColor:

  • GPUImageHazeFilter: 阴霾(haze) (类似 UV 滤镜,又叫紫外线滤光镜)。

    distance: 应用的颜色的强度(Strength)。 默认0\。 Values between -.3 and .3 are best.
    slope: 颜色变化量. 默认 0\. Values between -.3 and .3 are best.

  • GPUImageSepiaFilter: 简单的 sepia tone 滤镜

    intensity: 褐色色调替换正常图片颜色的度。(范围[0.0 - 1.0], 默认1.0)。

  • GPUImageOpacityFilter: 调整传入图片的Alpha通道。
    opacity: 改变Alpha值。 ([0.0 - 1.0], 默认 1.0)。

  • GPUImageSolidColorGenerator: 生成一张纯色(solid color)图片。通过-forceProcessingAtSize:方法设置图片尺寸。
    color: 该属性是一个由四种元素构成的结构体,用于填充图片。

  • GPUImageLuminanceThresholdFilter: 亮度(luminance)高于阈值(threshold)的像素将显示为白色,反之为黑色。
    threshold: The luminance threshold(亮度阈值), 范围[0.0 to 1.0], 默认 0.5

  • GPUImageAdaptiveThresholdFilter: 确定一个像素点周围的局部亮度(local luminance)。 然后,若低于该局部亮度将该像素点转为黑色,反之转为白色。这对于在不停变化亮度的情况下识别文字很有帮助。
    blurRadiusInPixels: A multiplier for the background averaging blur radius in pixels (以像素为单位的背景平均模糊半径的乘数), 默认4.

  • GPUImageAverageLuminanceThresholdFilter: 这适用于阈值操作,当阈值不停地根据场景的平均亮度不断变化的情况。
    thresholdMultiplier: This is a factor that the average luminance will be multiplied by in order to arrive at the final threshold to use。 默认1.0

  • GPUImageHistogramFilter: 分析图片并用每种色值出现的频率创建一个直方图(histogram)。该滤镜输出的是一个3像素高256像素宽的图片,图片垂直中心的像素包含了对应各个颜色出现频率的像素。每种色值占据了256宽的一个像素位置,从左到右分别是[0, 255]。 该直方图可以用于单个颜色通道(kGPUImageHistogramRed, kGPUImageHistogramGreen, kGPUImageHistogramBlue), 图片亮度(kGPUImageHistogramLuminance), 或者同时三种颜色 (kGPUImageHistogramRGB).
    downsamplingFactor: 并不是对每个像素进行采样,而是指定图像的哪一部分被采样。默认16,最小值为1。这需要阻止直方图被饱和(saturating),直方图在每个颜色值过载(overloaded)之前只能记录256个像素。

  • GPUImageHistogramGenerator: This is a special filter, in that it's primarily intended to work with the GPUImageHistogramFilter. It generates an output representation of the color histograms generated by GPUImageHistogramFilter, but it could be repurposed to display other kinds of values. It takes in an image and looks at the center (vertical) pixels. It then plots the numerical values of the RGB components in separate colored graphs in an output texture. You may need to force a size for this filter in order to make its output visible.

  • GPUImageAverageColor: This processes an input image and determines the average color of the scene, by averaging the RGBA components for each pixel in the image. A reduction process is used to progressively downsample the source image on the GPU, followed by a short averaging calculation on the CPU. The output from this filter is meaningless, but you need to set the colorAverageProcessingFinishedBlock property to a block that takes in four color components and a frame time and does something with them.

  • GPUImageLuminosity: Like the GPUImageAverageColor, this reduces an image to its average luminosity. You need to set the luminosityProcessingFinishedBlock to handle the output of this filter, which just returns a luminosity value and a frame time.

  • GPUImageChromaKeyFilter: For a given color in the image, sets the alpha channel to 0. This is similar to the GPUImageChromaKeyBlendFilter, only instead of blending in a second image for a matching color this doesn't take in a second image and just turns a given color transparent.

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

推荐阅读更多精彩内容