Tiling images on axis -- Matab code

14 views
Skip to first unread message

Hiho

unread,
Apr 10, 2008, 11:26:04 PM4/10/08
to MathTools
%This is a useful function for tiling images on axis

function tileimages(pc, ccount, rcount, w, h)
if(~exist('w','var'))
w = 64;
end
if(~exist('h','var'))
h = 64;
end
ww = min( max(w*ccount, h*rcount), 640);
hwr = h*rcount/(w*ccount);
if(hwr>1)
ww = ww/hwr;
end
figure('Position', [0 0 ww ww*hwr]);
axes('Position', [0 0 1 1], 'Visible', 'off');
hold on
c=0;

pcmax = max(max(pc));
pcmin = min(min(pc));

pcimage = (pc-pcmin)/(pcmax-pcmin);
for n=1:size(pcimage, 2)
xn = reshape(pcimage( :, n), [w h]);

nr = fix(c/ ccount);
nc = mod(c, ccount);
im8 = uint8(255*xn);
image(im8, 'XData',...
[nc/ccount (nc+1)/ccount], ...
'YData', [1-(nr)/rcount 1-(nr+1)/rcount], ...
'CDataMapping', 'scaled');

c=c+1;
end
xlim([0, 1]);
ylim([0, 1]);
colormap gray
Reply all
Reply to author
Forward
0 new messages