comparison util/sparco utils/thumbFromOp.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 = 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