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