1 ## Copyright (C) 2004 Josep Mones i Teixidor
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 2 of the License, or
6 ## (at your option) any later version.
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.
13 ## You should have received a copy of the GNU General Public License
14 ## along with this program; If not, see <http://www.gnu.org/licenses/>.
17 ## @deftypefn {Function File} {@var{J} = } qtsetblk (@var{I},@var{S},@var{dim},@var{vals})
18 ## Set block values in a quadtree decomposition.
20 ## J=qtsetblk(I,S,dim,vals) sets all the @var{dim}-by-@var{dim} blocks
21 ## in the quadtree decomposition (@var{S} returned by qtdecomp) of
22 ## @var{I} to @var{dim}-by-@var{dim} blocks in @var{vals}, which is
23 ## itself a @var{dim}-by-@var{dim}-by-k array. k is the number of
24 ## @var{dim}-by-@var{dim} blocks in the quadtree decomposition.
25 ## @seealso{qtdecomp, qtgetblk}
28 ## Author: Josep Mones i Teixidor <jmones@puntbarra.com>
30 function J = qtsetblk(I, S, dim, vals)
32 usage("J=qtsetblk(I,S,dim,vals)");
38 ## filter the ones which match dim
40 if(size(vals,3)<length(idx)) ## we won't complain if k>num blocks
41 error("qtsetblk: k (vals 3rd dimension) is not equal to number of blocks.");
53 J(ii(b):ie(b),ji(b):je(b))=vals(:,:,b);
59 %! J=qtsetblk(eye(4),qtdecomp(eye(4)),2,ones(2,2,2))
60 %! % Sets upper-right and lower-left blocks of 2*2 zeros to ones
63 %! A=[ 1, 4, 2, 5,54,55,61,62;
64 %! 3, 6, 3, 1,58,53,67,65;
65 %! 3, 6, 3, 1,58,53,67,65;
66 %! 3, 6, 3, 1,58,53,67,65;
67 %! 23,42,42,42,99,99,99,99;
68 %! 27,42,42,42,99,99,99,99;
69 %! 23,22,26,25,99,99,99,99;
70 %! 22,22,24,22,99,99,99,99];
76 %! vals(:,:,1)=reshape([1:16],4,4);
77 %! vals(:,:,2)=reshape([21:36],4,4);
78 %! R(1:4,1:4)=reshape([1:16],4,4);
79 %! R(5:8,5:8)=reshape([21:36],4,4);
80 %! assert(qtsetblk(A,S,4,vals),R);
87 %! assert(qtsetblk(A,S,2,ones(2,2,7)),R);
92 %! assert(qtsetblk(A,S,1,ones(1,1,4)*10),R);
98 % Revision 1.4 2007/03/23 16:14:37 adb014
99 % Update the FSF address
101 % Revision 1.3 2007/01/04 23:50:47 hauberg
102 % Put seealso before end deftypefn
104 % Revision 1.2 2007/01/04 23:41:47 hauberg
105 % Minor changes in help text
107 % Revision 1.1 2006/08/20 12:59:35 hauberg
108 % Changed the structure to match the package system
110 % Revision 1.1 2004/08/11 19:52:41 jmones