k means clustering using k=4

조회 수: 1 (최근 30일)
vijeta uppal
vijeta uppal 2021년 3월 29일
댓글: Walter Roberson 2021년 3월 29일
Perform K-means clustering on the mandrill image with K=4.
can someone please help me with code for this question, as I'm a begineer don't have much idea about how to proceed with this question.

채택된 답변

KSSV
KSSV 2021년 3월 29일
I = imread('Mandril.jpeg') ;
I = im2double(I);
R = I(:,:,1); R = R(:);
G = I(:,:,2); G = G(:);
B = I(:,:,3); B = B(:);
idx = kmeans([R G B], 4);
imshow(ind2rgb(reshape(idx, size(I,1), size(I, 2)), rand(4,3)))
  댓글 수: 1
Walter Roberson
Walter Roberson 2021년 3월 29일
Note that it was a homework question...

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2021년 3월 29일
The line that has
[idx,C] = kmeans(X,3);
would change to
[idx,C] = kmeans(X,4);
if you were clustering with four clusters.

Community Treasure Hunt

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

Start Hunting!

Translated by