Sunday, September 3, 2017

ios Image text and colour enhancement filter

Leave a Comment

I am trying CIFilter and GPUImage filter to apply various effects (brightness, contrast, saturation, etc.) on an image, but I'm struggling, would need an enhancement like the one shown below:

Before Enhancement filter

Before Enhancement filter:

After Enhancement filter

After Enhancement filter

CIFilter code that I tried:

NSDictionary *options = @{ CIDetectorImageOrientation :                                [[resultImage properties] valueForKey:kCGImagePropertyOrientation] }; NSArray *adjustments = [resultImage autoAdjustmentFiltersWithOptions:options]; for (CIFilter *filter in adjustments) {     [filter setValue:resultImage forKey:kCIInputImageKey];     resultImage = filter.outputImage; } 

GPUImage Filter:

UIImage *inputImage = [UIImage imageNamed:@"Msource.png"]; GPUImageAdaptiveThresholdFilter *stillImageFilter = [[GPUImageAdaptiveThresholdFilter alloc] init]; stillImageFilter.blurRadiusInPixels = 10.0;// adjust this to tweak the blur radius of the filter, defaults to 4.0  UIImage *filteredImage = [stillImageFilter imageByFilteringImage:inputImage]; 

1 Answers

Answers 1

//Hope this helps , its in swift 3 :

        var aCIImage = CIImage();         var contrastFilter: CIFilter!;         var brightnessFilter: CIFilter!;         var gaussianBlurFilter: CIFilter!;         var pointFilter: CIFilter!;         var vignettFilter : CIFilter!;         var context = CIContext();         var outputImage = CIImage();         var newUIImage = UIImage();         var finalImage = UIImage()         DispatchQueue.main.async                         {                             self.gaussianBlurFilter = CIFilter(name: "CIExposureAdjust");                             self.gaussianBlurFilter.setValue(self.aCIImage, forKey: "inputImage")                              self.gaussianBlurFilter.setValue(NSNumber(value: sender.value), forKey: "inputEV");                              self.outputImage = self.gaussianBlurFilter.outputImage!;                              let imageRef = self.context.createCGImage(self.outputImage, from: self.outputImage.extent)                              self.newUIImage = UIImage(cgImage: imageRef!)                             self.testView?.image = self.newUIImage;                     }    //  

enter image description here

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment