Decide on the best architecture for how to implement ITK Calculators. Should they inherit from Object and be separate from the pipeline, or should they inherit from ProcessObject and be part of the pipeline?
There are currently two different types of Calculators implemented in ITK, one that inherits from Object and is not part of the pipeline, and one that inherits from ProcessObject and is part of the pipeline.
- Originally, all calculators had the following properties:
- Inherit from Object
- Are not part of the pipeline
- Must include the following methods: Compute
- Must include context specific Set/Get methods such as SetImage and GetThreshold
- Examples: All calculators except those that inherit from itkHistogramThresholdCalculator, which inherits from ProcessObject. This includes, for example, OtsuMultipleThresholdsCalculator.
- A new group of calculators having the following properties:
- Inherit from ProcessObject
- Are part of the pipeline
- Must include the following methods: Update, SetInput, GetOutput
- Provide a Compute() method that simply calls Update()
- Examples: All calculators that inherit from itkHistogramThresholdCalculator. This includes, for example, OtsuThresholdCalculator.
- Having two separate implementations, both with the name "Calculator", that inherit from entirely different trees and with different methods is inconsistent and confusing.
- It also makes it difficult to for developers to know which framework to use for implementing new calculators.
Here is a very troublesome example:
A decision should be made on which framework should be chosen going forward. Then the current calculators should be refactored to all have the same inheritance tree and consistent methods.
If the original framework is chosen, methods like Compute() should be moved to a layer between Object and the calculator so that all calculators inherit them automatically to yield a consistent API. Such a layer could consist of classes that have consistent methods for inputs and outputs. For example:
- HistogramThresholdCalculator class with methods: Compute, SetInputHistogram, GetOutputThreshold
- ImageCalculator class with methods: Compute, SetInputImage