Image processing based on---skin color detection algorithm-based on simple region division of different color spaces

Source: Internet
Author: User

This article involves a lot of algorithms, there are many similar articles on the network, but it is certain that many are not worthy of code, or the accompanying code are symbolic, slow, not elegant, not practical value, this article tries to solve these problems.

The order of each algorithm in this paper does not represent the superiority of the algorithm, but only the random arrangement of the authors.

2. Simple threshold color recognition based on RGB color space

The following simple discriminant equations are presented in the human skin color clustering for face detection article:

R>95 and G>40 and B>20 and R>g and R>b and Max (r,g,b)-min (r,g,b) >15 and Abs (r-g) >15

The algorithm is very simple, the same mainly put the complex judgment conditions in the back to judge, can effectively reduce the execution time of the program, reference code:

for (Y = 0; Y < Height; y++) {    Pointer = Scan0 + Y * Stride;    SKINP = SkinScan0 + Y * skinstride;    for (X = 0; X < Width; x + +)    {        Blue = *pointer; Green = * (Pointer + 1); Red = * (Pointer + 2);        if (Red > Up && Green > All && blue > && red > Blue && red > Green && Amp Math.Abs (Red-green) >)        {            if (blue >= Green)                 {                Max = blue;                Min = Green;            }            else            {                Max = Green;                Min = Blue;            }            if (Red > Max)                max = red;            else if (Red < min)                min = red;            if (Max-min > *skinp) = 255;        }        Pointer + = 3;        skinp++;    }

Algorithm effect:

Original image recognition Result chart original recognition result diagram

By the above results it seems that the algorithm gets too much skin area, then the algorithm prefers beauty some (^_^).

3, based on YCbCr color space of simple threshold skin color recognition

The algorithm is more simple, convert the image to YCbCr color space, and then determine whether it belongs to the skin area according to the following calculation formula:

(CB > and CB < 127) and (Cr > 133 and CR < 173)

For an optimization algorithm of RGB and YCBCR color space conversion, refer to this blog related article.

Since the original writing this aspect did not indicate the source of the algorithm, and now did not mention.

Code reference:

for (Y = 0; Y < Height; y++) {    Pointer = Scan0 + Y * Stride;    SKINP = SkinScan0 + Y * skinstride;    for (X = 0; X < Width; x + +)    {        Blue = *pointer; Green = * (Pointer + 1); Red = * (Pointer + 2);        Cb = ( -176933 * Red-347355 * Green + 524288 * Blue + 134217728) >>;        if (CB > * && CB < 127)        {            Cr = (524288 * Red-439026 * Green-85262 * Blue + 134217728) >> ;            if (cr > 133 && CR < 173) *SKINP = 255;        }        Pointer + = 3;        skinp++;}    }

Original image recognition Result chart original recognition result diagram

The area of miscalculation is still very large.

Another is based on the YUV color space for skin color recognition, it seems not too accurate, can refer to http://www.doc88.com/p-97381067005.html.

http://blog.csdn.net/songhhll/article/details/12612601 Some pictures can not copy the picture, and then select Copy on the OK

Image processing based on---skin color detection algorithm-based on simple region division of different color spaces

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.