How do I perform a fast pixellation filter on an image?

后端 未结 6 513
心在旅途
心在旅途 2020-12-05 03:46

I have a little problem with my pixellation image processing algorithm.

I load the image from the beginning into an array of type unsigned char* After t

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-05 04:28

    Actually, it's simple as this. Higher input scale key means more pixellation.

    let filter = CIFilter(name: "CIPixellate")
    filter?.setValue(inputImage, forKey: kCIInputImageKey)
    filter?.setValue(30, forKey: kCIInputScaleKey)
    
    let pixellatedCIImage = filter?.outputImage
    

    The result is CIImage, you can convert it using UIImage using

    UIImage(ciImage: pixellatedCIImage)
    

提交回复
热议问题