Caricature in iOS [closed]

2019-06-14 19:20发布

问题:

I am trying to apply caricature effect to photos in iOS. I googled for so many things but found very things for it. I have checked https://github.com/BradLarson/GPUImage for to get sketch of an image so that I can apply various filters on sketch. But still stuck in it. I have seen this link also Create Sketch effect to photos using Brad Larson GPUImage in Obj C but unable to get proper combination for it. Please help me if you found something similar thing.

Thanks in advance.

回答1:

I have never heard of a caricature filter being part of the iOS. That's probably going to be a custom design. There are however a truck load of built in filters which are part of the iOS. Run this little script to get a complete listing of all CoreImage filters part of iOS6:

NSArray *ciFilters = [CIFilter filterNamesInCategory:kCICategoryBuiltIn];
for (NSString *filter in ciFilters) {
NSLog(@"filter name %@", filter);
NSLog(@"filter %@", [[CIFilter filterWithName:filter] attributes]);
}

and remember to add CoreImage to your project framework.

EDIT: Try this function as an edge detection filter:

-(CIImage *)simpleEdgeDetection:(CIImage *)inputImage {
CIFilter *desaturate = [CIFilter filterWithName:@"CIColorControls"];
[desaturate setValue:inputImage forKey:kCIInputImageKey];
[desaturate setValue:@0.0f forKey:@"inputSaturation"];
CIFilter *blur = [CIFilter filterWithName:@"CIGaussianBlur"];
[blur setValue:desaturate.outputImage forKey:kCIInputImageKey];
[blur setValue:@3.0f forKey:@"inputRadius"];
CIFilter *inverted = [CIFilter filterWithName:@"CIColorInvert"];
[inverted setValue:blur.outputImage forKey:kCIInputImageKey];
CIFilter *blendDodge = [CIFilter filterWithName:@"CIColorDodgeBlendMode"];
[blendDodge setValue:inverted.outputImage forKey:kCIInputBackgroundImageKey];
[blendDodge setValue:desaturate.outputImage forKey:kCIInputImageKey];
CIFilter *blendBurn = [CIFilter filterWithName:@"CIColorDodgeBlendMode"];
[blendBurn setValue:blendDodge.outputImage forKey:kCIInputImageKey];
[blendBurn setValue:inputImage forKey:kCIInputBackgroundImageKey];
return blendBurn.outputImage;

}

It is from the iOS6 Tutorial - www.raywenderlich.com