20 #include <itkImageDuplicator.h>
27 #include <mapImageRegistrationAlgorithmInterface.h>
28 #include <mapRegistrationAlgorithmInterface.h>
29 #include <mapPointSetRegistrationAlgorithmInterface.h>
30 #include <mapDummyImageRegistrationAlgorithm.h>
31 #include <mapAlgorithmIdentificationInterface.h>
37 m_AlgorithmBase(algorithm)
39 m_AllowImageCasting =
true;
48 unsigned int movingDim = m_AlgorithmBase->getMovingDimensions();
49 unsigned int targetDim = m_AlgorithmBase->getTargetDimensions();
51 if (movingDim != targetDim)
53 mapDefaultExceptionStaticMacro( <<
54 "Error, algorithm instance has unequal dimensionality and is therefore not supported in the current version of MITKAlgorithmHelper.");
59 mapDefaultExceptionStaticMacro( <<
60 "Error, algorithm instance has a dimensionality larger than 3 and is therefore not supported in the current version of MITKAlgorithmHelper.");
63 typedef ::map::algorithm::facet::RegistrationAlgorithmInterface<2, 2> RegistrationAlg2D2DInterface;
64 typedef ::map::algorithm::facet::RegistrationAlgorithmInterface<3, 3> RegistrationAlg3D3DInterface;
66 RegistrationAlg2D2DInterface* pRegAlgorithm2D2D =
dynamic_cast<RegistrationAlg2D2DInterface*
>
67 (m_AlgorithmBase.GetPointer());
68 RegistrationAlg3D3DInterface* pRegAlgorithm3D3D =
dynamic_cast<RegistrationAlg3D3DInterface*
>
69 (m_AlgorithmBase.GetPointer());
71 if (pRegAlgorithm2D2D)
73 spResult = pRegAlgorithm2D2D->getRegistration();
76 if (pRegAlgorithm3D3D)
78 spResult = pRegAlgorithm3D3D->getRegistration();
90 spResult->SetRegistration(spInternalResult);
109 if (! m_AlgorithmBase)
111 mapDefaultExceptionStaticMacro( <<
"Error, cannot check data. Helper has no algorithm defined.");
116 mapDefaultExceptionStaticMacro( <<
"Error, cannot check data. Moving data pointer is NULL.");
121 mapDefaultExceptionStaticMacro( <<
"Error, cannot check data. Target data pointer is NULL.");
127 unsigned int movingDim = m_AlgorithmBase->getMovingDimensions();
128 unsigned int targetDim = m_AlgorithmBase->getTargetDimensions();
130 if (movingDim != targetDim)
139 typedef ::map::core::continuous::Elements<3>::InternalPointSetType InternalDefaultPointSetType;
140 typedef ::map::algorithm::facet::PointSetRegistrationAlgorithmInterface<InternalDefaultPointSetType, InternalDefaultPointSetType>
141 PointSetRegInterface;
143 PointSetRegInterface* pPointSetInterface =
dynamic_cast<PointSetRegInterface*
>
144 (m_AlgorithmBase.GetPointer());
146 if (!pPointSetInterface)
159 else if (movingDim == 3)
184 this->m_AllowImageCasting = allowCasting;
189 return this->m_AllowImageCasting;
194 if (! m_AlgorithmBase)
196 mapDefaultExceptionStaticMacro( <<
"Error, cannot check data. Helper has no algorithm defined.");
201 mapDefaultExceptionStaticMacro( <<
"Error, cannot check data. Moving data pointer is NULL.");
206 mapDefaultExceptionStaticMacro( <<
"Error, cannot check data. Target data pointer is NULL.");
209 unsigned int movingDim = m_AlgorithmBase->getMovingDimensions();
210 unsigned int targetDim = m_AlgorithmBase->getTargetDimensions();
212 if (movingDim != targetDim)
214 mapDefaultExceptionStaticMacro( <<
215 "Error, cannot set data. Current version of MITKAlgorithmHelper only supports images/point sets with same dimensionality.");
220 typedef ::map::core::continuous::Elements<3>::InternalPointSetType InternalDefaultPointSetType;
221 typedef ::map::algorithm::facet::PointSetRegistrationAlgorithmInterface<InternalDefaultPointSetType, InternalDefaultPointSetType>
222 PointSetRegInterface;
224 PointSetRegInterface* pPointSetInterface =
dynamic_cast<PointSetRegInterface*
>
225 (m_AlgorithmBase.GetPointer());
238 else if (movingDim == 3)
245 template<
typename TInImageType,
typename TOutImageType>
248 typedef itk::CastImageFilter< TInImageType, TOutImageType > CastFilterType;
251 spImageCaster->SetInput(input);
254 spImageCaster->Update();
259 template<
typename TPixelType1,
unsigned int VImageDimension1,
260 typename TPixelType2,
unsigned int VImageDimension2>
261 void MITKAlgorithmHelper::DoSetImages(
const itk::Image<TPixelType1, VImageDimension1>* moving,
262 const itk::Image<TPixelType2, VImageDimension2>* target)
264 typedef itk::Image<TPixelType1, VImageDimension1> MovingImageType;
265 typedef itk::Image<TPixelType2, VImageDimension2> TargetImageType;
266 typedef itk::Image<map::core::discrete::InternalPixelType, VImageDimension1>
267 InternalDefaultMovingImageType;
268 typedef itk::Image<map::core::discrete::InternalPixelType, VImageDimension2>
269 InternalDefaultTargetImageType;
271 typedef ::map::algorithm::facet::ImageRegistrationAlgorithmInterface<MovingImageType, TargetImageType>
273 typedef ::map::algorithm::facet::ImageRegistrationAlgorithmInterface<InternalDefaultMovingImageType, InternalDefaultTargetImageType>
274 DefaultImageRegInterface;
277 ImageRegInterface* pImageInterface =
dynamic_cast<ImageRegInterface*
>(m_AlgorithmBase.GetPointer());
278 DefaultImageRegInterface* pDefaultImageInterface =
dynamic_cast<DefaultImageRegInterface*
>
279 (m_AlgorithmBase.GetPointer());
291 typedef itk::ImageDuplicator< MovingImageType > MovingDuplicatorType;
292 typedef itk::ImageDuplicator< TargetImageType > TargetDuplicatorType;
294 mDuplicator->SetInputImage(moving);
295 mDuplicator->Update();
298 tDuplicator->SetInputImage(target);
299 tDuplicator->Update();
304 pImageInterface->setTargetImage(clonedTarget);
305 pImageInterface->setMovingImage(clonedMoving);
307 else if (pDefaultImageInterface)
310 if (! m_AllowImageCasting)
312 mapDefaultExceptionStaticMacro( <<
313 "Error, cannot set images. MITKAlgorithmHelper has to convert them into MatchPoint default images, but is not allowed. Please reconfigure helper.");
317 CastImage<TargetImageType, InternalDefaultTargetImageType>(target);
319 CastImage<MovingImageType, InternalDefaultMovingImageType>(moving);
320 pDefaultImageInterface->setTargetImage(spCastedTarget);
321 pDefaultImageInterface->setMovingImage(spCastedMoving);
325 mapDefaultExceptionStaticMacro( <<
"Error, algorithm is not able to use the based images.");
329 template<
typename TPixelType1,
unsigned int VImageDimension1,
330 typename TPixelType2,
unsigned int VImageDimension2>
331 void MITKAlgorithmHelper::DoCheckImages(
const itk::Image<TPixelType1, VImageDimension1>* moving,
332 const itk::Image<TPixelType2, VImageDimension2>* target)
const
334 typedef itk::Image<TPixelType1, VImageDimension1> MovingImageType;
335 typedef itk::Image<TPixelType2, VImageDimension2> TargetImageType;
336 typedef itk::Image<map::core::discrete::InternalPixelType, VImageDimension1>
337 InternalDefaultMovingImageType;
338 typedef itk::Image<map::core::discrete::InternalPixelType, VImageDimension2>
339 InternalDefaultTargetImageType;
341 typedef ::map::algorithm::facet::ImageRegistrationAlgorithmInterface<MovingImageType, TargetImageType>
343 typedef ::map::algorithm::facet::ImageRegistrationAlgorithmInterface<InternalDefaultMovingImageType, InternalDefaultTargetImageType>
344 DefaultImageRegInterface;
346 ImageRegInterface* pImageInterface =
dynamic_cast<ImageRegInterface*
>(m_AlgorithmBase.GetPointer());
347 DefaultImageRegInterface* pDefaultImageInterface =
dynamic_cast<DefaultImageRegInterface*
>
348 (m_AlgorithmBase.GetPointer());
355 else if (pDefaultImageInterface)
371 typedef map::algorithm::DummyImageRegistrationAlgorithm<map::core::discrete::Elements<3>::InternalImageType, map::core::discrete::Elements<3>::InternalImageType, DummyRegIDPolicy>
378 dummyImg->Allocate();
379 regAlg->setTargetImage(dummyImg);
380 regAlg->setMovingImage(dummyImg);
383 dummyReg->SetRegistration(regAlg->getRegistration());
void SetAllowImageCasting(bool allowCasting)
map::core::RegistrationBase::Pointer GetRegistration() const
itk::SmartPointer< Self > Pointer
Base of all data objects.
DataCollection - Class to facilitate loading/accessing structured data.
bool CheckData(const mitk::BaseData *moving, const mitk::BaseData *target, CheckError::Type &error) const
bool GetAllowImageCasting() const
MITKMATCHPOINTREGISTRATION_EXPORT::map::core::continuous::Elements< 3 >::InternalPointSetType::Pointer ConvertPointSetMITKtoMAP(const mitk::PointSet::DataType *mitkSet)
Data structure which stores a set of points. Superclass of mitk::Mesh.
void SetData(const mitk::BaseData *moving, const mitk::BaseData *target)
mitk::MAPRegistrationWrapper::Pointer GetMITKRegistrationWrapper() const
Image class for storing images.
static const mitk::Image * GetDataAsImage(const mitk::BaseData *data)
static const mitk::PointSet * GetDataAsPointSet(const mitk::BaseData *data)
#define AccessTwoImagesFixedDimensionByItk(mitkImage1, mitkImage2, itkImageTypeFunction, dimension)
Access two mitk-images with known dimension by itk-images.
mitk::MAPRegistrationWrapper::Pointer GenerateIdentityRegistration3D()
MITKAlgorithmHelper(map::algorithm::RegistrationAlgorithmBase *algorithm=NULL)
mapGenerateAlgorithmUIDPolicyMacro(DummyRegIDPolicy,"de.dkfz.dipp","Identity","1.0.0","")
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.