annotate DL/RLS-DLA/private/thumbPlot.m @ 61:42fcbcfca132

(none)
author idamnjanovic
date Tue, 15 Mar 2011 12:21:31 +0000
parents ad36f80e2ccf
children
rev   line source
idamnjanovic@60 1 function P = thumbPlot(P,x,y,color)
idamnjanovic@60 2
idamnjanovic@60 3 % Copyright 2008, Ewout van den Berg and Michael P. Friedlander
idamnjanovic@60 4 % http://www.cs.ubc.ca/labs/scl/sparco
idamnjanovic@60 5 % $Id: thumbPlot.m 1040 2008-06-26 20:29:02Z ewout78 $
idamnjanovic@60 6
idamnjanovic@60 7 m = size(P,1);
idamnjanovic@60 8 n = size(P,2);
idamnjanovic@60 9 if (size(P,3) == 0) & (length(color) == 3)
idamnjanovic@60 10 % Convert to gray-scale
idamnjanovic@60 11 color = 0.30*color(1) + 0.59*color(2) + 0.11*color(3);
idamnjanovic@60 12 end
idamnjanovic@60 13
idamnjanovic@60 14 mnx = min(x); % Minimum x
idamnjanovic@60 15 mxx = max(x); % Maximum x
idamnjanovic@60 16 mny = min(y); % Minimum y
idamnjanovic@60 17 mxy = max(y); % Maximum y
idamnjanovic@60 18 dy = (mxy - mny) * 0.1; % Offset on vertical axis
idamnjanovic@60 19 sx = (mxx - mnx) * 1.0; % Scale of horizontal axis
idamnjanovic@60 20 sy = (mxy - mny) * 1.2; % Scale of vertical axis
idamnjanovic@60 21
idamnjanovic@60 22 if (sx < 1e-6), sx = 1; end
idamnjanovic@60 23 if (sy < 1e-6), sy = 1; end
idamnjanovic@60 24
idamnjanovic@60 25 for i=1:length(x)-1
idamnjanovic@60 26 x0 = floor(1 + (n-1) * (x(i ) - mnx) / sx);
idamnjanovic@60 27 x1 = floor(1 + (n-1) * (x(i+1) - mnx) / sx);
idamnjanovic@60 28 y0 = floor( (n-1) * (y(i ) - mny + dy) / sy);
idamnjanovic@60 29 y1 = floor( (n-1) * (y(i+1) - mny + dy) / sy);
idamnjanovic@60 30
idamnjanovic@60 31 samples = 1+2*max(abs(x1-x0)+1,abs(y1-y0)+1);
idamnjanovic@60 32 c = linspace(0,1,samples);
idamnjanovic@60 33 idx = round((1-c)*x0 + c*x1);
idamnjanovic@60 34 idy = n - round((1-c)*y0 + c*y1);
idamnjanovic@60 35 for j=1:samples
idamnjanovic@60 36 P(idy(j),idx(j),:) = color;
idamnjanovic@60 37 end
idamnjanovic@60 38 end