Inspiration
I wondered how the Instagram stories pick a background automatically when you add an image?! Well, I read about it, it said they analyze your picture through different algorithms and produce a background matching with the image. They primarily use the “colours” present in the image to process the output.
What it does
So in this project, we implemented a technique to find the colour which is of maximum proportion in our image. Although we can do much more, like generate the top 10 most used colours and make a pie chart!
How we built it
To find the most used colours, we utilised the K-Means Clustering algorithm to find the clusters of colours and then did a frequency count to take out the 10 most used colours. The RGB scales of the image were split and plotted into 3D points in space, and then on these points clustering was performed using the K-Means algorithm. The rest of the code involved sorting them into frequency wise count and displaying them on a pie-chart using matplotlib.
Challenges we ran into
The most challenging parts were to understand how the points would be plotted in 3D space and clustering will be performed. Another challenging part was to make a sorted frequency count corresponding to each color.
Accomplishments that we're proud of
In this project we successfully, extracted the most used colors and displayed them as our background.
What we learned
We learned how to split an image, plot its colors in 3D space, perform K-Means clustering, and visualise the results in a pie chart.
What's next for Background Color Detection
We can improve the detection techniques by involving more number of parameters to judge the suitable background instead of just the most used color from the image.
Built With
- machine-learning
- opencv
- python
- sklearn
Log in or sign up for Devpost to join the conversation.