使用 GPUImage 库的高斯模糊

Gaussian blur using GPUImage library

我用过 StackBlur for image blurring but it is too slow for big resolution photos... so I decided to swith to GPUImage library 因为大家都说这是最好用的。

我只使用了这一行代码来使用 StackBlur 实现模糊:

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

但我不知道如何以同样的方式使用 GPUImage...

网上有很多例子,但是因为GPUImage的更新,都已经过时了..

有人可以帮我实现高斯模糊吗?

对不起,如果这听起来很愚蠢...我是 objective-c 的新手。

您想做这样的事情(虽然未经测试,所以第一次可能无法工作;)

- (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];
}

这个用于 GPUImageGaussianSelectiveBlurFilter。

希望对你有帮助..

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;
}