Page MenuHomePhabricator

Relocate transfer function initialization into separate class
Closed, ResolvedPublic

Assigned To
None
Authored By
seitelm
Jul 15 2009, 5:02 PM
Referenced Files
F261: AllChanges.patch
Jul 28 2010, 2:19 PM
F260: TransferFunctionChanges.patch
Jun 30 2010, 3:05 PM

Description

mitk::TransferFunction currently holds several methods for initializing the encapsulated scalar opacity, gradient opacity, and color transfer functions. THe methods support automatic histogram-based initialization and initialization to neat-looking default Computed Tomography transfer functions.

Since mitk::TransferFunction is a data class, specific initialization code should be relocated into a separate Initializer class

Event Timeline

seitelm added a subscriber: seitelm.

Note: the unit test for mitk::TransferFunction (mitkTransferFunctionTest) currently does not cover initialization related code. When implementing a transfer function initializer class, a unit test should be created as well (cf. T2204)

Changes of the Transfer Function class

We implemented a new class for the initialization of the transfer function. Patch is attached.

Mathias: is this as intended?

Timo: you should also enhance the unit test if necessary

Thanks for looking into this. The basic implementation looks fine, I'd only suggest to decouple the new class completely from the mitk::TransferFunction. In your implementation it is still used by TransferFunction, and TransferFunction still has a method SetMode().

A simple way to achieve this decoupling would be to implement the new class as an initializer class, which takes an existing instance of TransferFunction and initializes it with the selected transfer function (e.g. in a method InitializeTransferFunction() after setting the desired TF by SetMode(). Have a look at the ITK class CeneteredTransformInitializer which uses a similar approach:

http://www.itk.org/Doxygen314/html/classitk_1_1CenteredTransformInitializer.html

Since the initialized TFs are just an arbitrary default set of TFs, it would be nice to create a general interface for TF initialization, and a derived class for the functions that you have. The basic implementation could look like this:

class TransferFunctionInitializer
{
public:

void SetTransferFunction( TransferFunction* transferFunction );

virtual void InitializeTransferFunction() = 0;

/* etc. */

}

class DefaultTransferFunctionInitializer
{
public:

enum TransferFunctionModes
{
  // like before
}

void SetMode( int mode );

virtual void InitializeTransferFunction(); // concrete implementation

}

DefaultTransferFunctionInitializer should of course derive from TransferFunctionInitializer :)

Unsetting needs_core_modification flag until until patch is adapted to Mathias' suggestions. Please set to ? again when changes are ready.

Patch contains all classes

We created an independent class for the Transferfunction to initialize the mode and updated the Test for Transferfunction

[SVN revision 24927]
FIX (#2274): Relocated transfer function initialization into separate class and updated test

[SVN revision 24928]
COMP (#2274): Committed missing files.cmake