iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CutPaste.H
Go to the documentation of this file.
1 /*! @file
2  @author Laurent Itti
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 #ifndef INCLUDE_NRT_IMAGEPROC_DRAWING_CUTPASTE_H
36 #define INCLUDE_NRT_IMAGEPROC_DRAWING_CUTPASTE_H
37 
38 #include <nrt/Core/Image/Image.H>
44 
45 #include <nrt/Eigen/Eigen.H>
46 #include <Eigen/Geometry>
47 
48 namespace nrt
49 {
50 
51  /*! @defgroup cutpaste Cut/Paste Operations
52  Methods used for cutting and pasting Images
53 
54  \ingroup imagedrawing
55  \see imagedrawing
56  \see image */
57 
58  /*! @{ */ // **********************************************************************
59 
60  //! Paste a source Image into the destination at the given position
61  /*! Only the overlapping portions of the source Image will actually be copied into the destination. */
62  template <class PixType>
63  void paste(Image<PixType> & destination, Image<PixType> const source, Point2D<int32> const & pos);
64 
65  //! Horizontally concatenate two Images
66  /*! The resulting Image will have height equal to the larger of the left and right Images' heights. */
67  template <class PixType>
68  Image<PixType> const concatX(Image<PixType> const left, Image<PixType> const right,
69  PixType const bgColor = PixType(0));
70 
71  //! Vertically concatenate two Images
72  /*! The resulting Image will have width equal to the larger of the top and bottom Images' widths. */
73  template <class PixType>
74  Image<PixType> const concatY(Image<PixType> const top, Image<PixType> const bottom,
75  PixType const bgColor = PixType(0));
76 
77  //! Extract a sub-image from the source Image
78  /*! The resulting Image will have a size of the intersection between the requested Rectangle and the source Image. */
79  template <class PixType>
80  Image<PixType> const crop(Image<PixType> const source, Rectangle<int32> const & rect);
81 
82  //! Extract a sub-ImageSet from the source ImageSet
83  template <class PixType>
84  ImageSet<PixType> const crop(ImageSet<PixType> const source, Rectangle<int32> const & rect);
85 
86  //! Extract a sub-image from the source Image, GenericImage version
87  GenericImage const crop(GenericImage const source, Rectangle<int32> const & rect);
88 
89  //! Extract a subImage from the source Image
90  /*! Any portion of the Rectangle that lies outside of the source Image will be filled with bgColor in the crop. */
91  template <class PixType>
92  Image<PixType> const cropAndFill(Image<PixType> const source, Rectangle<int32> const & rect,
93  PixType const bgColor = PixType(0));
94 
95  //! Extract a subImage from the source Image, GenericImage version
96  /*! Because the image is generic, we don't know what its pixel type is, which is a problem for specifying the
97  bgColor. Here we just specity it as PixRGB<float> which will then be converted to whatever the actual
98  GenericImage's content PixType is. */
99  GenericImage const cropAndFill(GenericImage const source, Rectangle<int32> const & rect,
100  PixRGB<float> const bgColor = PixRGB<float>(0.0F));
101 
102  //! Extract a warped sub-image from the source Image using the provided warping matrix
103  /*! The resulting Image will have a size of the intersection between the requested Rectangle and the source
104  Image. Pixels falling outside the source image will be filled-in with value bgColor. */
105  template <class PixType>
106  Image<PixType> const warpedCrop(Image<PixType> const source, Rectangle<int32> const & rect,
107  Eigen::AffineCompact2f const & m, PixType const bgColor = PixType(0));
108 
109  /*! @} */ // **********************************************************************
110 
112 }
113 
114 // Include implementation details
116 
117 #endif // INCLUDE_NRT_IMAGEPROC_DRAWING_CUTPASTE_H