iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MiscFilters.H
Go to the documentation of this file.
1 /*! @file
2  @author Randolph Voorhies
3  @copyright GNU Public License (GPL v3)
4  @section License
5  @verbatim
6  // ////////////////////////////////////////////////////////////////////////
7  // The iLab Neuromorphic Robotics Toolkit (NRT) //
8  // Copyright 2010-2012 by the University of Southern California (USC) //
9  // and the iLab at USC. //
10  // //
11  // iLab - University of Southern California //
12  // Hedco Neurociences Building, Room HNB-10 //
13  // Los Angeles, Ca 90089-2520 - USA //
14  // //
15  // See http://ilab.usc.edu for information about this project. //
16  // ////////////////////////////////////////////////////////////////////////
17  // This file is part of The iLab Neuromorphic Robotics Toolkit. //
18  // //
19  // The iLab Neuromorphic Robotics Toolkit is free software: you can //
20  // redistribute it and/or modify it under the terms of the GNU General //
21  // Public License as published by the Free Software Foundation, either //
22  // version 3 of the License, or (at your option) any later version. //
23  // //
24  // The iLab Neuromorphic Robotics Toolkit is distributed in the hope //
25  // that it will be useful, but WITHOUT ANY WARRANTY; without even the //
26  // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
27  // PURPOSE. See the GNU General Public License for more details. //
28  // //
29  // You should have received a copy of the GNU General Public License //
30  // along with The iLab Neuromorphic Robotics Toolkit. If not, see //
31  // <http://www.gnu.org/licenses/>. //
32  // ////////////////////////////////////////////////////////////////////////
33  @endverbatim */
34 
35 
36 #ifndef INCLUDE_NRT_IMAGEPROC_FILTERING_MISCFILTERS_H
37 #define INCLUDE_NRT_IMAGEPROC_FILTERING_MISCFILTERS_H
38 
39 #include <nrt/Core/Image/Image.H>
42 #include <nrt/Core/Typing/Macros.H>
45 
46 namespace nrt
47 {
48  /*! \defgroup imagefiltering Image Filtering
49  Methods for filtering Images in various ways
50 
51  \ingroup imageproc
52  \see image */
53 
54  /*! \defgroup miscfilters Miscellaneous Image Filters
55  Miscellaneous Image filters
56 
57  \ingroup imagefiltering */
58 
59  /*! @{ */ // **********************************************************************
60 
61  //! Compute center-surround difference, returning the absolute value if rectify==true
62  /*! The center-surround difference is computed as by subtracting a low resolution (surround) image from a high
63  resolution (center) image.
64 
65  @param center the image from which center pixels will be taken (fine scale)
66  @param surround the image with the surround pixels (coarse scale)
67  @param rectify If true, the absolute value of the difference is returned (otherwise, negative values are clamped
68  to zero)
69  @returns An Image holding the difference between the center and the surround. Its dims will be the same as
70  center.dims()
71 
72  \note center and surround sizes must be integer multiples. */
73  template <NRT_PROMOTE_PIX(double)>
74  Image<DestType> const
75  centerSurround(Image<PixType> const center, Image<PixType> const surround, bool const rectify = false);
76 
77  //! Oriented filter along theta (deg), spatial freq k
78  /*! This filter works on the difference between the image and itself low-passed. It modulates this difference by a
79  complex sinusoid, and then low-passes the real and imaginary parts, and finally takes the modulus. This method is
80  by Greenspan et al. (1994). CAUTION: *you* must provide as input (i.e., in "this") the difference between an
81  image and itself low-pass filtered. CAUTION: results are possibly bad with the integer versions. Use float.
82 
83  @param src source Image
84  @param k spatial frequency
85  @param theta angle in degrees
86  @param intensity intensity factor
87  @param fastMath Whether to use trig lookup tables internally to get sin and cos values. This may give up to a 2x
88  speedup, at the cost of some minor loss of precision
89 
90  \todo Make the CMake checks to define NRT_HAVE_ASM_FSINCOS and NRT_HAVE_SINCOS
91  \todo Reconsider the parameter name fastMath if SINCOS is comparably fast to the lookups */
92  template <NRT_PROMOTE_PIX(double)>
93  Image<DestType> const
94  orientedFilter(Image<PixType> const src, float const k, float const theta, float const intensity = 1.0,
95  bool const fastMath = false);
96 
97  //! Filter the Image with a 3x3 Sobel edge-detecting filter.
98  /*! \returns A tuple where the first element is a map of the edge magnitudes, and the second element is a map of the
99  edge orientations (in radians)
100 
101  This method will produce the orientation and magnitude of edges at every pixel of the input Image. See
102  http://en.wikipedia.org/wiki/Sobel_operator for details.
103 
104  Example:
105  @code
106  Image<PixRGB<byte>> inputImage = readImage("myImage.jpg").convertTo<PixRGB<byte>>();
107 
108  Image<PixRGB<float>> magnitude, orientation;
109  std::tie(magnitude, orientation) = sobelFilter3(inputImage);
110  @endcode
111 
112  \see sobelFilter5() */
113  template <NRT_PROMOTE_PIX(double)>
114  std::tuple<Image<DestType>, Image<DestType> > const
116 
117  //! Filter the Image with a 5x5 Sobel edge-detecting filter.
118  /*! \see sobelFilter3() */
119  template <NRT_PROMOTE_PIX(double)>
120  std::tuple<Image<DestType>, Image<DestType> > const
122 
123  //! Compute an integral image
124  /*! \note The resulting image from this function has same dims as the original (as opposed to OpenCV's version
125  which adds one to the dims). */
126  template <NRT_PROMOTE_PIX(double)>
127  Image<DestType> const integralImage(Image<PixType> const src);
128 
129  //! Compute an integral squares image
130  /*! \note The resulting image from this function has same dims as the original (as opposed to OpenCV's version
131  which adds one to the dims). */
132  template <NRT_PROMOTE_PIX(double)>
133  Image<DestType> const integralSquaresImage(Image<PixType> const src);
134 
135  //! Apply a 3-point median filter in the x direction
136  /*! \see median3y() median3() */
137  template <class PixType>
138  Image<PixType> median3x(Image<PixType> const & in);
139 
140  //! Apply a 3-point median filter in the y direction
141  /*! \see median3x() median3() */
142  template <class PixType>
143  Image<PixType> median3y(Image<PixType> const & in);
144 
145  //! Apply a 3-point median filter in the x and/or y directions;
146  /*! \see median3x() median3y() */
147  template <class PixType>
148  Image<PixType> median3(Image<PixType> const & in, bool go_x = true, bool go_y = true);
149 
150  /*! @} */ // **********************************************************************
151 
152 } // namespace nrt
153 
154 //! Include implementation details
156 
157 
158 #endif // INCLUDE_NRT_IMAGEPROC_FILTERING_MISCFILTERS_H