Edgar
Edgar

Reputation: 931

Gaussian blur using GPUImage library

I've used StackBlur for image blurring but it is too slow for big resolution photos... so I decided to swith to GPUImage library as everyone says it's the best one to use.

I've used just this one line of code to implement blur using StackBlur:

_editedImage = [_myImage stackBlur:round(self.blurSlider.value)];

But I can't figure out how to use GPUImage in the same manner...

There are a lot of examples on the web, but they are all outdated because of GPUImage updates..

Could someone please help me to implement gaussian blur?

Sorry if this sounds very stupid...I am new to objective-c.

Upvotes: 0

Views: 1331

Answers (2)

krushnsinh
krushnsinh

Reputation: 864

this one is for GPUImageGaussianSelectiveBlurFilter.

i hope it helps you..

GPUImageGaussianSelectiveBlurFilter *selectiveBlur;
GPUImagePicture *fx_image;
UIImage *final_image;

-(IBAction)upDateSliderValue:(id)sender 
{       
 fx_image = [[GPUImagePicture alloc] initWithImage:originalImage];
 [self aspectRatio]; //to get the Value of f..
 [selectiveBlur setAspectRatio:f];
 [selectiveBlur setExcludeCircleRadius:self.sliderChange.value];
 [fx_image addTarget:selectiveBlur];
 [fx_image processImage];
 final_image = [selectiveBlur imageFromCurrentlyProcessedOutput];
 selectedImageView.image = final_image;
}

Upvotes: 1

brandonscript
brandonscript

Reputation: 73024

You'd want to do something like this (untested though, so it might not work the first time ;)

- (UIImage*)blurImage {
    GPUImagePicture *source = [[GPUImagePicture alloc] initWithImage:self];
    GPUImageiOSBlurFilter *blur = [[GPUImageiOSBlurFilter alloc] init];
    blur.blurRadiusInPixels = 1.0f;
    [source addTarget:blur];
    [blur processImage];
    return [blur imageFromCurrentFramebuffer];
}

Upvotes: 1

Related Questions