This project is a Python script that analyzes the colors in an image and shows the most dominant ones in a pie chart.
- OpenCV
- NumPy
- Scikit-learn
- Matplotlib
You can install them using pip:
pip install opencv-python numpy scikit-learn matplotlib
Then, you need to have an image file named “image.jpg” in the same folder as the script. You can change the name of the file or the path in the code if you want.
To run the script, simply execute:
python dominant_colors.py
You should see a figure with two subplots: one showing the original image and one showing the dominant colors in a pie chart.
Sources This project is based on the following sources:
How to Extract Dominant Colors from an Image using Python K-Means Clustering in Python Matplotlib Tutorial: Learn basics of Python’s powerful Plotting library