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

scale_Filter.cpp

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------
00002     Phission :
00003         Realtime Vision Processing System
00004 
00005     Copyright (C) 2003-2006 Philip D.S. Thoren (pthoren@cs.uml.edu)
00006     University of Massachusetts at Lowell,
00007     Laboratory for Artificial Intelligence and Robotics
00008 
00009  ---------------------------------------------------------------------------
00010     <Add other copyrights here> 
00011  ---------------------------------------------------------------------------
00012 
00013     This file is part of Phission.
00014 
00015     Phission is free software; you can redistribute it and/or modify
00016     it under the terms of the GNU Lesser General Public License as published by
00017     the Free Software Foundation; either version 2 of the License, or
00018     (at your option) any later version.
00019 
00020     Phission is distributed in the hope that it will be useful,
00021     but WITHOUT ANY WARRANTY; without even the implied warranty of
00022     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023     GNU Lesser General Public License for more details.
00024 
00025     You should have received a copy of the GNU Lesser General Public License
00026     along with Phission; if not, write to the Free Software
00027     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028 
00029  ---------------------------------------------------------------------------*/
00030 #ifdef HAVE_CONFIG_H
00031     #include <phissionconfig.h>
00032 #endif
00033 
00034 #include <phStandard.h>
00035 
00036 #include <scale_Filter.h>
00037 
00038 #include <phError.h>
00039 #include <phMemory.h>
00040 #include <phPrint.h>
00041 
00042 /* ------------------------------------------------------------------------ */
00043 /*
00044   
00045  */
00046 /* ---------------------------------------------------------------------- */
00047 scale_Filter::scale_Filter(float r, float g, float b) :
00048     phFilter("scale_Filter")
00049 
00050 {
00051     this->m_format = phImageRGB24;
00052     set(r,g,b);
00053 }
00054 
00055 /* ---------------------------------------------------------------------- */
00056 scale_Filter::~scale_Filter()
00057 {
00058 }
00059 
00060 /* ------------------------------------------------------------------------ */
00061 phFilter *scale_Filter::cloneFilter()
00062 {
00063     return (phFilter *)new scale_Filter(this->m_r,this->m_g,this->m_b);
00064 }
00065 
00066 /* ---------------------------------------------------------------------- */
00067 int scale_Filter::set(float r, float g, float b)
00068 {
00069     this->m_r = r;
00070     this->m_g = g;
00071     this->m_b = b;
00072 
00073     return phSUCCESS;
00074 }
00075 
00076 /* ---------------------------------------------------------------------- */
00077 #define SCALE(x,f) { x = (int)(phMIN(phMAX(f * x,0),255)); }
00078 int scale_Filter::filter() 
00079 {
00080     phFUNCTION("scale_Filter::filter")
00081     
00082     unsigned int h = 0;
00083     unsigned int w = 0;
00084     
00085     unsigned int pixel = 0;
00086     unsigned int row = 0;
00087     
00088     /* Begin filter */
00089     for (h = 0; h < height; h++) 
00090     {
00091         row = h * width;
00092         for (w = 0; w < width; w++) 
00093         {
00094             pixel = (row + w) * depth;
00095             SCALE((Image)[pixel + phCHANNEL_RED],this->m_r);
00096             SCALE((Image)[pixel + phCHANNEL_GREEN],this->m_g);
00097             SCALE((Image)[pixel + phCHANNEL_BLUE],this->m_b);
00098         }
00099     }
00100 
00101     return phSUCCESS;
00102 }
00103 




Copyright (C) 2002 - 2007 Philip D.S. Thoren ( pthoren@users.sourceforge.net )
University Of Massachusetts at Lowell
Robotics Lab
SourceForge.net Logo

Generated on Sat Jun 16 02:44:11 2007 for phission by  doxygen 1.4.4