GPUImageGaussianBlurFilter似乎不适用于分层过滤器

时间:2014-05-07 18:24:00

标签: ios iphone gpuimage

我的分层滤镜对我正在使用的图像看起来都很棒但是如果我更高或更低的高斯模糊参数,模糊效果没有明显的差异。我做错了什么?

这是我的代码:

GPUImageView *finalView;

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIImage *topLayer = [UIImage imageNamed:@"Glass.png"];
    UIImage *baseLayer = [UIImage imageNamed:@"BasePhoto.png"];

    GPUImagePicture *stillImageSourceTop = [[GPUImagePicture alloc] initWithImage:topLayer];
    GPUImagePicture *stillImageSourceBottom = [[GPUImagePicture alloc] initWithImage:baseLayer];

    GPUImageScreenBlendFilter *screenBlendFilter = [[GPUImageScreenBlendFilter alloc] init];
    GPUImageBrightnessFilter *brightnessFilter = [[GPUImageBrightnessFilter alloc] init];
    GPUImageContrastFilter *contrastFilter = [[GPUImageContrastFilter alloc] init];
    GPUImageSaturationFilter *saturationFilter = [[GPUImageSaturationFilter alloc] init];
    GPUImageColorMatrixFilter *colorMatrixFilter = [[GPUImageColorMatrixFilter alloc] init];
    GPUImageOpacityFilter *opacityFilter = [[GPUImageOpacityFilter alloc] init];
    opacityFilter.opacity = 0;

    GPUImageGaussianBlurFilter *blurFilter = [[GPUImageGaussianBlurFilter alloc]init];
    blurFilter.texelSpacingMultiplier = 4.0;
    blurFilter.blurRadiusInPixels = 200.0;
    blurFilter.blurPasses = 4;


    [stillImageSourceTop addTarget:brightnessFilter];
    [brightnessFilter addTarget:contrastFilter];
    [contrastFilter addTarget:saturationFilter];
    [saturationFilter addTarget:colorMatrixFilter];
    [colorMatrixFilter addTarget:blurFilter];
    [blurFilter addTarget:opacityFilter];

    [stillImageSourceTop processImage]; 
    [opacityFilter useNextFrameForImageCapture];

    UIImage *topLayerImage = [opacityFilter imageFromCurrentFramebuffer];
    GPUImagePicture *stillImageSourceTopWithFilters = [[GPUImagePicture alloc] initWithImage:topLayerImage];

    [stillImageSourceBottom addTarget:screenBlendFilter];
    [stillImageSourceTopWithFilters addTarget:screenBlendFilter];
    [screenBlendFilter useNextFrameForImageCapture];

    [stillImageSourceBottom processImage];

    UIImage *mergedlayeredimage = [screenBlendFilter imageFromCurrentFramebuffer];
   [finalImageView setImage:mergedlayeredimage];

}

1 个答案:

答案 0 :(得分:1)

嗯,那是因为上面的大多数过滤器实际上都没有做任何事情。您连接的唯一过滤器是screenBlendFilter,您可以将源图像放入其中,然后从中拉出一个图像。你从来没有真正使用模糊的东西,所以当然它不会影响任何输出。