iosgpuimage

How to draw a sketch boundary or pencil boundary use GPUImage like this?


How to draw a sketch boundary or pencil boundary use GPUImage like this? The result is not good when i use a mask picture.So, i think this is a custom filter,but i don't kown how to implement it?I was puzzled for two weeks.any one can help me... the result like this(left is the PM needed, right is mine):enter image description here

the origianl picture and mask picture is: enter image description here

enter image description here


Solution

  • Hey xue looking to your problem I think you should use SketchFilter or Thresholdsketchfilter and play with values to get your desired output, but as you are asking for masking , I'm attaching a code, where I'm using Dissolve to blend two images.

    func addColorBlending(withImage : UIImage) {
    
            let blendImageFilter = DissolveBlend()
            blendImageFilter.mix = 0.3
    
            let blendImage = PictureInput(image: withImage)
            blendImage.processImage()
            blendImage.addTarget(blendImageFilter)
    
            let imageToBlendOn = PictureInput(image: self.processingModel.pencileDefaultImage)
            imageToBlendOn.processImage()
            imageToBlendOn.addTarget(blendImageFilter)
    
            let pictureOutput = PictureOutput()
            pictureOutput.imageAvailableCallback = { imageData in
    
                DispatchQueue.main.async {
                    self.handAndFootImageView.image = imageData
                    self.processingModel.blendedImage = imageData
                }
            }
    
            blendImageFilter.addTarget(pictureOutput)
    
        }
    

    Here you can tweak blendImageFitler.mix property to get your desired output. Hope it Helps you.