I am working on sparse recovery for a classification task. I use Pine hyperspectral dataset which is a freely available dataset and this image contains 200 Dimension (Depth/channels/bands). In addition, this dataset contains labels (Ground truth information). Thus I extract the corresponding pixels for each class and now I want to visualize them to see really how they look like. But I do know now how to visualize them for all 200 channels. I did this visualization for 3D but I want to know how can I expand this for 3D.

Here is my code for 3D, I would appreciate any help for visualizing my data in 3D Not: I simulate the dataset.

clear all
% Number of classes = 5   
B = [1 1 2; 2 3 4; 2 1 3; 4 3 4; 5 5 3];
B_vec = reshape(B, 5*3, 1);
% Image with 200 depth
A = rand(5,3, 200)*100;
A_vec = reshape(A, 5*3, 200);
%Indexing the desire classes. 
indx = find(or(B==1, B==4, B==3));
class_num = B_vec(indx);
%Extracting the corresponding pixels (base on indx)from 200D image.
for k = 1: length(indx)
img_value(k,:) = A_vec(indx(k),:);
G_idx_1 = (find(class_num==1));
for k = 1:length(G_idx_1)
C_1(k,:) = img_value(G_idx_1(k),:); 
G_idx_3 = (find(class_num==3));
for k = 1:length(G_idx_3)
C_3(k,:) = img_value(G_idx_3(k),:); 
G_idx_4 = (find(class_num==4));
for k = 1:length(G_idx_4)
C_4(k,:) = img_value(G_idx_4(k),:);

X1 = [C_1'];
X2 = [C_3'];
X3 = [C_4'];
plot3(X1(1,:), X1(2,:), X1(3,:),'bo'); axis on; grid on; hold on
plot3(X2(1,:), X2(2,:), X2(3,:),'go'); 
plot3(X3(1,:), X3(2,:), X3(3,:),'ro'); hold off;
title('class1, class2, class3')

You can use t-SNE to perform dimensionality reduction to create a 2-D or 3-D embedding space for data visualization purposes.

For Matlab you can check the implementation and the example.

  • $\begingroup$ Thanks. It seems to be what I want. I will check it out. $\endgroup$
    – morteza
    Nov 11 '18 at 14:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.