MY code: How to manage RGB value for differet shades of face,and how to apply? this code will change the color of face along with hair,but i want 1.only face to be colored excl
Try Masking the image ... it will help to change the specific range of colors defined in mask
Code:
- (UIImage *)doctorTheImage:(UIImage *)originalImage
{
const float brownsMask[6] = {85, 255, 85, 255, 85, 255};
UIImageView *imageView = [[UIImageView alloc] initWithImage:originalImage];
UIGraphicsBeginImageContext(originalImage.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor (context, 1.0,1.0, 1.0, 1);
CGContextFillRect(context, CGRectMake(0, 0, imageView.image.size.width, imageView.image.size.height));
CGImageRef brownRef = CGImageCreateWithMaskingColors(imageView.image.CGImage, brownsMask);
CGRect imageRect = CGRectMake(0, 0, imageView.image.size.width, imageView.image.size.height);
CGContextTranslateCTM(context, 0, imageView.image.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
//CGImageRef whiteRef = CGImageCreateWithMaskingColors(brownRef, whiteMask);
CGContextDrawImage (context, imageRect, brownRef);
//[originalImage drawInRect:CGRectMake(0, 0, imageView.image.size.width, imageView.image.size.height)];
CGImageRelease(brownRef);
// CGImageRelease(whiteRef);
UIImage *doctoredImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return doctoredImage;
}