Home

Awesome

MetalAcc Language Metal Carthage compatible Pod License

GPU-based media processing library using Metal written in Swift.

Overview

MetalAcc is a GPU-Based media processing library that lets you apply GPU-accelerated filters to images.

This library is highly insperad by famous library GPUImage. Basically following the interface of GPUImage, but using Metal and Swift, Apple's new graphics and compute application programming interface and programing language.

This library is currently under programing.And more filters will be adding soon.

Requirements

Device NameGPU
iPhone 6sApple A9 GPU
iPhone 6s PlusApple A9 GPU
iPhone 6Apple A8 GPU
iPhone 6 PlusApple A8 GPU
iPhone 5sApple A7 GPU
iPad Pro Wi-FiApple A9 GPU
iPad Pro Wi-Fi + CellularApple A9 GPU
iPad Air 2 Wi-FiApple A8 GPU
iPad Air 2 Wi-Fi + CellularApple A8 GPU
iPad Air Wi-FiApple A7 GPU
iPad Air Wi-Fi + CellularApple A7 GPU
iPad mini 4 Wi-FiApple A8 GPU
iPad mini 4 Wi-Fi + CellularApple A8 GPU
iPad mini 3 Wi-FiApple A7 GPU
iPad mini 3 Wi-Fi + CellularApple A7 GPU
iPad mini 2 Wi-FiApple A7 GPU
iPad mini 2 Wi-Fi + CellularApple A7 GPU
iPod Touch (6th generation)Apple A8 GPU

Instructions

Using Image filter

//create AccImage
let accImage = AccImage()
        
//Input resource
accImage.Input(inimage)
        
//Add filter
accImage.AddProcessor(AccBrightnessFilter())
        
//Processing
accImage.Processing()
        
//Output
let outimage = accImage.Output()

Color adjustments

<!-- - **AccVibranceFilter**: Adjusts the vibrance of an image - *vibrance*: The vibrance adjustment to apply, using 0.0 as the default, and a suggested min/max of around -1.2 and 1.2, respectively. --> <!-- - **AccToneCurveFilter**: Adjusts the colors of an image based on spline curves for each color channel. - *redControlPoints*: - *greenControlPoints*: - *blueControlPoints*: - *rgbCompositeControlPoints*: The tone curve takes in a series of control points that define the spline curve for each color component, or for all three in the composite. These are stored as NSValue-wrapped CGPoints in an NSArray, with normalized X and Y coordinates from 0 - 1. The defaults are (0,0), (0.5,0.5), (1,1). --> <!-- - **AccHighlightShadowTintFilter**: Allows you to tint the shadows and highlights of an image independently using a color and intensity - *shadowTintColor*: Shadow tint RGB color (GPUVector4). Default: `{1.0f, 0.0f, 0.0f, 1.0f}` (red). - *highlightTintColor*: Highlight tint RGB color (GPUVector4). Default: `{0.0f, 0.0f, 1.0f, 1.0f}` (blue). - *shadowTintIntensity*: Shadow tint intensity, from 0.0 to 1.0. Default: 0.0 - *highlightTintIntensity*: Highlight tint intensity, from 0.0 to 1.0, with 0.0 as the default. - **AccLookupFilter**: Uses an RGB color lookup image to remap the colors in an image. First, use your favourite photo editing application to apply a filter to lookup.png from Acc/framework/Resources. For this to work properly each pixel color must not depend on other pixels (e.g. blur will not work). If you need a more complex filter you can create as many lookup tables as required. Once ready, use your new lookup.png file as a second input for AccLookupFilter. - **AccAmatorkaFilter**: A photo filter based on a Photoshop action by Amatorka: http://amatorka.deviantart.com/art/Amatorka-Action-2-121069631 . If you want to use this effect you have to add lookup_amatorka.png from the Acc Resources folder to your application bundle. - **AccMissEtikateFilter**: A photo filter based on a Photoshop action by Miss Etikate: http://miss-etikate.deviantart.com/art/Photoshop-Action-15-120151961 . If you want to use this effect you have to add lookup_miss_etikate.png from the Acc Resources folder to your application bundle. - **AccSoftEleganceFilter**: Another lookup-based color remapping filter. If you want to use this effect you have to add lookup_soft_elegance_1.png and lookup_soft_elegance_2.png from the Acc Resources folder to your application bundle. - **AccSkinToneFilter**: A skin-tone adjustment filter that affects a unique range of light skin-tone colors and adjusts the pink/green or pink/orange range accordingly. Default values are targetted at fair caucasian skin, but can be adjusted as required. - *skinToneAdjust*: Amount to adjust skin tone. Default: 0.0, suggested min/max: -0.3 and 0.3 respectively. - *skinHue*: Skin hue to be detected. Default: 0.05 (fair caucasian to reddish skin). - *skinHueThreshold*: Amount of variance in skin hue. Default: 40.0. - *maxHueShift*: Maximum amount of hue shifting allowed. Default: 0.25. - *maxSaturationShift* = Maximum amount of saturation to be shifted (when using orange). Default: 0.4. - *upperSkinToneColor* = `AccSkinToneUpperColorGreen` or `AccSkinToneUpperColorOrange` --> <!-- - **AccAdaptiveThresholdFilter**: Determines the local luminance around a pixel, then turns the pixel black if it is below that local luminance and white if above. This can be useful for picking out text under varying lighting conditions. - *blurRadiusInPixels*: A multiplier for the background averaging blur radius in pixels, with a default of 4. - **AccAverageLuminanceThresholdFilter**: This applies a thresholding operation where the threshold is continually adjusted based on the average luminance of the scene. - *thresholdMultiplier*: This is a factor that the average luminance will be multiplied by in order to arrive at the final threshold to use. By default, this is 1.0. - **AccHistogramFilter**: This analyzes the incoming image and creates an output histogram with the frequency at which each color value occurs. The output of this filter is a 3-pixel-high, 256-pixel-wide image with the center (vertical) pixels containing pixels that correspond to the frequency at which various color values occurred. Each color value occupies one of the 256 width positions, from 0 on the left to 255 on the right. This histogram can be generated for individual color channels (kAccHistogramRed, kAccHistogramGreen, kAccHistogramBlue), the luminance of the image (kAccHistogramLuminance), or for all three color channels at once (kAccHistogramRGB). - *downsamplingFactor*: Rather than sampling every pixel, this dictates what fraction of the image is sampled. By default, this is 16 with a minimum of 1. This is needed to keep from saturating the histogram, which can only record 256 pixels for each color value before it becomes overloaded. - **AccHistogramGenerator**: This is a special filter, in that it's primarily intended to work with the AccHistogramFilter. It generates an output representation of the color histograms generated by AccHistogramFilter, 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. - **AccAverageColor**: 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. - **AccLuminosity**: Like the AccAverageColor, 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. -->

Image processing

License

MetalAcc is released under the MIT license. See LICENSE for details.