Mercurial > hg > smallbox
comparison util/classes/dictionaryMatrices/dctmatrix.m @ 160:e3035d45d014 danieleb
Added support classes
author | Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk> |
---|---|
date | Wed, 31 Aug 2011 10:53:10 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
159:23763c5fbda5 | 160:e3035d45d014 |
---|---|
1 function D = dctmatrix(N,K,type) | |
2 | |
3 error(nargchk(1,3,nargin,'struct')); | |
4 if ~exist('type','var') || isempty(type), type='II'; end | |
5 if ~exist('K','var') || isempty(K), K=N; end | |
6 | |
7 [c r] = meshgrid(0:K-1,0:N-1); | |
8 switch type | |
9 case 'I' | |
10 D = cos(pi*c.*r/(K-1)); | |
11 D(1,:) = D(1,:)/sqrt(2); | |
12 D(end,:) = D(end,:)/sqrt(2); | |
13 case 'II' | |
14 D = cos(pi*(2*c+1).*r/(2*K)); | |
15 D(1,:) = D(1,:)/sqrt(2); | |
16 case 'III' | |
17 D = cos(pi*(2*r+1).*c/(2*K)); | |
18 D(:,1) = D(:,1)/sqrt(2); | |
19 case 'IV' | |
20 D = cos(pi*(2*r+1+2*c+4*c.*r)/(4*K)); | |
21 otherwise | |
22 error('unsupported dct type'); | |
23 end | |
24 D = normcol(D); |