/
compute_quadsel.m
66 lines (63 loc) · 1.77 KB
/
compute_quadsel.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
function [selx,sely] = compute_quadsel(j,q, options)
% compute_quadsel - compute the indices for selecting subband of a wavelet transform.
%
% [selx,sely] = compute_quadrant_selection(j,q, options);
%
% q=1 is for phi/psi (on X / on Y)
% q=2 is for psi/phi (on X / on Y)
% q=3 is for psi/psi (on X / on Y)
%
% % Suppose that MW contains a wavelet transform
% j = 4; q = 2;
% [selx,sely] = compute_quadrant_selection(j,q);
% MWs = MW(selx,sely); % MWs contains the quadrant.
%
% Depending on the transform you are using, you should
% set options.transform to
% 'isotropic2d' (default): 2D standard wavelet basis.
% 'quincunx': for quincunx transform (perform_quincunx_wavelet_transform).
%
%
% Copyright (c) 2004 Gabriel Peyre
options.null = 0;
if isfield(options, 'transform')
transform = options.transform;
else
transform = 'isotropic2d';
end
switch lower(transform)
case 'isotropic2d'
if q<0 || q>3
error('Quadrant number is in {0,1,2,3}.');
end
if q==0
selx = 1:2^j;
sely = 1:2^j;
elseif q==1 % 1st quadrant
selx = 1:2^j;
sely = (2^j+1):2^(j+1);
elseif q==2
selx = (2^j+1):2^(j+1);
sely = 1:2^j;
elseif q==3
selx = (2^j+1):2^(j+1);
sely = (2^j+1):2^(j+1);
else
selx = []; sely = [];
end
case 'quincunx'
if q==0
selx = 1:2^j;
sely = 1:2^j;
elseif q==1
selx = 1:2^(j+1);
sely = 2^j+1:2^(j+1);
elseif q==2
selx = 2^j+1:2^(j+1);
sely = 1:2^j;
else
selx = []; sely = [];
end
otherwise
error('Unknown transform.');
end