Mercurial > hg > smallbox
comparison DL/RLS-DLA/private/thumbFromOp.m @ 60:ad36f80e2ccf
(none)
author | idamnjanovic |
---|---|
date | Tue, 15 Mar 2011 12:20:59 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
59:23f9dd7b9d78 | 60:ad36f80e2ccf |
---|---|
1 function P = thumbFromOp(op,m,n,sm,sn,grayscale) | |
2 % Output matrix P, of size m x n, sampled at | |
3 % sm x sn upper top | |
4 | |
5 % Copyright 2008, Ewout van den Berg and Michael P. Friedlander | |
6 % http://www.cs.ubc.ca/labs/scl/sparco | |
7 % $Id: thumbFromOp.m 1040 2008-06-26 20:29:02Z ewout78 $ | |
8 | |
9 if nargin < 6, grayscale = 0; end | |
10 | |
11 info = op([],0); | |
12 | |
13 sm = min(info{1},sm); | |
14 sn = min(info{2},sn); | |
15 M = zeros(sm,sn); | |
16 | |
17 for i=1:sn | |
18 v = zeros(info{2},1); v(i) = 1; | |
19 w = real(op(v,1)); | |
20 | |
21 M(:,i) = w(1:sm); | |
22 end | |
23 | |
24 mn = min(min(M)); | |
25 mx = max(max(M)); | |
26 M = (M - mn) / (mx-mn); | |
27 | |
28 idxm = floor(linspace(1,sm+1,m+1)); idxm = idxm(1:end-1); | |
29 idxn = floor(linspace(1,sn+1,n+1)); idxn = idxn(1:end-1); | |
30 | |
31 if grayscale | |
32 P = 1-M(idxm,idxn); | |
33 else | |
34 clrmap = hsv; | |
35 M = 1 + round(M * (length(clrmap)-1)); | |
36 P = zeros(m,n,3); | |
37 for j1=1:m | |
38 for j2=1:n | |
39 P(j1,j2,:) = clrmap(M(idxm(j1),idxn(j2)),:); | |
40 end | |
41 end | |
42 end |