Reputation: 5132
What would be the most efficient way to create an unsharp mask filter in Objective C targeting iOS? Would it be best to implement some open source like ImageMagick or build from scratch.
I think the basic formula is generally as follows (please comment if I have not gotten it right).
Upvotes: 0
Views: 1303
Reputation: 5050
Core Image has the CIUnsharpMask filter built-in, although I'm not sure if it's available on iOS yet. Brad Larson's GPUImage framework also has an unsharp mask filter.
Both methods should be very fast and much easier to implement than cross-compiling ImageMagick or writing your own.
Upvotes: 1
Reputation: 11
(UIImage *)useOfUnsharpMask:(CIImage *)beginImage
{
float sliderValue = sharpnessSlider.value;
CIFilter *filter = [CIFilter filterWithName:@"CIUnsharpMask" keysAndValues:kCIInputImageKey,beginImage,@"inputIntensity",[NSNumber numberWithFloat:sliderValue],@"inputRadius",@2.50, nil];
CIContext *context = [CIContext contextWithOptions:nil];
CIImage *outputImage = [filter valueForKey: @"outputImage"];
UIImage *finalImage = [UIImage imageWithCGImage:[context createCGImage:outputImage fromRect:outputImage.extent]];
return finalImage;
}
Hope that helps :)
Upvotes: 1