MMMFilterKit simplify usage of CIFilter to just few lines of code. You can simply chain them, create your own and perform them on EAGLContext.
To run the example project, clone the repo, and run pod install
from the Example directory first.
MMMFilterKit is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'MMMFilterKit'
Note that you'll also need to add use_frameworks!
to your Podfile if you haven't already.
Martin Pilch, martin.pilch@email.cz
MMMFilterKit is available under the MIT license. See the LICENSE file for more info.
You can simply get processed image by passing CIImage
to any of built-in filters.
let outImg = SharpenFilters.SharpenLuminance(0.5)(inImg)
Filters can be chained together using the |>
operator.
let randomFilter = GeneratorFilters.RandomGenerator()
let contrastFilter = ColorAdjustmentFilters.ColorControls(saturation: 0, brightness: 0, contrast: 1)
let colorFilter = ColorAdjustmentFilters.ColorMatrix(red: 0.2, green: 0.2, blue: 0.2, alpha: 0.5)
let filters = randomFilter |> contrastFilter |> colorFilter
let outImg = filters(inImg)
If you need to execute filters fast, you can use ImageProcessing
class to do it using EAGLContext
.
let filterExposure = ColorAdjustmentFilters.ExposureAdjust(exposure: exposure)
let filterSharpen = SharpenFilters.SharpenLuminance(sharpness: sharpen)
let filters: [Filter] = [filterExposure, filterSharpen]
ImageProcessing.sharedInstance.processImage(image: image, filters: filters) { [weak self] (outputImage) in
self?.imageView?.image = outputImage
}
Inspired by the "CIFilterKit" by Jeff Blagdon.