OpenWalnut  1.5.0dev
WMScalarSegmentation.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WMSCALARSEGMENTATION_H
26 #define WMSCALARSEGMENTATION_H
27 
28 #include <memory>
29 #include <string>
30 #include <vector>
31 
32 #include "WSegmentationAlgoLevelSetCanny.h"
33 #include "WSegmentationAlgoOtsu.h"
34 #include "WSegmentationAlgoRegionGrowingConfidenceConnected.h"
35 #include "WSegmentationAlgoThreshold.h"
36 #include "WSegmentationAlgoWatershed.h"
37 #include "core/common/WItemSelection.h"
38 #include "core/common/WItemSelector.h"
39 #include "core/dataHandler/WDataHandler.h"
40 #include "core/dataHandler/WDataSetScalar.h"
41 #include "core/kernel/WModule.h"
42 #include "core/kernel/WModuleInputData.h"
43 #include "core/kernel/WModuleOutputData.h"
44 
45 /**
46  * First version of a module that implements 3D-image segmentation algorithms.
47  *
48  * \ingroup modules
49  */
51 {
52 public:
53  /**
54  * Default constructor.
55  */
57 
58  /**
59  * Destructor.
60  */
61  virtual ~WMScalarSegmentation();
62 
63  /**
64  * Return the name of this module.
65  *
66  * \return the module's name.
67  */
68  virtual const std::string getName() const;
69 
70  /**
71  * Return a description of this module.
72  *
73  * \return description to module.
74  */
75  virtual const std::string getDescription() const;
76 
77  /**
78  * Return a new instance of this module.
79  *
80  * \return the prototype used to create every module in OpenWalnut.
81  */
82  virtual std::shared_ptr< WModule > factory() const;
83 
84  /**
85  * Get the icon for this module in XPM format.
86  *
87  * \return the icon.
88  */
89  virtual const char** getXPMIcon() const;
90 
91 protected:
92  /**
93  * Entry point after loading the module. Runs in separate thread.
94  */
95  virtual void moduleMain();
96 
97  /**
98  * Initialize the connectors this module is using.
99  */
100  virtual void connectors();
101 
102  /**
103  * Initialize the properties for this module.
104  */
105  virtual void properties();
106 
107  /**
108  * Callback for m_active. Overwrite this in your modules to handle m_active changes separately.
109  */
110  virtual void activate();
111 
112 private:
113  //! A List type for all available algorithms.
114  typedef std::vector< std::shared_ptr< WSegmentationAlgo > > AlgoList;
115 
116  /**
117  * Do a segmentation depending on the current module property values.
118  */
119  void doSegmentation();
120 
121  //! An input connector used to get datasets from other modules.
122  std::shared_ptr< WModuleInputData< WDataSetScalar > > m_input;
123 
124  //! The output connector used to provide the calculated data to other modules.
125  std::shared_ptr< WModuleOutputData< WDataSetScalar > > m_output;
126 
127  //! This is a pointer to the dataset the module is currently working on.
128  std::shared_ptr< WDataSetScalar > m_dataSet;
129 
130  //! This is a pointer to the segmented dataset.
131  std::shared_ptr< WDataSetScalar > m_result;
132 
133  //! A condition used to notify about changes in several properties.
134  std::shared_ptr< WCondition > m_propCondition;
135 
136  //! The number of the currently selected segmentation method.
137  std::size_t m_algoIndex;
138 
139  //! A list of possible segmentation algorithms.
140  std::shared_ptr< WItemSelection > m_algoSelection;
141 
142  //! A selection box for segmentation algorithms.
143  WPropSelection m_algoType;
144 
145  //! A list of algorithm objects.
147 };
148 
149 #endif // WMSCALARSEGMENTATION_H
First version of a module that implements 3D-image segmentation algorithms.
virtual void properties()
Initialize the properties for this module.
std::shared_ptr< WCondition > m_propCondition
A condition used to notify about changes in several properties.
void doSegmentation()
Do a segmentation depending on the current module property values.
virtual void connectors()
Initialize the connectors this module is using.
std::vector< std::shared_ptr< WSegmentationAlgo > > AlgoList
A List type for all available algorithms.
virtual void moduleMain()
Entry point after loading the module.
virtual void activate()
Callback for m_active.
std::shared_ptr< WModuleInputData< WDataSetScalar > > m_input
An input connector used to get datasets from other modules.
std::shared_ptr< WItemSelection > m_algoSelection
A list of possible segmentation algorithms.
AlgoList m_algos
A list of algorithm objects.
virtual std::shared_ptr< WModule > factory() const
Return a new instance of this module.
WMScalarSegmentation()
Default constructor.
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
virtual const std::string getDescription() const
Return a description of this module.
virtual ~WMScalarSegmentation()
Destructor.
virtual const std::string getName() const
Return the name of this module.
WPropSelection m_algoType
A selection box for segmentation algorithms.
std::shared_ptr< WModuleOutputData< WDataSetScalar > > m_output
The output connector used to provide the calculated data to other modules.
std::shared_ptr< WDataSetScalar > m_dataSet
This is a pointer to the dataset the module is currently working on.
std::size_t m_algoIndex
The number of the currently selected segmentation method.
std::shared_ptr< WDataSetScalar > m_result
This is a pointer to the segmented dataset.
Class representing a single module of OpenWalnut.
Definition: WModule.h:72