Mercurial > hg > smallbox
annotate util/classes/dictionaryMatrices/dctmatrix.m @ 168:ff866a412be5 danieleb
Removed tag danieleb
author | Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk> |
---|---|
date | Tue, 20 Sep 2011 15:52:33 +0100 |
parents | e3035d45d014 |
children |
rev | line source |
---|---|
daniele@160 | 1 function D = dctmatrix(N,K,type) |
daniele@160 | 2 |
daniele@160 | 3 error(nargchk(1,3,nargin,'struct')); |
daniele@160 | 4 if ~exist('type','var') || isempty(type), type='II'; end |
daniele@160 | 5 if ~exist('K','var') || isempty(K), K=N; end |
daniele@160 | 6 |
daniele@160 | 7 [c r] = meshgrid(0:K-1,0:N-1); |
daniele@160 | 8 switch type |
daniele@160 | 9 case 'I' |
daniele@160 | 10 D = cos(pi*c.*r/(K-1)); |
daniele@160 | 11 D(1,:) = D(1,:)/sqrt(2); |
daniele@160 | 12 D(end,:) = D(end,:)/sqrt(2); |
daniele@160 | 13 case 'II' |
daniele@160 | 14 D = cos(pi*(2*c+1).*r/(2*K)); |
daniele@160 | 15 D(1,:) = D(1,:)/sqrt(2); |
daniele@160 | 16 case 'III' |
daniele@160 | 17 D = cos(pi*(2*r+1).*c/(2*K)); |
daniele@160 | 18 D(:,1) = D(:,1)/sqrt(2); |
daniele@160 | 19 case 'IV' |
daniele@160 | 20 D = cos(pi*(2*r+1+2*c+4*c.*r)/(4*K)); |
daniele@160 | 21 otherwise |
daniele@160 | 22 error('unsupported dct type'); |
daniele@160 | 23 end |
daniele@160 | 24 D = normcol(D); |