Fawkes API  Fawkes Development Version
opening.cpp
1 
2 /***************************************************************************
3  * opening.cpp - implementation of morphological opening filter
4  *
5  * Created: Mon Jun 05 14:00:46 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/opening.h>
25 
26 #include <fvfilters/morphology/dilation.h>
27 #include <fvfilters/morphology/erosion.h>
28 
29 #include <cstddef>
30 
31 namespace firevision {
32 #if 0 /* just to make Emacs auto-indent happy */
33 }
34 #endif
35 
36 /** @class FilterOpening <fvfilters/morphology/opening.h>
37  * Morphological opening.
38  *
39  * @author Tim Niemueller
40  */
41 
42 
43 /** Constructor. */
45  : MorphologicalFilter("Morphological Opening")
46 {
47  dilate = new FilterDilation();
48  erode = new FilterErosion();
49 }
50 
51 
52 /** Destructor. */
54 {
55  delete dilate;
56  delete erode;
57 }
58 
59 
60 void
61 FilterOpening::set_src_buffer(unsigned char *buf, ROI *roi,
62  orientation_t ori, unsigned int buffer_num)
63 {
64  Filter::set_src_buffer(buf, roi, ori, buffer_num);
65  erode->set_src_buffer( buf, roi, ori, buffer_num );
66 }
67 
68 
69 void
70 FilterOpening::set_src_buffer(unsigned char *buf, ROI *roi, unsigned int buffer_num)
71 {
72  Filter::set_src_buffer(buf, roi, buffer_num);
73  erode->set_src_buffer( buf, roi, buffer_num );
74 }
75 
76 
77 void
78 FilterOpening::set_dst_buffer(unsigned char *buf, ROI *roi)
79 {
80  Filter::set_dst_buffer(buf, roi);
81  erode->set_dst_buffer( buf, roi );
82  dilate->set_src_buffer( buf, roi );
83 }
84 
85 
86 void
88  unsigned int se_width, unsigned int se_height,
89  unsigned int se_anchor_x, unsigned int se_anchor_y)
90 {
91  MorphologicalFilter::set_structuring_element(se, se_width, se_height, se_anchor_x, se_anchor_y);
92  dilate->set_structuring_element(se, se_width, se_height, se_anchor_x, se_anchor_y);
93  erode->set_structuring_element(se, se_width, se_height, se_anchor_x, se_anchor_y);
94 }
95 
96 
97 void
99 {
100  erode->apply();
101  dilate->apply();
102 }
103 
104 } // end namespace firevision
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: opening.cpp:87
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.
unsigned int se_anchor_y
Anchor point y offset of structuring element.
FilterOpening()
Constructor.
Definition: opening.cpp:44
unsigned int se_anchor_x
Anchor point x offset of structuring element.
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:93
virtual void apply()
Apply the filter.
Definition: erosion.cpp:60
virtual ~FilterOpening()
Destructor.
Definition: opening.cpp:53
Region of interest.
Definition: roi.h:58
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: opening.cpp:61
unsigned char * se
Structuring element.
unsigned int se_height
Height of structuring element.
Morphological dilation.
Definition: dilation.h:33
Morphological filter interface.
virtual void apply()
Apply the filter.
Definition: opening.cpp:98
Morphological erosion.
Definition: erosion.h:33
virtual void set_dst_buffer(unsigned char *buf, ROI *roi)
Set the destination buffer.
Definition: opening.cpp:78
unsigned int se_width
Width of structuring element.
virtual void apply()
Apply the filter.
Definition: dilation.cpp:83
orientation_t * ori
Orientations, one for each source image.
Definition: filter.h:75
virtual void set_dst_buffer(unsigned char *buf, ROI *roi)
Set the destination buffer.
Definition: filter.cpp:134