Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Color Detection System

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.


Features

  • 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

Technologies Used

  • Python 3
  • OpenCV
  • NumPy
  • Pandas
  • CSV

📂 Project Structure


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


How It Works

  • 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.

Installation

  1. Clone the Repository git clone https://github.com/yourusername/Color_Detection_System.git
  2. Navigate to the Project Directory cd Color_Detection_System
  3. Install Dependencies pip install opencv-python numpy pandas

How to Run

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


Screenshots

Screenshot 1 Double-click anywhere on the image to detect colors

Screenshot 2 Real-time color detection with RGB values

Screenshot 3

Screenshot 4


How to Use

After running the program:

  1. The selected image will open in a window.
  2. Double-click on any part of the image.
  3. The system will display:

Color name

  • Red (R) value
  • Green (G) value
  • Blue (B) value
  1. Press ESC to close the application.

Color Matching Algorithm

  • 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.

Example

  1. If the user selects a pixel with RGB values:
  • R = 255
  • G = 0
  • B = 0
  1. The system identifies it as:
  • Color: Red
  • RGB: (255, 0, 0)

Applications

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.

Future Improvements

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.

License

This project is open-source and available under the MIT License.


Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

A Python-based computer vision project that detects and identifies colors in images using OpenCV, NumPy, and Pandas. It analyzes pixel values and displays the closest matching color name and RGB values.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages