3

I'm currently using Brad Larson's excellent GPUImage framework to create an iPhone-based app, and I want to process a circular area in the centre of the camera input so that section is blurred and the surrounding area is in-focus.

I can achieve the opposite using the GPUImageGaussianSelectiveBlurFilter (i.e. make the central area of the screen in-focus and the surrounding area blurred).

Does anyone know a quick way of doing this by creating a new filter based on the GPUImageGaussianSelectiveBlurFilter which does the opposite?

1 Answer 1

2

Questions like this might be more appropriate on the GitHub issues page for the project, given how specific they are to the framework, but I can answer this pretty quickly.

Create a new filter using code from the GPUImageGaussianSelectiveBlurFilter and replace the following line in the fragment shader:

gl_FragColor = mix(sharpImageColor, blurredImageColor, smoothstep(excludeCircleRadius - excludeBlurSize, excludeCircleRadius, distanceFromCenter)); 

with

gl_FragColor = mix(blurredImageColor, sharpImageColor, smoothstep(excludeCircleRadius - excludeBlurSize, excludeCircleRadius, distanceFromCenter));

This will invert which image (blurred or sharp) is sampled from for points inside and outside of the focal circle. You'll now have the area inside the circle be blurred and the outside sharp.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.