Applying a GPUImageFilter using UISlider for intensity

5 replies [Last post]
SageWashabaugh
User offline. Last seen 8 years 46 weeks ago. Offline
Joined: 06/25/2012
Posts:

Hello, I want to apply a GPUImageSepiaFilter and use a UISlider to regulate the intensity. Has anyone done this? Could you help me out with it I just cant seem to get it right.

Brad Larson
Brad Larson's picture
User offline. Last seen 4 years 22 weeks ago. Offline
Joined: 05/14/2008
Posts:

What are you having problems with? The FilterShowcase example shows how to do this exact thing with a sepia tone filter and a slider, so you should just be able to duplicate what I do there. If you're doing this with a still image source, remember that you're going to need to send a -processImage message to the still image every time you adjust the filter chain in order for the image to be processed with the updated settings.

SageWashabaugh
User offline. Last seen 8 years 46 weeks ago. Offline
Joined: 06/25/2012
Posts:

Sorry I'm still having some trouble with that. Basically I want to do it like this:
sharpenImageSource = [[GPUImagePicture alloc] initWithImage:[image_view image]];
SharpenGPUFilter = [[GPUImageSharpenFilter alloc] init];
[SharpenGPUFilter setSharpness:[mySlider value]];
[sharpenImageSource addTarget:SharpenGPUFilter];
[sharpenImageSource processImage];
UIImage* outputImage = [SharpenGPUFilter imageFromCurrentlyProcessedOutput];
[image_view setImage:outputImage];

but the problem is when i slide the UISlider forward it works great but if I try to make it go backwards to reverse the effect it just makes it stronger

SageWashabaugh
User offline. Last seen 8 years 46 weeks ago. Offline
Joined: 06/25/2012
Posts:

Sorry I'm still having some trouble with that. Basically I want to do it like this:
sharpenImageSource = [[GPUImagePicture alloc] initWithImage:[image_view image]];
SharpenGPUFilter = [[GPUImageSharpenFilter alloc] init];
[SharpenGPUFilter setSharpness:[mySlider value]];
[sharpenImageSource addTarget:SharpenGPUFilter];
[sharpenImageSource processImage];
UIImage* outputImage = [SharpenGPUFilter imageFromCurrentlyProcessedOutput];
[image_view setImage:outputImage];

but the problem is when i slide the UISlider forward it works great but if I try to make it go backwards to reverse the effect it just makes it stronger

vipersnake
User offline. Last seen 8 years 39 weeks ago. Offline
Joined: 06/15/2012
Posts:

You are passing in the source image that was previously sharpened.

sharpenImageSource = [[GPUImagePicture alloc] initWithImage:[image_view image]];

sets the source from you image_view then down below you set the image_view to be the output of your sharpen. So no matter what you do it is going to sharpen again and again.

Try to keep the original image around and pass that in then set it on the image_view just like you do now.

UIImage * origImage = [UIImage imageNamed:@"Test.jpg"];
sharpenImageSource = [[GPUImagePicture alloc] initWithImage:origImage];

SageWashabaugh
User offline. Last seen 8 years 46 weeks ago. Offline
Joined: 06/25/2012
Posts:

Perfect! works great now! Thank you so much sir.

Syndicate content