Skip to content

Instantly share code, notes, and snippets.

@lukas2
Created January 5, 2018 10:56
Show Gist options
  • Select an option

  • Save lukas2/9723e3b125e5eaf856848c5c015adca5 to your computer and use it in GitHub Desktop.

Select an option

Save lukas2/9723e3b125e5eaf856848c5c015adca5 to your computer and use it in GitHub Desktop.

Revisions

  1. lukas2 created this gist Jan 5, 2018.
    7 changes: 7 additions & 0 deletions .swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    // example with CIColorPosterize

    let context = CIContext(options: nil)
    var ciImage = CIImage(cgImage: image.cgImage!)
    ciImage = ciImage.applyingFilter("CIColorPosterize", parameters: ["inputImage" : ciImage, "inputLevels" : 2])
    let cgImage = context.createCGImage(ciImage, from: ciImage.extent)!
    let filteredUiImage = UIImage(cgImage: cgImage, scale: image.scale, orientation: .up)