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 <inverse_Filter.h> 00037 00038 #include <phError.h> 00039 #include <phMemory.h> 00040 #include <phPrint.h> 00041 00042 /* ---------------------------------------------------------------------- */ 00043 /* (int32_t channel) */ 00044 /* ---------------------------------------------------------------------- */ 00045 inverse_Filter::inverse_Filter(int32_t channel) : 00046 phFilter("inverse_Filter") 00047 00048 { 00049 this->m_format = phImagePackedFormatMask; 00050 this->set(channel); 00051 } 00052 00053 /* ---------------------------------------------------------------------- */ 00054 inverse_Filter::~inverse_Filter() 00055 { 00056 } 00057 00058 /* ------------------------------------------------------------------------ */ 00059 phFilter *inverse_Filter::cloneFilter() 00060 { 00061 return (phFilter *)new inverse_Filter(this->m_channel); 00062 } 00063 00064 /* ---------------------------------------------------------------------- */ 00065 int inverse_Filter::set(int32_t channel) 00066 { 00067 this->m_channel = channel; 00068 00069 return phSUCCESS; 00070 } 00071 00072 /* ---------------------------------------------------------------------- */ 00073 int inverse_Filter::filter() 00074 { 00075 phFUNCTION("inverse_Filter::filter") 00076 00077 unsigned int i = 0; 00078 unsigned int x = 0; 00079 unsigned int y = 0; 00080 unsigned int row = 0; 00081 unsigned int pixel = 0; 00082 00083 /* Begin filter */ 00084 00085 for (y = 0; y < height; y++) 00086 { 00087 row = y*width; 00088 00089 for(x = 0; x < width; x++) 00090 { 00091 if ((this->m_channel < 0) || (this->m_channel > (int)depth)) 00092 { 00093 for (i = 0; i < depth; i++) 00094 { 00095 pixel = (x + row) * depth + i; 00096 (Image)[pixel] = 255 - (Image)[pixel]; 00097 } 00098 } 00099 else 00100 { 00101 pixel = (x + row) * depth + this->m_channel; 00102 (Image)[pixel] = 255 - (Image)[pixel]; 00103 } 00104 } 00105 } 00106 00107 /* End Filter */ 00108 00109 return phSUCCESS; 00110 } 00111 00112
Copyright (C) 2002 - 2007 |
Philip D.S. Thoren ( pthoren@users.sourceforge.net ) University Of Massachusetts at Lowell Robotics Lab |