% Script file for Problem 2 on exam 2. % You shouldn't need to change the next three lines: load Problem02Data; %This load the 256 x 256 x 3 matrix X. X=double(X); %Change the format for the clustering to work. % Reshape to get a regular matrix of data (65536 x 3) (fill in one line below) ??? % Perform k-means (fill in one line below). % Output should be idx for the index of each data point (which cluster it belongs to) % and C for the matrix of centers. ??? % VIsualization section- You shouldn't need to change this. Im=uint8(zeros(65536,3)); %This creates the matrix in memory with the new colors for j=1:65536 Im(j,:)=uint8(round(C(idx(j),:))); end subplot(1,2,1) image(uint8(X)); axis square; subplot(1,2,2) image(reshape(Im,256,256,3)) axis square