19 #include <itkImageMaskSpatialObject.h>
25 #include "mapMaskedRegistrationAlgorithmInterface.h"
26 #include <mapRegistrationAlgorithmInterface.h>
39 if (! m_AlgorithmBase) mapDefaultExceptionStaticMacro(<<
"Error, cannot check data. Helper has no algorithm defined.");
41 unsigned int movingDim = m_AlgorithmBase->getMovingDimensions();
42 unsigned int targetDim = m_AlgorithmBase->getTargetDimensions();
44 bool result = movingDim == targetDim;
48 result = result && (movingMask->
GetDimension() == movingDim);
55 result = result && (maskPixelType == movingMask->
GetPixelType());
57 else if (movingDim == 3)
62 result = result && (maskPixelType == movingMask->
GetPixelType());
68 result = result && (targetMask->
GetDimension() == targetDim);
75 result = result && (maskPixelType == targetMask->
GetPixelType());
77 else if (movingDim == 3)
82 result = result && (maskPixelType == targetMask->
GetPixelType());
88 typedef ::map::algorithm::facet::MaskedRegistrationAlgorithmInterface<2, 2> MaskedInterface;
89 const MaskedInterface* pMaskedReg =
dynamic_cast<const MaskedInterface*
>(m_AlgorithmBase.GetPointer());
91 result = result && pMaskedReg;
93 else if (movingDim == 3)
95 typedef ::map::algorithm::facet::MaskedRegistrationAlgorithmInterface<3, 3> MaskedInterface;
96 const MaskedInterface* pMaskedReg =
dynamic_cast<const MaskedInterface*
>(m_AlgorithmBase.GetPointer());
98 result = result && pMaskedReg;
110 if (! m_AlgorithmBase) mapDefaultExceptionStaticMacro(<<
"Error, cannot set data. Helper has no algorithm defined.");
112 if (!
CheckSupport(movingMask, targetMask))
return false;
114 unsigned int movingDim = m_AlgorithmBase->getMovingDimensions();
115 unsigned int targetDim = m_AlgorithmBase->getTargetDimensions();
117 if (movingDim!=targetDim)
return false;
121 return DoSetMasks<2,2>(movingMask, targetMask);
123 else if (movingDim == 3)
125 return DoSetMasks<3,3>(movingMask, targetMask);
130 template<
unsigned int VImageDimension1,
unsigned int VImageDimension2>
133 typedef itk::SpatialObject<VImageDimension1> MovingSpatialType;
134 typedef itk::SpatialObject<VImageDimension2> TargetSpatialType;
136 typedef ::map::algorithm::facet::MaskedRegistrationAlgorithmInterface<VImageDimension1, VImageDimension2> MaskedRegInterface;
137 MaskedRegInterface* pAlg =
dynamic_cast<MaskedRegInterface*
>(m_AlgorithmBase.GetPointer());
139 if (!pAlg)
return false;
145 if (! movingSpatial) mapDefaultExceptionStaticMacro(<<
"Error, cannot convert moving mask.");
146 pAlg->setMovingMask(movingSpatial);
153 if (! targetSpatial) mapDefaultExceptionStaticMacro(<<
"Error, cannot convert moving mask.");
154 pAlg->setTargetMask(targetSpatial);
160 template<
typename TPixelType,
unsigned int VImageDimension>
161 void MaskedAlgorithmHelper::DoConvertMask(
const itk::Image<TPixelType,VImageDimension>* mask)
163 typedef itk::Image<TPixelType,VImageDimension>
ImageType;
164 typedef itk::ImageMaskSpatialObject<VImageDimension> SpatialType;
167 spatial->SetImage(mask);
169 m_convertResult = spatial.GetPointer();
itk::SmartPointer< Self > Pointer
bool CheckSupport(const mitk::Image *movingMask, const mitk::Image *targetMask) const
DataCollection - Class to facilitate loading/accessing structured data.
#define AccessFixedTypeByItk(mitkImage, itkImageTypeFunction, pixelTypeSeq, dimSeq)
Access a mitk-image with known type (pixel type and dimension) by an itk-image.
map::core::discrete::Elements< 3 >::InternalImageType ImageType
MaskedAlgorithmHelper(map::algorithm::RegistrationAlgorithmBase *algorithm=NULL)
Image class for storing images.
itk::Image< unsigned char, 3 > MaskImageType
const mitk::PixelType GetPixelType(int n=0) const
Returns the PixelType of channel n.
bool SetMasks(const mitk::Image *movingMask, const mitk::Image *targetMask)
unsigned int GetDimension() const
Get dimension of the image.
Class for defining the data type of pixels.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.