Fawkes API  Fawkes Development Version
closing.cpp
1 
2 /***************************************************************************
3  * closing.cpp - implementation of morphological closing filter
4  *
5  * Created: Mon Jun 05 14:01:15 2006
6  * Copyright 2005-2007 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #include <fvfilters/morphology/closing.h>
25 #include <fvfilters/morphology/dilation.h>
26 #include <fvfilters/morphology/erosion.h>
27 
28 #include <cstddef>
29 
30 namespace firevision {
31 
32 /** @class FilterClosing <fvfilters/morphology/closing.h>
33  * Morphological closing.
34  *
35  * @author Tim Niemueller
36  */
37 
38 /** Constructor. */
39 FilterClosing::FilterClosing() : MorphologicalFilter("Morphological Closing")
40 {
41  dilate = new FilterDilation();
42  erode = new FilterErosion();
43 }
44 
45 /** Destructor. */
47 {
48  delete dilate;
49  delete erode;
50 }
51 
52 void
53 FilterClosing::set_src_buffer(unsigned char *buf,
54  ROI * roi,
55  orientation_t ori,
56  unsigned int buffer_num)
57 {
58  Filter::set_src_buffer(buf, roi, ori, buffer_num);
59  dilate->set_src_buffer(buf, roi, ori, buffer_num);
60 }
61 
62 void
63 FilterClosing::set_src_buffer(unsigned char *buf, ROI *roi, unsigned int buffer_num)
64 {
65  Filter::set_src_buffer(buf, roi, buffer_num);
66  dilate->set_src_buffer(buf, roi, buffer_num);
67 }
68 
69 void
70 FilterClosing::set_dst_buffer(unsigned char *buf, ROI *roi)
71 {
72  Filter::set_dst_buffer(buf, roi);
73  dilate->set_dst_buffer(buf, roi);
74  erode->set_src_buffer(buf, roi);
75 }
76 
77 void
79  unsigned int se_width,
80  unsigned int se_height,
81  unsigned int se_anchor_x,
82  unsigned int se_anchor_y)
83 {
87 }
88 
89 void
91 {
92  dilate->apply();
93  erode->apply();
94 }
95 
96 } // end namespace firevision
firevision::MorphologicalFilter::se_width
unsigned int se_width
Width of structuring element.
Definition: morphologicalfilter.h:59
firevision::MorphologicalFilter::se_height
unsigned int se_height
Height of structuring element.
Definition: morphologicalfilter.h:61
firevision::Filter::set_src_buffer
virtual void set_src_buffer(unsigned char *buf, ROI *roi, orientation_t ori=ORI_HORIZONTAL, unsigned int buffer_num=0)
Set source buffer with orientation.
Definition: filter.cpp:89
firevision::FilterClosing::set_dst_buffer
virtual void set_dst_buffer(unsigned char *buf, ROI *roi)
Set the destination buffer.
Definition: closing.cpp:76
firevision::MorphologicalFilter::se_anchor_y
unsigned int se_anchor_y
Anchor point y offset of structuring element.
Definition: morphologicalfilter.h:65
firevision::FilterDilation::apply
virtual void apply()
Definition: dilation.cpp:84
firevision::FilterClosing::FilterClosing
FilterClosing()
Constructor.
Definition: closing.cpp:45
firevision::ROI
Definition: roi.h:60
firevision::Filter::ori
orientation_t * ori
Orientations, one for each source image.
Definition: filter.h:83
firevision::MorphologicalFilter::set_structuring_element
virtual void set_structuring_element(unsigned char *se, unsigned int se_width, unsigned int se_height, unsigned int se_anchor_x, unsigned int se_anchor_y)
Set the structuring element for successive filter runs.
Definition: morphologicalfilter.cpp:67
firevision::Filter::set_dst_buffer
virtual void set_dst_buffer(unsigned char *buf, ROI *roi)
Set the destination buffer.
Definition: filter.cpp:123
firevision::FilterClosing::set_src_buffer
virtual void set_src_buffer(unsigned char *buf, ROI *roi, orientation_t ori=ORI_HORIZONTAL, unsigned int buffer_num=0)
Set source buffer with orientation.
Definition: closing.cpp:59
firevision::FilterClosing::set_structuring_element
virtual void set_structuring_element(unsigned char *se, unsigned int se_width, unsigned int se_height, unsigned int se_anchor_x, unsigned int se_anchor_y)
Set the structuring element for successive filter runs.
Definition: closing.cpp:84
firevision::MorphologicalFilter::se_anchor_x
unsigned int se_anchor_x
Anchor point x offset of structuring element.
Definition: morphologicalfilter.h:63
firevision::MorphologicalFilter::se
unsigned char * se
Structuring element.
Definition: morphologicalfilter.h:57
firevision::FilterClosing::~FilterClosing
virtual ~FilterClosing()
Destructor.
Definition: closing.cpp:52
firevision::FilterErosion::apply
virtual void apply()
Definition: erosion.cpp:59
firevision::FilterClosing::apply
virtual void apply()
Definition: closing.cpp:96