Functional Swift wrapper around a few matrix convolution functions from the Accelerate Framework (vImage Convolution Reference). Inspired by objc.io issue 16 (Functional APIs with Swift). I wrote this mainly because I did some research on image processing and because the functional nature of the API now possible with Swift and suggested in the objc.io issue fascinated me. This code is not optimized because its main purpose was to teach me how to use Accelerate from Swift.
The filters are mostly just different convolution matrices. I used this wikipedia article as a source for example matrices: Kernel (image processing).
vImageConvolve does the heavy lifting.
- Sharpen
- Gaussian blur
- 3 different edge detection matrices
- 5x5 Unsharp
- Box blur (using the dedicated function vImageBoxConvolve)
These are only examples of kernels.
var boxFilter = boxBlur(3)
var gaussFilter = gaussBlur()
var bothFilers = boxFilter >|> gaussFilter
var output = bothFilters(UIImage(named:"test"))
var sharpenTwice = sharpen() * 2
var sharper = sharpenTwice(UIImage(named:"test"))