image processing - How to apply filter on uiimage in ios to remove shadow and lights? -
i wants apply on filter uiimage in ios remove shadow , lights. have below android code it. needs equivalent in ios.
public static bitmap changebitmapcontrastbrightness(bitmap bmp, float contrast, float brightness) { colormatrix cm = new colormatrix(new float[] { contrast, 0, 0, 0, brightness, 0, contrast, 0, 0, brightness, 0, 0, contrast, 0, brightness, 0, 0, 0, 1, 0 }); bitmap ret = bitmap.createbitmap(bmp.getwidth(), bmp.getheight(), bmp.getconfig()); canvas canvas = new canvas(ret); paint paint = new paint(); paint.setcolorfilter(new colormatrixcolorfilter(cm)); canvas.drawbitmap(bmp, 0, 0, paint); return ret; } i have used below ios code can't proper result
ciimage *inputimage = [ciimage imagewithcgimage:[uiimage imagenamed:@"facedetectionpic.jpg"].cgimage]; // 1 // make filter cifilter *colormatrixfilter = [cifilter filterwithname:@"cicolormatrix"]; // 2 [colormatrixfilter setdefaults]; // 3 [colormatrixfilter setvalue:inputimage forkey:kciinputimagekey]; // 4 [colormatrixfilter setvalue:[civector vectorwithx:1 y:1 z:1 w:0] forkey:@"inputrvector"]; // 5 [colormatrixfilter setvalue:[civector vectorwithx:0 y:1 z:0 w:0] forkey:@"inputgvector"]; // 6 [colormatrixfilter setvalue:[civector vectorwithx:0 y:0 z:1 w:0] forkey:@"inputbvector"]; // 7 [colormatrixfilter setvalue:[civector vectorwithx:0 y:0 z:0 w:1] forkey:@"inputavector"]; // 8 // output image recipe ciimage *outputimage = [colormatrixfilter outputimage]; // 9 // create context , instruct coreimage draw output image recipe cgimage cicontext *context = [cicontext contextwithoptions:nil]; cgimageref cgimg = [context createcgimage:outputimage fromrect:[outputimage extent]]; // 10
this data filtration .this logic use in code image filtration remove shadow or brightness
if ([categorytitle isequaltostring:@"category"]) { iscategory=no; } else { categorydata=[[nsmutablearray alloc]init]; (int a=0; a<fetcheddataarray.count; a++) { categorydictionary=[[nsmutabledictionary alloc]init]; categorydictionary=[fetcheddataarray objectatindex:a]; nsstring *categ=[[[[[categorydictionary objectforkey:@"terms"] objectforkey:@"offershop"] objectatindex:0] objectforkey:@"parent"] objectforkey:@"name"]; if ([categorytitle isequaltostring:categ]) { [categorydata addobject:categorydictionary]; } //searchdictionary=nil; } nslog(@"done"); } [self.tableview reloaddata]; }
Comments
Post a Comment