GPU-based media processing library using Metal written in Swift

Related tags

Image MetalAcc
Overview

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 Name GPU
iPhone 6s Apple A9 GPU
iPhone 6s Plus Apple A9 GPU
iPhone 6 Apple A8 GPU
iPhone 6 Plus Apple A8 GPU
iPhone 5s Apple A7 GPU
iPad Pro Wi-Fi Apple A9 GPU
iPad Pro Wi-Fi + Cellular Apple A9 GPU
iPad Air 2 Wi-Fi Apple A8 GPU
iPad Air 2 Wi-Fi + Cellular Apple A8 GPU
iPad Air Wi-Fi Apple A7 GPU
iPad Air Wi-Fi + Cellular Apple A7 GPU
iPad mini 4 Wi-Fi Apple A8 GPU
iPad mini 4 Wi-Fi + Cellular Apple A8 GPU
iPad mini 3 Wi-Fi Apple A7 GPU
iPad mini 3 Wi-Fi + Cellular Apple A7 GPU
iPad mini 2 Wi-Fi Apple A7 GPU
iPad mini 2 Wi-Fi + Cellular Apple 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

  • AccBrightnessFilter: Adjusts the brightness of the image

    • brightness: The adjusted brightness (-1.0 ~ 1.0, with 0.0 as the default)
  • AccExposureFilter: Adjusts the exposure of the image

    • exposure: The adjusted exposure (-10.0 ~ 10.0, with 0.0 as the default)
  • AccContrastFilter: Adjusts the contrast of the image

    • contrast: The adjusted contrast (0.0 ~ 4.0, with 1.0 as the default)
  • AccSaturationFilter: Adjusts the saturation of an image

    • saturation: The degree of saturation or desaturation to apply to the image (0.0 ~ 2.0, with 1.0 as the default)
  • AccGammaFilter: Adjusts the gamma of an image

    • gamma: The gamma adjustment to apply (0.0 ~ 3.0, with 1.0 as the default)
  • AccLevelsFilter: Photoshop-like levels adjustment. The min, max, minOut and maxOut parameters are floats in the range [0, 1]. If you have parameters from Photoshop in the range [0, 255] you must first convert them to be [0, 1]. The gamma/mid parameter is a float >= 0. This matches the value from 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.

  • AccColorMatrixFilter: Transforms the colors of an image by applying a matrix to them

    • colorMatrix: A 4x4 matrix used to transform each color in an image
    • intensity: The degree to which the new transformed color replaces the original color for each pixel
  • AccRGBFilter: Adjusts the individual RGB channels of an image

    • red,green,blue: Normalized values by which each color channel is multiplied. The range is from 0.0 up, with 1.0 as the default.
  • AccHueFilter: Adjusts the hue of an image

    • hue: The hue angle, in degrees. 90 degrees by default
  • AccWhiteBalanceFilter: Adjusts the white balance of an image.
    • temperature: The temperature to adjust the image by, in ºK. A value of 4000 is very cool and 7000 very warm. The default value is 5000. Note that the scale between 4000 and 5000 is nearly as visually significant as that between 5000 and 7000.
    • tint: The tint to adjust the image by. A value of -200 is very green and 200 is very pink. The default value is 0.
  • AccHighlightShadowFilter: Adjusts the shadows and highlights of an image
    • shadows: Increase to lighten shadows, from 0.0 to 1.0, with 0.0 as the default.
    • highlights: Decrease to darken highlights, from 1.0 to 0.0, with 1.0 as the default.
  • AccColorInvertFilter: Inverts the colors of an image

  • AccGrayscaleFilter: Converts an image to grayscale (a slightly faster implementation of the saturation filter, without the ability to vary the color contribution)

  • AccMonochromeFilter: Converts the image to a single-color version, based on the luminance of each pixel

    • intensity: The degree to which the specific color replaces the normal image color (0.0 - 1.0, with 1.0 as the default)
    • color: The color to use as the basis for the effect, with (0.6, 0.45, 0.3, 1.0) as the default.
  • AccFalseColorFilter: Uses the luminance of the image to mix between two user-specified colors

    • firstColor: The first and second colors specify what colors replace the dark and light areas of the image, respectively. The defaults are (0.0, 0.0, 0.5) amd (1.0, 0.0, 0.0).
    • secondColor:
  • AccHazeFilter: Used to add or remove haze (similar to a UV filter)

    • distance: Strength of the color applied. Default 0. Values between -.3 and .3 are best.
    • slope: Amount of color change. Default 0. Values between -.3 and .3 are best.
  • AccSepiaFilter: Simple sepia tone filter

    • intensity: The degree to which the sepia tone replaces the normal image color (0.0 - 1.0, with 1.0 as the default)
  • AccOpacityFilter: Adjusts the alpha channel of the incoming image

    • opacity: The value to multiply the incoming alpha channel for each pixel by (0.0 - 1.0, with 1.0 as the default)
  • AccSolidColorGenerator: This outputs a generated image with a solid color. You need to define the image size using -forceProcessingAtSize:

    • color: The color, in a four component format, that is used to fill the image.
  • AccLuminanceThresholdFilter: Pixels with a luminance above the threshold will appear white, and those below will be black

    • threshold: The luminance threshold, from 0.0 to 1.0, with a default of 0.5
  • AccLuminanceRangeFilter: Pixels with a luminance above the threshold will appear white, and those below will be black

    • rangeReduction: The degree to reduce the luminance range, from 0.0 to 1.0. Default is 0.6.
  • AccChromaKeyFilter: For a given color in the image, sets the alpha channel to 0. This is similar to the AccChromaKeyBlendFilter, 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)

