Chaining multiple filters

No replies
petter
User offline. Last seen 9 years 29 weeks ago. Offline
Joined: 05/26/2012
Posts:

First of all, thank you for this framework. It's extremely powerful and helpful.
The only problem I can't seem to wrap around my head is how to chain filters.

So far I got the code below to work, but I've got a feeling that this is not the proper way to do it.
How can I chain multiple filters the correct way and also add multiple BlendFilters? Also, do you have an example of how to use the Curves class?

Here's my code to process a still image.

UIImage *fillBeigeImg = [UIImage imageNamed:@"fill_beige2.jpg"];
 
        GPUImagePicture *stillImageSource = [[GPUImagePicture alloc] initWithImage:inputImage];
 
        // Filter 1
        filter1 = [[GPUImageFilter alloc] initWithFragmentShaderFromFile:@"Nashville_RGBValue_2"];
 
        // Filter 2
        filter2 = [[GPUImageMultiplyBlendFilter alloc] init];
        GPUImagePicture *beigeMultiply = [[GPUImagePicture alloc] initWithImage:fillBeigeImg];
 
        // Filter 3
        filter3 = [[GPUImageExposureFilter alloc] init];
        [(GPUImageExposureFilter *)filter3 setExposure:0.30];
 
        // Filter 4
        filter4 = [[GPUImageSaturationFilter alloc] init];
        [(GPUImageSaturationFilter *)filter4 setSaturation:1.2];
 
 
        [stillImageSource addTarget:filter1];
        [beigeMultiply addTarget:filter2];
        [filter1 addTarget:filter2];
        [filter2 addTarget:filter3];
        [filter3 addTarget:filter4];
 
        [stillImageSource processImage];
 
        // Display the processed image from latest created filter
        newImage = [filter4 imageFromCurrentlyProcessedOutput];

Syndicate content