idamnjanovic@52: function P = thumbFromOp(op,m,n,sm,sn,grayscale) idamnjanovic@52: % Output matrix P, of size m x n, sampled at idamnjanovic@52: % sm x sn upper top idamnjanovic@52: idamnjanovic@52: % Copyright 2008, Ewout van den Berg and Michael P. Friedlander idamnjanovic@52: % http://www.cs.ubc.ca/labs/scl/sparco idamnjanovic@52: % $Id: thumbFromOp.m 1040 2008-06-26 20:29:02Z ewout78 $ idamnjanovic@52: idamnjanovic@52: if nargin < 6, grayscale = 0; end idamnjanovic@52: idamnjanovic@52: info = op([],0); idamnjanovic@52: idamnjanovic@52: sm = min(info{1},sm); idamnjanovic@52: sn = min(info{2},sn); idamnjanovic@52: M = zeros(sm,sn); idamnjanovic@52: idamnjanovic@52: for i=1:sn idamnjanovic@52: v = zeros(info{2},1); v(i) = 1; idamnjanovic@52: w = real(op(v,1)); idamnjanovic@52: idamnjanovic@52: M(:,i) = w(1:sm); idamnjanovic@52: end idamnjanovic@52: idamnjanovic@52: mn = min(min(M)); idamnjanovic@52: mx = max(max(M)); idamnjanovic@52: M = (M - mn) / (mx-mn); idamnjanovic@52: idamnjanovic@52: idxm = floor(linspace(1,sm+1,m+1)); idxm = idxm(1:end-1); idamnjanovic@52: idxn = floor(linspace(1,sn+1,n+1)); idxn = idxn(1:end-1); idamnjanovic@52: idamnjanovic@52: if grayscale idamnjanovic@52: P = 1-M(idxm,idxn); idamnjanovic@52: else idamnjanovic@52: clrmap = hsv; idamnjanovic@52: M = 1 + round(M * (length(clrmap)-1)); idamnjanovic@52: P = zeros(m,n,3); idamnjanovic@52: for j1=1:m idamnjanovic@52: for j2=1:n idamnjanovic@52: P(j1,j2,:) = clrmap(M(idxm(j1),idxn(j2)),:); idamnjanovic@52: end idamnjanovic@52: end idamnjanovic@52: end