Search code examples
iosgpuimage

Multiple Filters using GPUImage Library


I am trying to apply 3 filters to an image.

One rgbFilter which is has its values constant, a brightness filter and a saturation filter, both of which should be able to be modified and the image should update.

I have followed the advice here.

I have setup a UIView using IB and set its class to GPUImageView. For some reason the image doesnt show.

My steps are as follows:

self.gpuImagePicture = [[GPUImagePicture alloc] initWithImage:image];
[self.gpuImagePicture addTarget:self.brightnessFilter];
[self.brightnessFilter addTarget:self.contrastFilter];
[self.contrastFilter addTarget:self.imageView];

and then I call this which sets the constant values on the rgb filter

[self setRGBFilterValues]

I setup my filters before this using:

- (void) setupFilters
{
    self.brightnessFilter = [[GPUImageBrightnessFilter alloc] init];
    self.contrastFilter = [[GPUImageContrastFilter alloc] init];
    self.rgbFilter = [[GPUImageRGBFilter alloc] init];
}

Am I missing a step or why is the image just displaying nothing?


Solution

  • You're missing one step. You need to call -processImage on your GPUImagePicture instance to get it to propagate through the filter chain.

    You also need to call this anytime you change values within your filter chain and wish to update the final output.