1 ## Copyright (C) 2001 Paul Kienzle <pkienzle@users.sf.net>
3 ## This program is free software; you can redistribute it and/or modify it under
4 ## the terms of the GNU General Public License as published by the Free Software
5 ## Foundation; either version 3 of the License, or (at your option) any later
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 ## You should have received a copy of the GNU General Public License along with
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
17 ## Return the DCT transformation matrix of size n x n.
19 ## If A is an n x n matrix, then the following are true:
20 ## T*A == dct(A), T'*A == idct(A)
21 ## T*A*T' == dct2(A), T'*A*T == idct2(A)
23 ## A dct transformation matrix is useful for doing things like jpeg
24 ## image compression, in which an 8x8 dct matrix is applied to
25 ## non-overlapping blocks throughout an image and only a subblock on the
26 ## top left of each block is kept. During restoration, the remainder of
27 ## the block is filled with zeros and the inverse transform is applied
30 ## See also: dct, idct, dct2, idct2
32 function T = dctmtx(n)
38 T = [ sqrt(1/n)*ones(1,n) ; \
39 sqrt(2/n)*cos((pi/2/n)*([1:n-1]'*[1:2:2*n])) ];
43 error ("dctmtx: n must be at least 1");