Image processing

  • AccTransformFilter: This applies an arbitrary 2-D transformation to an image
    • affineTransform: This takes in a CGAffineTransform to adjust an image in 2-D

License

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

You might also like...
Kanvas is an open-source iOS library for adding effects, drawings, text, stickers, and making GIFs from existing media or the camera.
Kanvas is an open-source iOS library for adding effects, drawings, text, stickers, and making GIFs from existing media or the camera.

Kanvas Kanvas is an open-source iOS library for adding effects, drawings, text, stickers, and making GIFs from existing media or the camera.

📷 A composable image editor using Core Image and Metal.
📷 A composable image editor using Core Image and Metal.

Brightroom - Composable image editor - building your own UI Classic Image Editor PhotosCrop Face detection Masking component 🎉 v2.0.0-alpha now open!

📷 A composable image editor using Core Image and Metal.
📷 A composable image editor using Core Image and Metal.

Brightroom - Composable image editor - building your own UI Classic Image Editor PhotosCrop Face detection Masking component 🎉 v2.0.0-alpha now open!

A python library to run metal compute kernels on MacOS 12

metalcompute for Python A python library to run metal compute kernels on MacOS Usage Example execution from M1-based Mac running MacOS 12.0: ./build

Fabulous Image Processing in Swift
Fabulous Image Processing in Swift

Toucan is a Swift library that provides a clean, quick API for processing images. It greatly simplifies the production of images, supporting resizing,

Advanced framework for loading, caching, processing, displaying and preheating images.
Advanced framework for loading, caching, processing, displaying and preheating images.

Advanced framework for loading, caching, processing, displaying and preheating images. This framework is no longer maintained. Programming in Swift? C

PublisherKit - An open source implementation of Apple's Combine framework for processing asynchronous events over time

Publisher Kit Overview PublisherKit provides a declarative Swift API for processing asynchronous events over time. It is an open source version of App

Microblog-ref-app - A Twitter like social media app that users can share their moments
Microblog-ref-app - A Twitter like social media app that users can share their moments

HiPlace - iOS Table of Contents Introduction HMS Services Getting Started Suppor

Media view which subclasses UIImageView, and can display & load images, videos, GIFs, and audio and from the web, and has functionality to minimize from fullscreen, as well as show GIF previews for videos.
Media view which subclasses UIImageView, and can display & load images, videos, GIFs, and audio and from the web, and has functionality to minimize from fullscreen, as well as show GIF previews for videos.

