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