open_iA 2023.04
A tool for the visual analysis and processing of volumetric datasets, with a focus on industrial computed tomography.
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
iAFilter Class Referenceabstract

Base class for image filters. More...

#include <iAFilter.h>

Inheritance diagram for iAFilter:
[legend]
Collaboration diagram for iAFilter:
[legend]

Public Member Functions

 iAFilter (QString const &name, QString const &category, QString const &description="", unsigned int requiredImages=1, unsigned int outputCount=1, bool supportsAbort=false)
 Constructor initializing name, category and description of the filter.
 
virtual ~iAFilter ()
 virtual destructor, to enable proper destruction in derived classes and to avoid warnings
 
void abort () override
 Abort the filter.
 
virtual void adaptParametersToInput (QVariantMap &parameters, std::map< size_t, std::shared_ptr< iADataSet > > const &dataSets)
 if required, adapt (loaded/default) parameters to image only used from GUI for the moment if feature is implemented where parameters can be omitted (on command line), this could later also be used to provide useful defaults for parameters that need to adapt to input image
 
void addMsg (QString const &msg)
 Adds some message to the targeted output place for this filter.
 
void addOutput (std::shared_ptr< iADataSet > dataSet)
 adds an output dataset
 
void addOutputValue (QString const &name)
 Adds an output value name.
 
void addOutputValue (QString const &name, QVariant value)
 Adds an output value.
 
void addParameter (QString const &name, iAValueType valueType, QVariant defaultValue=0.0, double min=std::numeric_limits< double >::lowest(), double max=std::numeric_limits< double >::max())
 Adds the description of a parameter to the filter.
 
bool canAbort () const
 Whether the filter supports aborting.
 
QString category () const
 Retrieve the "base" filter category.
 
virtual bool checkParameters (QVariantMap const &parameters)
 Check whether the filter can be run with the given parameters.
 
void clearInput ()
 Clears the list of input images to this filter.
 
bool defaultParameterCheck (QSharedPointer< iAAttributeDescriptor > param, QVariant const &paramValue)
 the default check for a single parameter descriptor & value combination
 
QString description () const
 Retrieve the filter description.
 
size_t finalOutputCount () const
 Get the number of available outputs.
 
unsigned int firstInputChannels () const
 returns the number of input channels from the first input image.
 
QString fullCategory () const
 Retrieve the full category string (just as specified in the constructor).
 
iAImageData const * imageInput (size_t idx) const
 convenience function returning input datasets converted to image data (with error checks)
 
iAImageDataimageOutput (size_t idx) const
 convenience function returning output datasets converted to image data (with error checks)
 
std::shared_ptr< iADataSetinput (size_t idx) const
 Get input with the given index.
 
size_t inputCount () const
 Get the number of available inputs (that were already added to the filter).
 
QString inputName (unsigned int i) const
 Retrieve the name of the input image with given index.
 
iAITKIO::ScalarType inputScalarType () const
 return the ITK pixel type of the image in the first given input dataset (no check is performed whether that dataset actually contains an image!)
 
bool isAborted () const
 Whether the filter was aborted by the user.
 
iALoggerlogger ()
 Retrieve the logger used for log messages emitted by the filter.
 
QString name () const
 Retrieve the filter name.
 
std::shared_ptr< iADataSetoutput (size_t idx) const
 get output with the given index.
 
QString outputName (unsigned int i) const
 Retrieve the name of the output image with given index.
 
std::vector< std::shared_ptr< iADataSet > > outputs ()
 return the full list of outputs
 
QVector< QString > const & outputValueNames () const
 Retrieve a list of names of the output values that this filter can produce.
 
QVector< QPair< QString, QVariant > > const & outputValues () const
 retrieve a list of output values.
 
iAAttributes const & parameters () const
 Retrieve a list of the filter parameters.
 
unsigned int plannedOutputCount () const
 The planned number of outputs the filter will produce.
 
iAProgressprogress ()
 Retrieve the progress reporting object for this filter.
 
unsigned int requiredImages () const
 Returns the number of input images required by this filter.
 
unsigned int requiredMeshes () const
 Returns the number of input meshes required by this filter.
 
bool run (QVariantMap const &parameters)
 Initialize and run the filter.
 
void setFirstInputChannels (unsigned int c)
 sets the first input channels.
 
void setLogger (iALogger *logger)
 Set the logger to be used for status output / error messages.
 
void addInput (std::shared_ptr< iADataSet > con)
 
void addInput (vtkImageData *vtkImage)
 
void addOutput (itk::ImageBase< 3 > *img)
 
void addOutput (vtkImageData *img)
 
void addOutput (vtkPolyData *vtkPoly)
 
virtual void abort ()=0
 

Protected Member Functions

iAAttributesparamsWritable ()
 "Writable" list of the filter parameters.
 
void setInputName (unsigned int i, QString const &name)
 Set the name of the input with the given index.
 
void setOutputName (unsigned int i, QString const &name)
 Set the name of the output with the given index.
 
