[SOLVED] CS6375 Assignment 5- K-Means Clustering on Images

35.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon Assignment-5-o454ei.zip (4510.7 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
5/5 - (2 votes)

In this problem, you will use K-means clustering for image compression. Two image files provided in the elearning. The assignment task is to display the images after data compression using K-means clustering for different values of K (2, 5, 10, 15, 20).

Is there a tradeoff between image quality and degree of compression? What would be a good value of K for each of the two images?

from matplotlib import pyplot as io import numpy as np from PIL import Image

 

# Image to array

img1 = io.imread(imagefilename)  #image is saved as rows * columns * 3 array  print (img1)

#Array to image file

array = np.zeros([10,20,3], dtype = np.uint8)

 

array[:,:10] = [255, 128, 0]    # Orange left side array[:,10:]  = [0,0,255]   # Blue right side

Note that your program must compile and we should be able to replicate your results.

Otherwise no credit will be given.

What to turn in:

  1. Your code and datasets
  2. A README for your compiling/using your code
  3. A report (pdf or doc file) containing answers to the questions posed.

 

The following code is for reading and writing Image Files: Image to RGB array or RGB array to image:

 

print(array) img2 = Image.fromarray(array) img2.save(‘testrg.png’)

 

  • Assignment-5-o454ei.zip