ImFusion SDK 4.3
MorphologicalOperationsAlgorithm Class Reference

#include <ImFusion/Base/MorphologicalOperationsAlgorithm.h>

Algorithm for performing morphological operations on images. More...

+ Inheritance diagram for MorphologicalOperationsAlgorithm:

Detailed Description

Algorithm for performing morphological operations on images.

Supported operations are:

  • Dilation, on binary images it enlarges the regions of foreground pixels
  • Erosion, on binary images it shrinks the regions of foreground pixels
  • Opening, is the successive application of erosion and dilation, used for removing small non-connected regions
  • Closing, is the successive application of dilation and erosion, used for filling small holes
  • Skeletonization, reduces foreground regions to a thinner shape that is equidistant from its boundaries while preserving its connectivity

For further reference, see https://homepages.inf.ed.ac.uk/rbf/HIPR2/morops.htm

Public Types

enum class  OperationMode {
  DILATION = 0 , EROSION = 1 , OPENING = 2 , CLOSING = 3 ,
  SKELETONIZATION = 4
}
 
enum class  Distance { L1 = 0 , L2 = 1 }
 
- Public Types inherited from Algorithm
enum  Status {
  Unknown = -1 , Success = 0 , Error = 1 , InvalidInput ,
  IncompleteInput , OutOfMemoryHost , OutOfMemoryGPU , UnsupportedGPU ,
  UnknownAction , AbortedByUser , User = 1000
}
 Status codes. More...
 

Public Member Functions

 MorphologicalOperationsAlgorithm (SharedImageSet &img)
 Creates a MorphologicalOperationsAlgorithm instance that will be working on the given SharedImageSet.
 
 MorphologicalOperationsAlgorithm ()
 Creates a MorphologicalOperationsAlgorithm instance without input data.
 
 ~MorphologicalOperationsAlgorithm () override
 Destroy the output.
 
void compute () override
 Compute the result.
 
OwningDataList takeOutput () override
 If the algorithm creates new image data, it has to be transferred here.
 
void configuration (Properties *p) const override
 Serialize the current object configuration into the given Properties object.
 
std::pair< std::shared_ptr< SharedImage >, DataComponentListprocessImage (const SharedImage &image, const DataComponentList &components) const override
 SequentialImageProcessor interface method.
 
bool inPlace () const
 Returns the in-place computation flag.
 
void setInPlace (bool value)
 Sets the in-place computation flag.
 
OperationMode opMode () const
 Returns the operation mode.
 
void setOpMode (OperationMode value)
 Sets the operation mode.
 
int opSize () const
 Returns the kernel size of the morphological operation.
 
void setOpSize (int value)
 Sets the kernel size of the morphological operation.
 
Distance distance () const
 Returns whether the algorithm should use the L1 or L2 distance.
 
void setDistance (Distance distance)
 Sets whether the algorithm should use the L1 or L2 distance.
 
bool useCPU () const
 Returns the flag to force CPU computation.
 
void setUseCPU (bool value)
 Sets the flag to force computation on the CPU.
 
bool padding () const
 Returns the flag to use padding.
 
void setPadding (bool value)
 Sets the flag to use padding.
 
int paddingSize () const
 Returns the padding size in a single direction.
 
void setPaddingSize (int value)
 Sets the padding size in a single direction.
 
PaddingMode paddingMode () const
 Returns the padding mode.
 
void setPaddingMode (PaddingMode value)
 Sets the padding mode.
 
bool avoidsGlDriverTimeout () const
 Returns the flag whether to avoid a OpenGL driver timeout when using large kernels.
 
void setAvoidGlDriverTimeout (bool value)
 Sets the flag whether to avoid a OpenGL driver timeout when using large kernels.
 
template<typename T>
void processImage (const TypedImage< T > *imgIn, TypedImage< T > *imgOut) const
 Computes the morphological operation using the CPU according to the current configuration on imgIn and stores the result in imgOut.
 
void processImage (const GlImage *imgIn, GlImage *imgOut) const
 Computes the morphological operation using the GPU according to the current configuration on imgIn and stores the result in imgOut.
 
void setInput (SharedImageSet *sis)
 Update input image.
 
- Public Member Functions inherited from Algorithm
 Algorithm ()
 Default constructor will registers a single "compute" action that calls compute() and returns status().
 
virtual void setProgress (Progress *progress)
 Sets a Progress interface the algorithm can use to notify observers about its computing progress.
 
Progressprogress () const
 Returns the progress interface if set.
 
virtual int status () const
 Indicates the status of the last call to compute().
 
virtual bool survivesDataDeletion (const Data *) const
 Indicates whether the algorithm can handle (partial) deletion of the specified data, by default this checks whether the data is in the input list.
 
const FactoryInfofactoryInfo () const
 Returns the record describing how this Algorithm was instantiated by the AlgorithmFactory.
 
void setFactoryInfo (const FactoryInfo &value)
 Sets the record describing how this Algorithm was instantiated by the AlgorithmFactory.
 
Status runAction (const std::string &id)
 Run the action with name id if it exists.
 
const std::vector< Action > & actions ()
 Get a mapping from Action id to Action as registered in this algorithm.
 