void setRequiredMeshInputs (unsigned int i)
 Set the number of required mesh inputs (0 by default)
 

Detailed Description

Base class for image filters.

Derived classes should:

Constructor & Destructor Documentation

◆ iAFilter()

iAFilter::iAFilter ( QString const &  name,
QString const &  category,
QString const &  description = "",
unsigned int  requiredImages = 1,
unsigned int  outputCount = 1,
bool  supportsAbort = false 
)

Constructor initializing name, category and description of the filter.

Parameters
nameThe name of the filter. It will be used in its menu entry, as part of the title of the result window, and as title for the parameter selection dialog.
categoryThe filter category. It will be used for putting the filter into a fitting submenu and for categorizing the filter parameters when storing them in the registry you can use the slash character ("/") to specify subcategories. A category of "Segmentation/Global Thresholding" for example would put a filter in the "Global Thresholding" submenu of the "Segmentation" menu, which in turn is added as submenu to the Filter menu. When left empty, the filter will be added directly in the Filter menu
descriptionAn (optional) description of the filter algorithm, and ideally its settings. Can contain HTML (e.g. links)
requiredImagesThe number of (image) inputs required for this filter; by default, filters are assumed to require exactly one input image; you can override the number of inputs required for your filter with this parameter for filters that require mesh input, see the setRequiredMeshInputs method; set this to 0 if the filter requires no images in addition to the mesh
outputCountthe number of outputs this filter creates. Set it to 0 to disable image output. If you don't know this yet at the time of creating the filter (because it for example depends on the number of input images or the parameters), you can always adapt it at a later point (e.g. during iAFilter::Run) by calling SetOutputCount; but if you have some image output, make sure that you leave it at the default value of 1 or set it to some value other than zero, because setting it to zero has immediate side effects (e.g. not opening a result window if configured, in the GUI).
supportsAbortwhether the filter supports aborting. The typical way of aborting is by checking the boolean flag accessible via isAbort, but derived classes can implement custom abort listeners through overriding the abort() function

◆ ~iAFilter()

iAFilter::~iAFilter ( )
virtual

virtual destructor, to enable proper destruction in derived classes and to avoid warnings

Member Function Documentation

◆ abort()

void iAFilter::abort ( )
overridevirtual

Abort the filter.

Implements iAAbortListener.

◆ adaptParametersToInput()

void iAFilter::adaptParametersToInput ( QVariantMap &  parameters,
std::map< size_t, std::shared_ptr< iADataSet > > const &  dataSets 
)
virtual

if required, adapt (loaded/default) parameters to image only used from GUI for the moment if feature is implemented where parameters can be omitted (on command line), this could later also be used to provide useful defaults for parameters that need to adapt to input image

◆ addInput() [1/2]

void iAFilter::addInput ( std::shared_ptr< iADataSet con)

Adds a dataSet as input.

◆ addInput() [2/2]

void iAFilter::addInput ( vtkImageData *  vtkImage)

◆ addMsg()

void iAFilter::addMsg ( QString const &  msg)

Adds some message to the targeted output place for this filter.

Typically this will go into the log window of the result MdiChild

Parameters
msgthe message to print

◆ addOutput() [1/4]

void iAFilter::addOutput ( itk::ImageBase< 3 > *  img)

Adds an output image (helper function for adding ITK/VTK datasets).

Parameters
imgoutput image from the filter

◆ addOutput() [2/4]

void iAFilter::addOutput ( std::shared_ptr< iADataSet dataSet)

adds an output dataset

◆ addOutput() [3/4]

void iAFilter::addOutput ( vtkImageData *  img)

◆ addOutput() [4/4]

void iAFilter::addOutput ( vtkPolyData *  vtkPoly)

◆ addOutputValue() [1/2]

void iAFilter::addOutputValue ( QString const &  name)

Adds an output value name.

Call this method in the constructor of derived classes, to let the filter know which output values will later be added via the addOutputValue method with two parameters

Parameters
namethe name of the output value

◆ addOutputValue() [2/2]

void iAFilter::addOutputValue ( QString const &  name,
QVariant  value 
)

Adds an output value.

Parameters
namethe name of the output value
valuethe actual output value

◆ addParameter()

void iAFilter::addParameter ( QString const &  name,
iAValueType  valueType,
QVariant  defaultValue = 0.0,
double  min = std::numeric_limits<double>::lowest(),
double  max = std::numeric_limits<double>::max() 
)

Adds the description of a parameter to the filter.

Parameters
namethe parameter's name
valueTypethe type of value this parameter can have
defaultValuethe default value of the parameter; for Categorical valueTypes, this should be the list of possible values
minthe minimum value this parameter can have (inclusive).
maxthe maximum value this parameter can have (inclusive)

◆ canAbort()

bool iAFilter::canAbort ( ) const

Whether the filter supports aborting.

◆ category()

QString iAFilter::category ( ) const

Retrieve the "base" filter category.

If sub-categories were specified, this only returns the first one.

◆ checkParameters()

