This homework covers standard clustering methods (K-means and mean-shift) in the context of image segmentation. These methods
are often used for color quantization or for computing superpixels. Generalization of K-means and mean-shift are also commonly integrated into more advanced segmentation methods.
You can start from C++ visual studio
K-means project implementing an interface that allows to load images, enter seeds, play with parameters, switch between RGB and RGBXY features, and save your results as images. To make this into a working algorithm, just implement functions Kmeans and init_means in file Kmeans.cpp.
You can also use Python. In particular, you can start from MyKmeans Jupiter notebook posted here. If you are using Jupiter notebooks than you can combine your code and report/discussion (as markdown cells) in one notebook. (save and submit .html version of the notebook in addition to the notebook file .ipynb).
Implement K-means algorithm for clustering colors (RGB space, you can use other color spaces if you like) of image pixels.
Use your K-means algorithm for clustering image pixels based on RGB and RGBXY features. The former idea is commonly used for color quantization, the latter idea is used for superpixels (e.g SLIC superpixels, see the figure above).
Introduce parameter "w" that changes relative weight of XY component (x and y coordinates) in 5D feature [R,G,B,wX,wY] at each pixel. Compare the clustering results as you change w.
Use average color in each segment to visualize this segment.
Play with larger values of parameter k (e.g. in range 2-80) and investigate what happens as you vary w. Include representative results in your report and explain your observations.
Evaluate sensitivity of K-means to local minima. Show different solutions for different random initial means and compute the corresponding values of the K-means energy.
Implement automatic estimation of K using AIC/BIC energies discussed in class. E.g. run K-means for different K and select the optimal result over different K using an energy combining SSD and a sparcity constraint.
Implement mean-shift (or medoid-shift) with box-kernel (window) and evaluate sensitivity to bandwidth. Demonstrate your results for RGB and RGBXY features.
Discuss similarities and differences between K-means and mean-shift segmentation. Explain your observations.
What to submit
In addition to zipped code, submit a pdf file with your report (no more than 1.5 pages of text, but any number of images) presenting your experiments and discussion.
If you are using Python Jupiter notebooks combining your code and report/discussion (as markdown cells) then save and submit .html version of the notebook (with all figures) in addition to the notebook file .ipynb.
The report should be submitted electronically via OWL. The project report and code should be your independent effort.