简体   繁体   中英

How to use CIFilter CiColorCube

can someone explain me, how does this filter works, i saw WWDC 2012 and documentation and still don't understand quite. Where and how to define cube color map. Is it in .h or .m file? I have ViewController.h and .m, where i working with some filters and i need to use CiColorCube filter but i just don't know how. This is my code:

- (void)viewDidLoad
{
    // here i would like to use CIColorCube
    CIImage *inputImage = [[CIImage alloc]initWithImage:[UIImage imageNamed:@"background.jpg"]];
    CIImage *inputBackgroundImg = [[CIImage alloc]initWithImage:[UIImage imageNamed:@"image.jpeg"]];
    CIContext *context = [CIContext contextWithOptions:nil];
    vignette = [CIFilter filterWithName:@"CIVignette"];
    [vignette setValue:inputImage forKey:kCIInputImageKey];
    [vignette setValue:[NSNumber numberWithFloat:2.5] forKey:@"inputRadius"];
    [vignette setValue:[NSNumber numberWithFloat:2.9] forKey:@"inputIntensity"];
    sourceOC = [CIFilter filterWithName:@"CISourceOverCompositing"];
    [sourceOC setValue:vignette.outputImage forKey:kCIInputImageKey];
    [sourceOC setValue:inputBackgroundImg forKey:@"inputBackgroundImage"];
    maskToAlpha = [CIFilter filterWithName:@"CIMaskToAlpha"];
    [maskToAlpha setValue:inputImage forKey:kCIInputImageKey];
    CIImage *outputImage = maskToAlpha.outputImage;
    imageView.image = [UIImage imageWithCGImage:[context createCGImage:outputImage fromRect:outputImage.extent]];
    [super viewDidLoad];
}

In Apple's Developer Library, there is a document on 'Subclassing CIFilter: Recipes for Custom Effects' that shows how to make the color map..

Also, in XCode you can look up the ImageApp sample code, and it also shows how in ImageFilter.m.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM