-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathVisualization_dataset.m
38 lines (35 loc) · 1.08 KB
/
Visualization_dataset.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
%% Visualize some samples of the datasets we used
clc,clear
close all
addpath(genpath(cd))
f = {'ORL400_new';'YaleB944';'COIL20';'Isolet1';'2k2k_new';...
'Alphabet';'BF0502';'Notting-Hill'};
f1 = {'ORL';'YaleB';'COIL20';'Isolet';'MNIST';...
'Alphabet';'BF0502';'Notting-Hill'};
rng(42)
%% file loop
tic
for di = 1:8
k = 1;
%% load data
filename = fullfile('./data',f{di});
outfilename = fullfile('./result',f{di});
fn = [filename,'.mat'];
data = load(fn);
X = data.X;
[d,n] = size(X);
gnd = data.gnd;
clsnum = length(unique(gnd));
figure;
rand_indices = randperm(n, 64); % randomly select 64 samples
for i = 1:16
subplot(4, 4, i);
img = reshape(X(:, rand_indices(i)), sqrt(d), sqrt(d)); % reshape sample to image format
imshow(img, []);
title(sprintf('Class %d', gnd(rand_indices(i))), 'FontSize', 10);
end
% sgtitle(sprintf('Random samples from %s dataset', f1{di}));
set(gcf, 'PaperPositionMode', 'auto');
% saveas(gcf, fullfile(outfilename, sprintf('%s_samples.png', f{di})));
end
toc