unrollimg = [];
W = [];
totim = zeros(30000,1);
ct=0;
imlist = dir('/tmp/im/*-t.jpg');
tmp = size(imlist);
nim = tmp(1);
cd /tmp/im;
for inum = 1:nim
	tmp = imread(imlist(inum).name);
	tmp = imresize(tmp, [100 100], 'nearest');
	tmp = double(tmp);
	tmp = tmp./255;
	unroll = [];
	for i = 1:100
		for j = 1:3
			unroll = [unroll; tmp(:,i,j)];
		end
	end
%	unroll = unroll/max(unroll);
%	unroll = unroll - mean(unroll);
	totim = totim + unroll;
	ct = ct+1;
	unrollimg(:,inum) = unroll;
	imlist(inum).name
end

avim = totim./ct;

% unrollimg = unrollimg/max(max(unrollimg));
for inum = 1:nim-29
	unrollimg(:,inum) = unrollimg(:,inum) - avim;
end

xtx = unrollimg'*unrollimg;

[ew ev] = eig(xtx);

W = unrollimg*ew;
