Create a tilt-shift filter like instagram in objec

2019-02-11 08:40发布

问题:

I trying to create a tilt-shift filter of the image like instagram or iDarkroom in iOS.

My proposed method is use different Gaussian Blur levels for the partial image. But I don't known how to control the area to apply different Gaussian Blur Levels, especially when User can change the effect area by rotate, scale, etc.

Sorry about my complex presentation but simply, I want to create a tilf-shift tool for iOS like in Instagram.

I search and found this powerful framework https://github.com/BradLarson/GPUImage, but it's not good solution if include this huge framework to my tiny apps

回答1:

I found solution:

Use filter GPUImageGaussianSelectiveBlurFilter and change computing distanceFromCenter on this code:

distanceFromCenter = abs((textureCoordinate2.x - excludeCirclePoint.x) *
aspectRatio*cos(angle) + (textureCoordinate2.y-excludeCirclePoint.y)*sin(angle));


回答2:

GPUImage framework worked perfectly for my question. GPUImageGaussianSelectiveBlurFilter for radial tiltshif as Oleg Kovtun's answer above and GPUImageTiltShiftFilter for linear one.

Update answer for someone need