Applying a GPUImageFilter using UISlider for intensity
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.
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
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
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];
Perfect! works great now! Thank you so much sir.
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.