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 /** @class FilterClosing <filters/morphology/closing.h>
00032  * Morphological closing.
00033  *
00034  * @author Tim Niemueller
00035  */
00036
00037 
00038 /** Constructor. */
00039 FilterClosing::FilterClosing()
00040   : MorphologicalFilter("Morphological Closing")
00041 {
00042   dilate = new FilterDilation();
00043   erode  = new FilterErosion();
00044 }
00045
00046 
00047 /** Destructor. */
00048 FilterClosing::~FilterClosing()
00049 {
00050   delete dilate;
00051   delete erode;
00052 }
00053
00054
00055
00056 void
00057 FilterClosing::set_src_buffer(unsigned char *buf, ROI *roi,
00058                               orientation_t ori, unsigned int buffer_num)
00059 {
00060   Filter::set_src_buffer(buf, roi, ori, buffer_num);
00061   dilate->set_src_buffer( buf, roi, ori, buffer_num );
00062 }
00063
00064
00065 void
00066 FilterClosing::set_src_buffer(unsigned char *buf, ROI *roi, unsigned int buffer_num)
00067 {
00068   Filter::set_src_buffer(buf, roi, buffer_num);
00069   dilate->set_src_buffer( buf, roi, buffer_num );
00070 }
00071
00072
00073 void
00074 FilterClosing::set_dst_buffer(unsigned char *buf, ROI *roi)
00075 {
00076   Filter::set_dst_buffer(buf, roi);
00077   dilate->set_dst_buffer( buf, roi );
00078   erode->set_src_buffer( buf, roi );
00079 }
00080
00081
00082 void
00083 FilterClosing::set_structuring_element(unsigned char *se,
00084                                        unsigned int se_width, unsigned int se_height,
00085                                        unsigned int se_anchor_x, unsigned int se_anchor_y)
00086 {
00087   MorphologicalFilter::set_structuring_element(se, se_width, se_height, se_anchor_x, se_anchor_y);
00088   dilate->set_structuring_element(se, se_width, se_height, se_anchor_x, se_anchor_y);
00089   erode->set_structuring_element(se, se_width, se_height, se_anchor_x, se_anchor_y);
00090 }
00091
00092
00093 void
00094 FilterClosing::apply()
00095 {
00096   dilate->apply();
00097   erode->apply();
00098 }