Created
October 28, 2015 17:35
-
-
Save dsowsy/cefba186d3582cb2af4e to your computer and use it in GitHub Desktop.
The pattern I use for chaining GPUImage filters on a single UIImage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension UIImage { | |
func blur() -> UIImage { | |
let boxBlur = GPUImageBoxBlurFilter() | |
boxBlur.blurRadiusInPixels = 4.0 | |
return boxBlur.imageByFilteringImage(self) | |
} | |
func canny() -> UIImage { | |
let canny = GPUImageCannyEdgeDetectionFilter() | |
return canny.imageByFilteringImage(self) | |
} | |
} | |
// Example usage: | |
// let result = image.blur().canny() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment