1 | % LOCALMAX Find local maximizers |
---|
2 | % SEL=LOCALMAX(F) returns the indexes of the local maximizers of |
---|
3 | % the Q-dimensional array F. |
---|
4 | % |
---|
5 | % A local maximizer is an element whose value is greater than the |
---|
6 | % value of all its neighbors. The neighbors of an element i1...iQ |
---|
7 | % have subscripts j1...jQ such that iq-1 <= jq <= iq (excluding |
---|
8 | % i1...iQ itself). For example, if Q=1 the neighbors of an element |
---|
9 | % are its predecessor and successor in the linear order; if Q=2, its |
---|
10 | % neighbors are the elements immediately to its north, south, west, |
---|
11 | % est, north-west, north-est, south-west and south-est |
---|
12 | % (8-neighborhood). |
---|
13 | % |
---|
14 | % Points on the boundary of F are ignored (and never selected as |
---|
15 | % local maximizers). |
---|
16 | % |
---|
17 | % SEL=LOCALMAX(F,THRESH) accepts an element as a mazimizer only if |
---|
18 | % it is not smaller thatn THRES. |
---|
19 | % |
---|
20 | % SEL=LOCALMAX(F,THRESH,P) looks for neighbors only in the first P |
---|
21 | % dimensions of the Q-dimensional array F. This allows to process F |
---|
22 | % in ``slices''. |
---|
23 | % |
---|
24 | % REMARK. Matrices (2-array) with a singleton dimension are |
---|
25 | % interpreted as vectors (1-array). So for example LOCALMAX([0 1 0]) |
---|
26 | % and LOCALMAX([0 1 0]') both return 2 as an aswer. However, if [0 1 |
---|
27 | % 0] is to be interpreted as a 1x2 matrix, then the correct answer |
---|
28 | % is the empty set, as all elements are on the boundary. |
---|
29 | % Unfortunately MATLAB does not distinguish between vectors and |
---|
30 | % 2-matrices with a singleton dimension. To forece the |
---|
31 | % interpretation of all matrices as 2-arrays, use |
---|
32 | % LOCALMAX(F,TRESH,2) (but note that in this case the result is |
---|
33 | % always empty!). |
---|
34 | |
---|
35 | % AUTORIGHTS |
---|
36 | % Copyright (C) 2006 Andrea Vedaldi |
---|
37 | % |
---|
38 | % This file is part of VLUtil. |
---|
39 | % |
---|
40 | % VLUtil is free software; you can redistribute it and/or modify |
---|
41 | % it under the terms of the GNU General Public License as published by |
---|
42 | % the Free Software Foundation; either version 2, or (at your option) |
---|
43 | % any later version. |
---|
44 | % |
---|
45 | % This program is distributed in the hope that it will be useful, |
---|
46 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
47 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
48 | % GNU General Public License for more details. |
---|
49 | % |
---|
50 | % You should have received a copy of the GNU General Public License |
---|
51 | % along with this program; if not, write to the Free Software Foundation, |
---|
52 | % Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
53 | |
---|
54 | % TODO: Companion REFINELOCALMAX |
---|
55 | % TODO: Do something smarter at boundaries |
---|
56 | |
---|