vbl_local_minima.h
Go to the documentation of this file.
1 // This is core/vbl/vbl_local_minima.h
2 #ifndef vbl_local_minima_h_
3 #define vbl_local_minima_h_
4 //:
5 // \file
6 // \brief Find local minima in arrays
7 // \author J.L. Mundy
8 // October 2, 2010
9 // \verbatim
10 // Modifications
11 // <None>
12 // \endverbatim
13 
14 #include <vbl/vbl_array_1d.h>
15 #include <vbl/vbl_array_2d.h>
16 #include <vbl/vbl_array_3d.h>
17 
18 //: Find the local minima in arrays
19 // The result is an array with non-zero elements where local minima
20 // exist. A local minimum must be smaller than \e all neighboring elements
21 // by a threshold.
22 // The result is an array with non-zero elements at minima.
23 // The value of non-zero element indicates the smallest difference
24 // between the minima and the neighboring elements.
25 template <class T>
27 {
28  vbl_array_1d<T> m(in.size(), T(0));
29  if (local_minima(in, m, thresh)) return m;
30  else return vbl_array_1d<T>();
31 }
32 
33 //: Find the local minima in arrays
34 // The result is an array with non-zero elements where local minima
35 // exist. A local minimum must be smaller than \e all neighboring elements
36 // by a threshold. The neighborhoods are 4-connected.
37 // The result is an array with non-zero elements at minima.
38 // The value of non-zero element indicates the smallest difference
39 // between the minima and the neighboring elements.
40 template <class T>
42 {
43  vbl_array_2d<T> m(in.rows(), in.cols(), T(0));
44  if (local_minima(in, m, thresh)) return m;
45  else return vbl_array_2d<T>();
46 }
47 
48 //: Find the local minima in arrays
49 // The result is an array with non-zero elements where local minima
50 // exist. A local minimum must be smaller than \e all neighboring elements
51 // by a threshold. The neighborhoods are 8-connected.
52 // The result is an array with non-zero elements at minima.
53 // The value of non-zero element indicates the smallest difference
54 // between the minima and the neighboring elements.
55 template <class T>
57 {
58  vbl_array_3d<T> m=in;
59  if (local_minima(in, m, thresh)) return m;
60  else return vbl_array_3d<T>();
61 }
62 
63 
64 //: DEPRECATED
65 // \deprecated in favour of vbl_local_minima
66 template <class T>
67 bool local_minima(vbl_array_1d<T> const& in, vbl_array_1d<T>& minima,
68  T thresh = T(0));
69 
70 //: DEPRECATED
71 // \deprecated in favour of vbl_local_minima
72 template <class T>
73 bool local_minima(vbl_array_2d<T> const& in, vbl_array_2d<T>& minima,
74  T thresh = T(0));
75 
76 //: DEPRECATED
77 // \deprecated in favour of vbl_local_minima
78 template <class T>
79 bool local_minima(vbl_array_3d<T> const& in, vbl_array_3d<T>& minima,
80  T thresh = T(0));
81 
82 #endif // vbl_local_minima_h_
simple 2D array.
Definition: vbl_array_2d.h:25
size_type size() const
Definition: vbl_array_1d.h:148
A simple container.
Definition: vbl_array_1d.h:28
size_type rows() const
Return number of rows.
Definition: vbl_array_2d.h:122
size_type cols() const
Return number of columns.
Definition: vbl_array_2d.h:125
Contains class for templated 3d array.
Templated 3-dimensional array.
Definition: vbl_array_3d.h:38
A simple container.
vbl_array_1d< T > vbl_local_minima(vbl_array_1d< T > const &in, T thresh=T(0))
Find the local minima in arrays.
bool local_minima(vbl_array_1d< T > const &in, vbl_array_1d< T > &minima, T thresh=T(0))
DEPRECATED.
Contains class for a templated 2d array.