-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMyFCM9.m
More file actions
executable file
·32 lines (32 loc) · 876 Bytes
/
MyFCM9.m
File metadata and controls
executable file
·32 lines (32 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function [ClusterIm, CCIm] = MyFCM8(Image, ImageType, NumClusts)
[m, n, colors] = size(Image);
data = Image;
if(strcmp('RGB',ImageType)==1)
R = data(:,:,1);
G = data(:,:,2);
B = data(:,:,3);
R = double(R);
G = double(G);
B = double(B);
R = R(:);
G = G(:);
B = B(:);
data = [R,G,B];
end
if(strcmp('Hyper',ImageType)==1)
b = 20;
[Y, U, Lambda, Mu] = PCAbyDG(data,b);
data = Y;
end
[centers,U] = fcm(data, NumClusts);
maxU = max(U);
ClusterIm = zeros(m*n,1);
for itr = 1:NumClusts
index = find(U(itr,:) == maxU);
for jtr = 1 : size(index,2)
ClusterIm(index(jtr)) = itr;
end
end
CCIm = ConnectedComponent(ClusterIm,NumClusts,m,n);
imagesc(CCIm);
end