closing.cpp

00001 
00002 /***************************************************************************
00003  *  closing.cpp - implementation of morphological closing filter
00004  *
00005  *  Created: Mon Jun 05 14:01:15 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/closing.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 FilterClosing <filters/morphology/closing.h>
00037  * Morphological closing.
00038  *
00039  * @author Tim Niemueller
00040  */
00041 
00042 
00043 /** Constructor. */
00044 FilterClosing::FilterClosing()
00045   : MorphologicalFilter("Morphological Closing")
00046 {
00047   dilate = new FilterDilation();
00048   erode  = new FilterErosion();
00049 }
00050 
00051 
00052 /** Destructor. */
00053 FilterClosing::~FilterClosing()
00054 {
00055   delete dilate;
00056   delete erode;
00057 }
00058 
00059 
00060 
00061 void
00062 FilterClosing::set_src_buffer(unsigned char *buf, ROI *roi,
00063                               orientation_t ori, unsigned int buffer_num)
00064 {
00065   Filter::set_src_buffer(buf, roi, ori, buffer_num);
00066   dilate->set_src_buffer( buf, roi, ori, buffer_num );
00067 }
00068 
00069 
00070 void
00071 FilterClosing::set_src_buffer(unsigned char *buf, ROI *roi, unsigned int buffer_num)
00072 {
00073   Filter::set_src_buffer(buf, roi, buffer_num);
00074   dilate->set_src_buffer( buf, roi, buffer_num );
00075 }
00076 
00077 
00078 void
00079 FilterClosing::set_dst_buffer(unsigned char *buf, ROI *roi)
00080 {
00081   Filter::set_dst_buffer(buf, roi);
00082   dilate->set_dst_buffer( buf, roi );
00083   erode->set_src_buffer( buf, roi );
00084 }
00085 
00086 
00087 void
00088 FilterClosing::set_structuring_element(unsigned char *se,
00089                                        unsigned int se_width, unsigned int se_height,
00090                                        unsigned int se_anchor_x, unsigned int se_anchor_y)
00091 {
00092   MorphologicalFilter::set_structuring_element(se, se_width, se_height, se_anchor_x, se_anchor_y);
00093   dilate->set_structuring_element(se, se_width, se_height, se_anchor_x, se_anchor_y);
00094   erode->set_structuring_element(se, se_width, se_height, se_anchor_x, se_anchor_y);
00095 }
00096 
00097 
00098 void
00099 FilterClosing::apply()
00100 {
00101   dilate->apply();
00102   erode->apply();
00103 }
00104 
00105 } // end namespace firevision

Generated on 1 Mar 2011 for Fawkes API by  doxygen 1.6.1