open_iA 2023.04
A tool for the visual analysis and processing of volumetric datasets, with a focus on industrial computed tomography.
|
Base class for image filters. More...
#include <iAFilter.h>
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 ¶meters, 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 ¶meters) |
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 ¶mValue) |
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) | |
iAImageData * | imageOutput (size_t idx) const |
convenience function returning output datasets converted to image data (with error checks) | |
std::shared_ptr< iADataSet > | input (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. | |
iALogger * | logger () |
Retrieve the logger used for log messages emitted by the filter. | |
QString | name () const |
Retrieve the filter name. | |
std::shared_ptr< iADataSet > | output (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. | |
iAProgress * | progress () |
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 ¶meters) |
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 | |
iAAttributes & | paramsWritable () |
"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) | |
Base class for image filters.
Derived classes should:
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.
name | The 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. |
category | The 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 |
description | An (optional) description of the filter algorithm, and ideally its settings. Can contain HTML (e.g. links) |
requiredImages | The 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 |
outputCount | the 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). |
supportsAbort | whether 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 |
|
virtual |
virtual destructor, to enable proper destruction in derived classes and to avoid warnings
|
overridevirtual |
Abort the filter.
Implements iAAbortListener.
|
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
void iAFilter::addInput | ( | std::shared_ptr< iADataSet > | con | ) |
Adds a dataSet as input.
void iAFilter::addInput | ( | vtkImageData * | vtkImage | ) |
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
msg | the message to print |
void iAFilter::addOutput | ( | itk::ImageBase< 3 > * | img | ) |
Adds an output image (helper function for adding ITK/VTK datasets).
img | output image from the filter |
void iAFilter::addOutput | ( | std::shared_ptr< iADataSet > | dataSet | ) |
adds an output dataset
void iAFilter::addOutput | ( | vtkImageData * | img | ) |
void iAFilter::addOutput | ( | vtkPolyData * | vtkPoly | ) |
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
name | the name of the output value |
void iAFilter::addOutputValue | ( | QString const & | name, |
QVariant | value | ||
) |
Adds an output value.
name | the name of the output value |
value | the actual output value |
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.
name | the parameter's name |
valueType | the type of value this parameter can have |
defaultValue | the default value of the parameter; for Categorical valueTypes, this should be the list of possible values |
min | the minimum value this parameter can have (inclusive). |
max | the maximum value this parameter can have (inclusive) |
bool iAFilter::canAbort | ( | ) | const |
Whether the filter supports aborting.
QString iAFilter::category | ( | ) | const |
Retrieve the "base" filter category.
If sub-categories were specified, this only returns the first one.
|
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 | the generic list of parameters that the filter will be called with |
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
bool iAFilter::defaultParameterCheck | ( | QSharedPointer< iAAttributeDescriptor > | param, |
QVariant const & | paramValue | ||
) |
the default check for a single parameter descriptor & value combination
QString iAFilter::description | ( | ) | const |
Retrieve the filter description.
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!
unsigned int iAFilter::firstInputChannels | ( | ) | const |
returns the number of input channels from the first input image.
QString iAFilter::fullCategory | ( | ) | const |
Retrieve the full category string (just as specified in the constructor).
iAImageData const * iAFilter::imageInput | ( | size_t | idx | ) | const |
convenience function returning input datasets converted to image data (with error checks)
iAImageData * iAFilter::imageOutput | ( | size_t | idx | ) | const |
convenience function returning output datasets converted to image data (with error checks)
std::shared_ptr< iADataSet > iAFilter::input | ( | size_t | idx | ) | const |
Get input with the given index.
size_t iAFilter::inputCount | ( | ) | const |
Get the number of available inputs (that were already added to the filter).
QString iAFilter::inputName | ( | unsigned int | i | ) | const |
Retrieve the name of the input image with given index.
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!)
bool iAFilter::isAborted | ( | ) | const |
Whether the filter was aborted by the user.
iALogger * iAFilter::logger | ( | ) |
Retrieve the logger used for log messages emitted by the filter.
QString iAFilter::name | ( | ) | const |
Retrieve the filter name.
std::shared_ptr< iADataSet > iAFilter::output | ( | size_t | idx | ) | const |
get output with the given index.
QString iAFilter::outputName | ( | unsigned int | i | ) | const |
Retrieve the name of the output image with given index.
std::vector< std::shared_ptr< iADataSet > > iAFilter::outputs | ( | ) |
return the full list of outputs
QVector< QString > const & iAFilter::outputValueNames | ( | ) | const |
Retrieve a list of names of the output values that this filter can produce.
QVector< QPair< QString, QVariant > > const & iAFilter::outputValues | ( | ) | const |
retrieve a list of output values.
iAAttributes const & iAFilter::parameters | ( | ) | const |
Retrieve a list of the filter parameters.
|
protected |
"Writable" list of the filter parameters.
unsigned int iAFilter::plannedOutputCount | ( | ) | const |
The planned number of outputs the filter will produce.
iAProgress * iAFilter::progress | ( | ) |
Retrieve the progress reporting object for this filter.
unsigned int iAFilter::requiredImages | ( | ) | const |
Returns the number of input images required by this filter.
For typical image filters, this returns 1.
unsigned int iAFilter::requiredMeshes | ( | ) | const |
Returns the number of input meshes required by this filter.
bool iAFilter::run | ( | QVariantMap const & | parameters | ) |
Initialize and run the filter.
parameters | the map of parameters to use in this specific filter run |
void iAFilter::setFirstInputChannels | ( | unsigned int | c | ) |
sets the first input channels.
|
protected |
Set the name of the input with the given index.
void iAFilter::setLogger | ( | iALogger * | logger | ) |
Set the logger to be used for status output / error messages.
|
protected |
Set the name of the output with the given index.
|
protected |
Set the number of required mesh inputs (0 by default)