Question

I'm using GPUImage to blur a circular shaped image. Over the image, I have circular "frame" image. The problem is that the blur makes the image stretch outside the bounds of the original frame image.

I could mask the image with (like CALayer, cornerRadius then maskToBounds) but that really slow when I have a lot of these images.

Is it possible to mask the blurry image with GPUImage in a fast way?

Thanks.

enter image description here

GPUImageGaussianBlurFilter *blurFilter = [GPUImageGaussianBlurFilter new];
blurFilter.blurRadiusInPixels = 15;
self.blurryThumbNail.image = [blurFilter imageByFilteringImage:self.profileImage.image];
Was it helpful?

Solution

There's a handy filter for that: GPUImageGaussianBlurPositionFilter

You specify the blurCenter and blurSize. Note that coordinates are between 0.0 and 1.0.

GPUImageGaussianBlurPositionFilter is a subclass of GPUImageFilterGroup and basically it's a 2 step filter. First it applies a blur using the GPUImageGaussianBlurFilter (the one you're using) then it combines the result with the original unblurred one using the specified parameters.

There's an interesting article about the current implementation of GPUImageGaussianBlurFilter on Brad Larson's blog here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top