Foveator.C

Go to the documentation of this file.
00001 /*!@file Foveator/Foveator.C An abstract class for space-variant image processing */
00002 
00003 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Foveator/Foveator.C $
00004 // $Id: Foveator.C 9412 2008-03-10 23:10:15Z farhan $
00005 
00006 #include "Foveator/Foveator.H"
00007 
00008 #include "Image/Pixels.H"
00009 #include "Util/log.H"
00010 
00011 // ######################################################################
00012 
00013 // constructor
00014 Foveator::Foveator( const Image< PixRGB< byte > >& img ) :
00015   original( img ),
00016   width( img.getWidth() ), height( img.getHeight() ),
00017   origin( width/2, height/2 )
00018 {
00019 }
00020 
00021 // destructor
00022 Foveator::~Foveator()
00023 {
00024 }
00025 
00026 // ######################################################################
00027 
00028 // get coordinates of origin
00029 Point2D<int> Foveator::getOrigin( void ) const
00030 {
00031   return origin;
00032 }
00033 
00034 // get width
00035 int Foveator::getWidth( void ) const
00036 {
00037   return width;
00038 }
00039 
00040 // get height
00041 int Foveator::getHeight( void ) const
00042 {
00043   return height;
00044 }
00045 
00046 // ######################################################################
00047 
00048 // change the image to be foveated
00049 void Foveator::changeImage( const Image< PixRGB< byte > >& img )
00050 {
00051   if( width == img.getWidth() && height == img.getHeight() )
00052     {
00053       original = img;
00054     }
00055   else
00056     {
00057       LERROR( "New image must have same dimensions as original." );
00058       LERROR( "Image has not been changed." );
00059     }
00060 }
00061 
00062 // ######################################################################
00063 
00064 // set origin to Point2D<int>
00065 bool Foveator::setOrigin( Point2D<int> pt )
00066 {
00067   if( original.coordsOk( pt ) )
00068     {
00069       origin = pt;
00070       return true;
00071     }
00072   else
00073     {
00074       LERROR( "Center of foveation needs to be inside image bounds." );
00075       return false;
00076     }
00077 }
00078 
00079 // set origin to integer coordinates
00080 bool Foveator::setOrigin( int x, int y )
00081 {
00082   if( original.coordsOk( x, y ) )
00083     {
00084       origin.i = x;
00085       origin.j = y;
00086       return true;
00087     }
00088   else
00089     {
00090       LERROR( "Center of foveation needs to be inside image bounds." );
00091       return false;
00092     }
00093 }
00094 
00095 // ######################################################################
00096 /* So things look consistent in everyone's emacs... */
00097 /* Local Variables: */
00098 /* indent-tabs-mode: nil */
00099 /* End: */
Generated on Sun May 8 08:04:47 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3