idamnjanovic@60: function P = thumbPlot(P,x,y,color) idamnjanovic@60: idamnjanovic@60: % Copyright 2008, Ewout van den Berg and Michael P. Friedlander idamnjanovic@60: % http://www.cs.ubc.ca/labs/scl/sparco idamnjanovic@60: % $Id: thumbPlot.m 1040 2008-06-26 20:29:02Z ewout78 $ idamnjanovic@60: idamnjanovic@60: m = size(P,1); idamnjanovic@60: n = size(P,2); idamnjanovic@60: if (size(P,3) == 0) & (length(color) == 3) idamnjanovic@60: % Convert to gray-scale idamnjanovic@60: color = 0.30*color(1) + 0.59*color(2) + 0.11*color(3); idamnjanovic@60: end idamnjanovic@60: idamnjanovic@60: mnx = min(x); % Minimum x idamnjanovic@60: mxx = max(x); % Maximum x idamnjanovic@60: mny = min(y); % Minimum y idamnjanovic@60: mxy = max(y); % Maximum y idamnjanovic@60: dy = (mxy - mny) * 0.1; % Offset on vertical axis idamnjanovic@60: sx = (mxx - mnx) * 1.0; % Scale of horizontal axis idamnjanovic@60: sy = (mxy - mny) * 1.2; % Scale of vertical axis idamnjanovic@60: idamnjanovic@60: if (sx < 1e-6), sx = 1; end idamnjanovic@60: if (sy < 1e-6), sy = 1; end idamnjanovic@60: idamnjanovic@60: for i=1:length(x)-1 idamnjanovic@60: x0 = floor(1 + (n-1) * (x(i ) - mnx) / sx); idamnjanovic@60: x1 = floor(1 + (n-1) * (x(i+1) - mnx) / sx); idamnjanovic@60: y0 = floor( (n-1) * (y(i ) - mny + dy) / sy); idamnjanovic@60: y1 = floor( (n-1) * (y(i+1) - mny + dy) / sy); idamnjanovic@60: idamnjanovic@60: samples = 1+2*max(abs(x1-x0)+1,abs(y1-y0)+1); idamnjanovic@60: c = linspace(0,1,samples); idamnjanovic@60: idx = round((1-c)*x0 + c*x1); idamnjanovic@60: idy = n - round((1-c)*y0 + c*y1); idamnjanovic@60: for j=1:samples idamnjanovic@60: P(idy(j),idx(j),:) = color; idamnjanovic@60: end idamnjanovic@60: end