www.pudn.com > jpegtool_matlab.rar > basisgrid.m
% basisgrid - create matrix of NxN basis elements
%
% SYNOPSIS
% basisgrid
% basisgrid(N)
%
% DESCRIPTION
% The NxN basis matrices in a cosine expansion are returned in a
% matrix (with (N+1)N rows, due to the space between submatrices).
% N defaults to 8.
%
% SEE ALSO
% basis, psumgrid
% Copyright (C) 1995-1997 Darrel Hankerson and Greg A. Harris
%
% This file is part of the JPEGtool collection of scripts for Octave
% and Matlab; see http://www.dms.auburn.edu/compression
%
% The JPEGtool collection is free software; you can redistribute it
% and/or modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2, or
% (at your option) any later version.
%
% The collection is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this package; see the file COPYING. If not, write to the
% Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
% 02111-1307, USA.
function B = basisgrid(N)
if ~exist('N')
N = 8;
end
if N > 16
error('basisgrid: basis size limited to 16');
end
NN = (N+1)*N;
B = zeros(NN + 1)-1;
B(2:NN, 2:NN) = ones(NN - 1)*1.1;
for v=1:N
y=(v-1)*(N+1)+2;
rows=y:y+(N-1);
for u=1:N
x = (u-1)*(N+1) + 2;
B(rows, x:x+N-1) = basis(v,u,N);
end
end