コード例 #1
0
 /// <summary>
 /// A first pass is made to try to create a skin mask, this filter dictates what pixels are acceptable for that pass (taking into account hue, saturation and
 /// texture amplitude)
 /// </summary>
 public bool SkinFilter(HueSaturation colour)
 {
     return((
                ((colour.Hue >= 105) && (colour.Hue <= 160) && (colour.Saturation >= 10) && (colour.Saturation <= 60)) || // Reduced minimum hue slightly to allow some lighter tones
                ((colour.Hue >= 160) && (colour.Hue <= 180) && (colour.Saturation >= 30) && (colour.Saturation <= 30))    // Reduced acceptable saturation so that strong yellow tones aren't as readibly recognised
                ) &&
            (colour.TextureAmplitude <= 5));                                                                              // I've found that some photos struggle to match faces with low texture amplitudes so I've jumped this value up a lot
 }
コード例 #2
0
 /// <summary>
 /// After the first skin mask pass, a number of subsequent passes (see NumberOfSkinMaskRelaxedExpansions) are made to expand the mask to include any nearby pixels
 /// using more relaxed criteria (to make it more likely that edge pixels that are in shade, for example, are captured)
 /// </summary>
 public bool RelaxedSkinFilter(HueSaturation colour)
 {
     // This is the same as described at http://web.archive.org/web/20090723024922/http:/geocities.com/jaykapur/face.html, which is the same as the article "Naked People Skin
     // Filter (Margaret M. Fleck and David A Forsyth)" that it references (http://mfleck.cs.illinois.edu/naked-skin.html)
     return((colour.Hue >= 110) && (colour.Hue <= 180) && (colour.Saturation >= 0) && (colour.Saturation <= 180));
 }