-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode_for_project.m
40 lines (32 loc) · 1.41 KB
/
code_for_project.m
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
33
34
35
36
37
38
39
40
% This code is supplementary material for the project of the course
% "Clustering algorithms"
function [X,cl_label] = code_for_project()
% clear
% format compact
% close all
load Salinas_Data
[p,n,l]=size(Salinas_Image); % Size of the Salinas cube
% Depicting the bands of the Salinas cube
% for i=1:l
% figure(1); imagesc(Salinas_Image(:,:,i))
% pause(0.1)
% end
% Making a two dimensional array whose rows correspond to the pixels and
% the columns to the bands, containing only the pixels with nonzero label.
X_total=reshape(Salinas_Image, p*n,l);
L=reshape(Salinas_Labels,p*n,1);
existed_L=(L>0); %This contains 1 in the positions corresponding to pixels with known class label
X=X_total(existed_L,:);
[px,nx]=size(X); % px= no. of rows (pixels) and nx=no. of columns (bands)
cl_label = L(existed_L);
%...---> cl_label
% The following code can be used after the execution of an algorithm
% Let "cl_label" be the px-dimensional vector, whose i-th element is the label
% of the class where the i-th vector in X has been assigned
% The code below, helps in depicting the results as an image again
% cl_label_tot=zeros(p*n,1);
% cl_label_tot(existed_L)=cl_label;
% im_cl_label=reshape(cl_label_tot,p,n);
% figure(10), imagesc(im_cl_label), axis equal
% figure(11), imagesc(Salinas_Labels), axis equal
end