bool iAFilter::checkParameters ( QVariantMap const &  parameters)
virtual

Check whether the filter can be run with the given parameters.

If you need to perform special checks on your parameters, override this method. The standard implementation here just checks parameters with Discrete and Continuous value type for minimum and maximum values.

Parameters
parametersthe generic list of parameters that the filter will be called with
Returns
true if the given parameters are acceptable for the filter, false otherwise

◆ clearInput()

void iAFilter::clearInput ( )

Clears the list of input images to this filter.

Call this in case you are re-using a filter already called before, and you want to call it with new input images

◆ defaultParameterCheck()

bool iAFilter::defaultParameterCheck ( QSharedPointer< iAAttributeDescriptor param,
QVariant const &  paramValue 
)

the default check for a single parameter descriptor & value combination

◆ description()

QString iAFilter::description ( ) const

Retrieve the filter description.

◆ finalOutputCount()

size_t iAFilter::finalOutputCount ( ) const

Get the number of available outputs.

Only set after the filter has run and the outputs are actually produced! see plannedOutputCount() for the number of probable outcomes before the filter has run!

◆ firstInputChannels()

unsigned int iAFilter::firstInputChannels ( ) const

returns the number of input channels from the first input image.

◆ fullCategory()

QString iAFilter::fullCategory ( ) const

Retrieve the full category string (just as specified in the constructor).

◆ imageInput()

iAImageData const * iAFilter::imageInput ( size_t  idx) const

convenience function returning input datasets converted to image data (with error checks)

◆ imageOutput()

iAImageData * iAFilter::imageOutput ( size_t  idx) const

convenience function returning output datasets converted to image data (with error checks)

◆ input()

std::shared_ptr< iADataSet > iAFilter::input ( size_t  idx) const

Get input with the given index.

See also
inputCount for the number of available inputs

◆ inputCount()

size_t iAFilter::inputCount ( ) const

Get the number of available inputs (that were already added to the filter).

◆ inputName()

QString iAFilter::inputName ( unsigned int  i) const

Retrieve the name of the input image with given index.

◆ inputScalarType()

iAITKIO::ScalarType iAFilter::inputScalarType ( ) const

return the ITK pixel type of the image in the first given input dataset (no check is performed whether that dataset actually contains an image!)

◆ isAborted()

bool iAFilter::isAborted ( ) const

Whether the filter was aborted by the user.

◆ logger()

iALogger * iAFilter::logger ( )

Retrieve the logger used for log messages emitted by the filter.

◆ name()

QString iAFilter::name ( ) const

Retrieve the filter name.

◆ output()

std::shared_ptr< iADataSet > iAFilter::output ( size_t  idx) const

get output with the given index.

See also
outputCount for the number of available inputs

◆ outputName()

QString iAFilter::outputName ( unsigned int  i) const

Retrieve the name of the output image with given index.

◆ outputs()

std::vector< std::shared_ptr< iADataSet > > iAFilter::outputs ( )

return the full list of outputs

◆ outputValueNames()

QVector< QString > const & iAFilter::outputValueNames ( ) const

Retrieve a list of names of the output values that this filter can produce.

◆ outputValues()

QVector< QPair< QString, QVariant > > const & iAFilter::outputValues ( ) const

retrieve a list of output values.

◆ parameters()

iAAttributes const & iAFilter::parameters ( ) const

Retrieve a list of the filter parameters.

◆ paramsWritable()

iAAttributes & iAFilter::paramsWritable ( )
protected

"Writable" list of the filter parameters.

◆ plannedOutputCount()

unsigned int iAFilter::plannedOutputCount ( ) const

The planned number of outputs the filter will produce.

◆ progress()

iAProgress * iAFilter::progress ( )

Retrieve the progress reporting object for this filter.

◆ requiredImages()

unsigned int iAFilter::requiredImages ( ) const

Returns the number of input images required by this filter.

For typical image filters, this returns 1.

Returns
the number of images required as input

◆ requiredMeshes()

unsigned int iAFilter::requiredMeshes ( ) const

Returns the number of input meshes required by this filter.

◆ run()

bool iAFilter::run ( QVariantMap const &  parameters)

Initialize and run the filter.

Parameters
parametersthe map of parameters to use in this specific filter run

◆ setFirstInputChannels()

void iAFilter::setFirstInputChannels ( unsigned int  c)

sets the first input channels.

◆ setInputName()

void iAFilter::setInputName ( unsigned int  i,
QString const &  name 
)
protected

Set the name of the input with the given index.

◆ setLogger()

void iAFilter::setLogger ( iALogger logger)

Set the logger to be used for status output / error messages.

◆ setOutputName()

void iAFilter::setOutputName ( unsigned int  i,
QString const &  name 
)
protected

Set the name of the output with the given index.

◆ setRequiredMeshInputs()

void iAFilter::setRequiredMeshInputs ( unsigned int  i)
protected

Set the number of required mesh inputs (0 by default)


The documentation for this class was generated from the following files: