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 enter image description here

you can use blendmode: kcgblendmodeluminosity alpha value:1.0


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -