Fawkes API Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * opening.cpp - implementation of morphological opening filter 00004 * 00005 * Created: Mon Jun 05 14:00:46 2006 00006 * Copyright 2005-2007 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #include <filters/morphology/opening.h> 00025 00026 #include <filters/morphology/dilation.h> 00027 #include <filters/morphology/erosion.h> 00028 00029 #include <cstddef> 00030 00031 namespace firevision { 00032 #if 0 /* just to make Emacs auto-indent happy */ 00033 } 00034 #endif 00035 00036 /** @class FilterOpening <filters/morphology/opening.h> 00037 * Morphological opening. 00038 * 00039 * @author Tim Niemueller 00040 */ 00041 00042 00043 /** Constructor. */ 00044 FilterOpening::FilterOpening() 00045 : MorphologicalFilter("Morphological Opening") 00046 { 00047 dilate = new FilterDilation(); 00048 erode = new FilterErosion(); 00049 } 00050 00051 00052 /** Destructor. */ 00053 FilterOpening::~FilterOpening() 00054 { 00055 delete dilate; 00056 delete erode; 00057 } 00058 00059 00060 void 00061 FilterOpening::set_src_buffer(unsigned char *buf, ROI *roi, 00062 orientation_t ori, unsigned int buffer_num) 00063 { 00064 Filter::set_src_buffer(buf, roi, ori, buffer_num); 00065 erode->set_src_buffer( buf, roi, ori, buffer_num ); 00066 } 00067 00068 00069 void 00070 FilterOpening::set_src_buffer(unsigned char *buf, ROI *roi, unsigned int buffer_num) 00071 { 00072 Filter::set_src_buffer(buf, roi, buffer_num); 00073 erode->set_src_buffer( buf, roi, buffer_num ); 00074 } 00075 00076 00077 void 00078 FilterOpening::set_dst_buffer(unsigned char *buf, ROI *roi) 00079 { 00080 Filter::set_dst_buffer(buf, roi); 00081 erode->set_dst_buffer( buf, roi ); 00082 dilate->set_src_buffer( buf, roi ); 00083 } 00084 00085 00086 void 00087 FilterOpening::set_structuring_element(unsigned char *se, 00088 unsigned int se_width, unsigned int se_height, 00089 unsigned int se_anchor_x, unsigned int se_anchor_y) 00090 { 00091 MorphologicalFilter::set_structuring_element(se, se_width, se_height, se_anchor_x, se_anchor_y); 00092 dilate->set_structuring_element(se, se_width, se_height, se_anchor_x, se_anchor_y); 00093 erode->set_structuring_element(se, se_width, se_height, se_anchor_x, se_anchor_y); 00094 } 00095 00096 00097 void 00098 FilterOpening::apply() 00099 { 00100 erode->apply(); 00101 dilate->apply(); 00102 } 00103 00104 } // end namespace firevision