显示在软件太多“皮肤”检测 [英] Showing too much 'skin' detection in software

查看:88
本文介绍了显示在软件太多“皮肤”检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个ASP.NET网站,在这里用户可以上传自己的照片。可能有成千上万,每天上传的照片。有一件事我的老板问了一些时间,如果有任何的方式,如果任何照片都出现了太多皮肤,我们可以检测并自动运行这些标志的编辑前只有成年人做出最终决定。

I am building an ASP.NET web site where the users may upload photos of themselves. There could be thousands of photos uploaded every day. One thing my boss has asked a few time is if there is any way we could detect if any of the photos are showing too much 'skin' and automatically move flag these as 'Adults Only' before the editors make the final decision.

推荐答案

您最好的选择是处理在HSV色彩空间的图像(见的这里 RGB - HSV转换)。皮肤的颜色是pretty多种族,它只是饱和度改变的相同。通过处理在HSV图像可以简单地寻找皮肤的颜色。

Your best bet is to deal with the image in the HSV colour space (see here for rgb - hsv conversion). The colour of skin is pretty much the same between all races, its just the saturation that changes. By dealing with the image in HSV you can simply search for the colour of skin.

您可以通过简单地计算颜色范围内的像素数量做到这一点,或者你可以的 周围像素生长来计算的区域的大小的颜色执行区域

You might do this by simply counting the number of pixel within a colour range, or you could perform region growing around pixel to calculate the size of the areas the colour.

编辑:用于处理图像的颗粒感,您可能要首先执行图像上的中值滤波,然后降低颜色分割数的形象第一次,你将不得不与设置上所扮演的一大套pre-classifed的(成人与否)的图像,看看价值观的行为得到检测令人满意的水平

for dealing with grainy images, you might want to perform a median filter on the image first, and then reduce the number of colours to segment the image first, you will have to play around with the settings on a large set of pre-classifed (adult or not) images and see how the values behave to get a satisfactory level of detection.

编辑:下面有一些code应该做一个简单的计数(没有测试它,它的一些code <的快速混搭href=\"http://www.obnoxiouslyverbose.com/8/c-image-processing-performance-unsafe-vs-safe-$c$c-part-i\">here和RGB到这里 HSL

Heres some code that should do a simple count (not tested it, its a quick mashup of some code from here and rgb to hsl here)

Bitmap b = new Bitmap(_image);
BitmapData bData = b.LockBits(new Rectangle(0, 0, _image.Width, _image.Height), ImageLockMode.ReadWrite, b.PixelFormat);
byte bitsPerPixel = GetBitsPerPixel(bData.PixelFormat);
byte* scan0 = (byte*)bData.Scan0.ToPointer();

int count;

for (int i = 0; i < bData.Height; ++i)
{
    for (int j = 0; j < bData.Width; ++j)
    {
        byte* data = scan0 + i * bData.Stride + j * bitsPerPixel / 8;

        byte r = data[2];
        byte g = data[1];
        byte b = data[0];

        byte max = (byte)Math.Max(r, Math.Max(g, b));
        byte min = (byte)Math.Min(r, Math.Min(g, b));

        int h;

        if(max == min)
            h = 0;
        else if(r > g && r > b)
            h = (60 * ((g - b) / (max - min))) % 360;
        else if (g > r && g > b)
            h = 60 * ((b - r)/max - min) + 120;
        else if (b > r && b > g)
            h = 60 * ((r - g) / max - min) + 240;


        if(h > _lowerThresh && h < _upperThresh)
            count++;
    }
}
b.UnlockBits(bData);

这篇关于显示在软件太多“皮肤”检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