29 #include "WMScalarSegmentation.h"
30 #include "WMScalarSegmentation.xpm"
31 #include "core/common/WColor.h"
32 #include "core/common/WPropertyHelper.h"
33 #include "core/kernel/WKernel.h"
44 m_algos.push_back( std::shared_ptr< WSegmentationAlgo >(
new WSegmentationAlgoWatershed() ) );
45 m_algos.push_back( std::shared_ptr< WSegmentationAlgo >(
new WSegmentationAlgoOtsu() ) );
46 m_algos.push_back( std::shared_ptr< WSegmentationAlgo >(
new WSegmentationAlgoRegionGrowingConfidenceConnected() ) );
47 m_algos.push_back( std::shared_ptr< WSegmentationAlgo >(
new WSegmentationAlgoLevelSetCanny() ) );
63 return scalarSegmentation_xpm;
68 return "Scalar Segmentation";
73 return "This module segments scalar datasets.";
78 m_input = std::shared_ptr< WModuleInputData < WDataSetScalar > >(
84 m_output = std::shared_ptr< WModuleOutputData < WDataSetScalar > >(
98 for( AlgoList::iterator it =
m_algos.begin(); it !=
m_algos.end(); ++it )
100 m_algoSelection->addItem( ( *it )->getName(), ( *it )->getDescription() );
105 for( AlgoList::iterator it =
m_algos.begin(); it !=
m_algos.end(); ++it )
107 ( *it )->initProperties(
m_properties->addPropertyGroup( ( *it )->getName(),
"The properties for this segmentation algorithm.",
true ) );
110 m_algos.at( 0 )->hideProperties(
false );
123 for( AlgoList::iterator it =
m_algos.begin(); it !=
m_algos.end(); ++it )
139 std::shared_ptr< WDataSetScalar > newDataSet =
m_input->getData();
140 bool dataChanged = (
m_dataSet != newDataSet );
141 bool dataValid = ( newDataSet != NULL );
143 if( dataChanged && dataValid )
147 ||
m_dataSet->getValueSet()->dimension() != 1 ||
m_dataSet->getValueSet()->order() != 0 )
149 m_dataSet = std::shared_ptr< WDataSetScalar >();
164 if(
m_dataSet && ( dataChanged || propChanged || algoChanged ) )
172 for( AlgoList::iterator it =
m_algos.begin(); it !=
m_algos.end(); ++it )
185 debugLog() <<
"Starting segmentation.";
187 debugLog() <<
"Segmentation finished.";
virtual void wait() const
Wait for the condition.
void setResetable(bool resetable=true, bool autoReset=true)
Sets the resetable flag.
virtual void remove(std::shared_ptr< WCondition > condition)
Removes the specified condition.
virtual void add(std::shared_ptr< WCondition > condition)
Adds another condition to the set of conditions to wait for.
Class to encapsulate boost::condition_variable_any.
A class containing a list of named items.
This class represents a subset of a WItemSelection.
virtual size_t getItemIndexOfSelected(size_t index) const
Helps to get the index of an selected item in the WItemSelection.
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.
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 offering an instantiate-able data connection between modules.
Class representing a single module of OpenWalnut.
virtual void properties()
Initialize properties in this function.
wlog::WStreamedLogger debugLog() const
Logger instance for comfortable debug logging.
void addConnector(std::shared_ptr< WModuleInputConnector > con)
Adds the specified connector to the list of inputs.
std::shared_ptr< WProperties > m_properties
The property object for the module.
void ready()
Call this whenever your module is ready and can react on property changes.
WConditionSet m_moduleState
The internal state of the module.
virtual void activate()
Callback for m_active.
virtual void connectors()
Initialize connectors in this function.
A very simple threshold segmentation working in two modi: If in LOWER_THRESHOLD mode than voxels that...
WBoolFlag m_shutdownFlag
Condition getting fired whenever the thread should quit.
void addTo(WPropSelection prop)
Add the PC_NOTEMPTY constraint to the property.
void addTo(WPropSelection prop)
Add the PC_SELECTONLYONE constraint to the property.