I've built out the Swift version of this library! Screenshots Description ABMediaView can display images, videos, as well as now GIFs and Audio! It su

Comments
  • 我运行的时候怎么报这个错误呢?

    我运行的时候怎么报这个错误呢?

    今天我在iPhone5上运行了你这个程序,可是报了下面这个错误。 2016-04-07 10:42:51.419 MetalAcc[530:107537] Metal GPU Frame Capture Enabled 2016-04-07 10:42:51.422 MetalAcc[530:107537] Metal API Validation Enabled fatal error: unexpectedly found nil while unwrapping an Optional value (lldb)

    opened by arden 2
  • 请问下如果多级处理链,纹理如果需要改变大小怎么做

    请问下如果多级处理链,纹理如果需要改变大小怎么做

    最近想写个类似 gpuimage 的处理链,就是上级A生成一张纹理给下级B再处理,用的是 metal 文件用的是kernel开头的函数那种,如果我想上级A输出的纹理尺寸是(1000,1000)给下级,下级B再处理完生成(100 , 900)这种尺寸的, 我在MTLTextureDescriptor设置纹理尺寸了,但是生成出来的B纹理是A纹理的(100,900)位置裁剪,并不是将1000 1000 尺寸纹理 压缩画到 100 900 上面,请问下应该怎么设置呢,新手研究

    opened by swlfigo 0
Owner
Jiawei Wang
Jiawei Wang
A GPU accelerated image and video processing framework built on Metal.

MetalPetal An image processing framework based on Metal. Design Overview Goals Core Components MTIContext MTIImage MTIFilter MTIKernel Optimizations C

null 1.5k Jan 4, 2023
An open source iOS framework for GPU-based image and video processing

GPUImage Brad Larson http://www.sunsetlakesoftware.com @bradlarson [email protected] Overview The GPUImage framework is a BSD-licensed iO

Brad Larson 20k Jan 1, 2023
GPUImage 2 is a BSD-licensed Swift framework for GPU-accelerated video and image processing.

GPUImage 2 Brad Larson http://www.sunsetlakesoftware.com @bradlarson [email protected] Overview GPUImage 2 is the second generation of th

Brad Larson 4.8k Dec 29, 2022
Swift Package Manager plug-in to compile Metal files that can be debugged in Xcode Metal Debugger.

MetalCompilerPlugin Swift Package Manager plug-in to compile Metal files that can be debugged in Xcode Metal Debugger. Description Swift Package Manag

Jonathan Wight 10 Oct 30, 2022
Patch out the GPU checks for any x86-64 macOS Unreal Engine-based game

UnrealGPUPatcher Download here Patch out the GPU checks for any x86-64 macOS Unreal Engine-based game, particularly ARK: Survival Evolved. Requirement

Jacob Greenfield 35 Jan 1, 2023
A simple mesh viewer for MacOS based on Swift and Metal and using Assimp for loading meshes

Metal Mesh Viewer A simple triangle mesh viewer for MacOS This application is a simple (triangle) mesh viewer that should be capable of rendering even

J. Andreas Bærentzen 0 Dec 13, 2021
A high-performance image library for downloading, caching, and processing images in Swift.

Features Asynchronous image downloader with priority queuing Advanced memory and database caching using YapDatabase (SQLite) Guarantee of only one ima

Yap Studios 72 Sep 19, 2022
Boids written in the Metal Shader language + Swift

MetalBoid Boids written in the Metal Shader language + Swift This is an example of a Boid simulating running in iOS using Swift+Metal. The parameters

Mark Dawson 10 Nov 8, 2022
Visualiser written in Swift, SwiftUI and Metal API

ModularMTL About Visualisation of modular multiplication on a circle. Written in Swift using Metal API and SwiftUI. Images Features Keyboard controls

Gracien 12 Dec 20, 2022
IOS UIImage processing functions using the vDSP/Accellerate framework for speed.

UIImage Image Processing extensions using the vDSP/Accelerate framework.

null 372 Sep 1, 2022