This project implements pixel-wise human skin detection using 2D color histograms in Lab space and Bayesian classification. Trained on 30 skin images (base/skin/) + 30 non-skin images (base/non-skin/), it achieves 85.6% accuracy on test images (base/test/) (threshold 0.4, scale 32).
The project was carried out as part of the computer vision course, in the Master's program in Intelligent Systems and Multimedia at the International Francophone Institute / Vietnam National University. The file Repport/goint_p22-tp1.pdf details the implementation, operation, experimentation, and results of the program.
human-skin-detection/
├── src/ → Source files (main.cpp, skin_detection.cpp)
├── include/ → Header files (skin_detection.hpp)
├── base/ → Dataset
│ ├── skin/ → 30 images (only skin visible, rest black)
│ ├── non-skin/ → 30 images (skin black, rest visible)
│ └── test/ → Original images
├── build/ → Object files (.o) generated by Makefile
├── result/ → Output images after detection
├── histogramme/ → 2D histogram images
├── Makefile → Build instructions
└── README.mdTip: Use GIMP to create masks: Layer → Transparency → Add Alpha Channel → paint non-skin black.
Key features:
- Lab color space conversion
- Histogram smoothing & normalization
- Bayes decision rule
- Morphological post-processing
- Performance evaluation (TP/FP/FN)
This README provides Ubuntu (Linux) instructions.
Before you begin, ensure you have:
The first things you need to do are cloning this repository and setting up the project environment files
git clone https://github.com/Mongetro/human-skin-detection.gitcd human-skin-detectionmake-
The Makefile uses the src/ and include/ structure.
-
Object files are created in build/.
-
The executable is human_skin_detection.
./human_skin_detection <scale> <threshold> <image_name>Example :
./human_skin_detection 32 0.4 29.jpghuman_skin_detection : name of the executable generated by make from the C++ code
Parameters
- 32 : scale => Histogram resolution / color space value reduction scale (32 recommended)
- 0.4 : threshold => Bayes threshold (0.4 optimal)
- 29.jpg : image => Filename in base/test/
As indicated in the PDF report goint_p22-tp1.pdf, after running the program, the following specific results are obtained:
- 1 . Display in the terminal
=== PERFORMANCE EVALUATION ===
Reference skin pixels : 21289
True positives : 20616
False positives : 2797
False negatives : 673
Performance : 85.5933 %
=============================-
2 . Files saved automatically
- result/result_image_ImageName.jpg: Final image => skin detected (remains black)
- histogram/histogram_skin.jpg: histogram/2D (a-b) => histogram of skin pixels
- histogram/histogram_non_skin.jpg: histogram/2D (a-b) => histogram of non skin pixels
-
3 . OpenCV windows displayed (5 in total)
- Input Image
- Reference Skin
- Detected Skin
- Skin Mask
- Histogram - peau
- Histogram - non_peau
Quick check :
ls result/ histogramme/make cleanmake