A Python-based Color Detection System built using OpenCV, NumPy, and Pandas. The application allows users to identify the name and RGB values of a color by simply double-clicking on any pixel in an image.
- Detect colors from any image
- Interactive double-click color selection
- Displays the closest matching color name
- Shows RGB values of the selected pixel
- Uses a color database containing hundreds of predefined colors
- Fast and simple image-based color detection
- Command-line support for selecting input image
- Python 3
- OpenCV
- NumPy
- Pandas
- CSV
Color_Detection_System/
│
├── color_detection.py # Main Python program
├── colors.csv # Color name and RGB dataset
├── colorpic.jpg # Sample image
├── README.md # Project documentation
└── data/ # Project data files
- The user provides an image path through the command line.
- OpenCV loads and displays the image.
- The user double-clicks on any pixel in the image.
- The program extracts the pixel's RGB values.
- These RGB values are compared with the colors stored in colors.csv.
- The program calculates the closest matching color using RGB distance.
- The detected color name and RGB values are displayed on the image.
- Clone the Repository git clone https://github.com/yourusername/Color_Detection_System.git
- Navigate to the Project Directory cd Color_Detection_System
- Install Dependencies pip install opencv-python numpy pandas
Run the following command:
python color_detection.py -i colorpic.jpg
You can also provide the path of any other image:
python color_detection.py -i path/to/your/image.jpg
Double-click anywhere on the image to detect colors
Real-time color detection with RGB values
After running the program:
- The selected image will open in a window.
- Double-click on any part of the image.
- The system will display:
Color name
- Red (R) value
- Green (G) value
- Blue (B) value
- Press ESC to close the application.
-
The system compares the RGB values of the selected pixel with the RGB values stored in the color dataset.
-
The distance is calculated using:
- Distance = |R - R₁| + |G - G₁| + |B - B₁|
- The color with the minimum distance is selected as the closest matching color.
- If the user selects a pixel with RGB values:
- R = 255
- G = 0
- B = 0
- The system identifies it as:
- Color: Red
- RGB: (255, 0, 0)
This project can be useful for:
- Image processing.
- Computer vision learning.
- Color analysis.
- Graphic design tools.
- Educational computer vision projects.
- Understanding pixel-level image processing.
Some possible improvements include:
- Add support for live webcam color detection.
- Add HEX and HSV color values.
- Build a graphical user interface using Tkinter or PyQt.
- Improve color matching using advanced color spaces.
- Add automatic image upload functionality.
- Create a web-based version of the application.
This project is open-source and available under the MIT License.
Contributions are welcome! Please feel free to submit a Pull Request.

