swiftimage-processinggpuimageimagefilter

How to cartoonize images using GPUImage framework?


I'm trying to create cartoon effect by combining multiple filters from GPUImage framework but the result is not as desired. Already I read all questions that about cartoonizing or cartoonify images but all them old and actually there is no answer with code example. So someone can help me with this topic if it's posible.

My code looks like :

var picture:PictureInput!

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()

    // Filtering image for display
    picture = PictureInput(image:UIImage(named:"girlFace.png")!)

    DispatchQueue.main.async {
        self.doFilter()
    }
}

private func doFilter() {
    // to soften
    let sharp = UnsharpMask()
    sharp.blurRadiusInPixels = 30
    sharp.intensity = 8

    // to give oil paint look
    let kuwahara = KuwaharaFilter()
    kuwahara.radius = 6

    picture --> sharp --> kuwahara --> renderView
    picture.processImage()
}

And here is the result but I want something like or near to this image

All answers, ideas acceptable.


Solution

  • Hey Coder ACJHP understanding your question,

    First thing is why don't you use ToonFilter and after that apply KuwaharaFilter, it might work. But Seeing your final image output, I'm sure that this can be done using AI and coreMl Models.

    For your output you can see this link - https://blog.prismalabs.ai/diy-prisma-app-with-coreml-6b4994cc99e1

    For coreml models use this link - https://likedan.github.io/Awesome-CoreML-Models/

    here you can directly download the models and use it. Hope this is helpfull