2015-03-02 86 views
0

我已经使用StackBlur进行图像模糊,但对于大分辨率的照片来说太慢了......所以我决定随着每个人都说它是最好的使用方法而开关GPUImage library使用GPUImage库的高斯模糊

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

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

但我无法弄清楚如何以同样的方式使用GPUImage ...

有在网上很多例子,但他们都是过时的,因为GPUImage更新..

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

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

回答

1

你会想要做这样的事情(虽然未经测试,因此可能无法正常工作的第一次;)

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

谢谢你,但Xcode中给出了错误:'[过滤imageFromCurrentFramebuffer]' - 宣言“过滤器”必须从模块“Darwin.ncurses”之前进口是必须的; &坏接收器类型'void(*)(void)'; – Edgar 2015-03-03 12:55:47

+0

哎呦。更改过滤器来源;) – brandonscript 2015-03-03 15:51:39

+0

更新了示例,我认为它现在是正确的。我总是对过滤器链接的方式感到困惑。 – brandonscript 2015-03-03 16:56:54

1

这一个是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; 
}