A Python-based Color Detection App that identifies the color name of a pixel in an image upon double-clicking. This project uses OpenCV and Pandas to detect color names from a CSV file containing color data.
- Detect RGB Values: Displays the RGB values of the pixel you click on.
- Display Color Names: Shows the name of the color closest to the clicked pixel based on a dataset.
- Light and Dark Color Handling: Adjusts text color for visibility based on light or dark background.
- Python 3.x
- OpenCV
- Pandas
- Numpy
-
Clone this repository:
git clone https://github.com/AadityaPanda/Image-Colour-Identifier.git
-
Install the required packages:
pip install opencv-python-headless pandas numpy
-
Ensure you have a
colors.csv
file in the same directory as the script. A sample CSV format is explained below.
Run the script from the command line and pass an image file path as an argument:
python color_detection.py -i path_to_image.jpg
- Launch the script with the image path.
- Double-click on any pixel in the image window to see its color name and RGB values.
- Press the ESC key to exit the application.
Image-Colour-Identifier/
├── colors.csv # CSV file with color names and RGB values
├── color_detection.py # Main Python script for the color detection app
└── README.md # Project README
The colors.csv
file should have the following columns:
- color: Index or ID of the color.
- color_name: Name of the color (e.g., Red, Blue).
- hex: Hexadecimal code of the color (e.g., #FFFFFF for white).
- R: Red component (0-255).
- G: Green component (0-255).
- B: Blue component (0-255).
Example CSV Content:
color,color_name,hex,R,G,B
0,Black,#000000,0,0,0
1,White,#FFFFFF,255,255,255
2,Red,#FF0000,255,0,0
...