Download the following Python script and images. Don't look at the images!
Read over the Python code to make sure you understand what the script is doing.
Try running the script on image1.jpg. Can you tell how many distinct colors are represented in this image? Try running the script on the other images. What can you determine about the contents of these images without actually opening them?
Download the following script, read it over and make sure you understand the code.
Try using this script to repaint image1.jpg based on the ideal number of clusters you determined from the previous exercise. Try repainting it using fewer clusters. Experiment with repainting the other images using varying numbers of clusters. In general, is it possible to find a value of K that cleanly separates objects from one another?
If we wanted to use this approach for image segmentation, it might make sense to include information about a pixel's location in the image as well as its color. A pixel should not be clustered together with another pixel an the far side of the image. Update the code in repaint.py to use this approach.