annotate util/sparco utils/thumbFromOp.m @ 115:921f9931c84f sup_158_IMG_Processing_toolbox_

IMP toolbox dependency removed from SMALL_ImgDeNoiseResult
author Ivan Damnjanovic lnx <ivan.damnjanovic@eecs.qmul.ac.uk>
date Tue, 24 May 2011 16:13:04 +0100
parents 62f20b91d870
children
rev   line source
ivan@77 1 function P = thumbFromOp(op,m,n,sm,sn,grayscale)
ivan@77 2 % Output matrix P, of size m x n, sampled at
ivan@77 3 % sm x sn upper top
ivan@77 4
ivan@77 5 % Copyright 2008, Ewout van den Berg and Michael P. Friedlander
ivan@77 6 % http://www.cs.ubc.ca/labs/scl/sparco
ivan@77 7 % $Id: thumbFromOp.m 1040 2008-06-26 20:29:02Z ewout78 $
ivan@77 8
ivan@77 9 if nargin < 6, grayscale = 0; end
ivan@77 10
ivan@77 11 info = op([],0);
ivan@77 12
ivan@77 13 sm = min(info{1},sm);
ivan@77 14 sn = min(info{2},sn);
ivan@77 15 M = zeros(sm,sn);
ivan@77 16
ivan@77 17 for i=1:sn
ivan@77 18 v = zeros(info{2},1); v(i) = 1;
ivan@77 19 w = real(op(v,1));
ivan@77 20
ivan@77 21 M(:,i) = w(1:sm);
ivan@77 22 end
ivan@77 23
ivan@77 24 mn = min(min(M));
ivan@77 25 mx = max(max(M));
ivan@77 26 M = (M - mn) / (mx-mn);
ivan@77 27
ivan@77 28 idxm = floor(linspace(1,sm+1,m+1)); idxm = idxm(1:end-1);
ivan@77 29 idxn = floor(linspace(1,sn+1,n+1)); idxn = idxn(1:end-1);
ivan@77 30
ivan@77 31 if grayscale
ivan@77 32 P = 1-M(idxm,idxn);
ivan@77 33 else
ivan@77 34 clrmap = hsv;
ivan@77 35 M = 1 + round(M * (length(clrmap)-1));
ivan@77 36 P = zeros(m,n,3);
ivan@77 37 for j1=1:m
ivan@77 38 for j2=1:n
ivan@77 39 P(j1,j2,:) = clrmap(M(idxm(j1),idxn(j2)),:);
ivan@77 40 end
ivan@77 41 end
ivan@77 42 end