image block clustering using kmeans

Hi all.
I have block from an image obtained using:
How best can I cluster similar blocks from my BlockImage matrix using: kmeans?
I also wish to display the distance between; any two intra-cluster blocks, any two blocks from different clusters; any two centroids if possible.
Honestly, am not so sure how to tackle this. Looking at the kmeans examples from the document, is not so intuitive for this particular scenario.
Thanks alot.

 Accepted Answer

6 Comments

@Image Analyst thanks. Let me look into them. The reason is I want to cluster blocks.
How is this different than just getting a class for every pixel in the image?
because, I already generated the distinct blocks with pre determined dimensions. So clustering over blocks, I can easily tell how many blocks are in a cluster(hopefully) - thats the aim. Maybe even play with the individual blocks see their effect on the image.
Maybe this is why I never use im2col(). Explain to me what's going on here:
grayImage = imread('moon.tif');
[rows, columns, numberOfColorChannels] = size(grayImage)
rows = 537
columns = 358
numberOfColorChannels = 1
subplot(1, 2, 1);
imshow(grayImage);
axis on
m = rows;
n = 8;
BlockImage = im2col(grayImage,[m n],'distinct');
subplot(1, 2, 2);
imshow(BlockImage);
axis on
you converted the distinct image blocks to a column matrix?
but seriously whats happening?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!