ios - Fastest way to remove a color from a UIImage? -


i have image i'm using create anaglyph splitting separate red , cyan versions , setting parallax between them.

the source image 1146 x 580 (at retina resolution). i'm using cicolormatrix create each image. here's code cyan version removes of red.

-(uiimage *)createcyan:(uiimage *)animage {      ciimage *inputimage = [ciimage imagewithcgimage:animage.cgimage];      cifilter *matrixfilter = [cifilter filterwithname:@"cicolormatrix"];     [matrixfilter setdefaults];     [matrixfilter setvalue:inputimage forkey:kciinputimagekey];     [matrixfilter setvalue:[civector vectorwithx:0 y:0 z:0 w:0] forkey:@"inputrvector"];     [matrixfilter setvalue:[civector vectorwithx:0 y:1 z:0 w:0] forkey:@"inputgvector"];     [matrixfilter setvalue:[civector vectorwithx:0 y:0 z:1 w:0] forkey:@"inputbvector"];     [matrixfilter setvalue:[civector vectorwithx:0 y:0 z:0 w:1] forkey:@"inputavector"];      ciimage *outputimage = [matrixfilter outputimage];      cicontext *context = [cicontext contextwithoptions:nil];     cgimageref cgimg = [context createcgimage:outputimage fromrect:[outputimage extent]];       return [uiimage imagewithcgimage:cgimg]; } 

the problem takes on second process. need find faster means (if 1 exists) of accomplishing same thing.

is there better method?

the issue speed not filter, you're initializing cicontext, expensive process, repeatedly. create cicontext beforehand, , problem solved.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -