內置濾鏡 (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)。 參數(shù)
min,max,minOut,maxOut都是 float 類型,范圍[0, 1]。 Photoshop獲取的參數(shù)值是從[0, 255],需要轉換成[0, 1]。參數(shù)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:每個像素新轉換的顏色替換原始顏色的一個度數(shù)。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(溫度)屬性以oK為單位。默認為5000,4000時偏冷,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: 根據(jù)每個顏色通道的樣條曲線(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圖片加一個濾鏡。 要想準確,每種像素顏色必須不能依賴其他像素(如,模糊效果就不會起作用)。如果需要更復雜的濾鏡,可以根據(jù)需要創(chuàng)建查找表(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.png和lookup_soft_elegance_2.png文件到程序bundle中。GPUImageSkinToneFilter: 膚色調整濾鏡,影響的范圍一個獨特的淺膚色( light skin-tone colors)的范圍,調整粉色/綠色( pink/green)或者粉色/橘黃色(pink/orange)范圍。 默認是針對白種人的膚色(fair caucasian skin),不過可根據(jù)需要調整。
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=GPUImageSkinToneUpperColorGreen或GPUImageSkinToneUpperColorOrangeGPUImageColorInvertFilter: 反轉顏色。
GPUImageGrayscaleFilter: 將圖片轉為灰階(grayscale)(略快的實現(xiàn)飽和度濾鏡,但不能改變顏色的貢獻
a slightly faster implementation of the saturation filter, without the ability to vary the color contribution)GPUImageMonochromeFilter: 根據(jù)每個像素的亮度(luminance)將圖片轉為單色版本。
intensity: 亮度/強度。某種具體的顏色替代正常圖片顏色的度。[0, 1],默認為1。
color: 該效果的基礎色, 默認(0.6, 0.45, 0.3, 1.0)。GPUImageFalseColorFilter: 在用戶指定的兩種顏色之間,使用亮度(luminance)來混合。
firstColor: 兩種顏色分別指定了哪些顏色分別代替圖像的暗區(qū)和亮區(qū)。 默認(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 (以像素為單位的背景平均模糊半徑的乘數(shù)), 默認4.GPUImageAverageLuminanceThresholdFilter: 這適用于閾值操作,當閾值不停地根據(jù)場景的平均亮度不斷變化的情況。
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: 分析圖片并用每種色值出現(xiàn)的頻率創(chuàng)建一個直方圖(histogram)。該濾鏡輸出的是一個3像素高256像素寬的圖片,圖片垂直中心的像素包含了對應各個顏色出現(xiàn)頻率的像素。每種色值占據(jù)了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)