1## Copyright (C) 2001 Paul Kienzle <pkienzle@users.sf.net>
2##
3## This program is free software: you can redistribute it and/or modify
4## it under the terms of the GNU General Public License as published by
5## the Free Software Foundation, either version 3 of the License, or
6## (at your option) any later version.
7##
8## This program is distributed in the hope that it will be useful,
9## but WITHOUT ANY WARRANTY; without even the implied warranty of
10## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11## GNU General Public License for more details.
12##
13## You should have received a copy of the GNU General Public License
14## along with this program; see the file COPYING. If not, see
15## <https://www.gnu.org/licenses/>.
16
17## -*- texinfo -*-
18## @deftypefn  {Function File} {} dct2 (@var{x})
19## @deftypefnx {Function File} {} dct2 (@var{x}, @var{m}, @var{n})
20## @deftypefnx {Function File} {} dct2 (@var{x}, [@var{m}, @var{n}])
21## Compute the 2-D discrete cosine transform of matrix @var{x}.  If
22## @var{m} and @var{n} are specified, the input is padded or trimmed
23## to the desired size.
24## @seealso{dct, idct, idct2}
25## @end deftypefn
26
27function y = dct2 (x, m, n)
28
29  if (nargin < 1 || nargin > 3)
30    print_usage;
31  endif
32
33  if nargin == 1
34    [m, n] = size(x);
35  elseif (nargin == 2)
36    n = m(2);
37    m = m(1);
38  endif
39
40  if m == 1
41    y = dct (x.', n).';
42  elseif n == 1
43    y = dct (x, m);
44  else
45    y = dct (dct (x, m).', n).';
46  endif
47
48endfunction
49