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

setPlane_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 <setPlane_Filter.h>
00037 
00038 #include <phError.h>
00039 #include <phMemory.h>
00040 #include <phPrint.h>
00041 
00042 /* ---------------------------------------------------------------------- */
00043 /* ::set the whole color plane to a value */
00044 /* ---------------------------------------------------------------------- */
00045 /*
00046   
00047 (int d, int value)  */
00048 /* ---------------------------------------------------------------------- */
00049 setPlane_Filter::setPlane_Filter(int d, unsigned int value) :
00050     phFilter("setPlane_Filter")
00051 
00052 {
00053     this->m_format = phImageRGB24;
00054     this->set(d,value);
00055 }
00056 
00057 /* ---------------------------------------------------------------------- */
00058 setPlane_Filter::~setPlane_Filter()
00059 {
00060 }
00061 
00062 /* ------------------------------------------------------------------------ */
00063 phFilter *setPlane_Filter::cloneFilter()
00064 {
00065     return (phFilter *)new setPlane_Filter( this->m_d,
00066                                 this->m_value);
00067 }
00068 
00069 /* ---------------------------------------------------------------------- */
00070 int setPlane_Filter::set(int d, unsigned int value)
00071 {
00072     this->m_d = d;
00073     this->m_value = value;
00074 
00075     return phSUCCESS;
00076 }
00077 
00078 /* ---------------------------------------------------------------------- */
00079 int setPlane_Filter::filter()
00080 {
00081     phFUNCTION("setPlane_Filter::filter")
00082     
00083     unsigned int width = 0;
00084     unsigned int height = 0;
00085     int depth = 0;
00086 
00087     unsigned int h = 0;
00088     unsigned int w = 0;
00089     unsigned int row = 0;
00090     
00091     /* Begin filter */
00092     
00093     for ( h = 0; h < height; h++) 
00094     {
00095         row = h * width;
00096         for ( w = 0; w < width; w++) 
00097         {
00098             if ((this->m_d < depth) && (this->m_d > 0))
00099             {
00100                 (Image)[(row + w) * depth + this->m_d] = this->m_value;
00101             }
00102             else if (this->m_d == phCHANNEL_ALL)
00103             {
00104                 phMemset((void *)&((Image)[(row + w) * depth]),
00105                        this->m_value,
00106                        depth * sizeof(uint8_t));
00107             }
00108             else 
00109             {
00110                 phERR_PRINT("this->m_d is set to invalid value. m_d:%u img_d:%u",
00111                         this->m_d,depth);
00112                 goto error;
00113             }
00114         }
00115     }
00116     
00117     return phSUCCESS;
00118 error:
00119     return phFAIL;
00120 }
00121 
00122 




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