Mercurial > hg > smallbox
comparison util/sparco utils/thumbPlot.m @ 77:62f20b91d870
add routines from sparco problems privite folder to {root}\util
some changes to ksvd vs rlsdla image denoising example
author | Ivan <ivan.damnjanovic@eecs.qmul.ac.uk> |
---|---|
date | Fri, 25 Mar 2011 14:01:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
76:d052ec5b742f | 77:62f20b91d870 |
---|---|
1 function P = thumbPlot(P,x,y,color) | |
2 | |
3 % Copyright 2008, Ewout van den Berg and Michael P. Friedlander | |
4 % http://www.cs.ubc.ca/labs/scl/sparco | |
5 % $Id: thumbPlot.m 1040 2008-06-26 20:29:02Z ewout78 $ | |
6 | |
7 m = size(P,1); | |
8 n = size(P,2); | |
9 if (size(P,3) == 0) & (length(color) == 3) | |
10 % Convert to gray-scale | |
11 color = 0.30*color(1) + 0.59*color(2) + 0.11*color(3); | |
12 end | |
13 | |
14 mnx = min(x); % Minimum x | |
15 mxx = max(x); % Maximum x | |
16 mny = min(y); % Minimum y | |
17 mxy = max(y); % Maximum y | |
18 dy = (mxy - mny) * 0.1; % Offset on vertical axis | |
19 sx = (mxx - mnx) * 1.0; % Scale of horizontal axis | |
20 sy = (mxy - mny) * 1.2; % Scale of vertical axis | |
21 | |
22 if (sx < 1e-6), sx = 1; end | |
23 if (sy < 1e-6), sy = 1; end | |
24 | |
25 for i=1:length(x)-1 | |
26 x0 = floor(1 + (n-1) * (x(i ) - mnx) / sx); | |
27 x1 = floor(1 + (n-1) * (x(i+1) - mnx) / sx); | |
28 y0 = floor( (n-1) * (y(i ) - mny + dy) / sy); | |
29 y1 = floor( (n-1) * (y(i+1) - mny + dy) / sy); | |
30 | |
31 samples = 1+2*max(abs(x1-x0)+1,abs(y1-y0)+1); | |
32 c = linspace(0,1,samples); | |
33 idx = round((1-c)*x0 + c*x1); | |
34 idy = n - round((1-c)*y0 + c*y1); | |
35 for j=1:samples | |
36 P(idy(j),idx(j),:) = color; | |
37 end | |
38 end |