Image Manipulation Filter, for example, white balance, exposure, tone separation, etc. On iOS

I try to use some filters for image processing from one week, such as WHITE BALANCE, EXPOSURE and SPLIT TONING (as in Photoshop) for my iOS application, but I did not get a standard implementation to achieve any of them.

I found shell scripts to achieve them through ImageMagick

but they don’t know how to change these scripts to an equivalent in C or object C. I just use the convert command to do magic things.

Thanks in advance. Please, help.

White balance is also achieved by changing the temperature and hue of the image. therefore, if someone knows how to manipulate this hue and image temperature, please help me with this. Thanks.

+6
source share
2 answers

As the author of ios-image-filters , I can say that our project has a level method that can be used to change the white balance. It is implemented as a category in UIImage and imitates Photoshop filters, so calling it is as simple as calling it:

[self.imageView.image levels:0 mid:128 white:255]; 

In addition, it is compatible with iOS 3 and 4, and not just with iOS 5. It works with open source and has no dependencies, so it is easy to change it if you do not find the filter you need.

+9
source

Starting with iOS 5, Main Image Filters are available.

A very simplified example, assuming you added an IBOutlet UIImageView named imageView in Interface Builder and configured it with an image file.

  • Add CoreImage Infrastructure.
  • #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 would be to use filters from the GitHub ios-image-filters project.

+14
source

Source: https://habr.com/ru/post/900226/


All Articles