资源简介
t-sne,显示图片在tsne上的分布,不是点状图,需要自己准备图片数据
代码片段和文件信息
%% load embedding
load(‘imagenet_val_embed.mat‘); % load x (the embedding 2d locations from tsne)
x = bsxfun(@minus x min(x));
x = bsxfun(@rdivide x max(x));
%% load validation image filenames
fs = textread(‘val_imgs_med.txt‘ ‘%s‘);
N = length(fs);
%% create an embedding image
S = 2000; % size of full embedding image
G = zeros(S S 3 ‘uint8‘);
s = 50; % size of every single image
Ntake = 50000;
for i=1:Ntake
if mod(i 100)==0
fprintf(‘%d/%d...\n‘ i Ntake);
end
% location
a = ceil(x(i 1) * (S-s)+1);
b = ceil(x(i 2) * (S-s)+1);
a = a-mod(a-1s)+1;
b = b-mod(b-1s)+1;
if G(ab1) ~= 0
continue % spot already filled
end
I = imread(fs{i});
if size(I3)==1 I = cat(3III); end
I = imresize(I [s s]);
G(a:a+s-1 b:b+s-1 :) = I;
end
imshow(G);
%%
%imwrite(G ‘cnn_embed_2k.jpg‘ ‘jpg‘);
%% average up images
% % (doesnt look very good failed experiment...)
%
% S = 1000;
% G = zeros(S S 3);
% C = zeros(S S 3);
% s = 50;
%
% Ntake = 5000;
% for i=1:Ntake
%
% if mod(i 100)==0
% fprintf(‘%d/%d...\n‘ i Ntake);
% end
%
% % location
% a = ceil(x(i 1) * (S-s-1)+1);
% b = ceil(x(i 2) * (S-s-1)+1);
% a = a-mod(a-1s)+1;
% b = b-mod(b-1s)+1;
%
% I = imread(fs{i});
% if size(I3)==1 I = cat(3III); end
% I = imresize(I [s s]);
%
% G(a:a+s-1 b:b+s-1 :) = G(a:a+s-1 b:b+s-1 :) + double(I);
% C(a:a+s-1 b:b+s-1 :) = C(a:a+s-1 b:b+s-1 :) + 1;
%
% end
%
% G(C>0) = G(C>0) ./ C(C>0);
% G = uint8(G);
% imshow(G);
%% do a guaranteed quade grid layout by taking nearest neighbor
S = 2000; % size of final image
G = zeros(S S 3 ‘uint8‘);
s = 50; % size of every image thumbnail
xnum = S/s;
ynum = S/s;
used = false(N 1);
qq=length(1:s:S);
abes = zeros(qq*22);
i=1;
for a=1:s:S
for b=1:s:S
abes(i:) = [ab];
i=i+1;
end
end
%abes = abes(randperm(size(abes1)):); % randperm
for i=1:size(abes1)
a = abes(i1);
b = abes(i2);
%xf = ((a-1)/S - 0.5)/2 + 0.5; % zooming into middle a bit
%yf = ((b-1)/S - 0.5)/2 + 0.5;
xf = (a-1)/S;
yf = (b-1)/S;
dd = sum(bsxfun(@minus x [xf yf]).^22);
dd(used) = inf; % dont pick these
[dvdi] = min(dd); % find nearest image
used(di) = true; % mark as done
I = imread(fs{di});
if size(I3)==1 I = cat(3III); end
I = imresize(I [s s]);
G(a:a+s-1 b:b+s-1 :) = I;
if mod(i100)==0
fprintf(‘%d/%d\n‘ i size(abes1));
end
end
imshow(G);
%%
% imwrite(G ‘cnn_embed_full_2k.jpg‘ ‘jpg‘);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 770981 2014-07-05 12:31 imagenet_val_em
文件 2653 2014-07-05 13:49 show_em
文件 3050000 2014-07-04 19:17 val_imgs_med.txt
- 上一篇:倒立摆程序简介
- 下一篇:KNN实现代码+数据可视化+决策边界
评论
共有 条评论