Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image Manipulation Filter like white Balance, Exposure, split Tone etc on IOS

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.

like image 789
Nawaz Avatar asked Oct 27 '11 17:10

Nawaz


2 Answers

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.

  1. Add the CoreImage framework.
  2. #import <CoreImage/CoreImage.h>
  3. 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.

like image 177
Ingve Avatar answered Oct 26 '22 06:10

Ingve


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.

like image 32
esilver Avatar answered Oct 26 '22 07:10

esilver