【发布时间】:2014-08-04 23:51:12
【问题描述】:
我已经使用 FastICA 对一组人脸图像应用了独立分量分析。我已成功检索到独立组件和混合矩阵。独立组件的值是双倍的,我想将这些组件显示为 Web 上可用的图像,例如 http://research.ics.aalto.fi/ica/imageica/。我不知道如何显示这个。
【问题讨论】:
我已经使用 FastICA 对一组人脸图像应用了独立分量分析。我已成功检索到独立组件和混合矩阵。独立组件的值是双倍的,我想将这些组件显示为 Web 上可用的图像,例如 http://research.ics.aalto.fi/ica/imageica/。我不知道如何显示这个。
【问题讨论】:
使用montage 函数可以更自动地执行此操作。或者您可以查看subimage。另见this StackOverflow question and answer。
【讨论】:
试试下面的功能
function [XX,fh]=dispImgs(X,cols,gap,ihw,fh)
% Courtesy A. Leonardis, D. Skocaj
% see http://vicos.fri.uni-lj.si/danijels/downloads
[M,N]=size(X);
if nargin<2 cols=floor(sqrt(N)); end;
if nargin<3 gap=0; end;
if nargin<4 ihw=[sqrt(M),sqrt(M)]; end;
if nargin<5 fh = figure; end; % new figure
ih=ihw(1);iw=ihw(2);
maxv=max(X(:));
rows=floor(N/cols);
XX=zeros((rows*ih)+(rows-1)*gap,(cols*iw)+(cols-1)*gap)+maxv;
for i=1:N
a=(iw+gap)*mod(i-1,cols)+1;
b=(iw+gap)*mod(i-1,cols)+iw;
c=(ih+gap)*(floor((i-1)/cols))+1;
d=(ih+gap)*(floor((i-1)/cols))+ih;
XX(c:d,a:b)=reshape(X(:,i)',ih,iw);
end;
xxmax=max(XX(:));
xxmin=min(XX(:));
fh = figure(fh);
imshow((XX-xxmin)/(xxmax-xxmin));
axis off;
例子:
X: imsize by N
dispImgs( X, 8, 4, imsize );%show all N images in 8 columns with Gap=4
【讨论】: