Swift Gaussian Blur an image

Dan Moldovan picture Dan Moldovan · Nov 20, 2014 · Viewed 19.6k times · Source

I've been developing an app for quite a while now and am soon to finish. I have been blurring some images using the UIImage+ImageEffects.h library, but now I want to switch to Gaussian blurring an UIImage

Is there any library or something similar that would allow me to gaussian blur an image in my app?

Answer

bpolat picture bpolat · Nov 20, 2014

I use following in my app.

 func applyBlurEffect(image: UIImage){
    var imageToBlur = CIImage(image: image)
    var blurfilter = CIFilter(name: "CIGaussianBlur")
    blurfilter.setValue(imageToBlur, forKey: "inputImage")
    var resultImage = blurfilter.valueForKey("outputImage") as CIImage
    var blurredImage = UIImage(CIImage: resultImage)
    self.blurImageView.image = blurredImage

  }