I have been trying since one week to achieve some image manipulation filters like WHITE BALANCE, EXPOSURE and SPLIT TONING (as in Photoshop) for my IOS app, but I didn't get a standard implementation to achieve any of them.
I found the shell scripts to achieve them through ImageMagick
but don't know how to change these scripts to its equivalent in C or objective C. I simply uses some convert command to do the magic things.
Thanks in advance. Please Help.
White Balance is achievable through changing temperature and tint of the image also. so if someone out there knows how to manipulate these tint and temperature of image, please help me out of this. Thanks.
Starting with iOS 5, Core Image filters are available.
A very simplified example, assuming you have added a UIImageView IBOutlet named imageView in Interface Builder, and set it up with an image file.
#import <CoreImage/CoreImage.h>
In viewDidLoad
, add the following:
CIImage *inputImage = [[CIImage alloc] initWithImage:self.imageView.image];
CIFilter *exposureAdjustmentFilter = [CIFilter filterWithName:@"CIExposureAdjust"];
[exposureAdjustmentFilter setDefaults];
[exposureAdjustmentFilter setValue:inputImage forKey:@"inputImage"];
[exposureAdjustmentFilter setValue:[NSNumber numberWithFloat:5.0f] forKey:@"inputEV"];
CIImage *outputImage = [exposureAdjustmentFilter valueForKey:@"outputImage"];
CIContext *context = [CIContext contextWithOptions:nil];
self.imageView.image = [UIImage imageWithCGImage:[context createCGImage:outputImage fromRect:outputImage.extent]];
Another option might be to use the filters from the GitHub ios-image-filters project.
As the author of ios-image-filters, I can tell you that our project has a levels method that you can use to modify white balance. It is implemented as a category on UIImage and mimics Photoshop filters, so calling it is as straightforward as:
[self.imageView.image levels:0 mid:128 white:255];
Moreover, it's compatible with iOS 3 & 4, not just iOS 5. It's open source and has no dependencies, so it should be easy to modify if you don't find the filter you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With