
00001 /*!@file Image/CutPaste.H Cut+paste operations from/to Image subregions */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the // 00005 // University of Southern California (USC) and the iLab at USC. // 00006 // See http://iLab.usc.edu for information about this project. // 00007 // //////////////////////////////////////////////////////////////////// // 00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00010 // in Visual Environments, and Applications'' by Christof Koch and // 00011 // Laurent Itti, California Institute of Technology, 2001 (patent // 00012 // pending; application number 09/912,225 filed July 23, 2001; see // 00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00014 // //////////////////////////////////////////////////////////////////// // 00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00016 // // 00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00018 // redistribute it and/or modify it under the terms of the GNU General // 00019 // Public License as published by the Free Software Foundation; either // 00020 // version 2 of the License, or (at your option) any later version. // 00021 // // 00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00025 // PURPOSE. See the GNU General Public License for more details. // 00026 // // 00027 // You should have received a copy of the GNU General Public License // 00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00030 // Boston, MA 02111-1307 USA. // 00031 // //////////////////////////////////////////////////////////////////// // 00032 // 00033 // Primary maintainer for this file: Rob Peters <rjpeters@klab.caltech.edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Image/CutPaste.H $ 00035 // $Id: CutPaste.H 9757 2008-05-11 21:14:48Z rjpeters $ 00036 // 00037 00038 #ifndef IMAGE_CUTPASTE_H_DEFINED 00039 #define IMAGE_CUTPASTE_H_DEFINED 00040 00041 class Dims; 00042 template <class T> class Point2D; 00043 class Rectangle; 00044 template <class T> class Image; 00045 00046 //! Horizontally concatenate two arrays of same height 00047 template <class T_or_RGB> 00048 Image<T_or_RGB> concatX(const Image<T_or_RGB>& left, 00049 const Image<T_or_RGB>& right); 00050 00051 //! Vertically concatenate two arrays of same width 00052 template <class T_or_RGB> 00053 Image<T_or_RGB> concatY(const Image<T_or_RGB>& top, 00054 const Image<T_or_RGB>& bottom); 00055 00056 //! Vertically concatenate topImg and bottomImg 00057 /*! Like concatY(), but doesn't require the two images to have the 00058 same width. */ 00059 template <class T_or_RGB> 00060 Image<T_or_RGB> concatLooseY(const Image<T_or_RGB>& topImg, 00061 const Image<T_or_RGB>& bottomImg, 00062 const T_or_RGB& bgColor = T_or_RGB()); 00063 00064 //! Horizontally concatenate leftImg and rightImg 00065 /*! Like concatX(), but doesn't require the two images to have the 00066 same height. */ 00067 template <class T_or_RGB> 00068 Image<T_or_RGB> concatLooseX(const Image<T_or_RGB>& leftImg, 00069 const Image<T_or_RGB>& rightImg, 00070 const T_or_RGB& bgColor = T_or_RGB()); 00071 00072 //! Extract a subimage from the input image. 00073 /*! The upper left corner of the subimage is given by a Point2D<int>, and the 00074 size of the subimage is given by the Dims. If zerofill is false, then 00075 the rectangle given by Point2D<int>+Dims must be wholly contained within the 00076 bounds of the input image. If zerofill is true, then any output region 00077 that lies outside the bounds of the input will be zero-filled (where 00078 zero means the default value for type T). */ 00079 template <class T_or_RGB> 00080 Image<T_or_RGB> crop(const Image<T_or_RGB>& src, 00081 const Point2D<int>& upperLeft, const Dims& size, 00082 const bool zerofill = false); 00083 00084 //! Overload of crop() using a Rectangle instead of a Point2D<int>+Dims. 00085 template <class T_or_RGB> 00086 Image<T_or_RGB> crop(const Image<T_or_RGB>& src, 00087 const Rectangle& rect, const bool zerofill = false); 00088 00089 //! Shift an image by (int dx, int dy), with horizontal wraparound 00090 template <class T_or_RGB> 00091 Image<T_or_RGB> shift(const Image<T_or_RGB>& srcImg, 00092 const int dx, const int dy); 00093 00094 //! Shift an image by (float dx, float dy) 00095 template <class T_or_RGB> 00096 Image<T_or_RGB> shiftImage(const Image<T_or_RGB>& srcImg, 00097 const float dx, const float dy); 00098 00099 //! Shift an image by (int dx, int dy), without wraparound 00100 template <class T_or_RGB> 00101 Image<T_or_RGB> shiftClean(const Image<T_or_RGB>& srcImg, 00102 const int dx, const int dy, 00103 const T_or_RGB bgval = T_or_RGB()); 00104 00105 //! Paste image into dst at given position 00106 /*! Image must fit within dst and no resizing/interpolation is done. 00107 See embed() for a more sophisticated version with interpolation 00108 and resizing. */ 00109 template <class T_or_RGB> 00110 void inplacePaste(Image<T_or_RGB>& dst, 00111 const Image<T_or_RGB>& img, const Point2D<int>& pos); 00112 00113 //! Set all pixels within a given region to the specified value 00114 /*! Does nothing if the rectangle is invalid. */ 00115 template <class T_or_RGB> 00116 void inplaceClearRegion(Image<T_or_RGB>& dst, 00117 const Rectangle& region, const T_or_RGB& val); 00118 00119 //! Embed image into dst with position & size given in rectangle 00120 template <class T_or_RGB> 00121 void inplaceEmbed(Image<T_or_RGB>& embed, 00122 const Image<T_or_RGB>& img, const Rectangle& r, 00123 const T_or_RGB background, 00124 const bool keep_aspect = true); 00125 00126 //! Find the smallest bounding rectangle around pixels greater than the threshold 00127 template <class T> 00128 Rectangle findBoundingRect(const Image<T>& src, const T threshold); 00129 00130 #endif // !IMAGE_CUTPASTE_H_DEFINED 00131 00132 // ###################################################################### 00133 /* So things look consistent in everyone's emacs... */ 00134 /* Local Variables: */ 00135 /* indent-tabs-mode: nil */ 00136 /* End: */
1.4.4