Nude Detect Algo
Nude Detect Algo
Rigan Ap-apid
College of Computer Studies De La Salle University Manila, Philippines
ABSTRACT
This paper presents an algorithm for detecting nudity in color images. A skin color distribution model based on the RGB, Normalized RGB, and HSV color spaces is constructed using correlation and linear regression. The skin color model is used to identify and locate skin regions in an image. These regions are analyzed for clues indicating nudity or nonnudity such as their sizes and relative distances from each other. Based on these clues and the percentage of skin in the image, an image is classified nude or non-nude. The skin color distribution model performs with 96.29% recall and 6.76% false positive rate on a test set consisting of 2,303,824 manually labeled skin pixels and 24,285,952 manually labeled non-skin pixels. The Nudity Detection Algorithm is able to detect nudity with a 94.77% recall and a false positive rate of 5.04% on a set of images consisting of 421 nude images and 635 non-nude images.
In recent years, problems with the lack of control and regulation over what information can be made available, especially over the Internet, have increasingly been apparent. One such problem is the proliferation of pornography or nudity, which has been the focus of various studies in Internet security. Determining image content continues to be an active research area even as the distribution of all types of images becomes more widespread than ever. Nudity detection is recognized as an important step towards limiting the proliferation of unwanted and damaging information. Technology companies devoted to image recognition acknowledge that the state of the art in nudity detection is still crude, yielding inexact results at the cost of computing power. Thus, new methods for detecting nudity are continually being sought. This paper describes an algorithm for detecting nudity in images. Contrary to most detection systems, images are not compared to pre-classified images in a database. Aside from raw RGB values, the system uses two other color spaces (HSV and normalized RGB) to aid in the classification. The set of images used is limited to color images in JPEG (Joint Photographic Experts Group) format. However, the detection scheme can theoretically be easily modified to allow for classification of images in other formats.
Keywords: pornography, nudity, non-nudity, skin color, correlation, linear regression, skin regions
1. INTRODUCTION
The rapid development in the field of digital media has exposed us to huge amounts of non-textual information such as audio, video, and images. In fact, one can be easily overwhelmed by the amount of information available through electronic means. More often than not, we are exposed to information that is irrelevant for our own purposes. Thus, retrieval and classification techniques have been and are continuously being developed and improved to facilitate the exchange of relevant information. Correspondingly, there is a clear necessity for usercustomized information selection.
2. BACKGROUNDS
A basic nudity filtering solution requires the analysis of an image to determine the presence of objects in the image that may signify nudity or inappropriate content. Image features are initially extracted and analyzed, and then classified according to some parameters. Common features that give clues to image content include color, texture, filenames, image dimensions, object shapes, and the number of relevant objects found in the image.
Nudity often consists of showing naked persons, special shots of sexual organs, or a picture of sexual intercourse (Lin et al., 2003). These images show a lot of skin and thus, skin color is a basic feature used in nudity detection. A disadvantage of systems using color as a primary feature is that the systems will not work with black and white images. However, nude images are rarely in black and white. The simplest methods in skin detection define or assume skin color to have a certain range or values in some coordinates of a color space. Usually, the skin is recognized due to the fact that it is composed of a group of color containing red for the blood and yellow and brown for melanin. In general, the fairness or darkness of skin depends on the amount of melanin in the skin. Due to the emerging importance of skin detection in computer vision several studies have been made on the behavior of skin chromaticity at different color spaces. Many studies such as those by Yang and Waibel (1996) and Graf et al. (1996) indicate that skin tones differ mainly in their intensity value while they are very similar in chrominance coordinates. Several surveys on the use of color spaces such as those by Zarit et al. (1999) and Vezhnevets et al. (2003) have been made to identify optimal methods for skin detection using different color spaces. While some studies show differences in performance due to the color space used (Terillon et al., 2000), (Vezhnevets et al., 2003), some researchers (Bosson et al., 2002), (Chan et al. 1999) agree that the choice of color space is not critical provided that enough training is done and that an appropriate data set is used. The main goal of skin color detection or classification is to build a decision rule that will discriminate between skin and non-skin pixels. Identifying skin colored pixels involves finding the range of values for which most skin pixels would fall in a given color space. This may be as simple as explicitly classifying a pixel as a skin pixel if R>G or R>B or both (Brown et al., 2000) or may be as complex as models using neural networks and Bayesian methods (Jones & Rehg, 1999), (Chai & Bouzerdoum, 1999). In general, a good skin color model must have a high detection rate and a low falsepositive rate. That is, it must detect most skin pixels while minimizing the amount of non-skin pixels classified as skin.
reason for this is the lack of a standard set of images that can be used as a benchmark for algorithms using different color spaces.
S = 1 3
min( R , G , B ) R + G+ B
V = 1 (R + G + B) 3
Some studies show that HSV is invariant to highlights at white light sources, to matte surfaces, and ambient lighting. However, hue discontinuities and the computation of the luminance component conflict badly with the properties of color vision. The cyclic nature of Hue-Saturation spaces also makes it inconvenient for parametric skin color models that need a tight cluster of skin performance for optimum performance (Vezhnevets et al., 2003).
The pornography detection algorithm developed by Lin et al. (2003) uses the correlation between skin and non-skin regions as the input of a support vector machine (SVM), a tool for classification with learning abilities. The algorithm has an accuracy of 75% and a false alarm rate of 35%. Jones & Rehg (1998) constructed skin and non-skin models from a dataset of nearly one billion labeled pixels. A neural network was then trained on 5453 adult images and 5226 non-adult images. The procedure resulted in 93% correct detections with 8% false-positives. Lin, Chen, & Fuh (2003) contends that the training process for neural networks is very slow and difficult because pornography classification is a matter of opinion. PornsweeperTM (Bosson, 2002) first compares an image with images in its exception list, which are common images preclassified by an administrator as pornographic or not. If an image is found to be in the exception list, it is quarantined for administrator inspection. If the image is not on the list, it is passed on to an analyzer for further analysis. PornsweeperTM detects nude images with 15% false negatives. We can compare the performance of nudity detection systems in terms of the percentages of the images correctly or wrongly classified by the systems. However, this method is very unreliable because different systems use different test data sets (Jones & Rehg, 1998). Different data sets generally yield different results.
r=
g=
b =
R R+G+B
G R+G+ B
B R + G+ B
Since the sum of the three components r, g, and b is 1, the blue (b) component can be omitted to reduce space dimensionality.
3. THE ALGORITHM
The Nudity Detection Algorithm is based primarily on observations that in general, nude images contain large amounts of skin, people have different skin tones, and skin regions in nude images are relatively close to each other. These observations require the identification of skin and nonskin pixels in an image to be classified. The identified skin pixels are analyzed to determine which among them are connected or form continuous regions. These skin regions are further analyzed for clues of nudity or non-nudity. In general, the Nudity Detection Algorithm consists of the following steps: 1. 2. 3. 4. Detect skin-colored pixels in the image. Locate or form skin regions based on the detected skin pixels. Analyze the skin regions for clues of nudity or non-nudity. Classify the image as nude or not.
The first step in the algorithm requires a skin color distribution model, which is the basis for classifying pixels as skin or non-skin.
Most skin color distribution models use a single color space to classify pixels as skin-colored or not (Chai & Bouzerdoum, 1999), (Lin et al., 2003), (Forsyth & Fleck, 1999), (Jones & Rehg, 1999). However, based on the researchers experiments, the performance of a model can be improved by using two or more other color spaces. Thus, aside from RGB values, the skin color model used in this system uses the Normalized RGB and HSV color spaces. The set of images used for developing the color model in this study consists of manually labeled skin regions representing all types of skin color. Contrary to some studies, different skin tones do not exhibit the same chromaticity if the luminance component is removed. Thus, the set of images were partitioned into three subsets based on perceived illumination level light, brown, and dark. Using correlation and linear regression the color properties of each subset are analyzed and used to develop the skin color model. Experiments show that the skin filter developed for this study works with 96.29% recall and a 6.76% false positive rate on the training set. The percentage of skin pixels relative to the image size is one of the main features that affect the probability of an image being nude or not. The larger the percentage of skin is, the higher the probability that an image will be classified nude. Experiments show that a threshold of 15% yields good results in terms of recall. Thus, for this study an image is considered not nude if it contains less than 15 percent skin. If the skin percentage is greater than or equal to 15, the image has to be analyzed further. The next step in the algorithm is the analysis of detected skin pixels in terms of adjacency or continuity to identify or locate skin regions. The number of skin regions, the sizes of the three largest skin regions and the relative positions of these skin regions are important features that aid in the classification. Although the percentage of skin is a good indicator of the presence or absence of nudity in an image, it allows too many false positives if used alone. The results show that the performance can be improved by combining skin percentage feature and region properties. In summary, the nudity detection algorithm works in the following manner: 1. 2. 3. 4. Scan the image starting from the upper left corner to the lower right corner. For each pixel, obtain the RGB component values. Calculate the corresponding Normalized RGB and HSV values from the RGB values. Determine if the pixel color satisfies the parameters for being skin established by the skin color distribution model. Label each pixel as skin or non-skin. Calculate the percentage of skin pixels relative to the size of the image. Identify connected skin pixels to form skin regions. Count the number of skin regions.
9. 10. 11.
15. 16.
Identify pixels belonging to the three largest skin regions. Calculate the percentage of the largest skin region relative to the image size. Identify the leftmost, the uppermost, the rightmost, and the lowermost skin pixels of the three largest skin regions. Use these points as the corner points of a bounding polygon. Calculate the area of the bounding polygon. Count the number of skin pixels within the bounding polygon. Calculate the percentage of the skin pixels within the bounding polygon relative to the area of the polygon. Calculate the average intensity of the pixels inside the bounding polygon. Classify an image as follows: a. If the percentage of skin pixels relative to the image size is less than 15 percent, the image is not nude. Otherwise, go to the next step. b. If the number of skin pixels in the largest skin region is less than 35% of the total skin count, the number of skin pixels in the second largest region is less than 30% of the total skin count and the number of skin pixels in the third largest region is less than 30 % of the total skin count, the image is not nude. c. If the number of skin pixels in the largest skin region is less than 45% of the total skin count, the image is not nude. d. If the total skin count is less than 30% of the total number of pixels in the image and the number of skin pixels within the bounding polygon is less than 55 percent of the size of the polygon, the image is not nude. e. If the number of skin regions is more than 60 and the average intensity within the polygon is less than 0.25, the image is not nude. f. Otherwise, the image is nude.
The threshold values used in the algorithm have been determined empirically.
4. RESULTS
Separate sets of images were collected for training and testing the algorithms developed in this study. The training set for the skin filter consisted of 1,182,608 manually labeled skin pixels and 10,471,553 manually labeled non-skin pixels while the testing set consisted of 2,303,824 manually labeled skin pixels and 24,285,952 manually labeled non-skin pixels. The training set for the nudity detection algorithm consisted of 264 nude images and 300 non-nude images. The testing set consisted of 421 nude images and 635 non-nude images.
5. 6. 7. 8.
Kovac et al., 2003 Marius et al., Lin et al., 2003 Solina et al., 2002 The Skin Color Distribution Model in This Study
Although it cannot be concluded that the Nudity Detection Algorithm designed by the proponent is better than other similar systems, it can be said that it performs relatively well compared to other similar algorithms.
5. CONCLUSIONS
The proponent is inclined to agree with the belief that the choice of color space is not crucial as shown by several studies. However, using a single color space may limit the performance of the skin color filter. This study shows that better performance can be achieved by using two or more color spaces. Contrary to some studies, experimental results in this study suggest that chrominance values still significantly differ for light and dark skin even if the luminance component is removed through a normalization or transformation of RGB values. Thus, a skin color model should not treat light and dark skin in the same manner. This may be more computationally expensive but it allows for more skin pixels to be labeled correctly. The proponent was unable to find researches on skin color using linear regression. The correlation coefficients for the color values (Normalized RGB and HSV) for different skin color suggest a high linear correlation. Thus, it is possible to model skin color using linear regression analysis and this is confirmed by the results of this study. However, linear regression may not be the best model for skin color. The relationship between the values may not be strictly linear. If this is the case, using curves may be more appropriate than using lines to model the relationship. The proponent believes that the performance of the system can be improved by using similarity measures or template matching where images are compared to pre-classified nude images. However, large memory requirements for the use of templates may present undesirable consequences. The appropriateness of the templates used must also be carefully established.
The performance may also be improved by using convex bounding polygons and using polygons with more than four sides. The drawback is the effect on execution time. It is computationally more expensive to identify interior points for concave polygons than for convex ones. Increasing the number of sides also has a corresponding increase in execution time. Thus, care must be taken in determining the appropriate threshold for the optimal number of sides of the bounding polygon. The evaluation of performance results would have been more meaningful if the comparison with other similar systems was done using a single image set. However, it is difficult to obtain image sets used in other researches on skin color. The implementations of the algorithms are also not publicly available. Thus, it would be worthwhile for someone to develop a benchmark for algorithms in skin and nudity detection. This would enable researchers on the field to establish standard performance targets and to carry out objective performance evaluations.
[9] Kovac, J. (2002). Eliminating the Influence of Nonstandard Illumination From Images. Diploma Thesis, University of Ljubljana.
[10] Lin, Y., Tseng, H. & Fuh, C. Pornography Detection Using Support Vector Machine. 16th IPPR Conference on Computer Vision, Graphics and Image Processing (CVGIP 2003). Kinmen, ROC. [11] Martinkauppi, B. 2002. Face Colour Under varying Illumination. [online]. Available: http://herkules.oulu.fi/isbn9514267885/isbn9514267885 .pdf. (02 October 2003)
[12] Peer, P., Kovac, J, & Solina, F. Human Skin Colour Clustering for Face Detection. In Proc. Of EUROCON 2003 International Conference on Computer as a Tool, 2003. [13] Pornsweeper Review (2002). [online]. Available: http://www.dansdata.com/pornsweeper.htm. (24 September 2003) [14] Solina, F., Peer, P., Batagelj, B., & Juvan, S. 15 seconds of Fame An Interactive, Computer-Vision Based Art Illustration. In Proc. Of the 7th Intl Conference on Control, Automation, Robotics, and Vision, pp. 198-204, 2002. [15] Terrillon, J., Shizarit M, Fukamachi, H, & Akamatsu, S. Comparative Performance of Different Skin Chrominance Models and Chrominance Spaces for the Automatic Detection of Human Faces in color Images. In Proc. Of the International Conference on Face and Gesture Recognition, pp. 54-61, France, 2000. [16] Vezhnevets, V., Sazonov, V. & Andreeva, A. A Survey on Pixel-Based Skin Color Detection Techniques. In Proc. Graphicon-2003, pp. 85-92, Moscow, Russia, Sep. 2003. [17] Waibel, A., Yang, J., & Lu, W. Skin-color modeling and Adaptation. In Proc. Of ACCV1998, 687-694, 1998. [18] Wang, J., Li, J., Wiederhold, G., & Firschein, O. System for Screening Objectionable Images Using Daubechies Wavelets and Color Histograms. In Proc. of the International Workshop on Interactive Distributed Multimedia Systems and Telecommunication Services, pp. 1030, 1997. [19] Zarit, B., Super, B. & Quek, F. Comparison of Five Color Models in Skin Classification. In Proc. Of ICCV 99 International Workshop on Recognition, Analysis, and Tracking of Faces and Gesture
6. REFERENCES
[1] Bosson, A., Cawleyz, G., Chanz, Y., & Harveyz, R. (2002). Non-retrieval: blocking pornographic images. [online]. Available: ttp://www2.cmp.uea.ac.uk/~rwh/research/reprints/civr2 002.pdf. (17 September 2004) [2] Brown, D., Craw, I., & Lewthwaite, J. A SOM Based Approach to Skin Detection with Application in Real Time Systems. In Proc. Of the British Machine Vision Conference, 2001. [3] Chan, Y, Harvey, R., & Smith, D. Building Systems to Block Pornography. In Proc. Of Challenge of Image Retrieval, BCS Electronic Worckshops in Computing Series, pp.34-40, 1999. [4] Chai, D. & Bouzerdoum, A. A Bayesian Approach to Skin Color Classification in YCbCr Color Space. In Proc. Of IEEE Region Ten Conference, vol. 2, 4214124. [5] Forsyth,D.A. & Fleck, M.M. (1999). Automatic Detection of Human Nudes. In Proc. International Journal of Computer Vision, 32(1), 63-77. [6] Gomez , G. On Selecting Colour Components for Skin Detection. In Proc. Of the ICPR, vol. 2, 961-964, 2000. [7] Gomez, G & Morales, E. Automatic Feature Construction and a Simple Rule Induction Algorithm for Skin Detection. In Proc. Of the ICML Workshop on Machine Learning in Computer Vision, 31-38, 2002. [8] Jones, M. & Rehg, J. (1998) Statistical Color Models with Application to Skin Detection. [online] Available: http://www.hpl.hp.com/techreports/Compaq-DEC/ CRL-98-11.pdf. (30 September 2004)