## **Problem 6: Implementing Image Segmentation via Unsupervised Clustering on Kaggle Competition (20pts)**

This is a Kaggle competition problem where you are asked to perform unsupervised clustering on an RGB image using the algorithms you studied in class in conjunction with the various feature combinations and color spaces. We provide you with two images: a simple image consisting of geometric shapes and another one containing more complicated objects, both in RGB. The images can be downloaded by running the following snippet of code:

```
!gdown --id 1ZAvUJktJ0aojeXWJnuxuYqHlLslCZ9T-
!gdown --id 1Qh2HppgVSAniVqWxRsbJ7cZFhUpRdUpI
```
You can then load the two images as shown below:

```
import imageio

im1 = imageio.imread('img1.png')
im2 = imageio.imread('img2.png')
```

Since this is an open-ended question, you should try to design your own features to achieve better classification results. By submitting your result to Kaggle, you will see your multi-class classification accuracy and ranking on the leaderborad. 10 pts will depend on your ranking (top 10% get 10pts, top 11%-20% get 9pts, etc.), and another 5 pts depend on your method explanation and clear, well-labeled plots and images.
[Note:]
- After having your ideal result, please save your result in `result_img1` and `result_img2` in the cell below.

- We have defined the label for each class in each image. Make sure you use the same settings as us and feel free to use the provided swapping label code to swap labels if needed.

 - for `img1.png`, use k=3, background labels as 0, rectangle labels as 1 and triangle labels as 2
 - for `img2.png`, use k=2, background labels as 0, dog labels as 1 

- After your `result_img1` and `result_img2` are ready, run the cell below to create a `submission.csv`. Please download it from this notebook and submit it in our [Kaggle](https://www.kaggle.com/c/funml-hw4-p6) competition.

- Please remember to note your Kaggle competition nickname in this notebook. We will use your ranking to grade.

- You have 10 submission quota each day to submit your result and get your multi-class classification accuracy and ranking.

- We calculate the multi-class classification accuracy with ground-turth hand-crafted labels in both images by 

$$\text{Accuracy} = \frac{\text{# of correctly labeled pixels}}{\text{total # of pixels}}$$

### Reference

T.-Y. Lin, M. Maire, S. Belongie, J. Hays, P. Perona, D. Ramanan, P. Dollar, and C. L. Zitnick. Microsoft COCO: Com- ´
mon objects in context. In ECCV, 2014.