Skip to content

Functional Swift wrapper around a few matrix convolution functions.

License

Notifications You must be signed in to change notification settings

j4nnis/AImageFilters

Repository files navigation

AImageFilters

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.

Filters

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.

Usage

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"))

About

Functional Swift wrapper around a few matrix convolution functions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages