Difference between revisions of "ITK v4 Migration Guide"

From mitk.org
Jump to navigation Jump to search
(Make it viewable for the public)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
__NOTOC__
+
With the MITK 2013.06 release, MITK migrated from ITK 3 to ITK 4. Developers using MITK should read through the official [http://itk.org/migrationv4/ ITK migration guide] and the MITK specific changes listed below.
<!-- ## page was renamed from internal/ITKv4/ITKv4_MigrationGuide -->
+
 
<!-- ## page was renamed from internal/ITKv4/MigrationGuide -->
+
__TOC__
= Migration Guide =
+
 
 +
 
 
== Histogram Initialization ==
 
== Histogram Initialization ==
[[MeasurementVectorSize]] and histogramSize has to be set explicitly when initializing a histogram
+
MeasurementVectorSize and histogramSize has to be set explicitly when initializing a histogram
 +
 
  
 
'''Old:'''
 
'''Old:'''
 
+
<syntaxhighlight lang="cpp">
 
 
<pre><nowiki>
 
 
m_EmptyHistogram = HistogramType::New();
 
m_EmptyHistogram = HistogramType::New();
 
  HistogramType::SizeType histogramSize;
 
  HistogramType::SizeType histogramSize;
 
  histogramSize.Fill( 256 );
 
  histogramSize.Fill( 256 );
 
  m_EmptyHistogram->Initialize( histogramSize );
 
  m_EmptyHistogram->Initialize( histogramSize );
</nowiki></pre>
+
</syntaxhighlight>
 +
 
  
 
'''New:'''
 
'''New:'''
 
+
<syntaxhighlight lang="cpp">
 
 
<pre><nowiki>
 
 
m_EmptyHistogram = HistogramType::New();
 
m_EmptyHistogram = HistogramType::New();
 
m_EmptyHistogram->SetMeasurementVectorSize(2);
 
m_EmptyHistogram->SetMeasurementVectorSize(2);
Line 25: Line 24:
 
histogramSize.Fill( 256 );
 
histogramSize.Fill( 256 );
 
m_EmptyHistogram->Initialize( histogramSize );
 
m_EmptyHistogram->Initialize( histogramSize );
</nowiki></pre>
+
</syntaxhighlight>
 +
 
  
== get/Set Output ==
+
== Get/Set Output ==
* [[SetOutput]](0,output) does not work since it expects a string as identifier --> use [[SetNthOutput|SetPrimaryOutput]](output) instead!
+
* SetOutput(0,output) does not work since it expects a string as identifier --> use SetPrimaryOutput(output) instead!
  
== Subclasses of itk::[[ImageSource]] ==
 
* The method signature of itk::[[ImageSource]]::[[ThreadedGenerateData]] changed: The thread id is now of type ''unsigned int'' instead of ''int''. Use the new ''[[ThreadIdType]]'' typedef to correctly overload the virtual [[ThreadedGenerateData]] method.
 
  
== mitk::[[PixelType]] ==
+
== Subclasses of itk::ImageSource ==
The mitk::[[PixelType]] class was adapted to changes in itk::ImageIOBase and its interface was cleaned up.
+
* The method signature of itk::ImageSource::ThreadedGenerateData changed: The thread id is now of type ''unsigned int'' instead of ''int''. Use the new ''ThreadIdType'' typedef to correctly overload the virtual ThreadedGenerateData method.
{| border="1" cellpadding="2" cellspacing="0"
+
 
| Old  
+
 
| New  
+
== mitk::PixelType ==
| Comment  
+
The mitk::PixelType class was adapted to changes in itk::ImageIOBase and its interface was cleaned up.
 +
{| class="wikitable" style="background-color:#ffffff;"  
 +
! Old  
 +
! New  
 +
! Comment  
 
|-
 
|-
| itk::ImageIOBase::IOPixelType [[GetPixelTypeId]]()  
+
| itk::ImageIOBase::IOPixelType GetPixelTypeId()  
| itk::ImageIOBase::IOPixelType [[GetPixelType]]()  
+
| itk::ImageIOBase::IOPixelType GetPixelType()  
 
| Renamed  
 
| Renamed  
 
|-
 
|-
| const std::type_info& [[GetTypeId]]()  
+
| const std::type_info& GetTypeId()  
| int [[GetComponentType]]()  
+
| int GetComponentType()  
| To compare the component type, use either the itk::ImageIOBase::IOComponentType enum directly or use mitk::[[MapPixelComponentType]]<T>::value to map a pixel component type to an integer value (this will also work for user component types not known to the itk::ImageIOBase class  
+
| To compare the component type, use either the itk::ImageIOBase::IOComponentType enum directly or use mitk::MapPixelComponentType<T>::value to map a pixel component type to an integer value (this will also work for user component types not known to the itk::ImageIOBase class  
 
|-
 
|-
| std::string [[GetItkTypeAsString]]()  
+
| std::string GetItkTypeAsString()  
| std::string [[GetPixelTypeAsString]]()  
+
| std::string GetPixelTypeAsString()  
 
| Renamed  
 
| Renamed  
 
|}
 
|}
 +
  
 
== Rigid3DTransform ==
 
== Rigid3DTransform ==
Line 59: Line 62:
 
* mitkRigidRegistrationPreset (removed in bf88544ebacc9ea31fb9f922172fb82eea900b4c)
 
* mitkRigidRegistrationPreset (removed in bf88544ebacc9ea31fb9f922172fb82eea900b4c)
  
== Remove [[WeakPointer]] Workaround ==
+
 
 +
== Remove WeakPointer Workaround ==
 
* remove all MITK_WEAKPOINTER_PROBLEM_WORKAROUND_ENABLED
 
* remove all MITK_WEAKPOINTER_PROBLEM_WORKAROUND_ENABLED
 
* remove m_SmartSourcePointer from mitkBaseData
 
* remove m_SmartSourcePointer from mitkBaseData
 +
  
 
== Deformation vs. Displacement ==
 
== Deformation vs. Displacement ==
* Deformation is rename into Displacement, see http://itk.org/migrationv4/index.php?action=artikel&cat=3&id=90&artlang=en&highlight=itkInverseDeformationFieldImageFilter
+
* Deformation is renamed into Displacement, see http://itk.org/migrationv4/index.php?action=artikel&cat=3&id=90&artlang=en&highlight=itkInverseDeformationFieldImageFilter
 +
 
  
== [[BaseProcess]] vs. [[BaseDataSource]] or "cannot allocate an object of abstract type" ==
+
== BaseProcess vs. BaseDataSource or "cannot allocate an object of abstract type" ==
* Due to changes in the ITK Filterpipeline we decided to mark mitk::[[BaseProcess]] as deprecated.
+
* Due to changes in the ITK Filterpipeline we decided to mark mitk::BaseProcess as deprecated.
* The new class mitk::[[BaseDataSource]] should be used by now
+
* The new class mitk::BaseDataSource should be used by now
* mitk::[[BaseDataSource]] has some pure virtual functions (actually the [[MakeOutput]](..) functions)
+
* mitk::BaseDataSource has some pure virtual functions (actually the MakeOutput(..) functions)
 
* These functions must be implemented by each subclass
 
* These functions must be implemented by each subclass
  
== Clone() const' cannot be overloaded" ==
+
 
 +
== Clone() const' cannot be overloaded ==
 
* ITK 4 implements various new clone() methods which we used to implement in MITK in the past resulting in the error mentioned above.
 
* ITK 4 implements various new clone() methods which we used to implement in MITK in the past resulting in the error mentioned above.
 
* Most of the time, the Clone() method in MITK can just be removed.
 
* Most of the time, the Clone() method in MITK can just be removed.
* If there is anything happening except for the call to [[InternalClone]]() this code should be moved to the [[InternalClone]]() method.
+
* If there is anything happening except for the call to InternalClone() this code should be moved to the InternalClone() method.
 +
 
  
== itk::[[PointSet]] does not have a boundingbox anymore ==
+
== itk::PointSet does not have a boundingbox anymore ==
* itk::[[PointSet]]->[[GetBoundingBox]]() is not available anymore. Whenever you need the bounding box, you must create it on your own and fill it the pointset points.
+
* itk::PointSet::GetBoundingBox() is not available anymore. Whenever you need the bounding box, you must create it on your own and fill it the pointset points.
 
* an example is given here: http://itk.org/ITKExamples/Examples/Core/Common/BoundingBoxOfAPointSet/BoundingBoxOfAPointSet.html
 
* an example is given here: http://itk.org/ITKExamples/Examples/Core/Common/BoundingBoxOfAPointSet/BoundingBoxOfAPointSet.html

Latest revision as of 15:30, 1 December 2014

With the MITK 2013.06 release, MITK migrated from ITK 3 to ITK 4. Developers using MITK should read through the official ITK migration guide and the MITK specific changes listed below.


Histogram Initialization

MeasurementVectorSize and histogramSize has to be set explicitly when initializing a histogram


Old: <syntaxhighlight lang="cpp"> m_EmptyHistogram = HistogramType::New();

HistogramType::SizeType histogramSize;
histogramSize.Fill( 256 );
m_EmptyHistogram->Initialize( histogramSize );

</syntaxhighlight>


New: <syntaxhighlight lang="cpp"> m_EmptyHistogram = HistogramType::New(); m_EmptyHistogram->SetMeasurementVectorSize(2); HistogramType::SizeType histogramSize(2); histogramSize.Fill( 256 ); m_EmptyHistogram->Initialize( histogramSize ); </syntaxhighlight>


Get/Set Output

  • SetOutput(0,output) does not work since it expects a string as identifier --> use SetPrimaryOutput(output) instead!


Subclasses of itk::ImageSource

  • The method signature of itk::ImageSource::ThreadedGenerateData changed: The thread id is now of type unsigned int instead of int. Use the new ThreadIdType typedef to correctly overload the virtual ThreadedGenerateData method.


mitk::PixelType

The mitk::PixelType class was adapted to changes in itk::ImageIOBase and its interface was cleaned up.

Old New Comment
itk::ImageIOBase::IOPixelType GetPixelTypeId() itk::ImageIOBase::IOPixelType GetPixelType() Renamed
const std::type_info& GetTypeId() int GetComponentType() To compare the component type, use either the itk::ImageIOBase::IOComponentType enum directly or use mitk::MapPixelComponentType<T>::value to map a pixel component type to an integer value (this will also work for user component types not known to the itk::ImageIOBase class
std::string GetItkTypeAsString() std::string GetPixelTypeAsString() Renamed


Rigid3DTransform


Remove WeakPointer Workaround

  • remove all MITK_WEAKPOINTER_PROBLEM_WORKAROUND_ENABLED
  • remove m_SmartSourcePointer from mitkBaseData


Deformation vs. Displacement


BaseProcess vs. BaseDataSource or "cannot allocate an object of abstract type"

  • Due to changes in the ITK Filterpipeline we decided to mark mitk::BaseProcess as deprecated.
  • The new class mitk::BaseDataSource should be used by now
  • mitk::BaseDataSource has some pure virtual functions (actually the MakeOutput(..) functions)
  • These functions must be implemented by each subclass


Clone() const' cannot be overloaded

  • ITK 4 implements various new clone() methods which we used to implement in MITK in the past resulting in the error mentioned above.
  • Most of the time, the Clone() method in MITK can just be removed.
  • If there is anything happening except for the call to InternalClone() this code should be moved to the InternalClone() method.


itk::PointSet does not have a boundingbox anymore