Artificial Intelligence 8 min read

Skin Color Detection with OpenCV: YCrCb and HSV Based Algorithms

This tutorial explains how to use OpenCV in Python to detect human skin tones by converting images to YCrCb or HSV color spaces, applying Gaussian blur, range filtering, and Otsu thresholding, and compares the results of three different detection methods with visual examples.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Skin Color Detection with OpenCV: YCrCb and HSV Based Algorithms

Overview: This article introduces skin color detection using the OpenCV library, a cross‑platform computer‑vision toolkit that provides Python bindings and implements many common image‑processing algorithms.

Preparation: Install the Python packages opencv-python and numpy from a fast mirror, then import them and read an image.

Basic image operations: Demonstrates reading, displaying and saving images with cv2.imread , cv2.imshow , cv2.waitKey , and cv2.imwrite .

Algorithm 1 – Cr channel of YCrCb + Otsu: Convert the image to YCrCb, extract the Cr channel, apply Gaussian blur, then threshold using Otsu’s method to obtain a binary skin mask.

Algorithm 2 – Cr and Cb range filtering in YCrCb: After conversion, pixels whose Cr value is between 140‑175 and Cb between 100‑120 are marked as skin.

Algorithm 3 – HSV range filtering: Convert to HSV, then keep pixels with H in 7‑20, S in 28‑255, V in 50‑255.

Results: Screenshots show the output of each method and a side‑by‑side comparison of the three detection results.

computer visionPythonimage processingopencvHSVSkin DetectionYCrCb
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.