Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef MITKLANDMARKWARPING_H
00019 #define MITKLANDMARKWARPING_H
00020
00021 #include "itkDeformationFieldSource.h"
00022 #include "itkWarpImageFilter.h"
00023 #include "itkCommand.h"
00024 #include "mitkProgressBar.h"
00025
00026 namespace mitk
00027 {
00028 class LandmarkWarping
00029 {
00030
00031 public:
00032 LandmarkWarping();
00033 ~LandmarkWarping();
00034
00035 static const unsigned int Dimension = 3;
00036 typedef float VectorComponentType;
00037
00038 typedef itk::Vector< VectorComponentType, Dimension > VectorType;
00039
00040 typedef itk::Image< VectorType, Dimension > DeformationFieldType;
00041
00042
00043 typedef unsigned char PixelType;
00044 typedef itk::Image< PixelType, Dimension > FixedImageType;
00045 typedef itk::Image< PixelType, Dimension > MovingImageType;
00046 typedef itk::DeformationFieldSource< DeformationFieldType > DeformationSourceType;
00047 typedef DeformationSourceType::LandmarkContainerPointer LandmarkContainerPointer;
00048 typedef DeformationSourceType::LandmarkContainer LandmarkContainerType;
00049 typedef DeformationSourceType::LandmarkPointType LandmarkPointType;
00050 typedef itk::WarpImageFilter< MovingImageType, MovingImageType, DeformationFieldType > FilterType;
00051
00052 FixedImageType::Pointer m_FixedImage;
00053 MovingImageType::Pointer m_MovingImage;
00054 DeformationSourceType::Pointer m_Deformer;
00055 DeformationSourceType::Pointer m_LandmarkDeformer;
00056 LandmarkWarping::LandmarkContainerType::Pointer m_TargetLandmarks;
00057 LandmarkWarping::LandmarkContainerType::Pointer m_SourceLandmarks;
00058 FilterType::Pointer m_Warper;
00059 DeformationFieldType::ConstPointer m_DeformationField;
00060 DeformationFieldType::ConstPointer m_InverseDeformationField;
00061
00062
00063 void SetFixedImage(FixedImageType::Pointer fi);
00064 void SetMovingImage(MovingImageType::Pointer mi);
00065 void SetLandmarks(LandmarkContainerType::Pointer source, LandmarkContainerType::Pointer target);
00066 MovingImageType::Pointer Register();
00067 LandmarkContainerType::Pointer GetTransformedTargetLandmarks();
00068
00069 protected:
00070
00071
00072 class Observer : public itk::Command
00073 {
00074 public:
00075 typedef Observer Self;
00076 typedef itk::Command Superclass;
00077 typedef itk::SmartPointer<Self> Pointer;
00078
00079 itkNewMacro( Self );
00080
00081 protected:
00082 Observer()
00083 {
00084 m_Counter = 0;
00085 };
00086 unsigned int m_Counter;
00087
00088 public:
00089
00090 void Execute(itk::Object *object, const itk::EventObject & event)
00091 {
00092 Execute( (const itk::Object*) object, event );
00093 }
00094
00095 void Execute(const itk::Object * object, const itk::EventObject & )
00096 {
00097 const itk::ProcessObject * internalFilter = dynamic_cast<const itk::ProcessObject *>( object );
00098 if (!(internalFilter->GetProgress() == 0 || internalFilter->GetProgress() == 1))
00099 {
00100 ++m_Counter;
00101 mitk::ProgressBar::GetInstance()->Progress();
00102 }
00103 if (internalFilter->GetProgress() == 1 && m_Counter > 20 && m_Counter < 120)
00104 {
00105 mitk::ProgressBar::GetInstance()->Progress(120 - m_Counter);
00106 m_Counter = 120;
00107 }
00108 }
00109 };
00110
00111 Observer::Pointer m_Observer;
00112 };
00113 }
00114
00115 #endif // MITKLANDMARKWARPING_H