- Public Member Functions inherited from Configurable
virtual void configure (const Properties *p)
 Configure this object instance by de-serializing the given Properties.
 
virtual void configureDefaults ()
 Retrieve the properties of this object, replaces values with their defaults and sets it again.
 
void registerParameter (ParameterBase *param)
 Register the given Parameter or SubProperty, so that it will be configured during configure()/configuration().
 
void unregisterParameter (const ParameterBase *param)
 Remove the given Parameter or SubProperty from the list of registered parameters.
 
 Configurable (const Configurable &rhs)
 
 Configurable (Configurable &&rhs) noexcept
 
Configurableoperator= (const Configurable &)
 
Configurableoperator= (Configurable &&) noexcept
 
- Public Member Functions inherited from SequentialImageProcessor
virtual void setSequentialMode (bool b)
 This method should be called to let the algorithm know that it should only run in sequential mode.
 
virtual bool isSequentialMode () const
 Returns of the algorithm should only run in sequential mode.
 

Static Public Member Functions

static bool createCompatible (const DataList &data, Algorithm **a)
 If data is compatible with algorithm return true. If a is not zero, create algorithm with input data.
 
- Static Public Member Functions inherited from Algorithm
static bool createCompatible (const DataList &data, Algorithm **a=nullptr)
 Factory function to check algorithm compatibility with input data and optionally instantiate it.
 

Protected Attributes

SharedImageSetm_img = nullptr
 
std::unique_ptr< SharedImageSetm_output
 
Parameter< bool > m_inPlace = {"inPlace", false, this}
 
Parameter< OperationMode > m_opMode = {"opMode", OperationMode::DILATION, this}
 
Parameter< int > m_opSize = {"opSize", 3, this}
 
Parameter< Distance > m_distance = {"distance", Distance::L1, this}
 
Parameter< bool > m_useCPU = {"useCPU", false, this}
 
Parameter< bool > m_padding = {"padding", false, this}
 
Parameter< int > m_paddingSize = {"paddingSize", 1, this}
 Padding size in a single direction.
 
Parameter< PaddingModem_paddingMode = {"paddingMode", PaddingMode::Zero, this}
 Padding mode.
 
Parameter< bool > m_avoidGlDriverTimeout = {"avoidGlDriverTimeout", false, this}
 
std::unique_ptr< GL::ImageProgramm_program
 Main program.
 
std::unique_ptr< GL::ImageProgramm_programSecondPass
 Secondary program for opening and closing.
 
- Protected Attributes inherited from Algorithm
std::string m_name
 Algorithm name.
 
Progressm_progress = nullptr
 Non-owing pointer to a progress interface. May be a nullptr.
 
FactoryInfo m_factoryInfo = {}
 Record describing how this algorithm was instantiated by the AlgorithmFactory.
 
int m_status = Status::Unknown
 Algorithm status after last call to compute()
 
std::vector< Actionm_actions
 Map of key given by the id of the action, of the available actions of this algorithm.
 
- Protected Attributes inherited from Configurable
std::vector< Paramm_params
 List of all registered Parameter and SubProperty instances.
 
- Protected Attributes inherited from SequentialImageProcessor
bool m_isSequentialMode = false
 Flag to determine if algorithm is running in sequential mode.
 

Additional Inherited Members

- Public Attributes inherited from Algorithm
Signal signalOutputChanged
 Signal should be emitted by Algorithms when their output/result has changed.
 
Signal signalParametersChanged
 Signal should be emitted by Algorithms when their parameter configuration has changed.
 
- Public Attributes inherited from Configurable
Signal signalParametersChanged
 Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted.
 
- Protected Member Functions inherited from Algorithm
void loadDefaults ()
 
void registerAction (const std::string &id, const std::string &guiName, const std::function< Algorithm::Status(void)> &action)
 Register an action to be run via runAction.
 
template<typename D>
void registerAction (const std::string &id, const std::string &guiName, Algorithm::Status(D::*action)(void))
 Template version of runAction that can be used with a pointer to a member function.
 
void registerAction (const Action &action)
 Register an action.
 

Constructor & Destructor Documentation

◆ MorphologicalOperationsAlgorithm()

Creates a MorphologicalOperationsAlgorithm instance without input data.

Thus, compute() won't do anything. However, you can still configure the instance and call processImage() directly.

Member Function Documentation

◆ compute()

void compute ( )
overridevirtual

Compute the result.

Implements Algorithm.

◆ takeOutput()

OwningDataList takeOutput ( )
overridevirtual

If the algorithm creates new image data, it has to be transferred here.

Reimplemented from Algorithm.

◆ configuration()

void configuration ( Properties * p) const
overridevirtual

Serialize the current object configuration into the given Properties object.

The default implementation will do so automatically for all registered Parameter and SubProperty instances.

See also
configure() for the inverse functionality

Reimplemented from Configurable.

◆ processImage()

std::pair< std::shared_ptr< SharedImage >, DataComponentList > processImage ( const SharedImage & image,
const DataComponentList & components ) const
overridevirtual

SequentialImageProcessor interface method.

Processes an image without modifying the algorithm's status Warning: Not to be confused with the processImage functions below!

Implements SequentialImageProcessor.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close