The Machine Perception Toolbox

[Introduction]- [News]- [Download]- [Screenshots]- [Manual (pdf)]- [Forums]- [API Reference]- [Repository ]

 

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

MPColorTrackerImage.h

Go to the documentation of this file.
00001 /*
00002  *  ffimage.h
00003  *  
00004  *
00005  *  Created by Ian Fasel 2002.
00006  *  Copyright (c) 2003 Machine Perception Laboratory
00007  *  University of California San Diego.
00008  *  Please read the disclaimer and notes about redistribution
00009  *  at the end of this file.
00010  *
00011  *  Authors: Ian Fasel, Bret Fortenberry
00012  */
00013  *
00014  */
00015 #ifndef _FFIMAGE_H_
00016 #define _FFIMAGE_H_
00017 
00018 #include "common.h"
00019 #include "rimage.h"
00020 #include <iostream>
00021 
00022 template <class T>
00023 class FFImage : public RImage<T> {
00024 public:
00025   // Construct an FFImage from a pixel array
00026   FFImage(T *array_, const int width_, const int height_, const bool flipped)
00027     : RImage<T>(array_, width_, height_), m_flipped(flipped){};
00028   
00029   // A copy constructor specific to the RGBTRIPLE case, used to convert from RGB to grayscale
00030   FFImage<T>(const FFImage<RGBTRIPLE>& source);
00031 
00032   FFImage<T>(const bool flipped = FALSE) : m_flipped(flipped){};
00033   ~FFImage(){;};
00034   
00035   inline T getPixel ( const int x, int y ) const{       
00036         if(m_flipped) y = height-y;
00037         if(x >= 0 && y >= 0 && x < width && y < height)
00038           return array[width * y + x];
00039         else
00040           return 0;
00041   };
00042   
00043   inline void setPixel ( const int x, int y, const T value ){
00044         if(m_flipped) y = height-y;
00045         if(x >= 0 && y >= 0 && x < width && y < height)
00046           array[width * y + x] = value;
00047   };
00048 
00049   inline void setSize(const int width_, const int height_, const bool flipped_){
00050         width = width_;
00051         height = height_;
00052         array = new T[width * height];
00053         m_flipped = flipped_;
00054         my_memory = 1;
00055   }
00056 
00057   inline bool isFlipped() const {return m_flipped;};
00058 private:
00059         bool m_flipped;
00060 };
00061 
00062 #endif
00063 
00064 /*
00065  * 
00066  * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
00067  * 
00068  *    1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
00069  *    2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
00070  *    3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
00071  * 
00072  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00073  * 
00074  */

Generated on Mon Nov 8 17:07:43 2004 for MPT by  doxygen 1.3.9.1