ios - Get black & white image from UIImage in iPhone SDK? -
i want convert image pure black & white. tried , got result left image have attached , result should right image have attached according requirements of application.
i have used lots of cifilter (cicolormonochrome, cicolorcontrols, ciphotoeffecttonal etc.) none of working.
please check below code , attached result of images.
- (uiimage *)imageblackandwhite { ciimage *beginimage = [ciimage imagewithdata: uiimagejpegrepresentation(self.captureimage.image, .1)]; //ciimage *beginimage = [ciimage imagewithcgimage:self.cgimage]; ciimage *output = [cifilter filterwithname:@"cicolormonochrome" keysandvalues:kciinputimagekey, beginimage, @"inputintensity", [nsnumber numberwithfloat:1.0], @"inputcolor", [[cicolor alloc] initwithcolor:[uicolor whitecolor]], nil].outputimage; cicontext *context = [cicontext contextwithoptions:nil]; cgimageref cgiimage = [context createcgimage:output fromrect:output.extent]; uiimage *newimage = [uiimage imagewithcgimage:cgiimage]; cgimagerelease(cgiimage); return newimage; }
my result----------------------------------------------expected result
you can use blendmode: kcgblendmodeluminosity
alpha value:1.0
Comments
Post a Comment