How to change the skin color of face from the source image in ios?

后端 未结 6 404
失恋的感觉
失恋的感觉 2021-01-31 21:45

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

6条回答
  •  闹比i
    闹比i (楼主)
    2021-01-31 22:01

    1) Get a CGPath of face where you want to apply your algorithm. 2) Get width of CGimage.

    int width = CGImageGetWidth(image);
    

    3) Get pixel CGPoint of currently processing pixel. Check for the condition before applying your algorithm. And then apply your condition. That's it. Here is the sample portion of code.

    CGFloat pointY = (int)(i/4)/(int)width;
    CGFloat pointX = (int)(i/4)%(int)width;
    CGPoint point = CGPointMake(pointX, pointY);
    
    if (CGPathContainsPoint(yourFacePath, NULL, point, NO))
    {
        if( ( (R>0)&&(R<260) ) || ((G>0)&&(G<210))||((B>0) && (B<170)))
        {
            rawData[ii+1]=R;//13;
            rawData[ii+2]=G;//43;
            rawData[ii+3]=value;//63
        }
    }
    

提交回复
热议问题