About K means clustering
Show older comments
% Machine Learning
%%
clc
clear all
% Adjustable Parameters
k=3;
threshold = .68;
%%
%Load image2 image
I = double(imread('3.jpg'));
[row, col, x] = size(I);
input =reshape(I,row*col,3);
%%
% Fuzzy C Means
[center,U] = fcm(input,k);
% Finding the pixels for each class
maxU = max(U);
index1 = find(U(1,:) == maxU);
index2 = find(U(2,:) == maxU);
index3 = find(U(3,:) == maxU);
%%
% Assigning pixel to each class
input(1:length(input))=0;
input(index1)= 0.5;
input(index2)= 0.3;
input(index3)= 0.1;
[nRows, nCols ]=size(U);
%%
% ITERATE THROUGH U
renew=input;
for u = 1:k
for m = 1:nCols
if U(u,m)< threshold
input(m,:)=0;
end
end
%Reshape input and display each result
input = reshape(input,row,col,3);
figure;imshow(input,[]);impixelinfo;
input=renew;
end
This is the code , but I wanna find mean for the first cluter but I'm not able to find it please help me
Answers (0)
Categories
Find more on Genomics and Next Generation Sequencing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!