In my code below can u tell why the number of elements are different or size is different
>> img=imread('peppers.png'); >> flatImg = double(reshape(img,size(img,1)*size(img,2),size(img,3))); idx = kmeans(flatImg,3)
please provide assistance
No products are associated with this question.
You have 196608 pixels. In flatImg you rearranged them into rows where each column is the red, green, and blue values.
With kmeans, each of the 196608 pixels is classified as a "1", "2", or a "3" depending on its color, so it's a 1D array. There is no information along any second dimension like there was with flatImg.
There is no reason why they should be the same size because they represent different things. Do you think they should?