| 112 | |
| 113 | template <typename TPixelType, unsigned int VImageDimension > |
| 114 | void doMITKMap(const ::itk::Image<TPixelType,VImageDimension>* input, mitk::ImageMappingHelper::ResultImageType::Pointer& result, const mitk::ImageMappingHelper::RegistrationType*& registration, |
| 115 | bool throwOnOutOfInputAreaError, const double& paddingValue, const mitk::ImageMappingHelper::ResultImageGeometryType*& resultGeometry, |
| 116 | bool throwOnMappingError, const double& errorValue, mitk::ImageMappingInterpolator::Type interpolatorType) |
| 117 | { |
| 118 | typedef ::map::core::Registration<VImageDimension,VImageDimension> ConcreteRegistrationType; |
| 119 | typedef ::map::core::ImageMappingTask<ConcreteRegistrationType, ::itk::Image<TPixelType,VImageDimension>, ::itk::Image<TPixelType,VImageDimension> > MappingTaskType; |
| 120 | typename MappingTaskType::Pointer spTask = MappingTaskType::New(); |
| 121 | |
| 122 | typedef typename MappingTaskType::ResultImageDescriptorType ResultImageDescriptorType; |
| 123 | typename ResultImageDescriptorType::Pointer resultDescriptor; |
| 124 | |
| 125 | //check if image and result geometry fits the passed registration |
| 126 | ///////////////////////////////////////////////////////////////// |
| 127 | if (registration->getMovingDimensions()!=VImageDimension) |
| 128 | { |
| 129 | map::core::OStringStream str; |
| 130 | str << "Dimension of MITK image ("<<VImageDimension<<") does not equal the moving dimension of the registration object ("<<registration->getMovingDimensions()<<")."; |
| 131 | throw mitk::AccessByItkException(str.str()); |
| 132 | } |
| 133 | |
| 134 | if (registration->getTargetDimensions()!=VImageDimension) |
| 135 | { |
| 136 | map::core::OStringStream str; |
| 137 | str << "Dimension of MITK image ("<<VImageDimension<<") does not equal the target dimension of the registration object ("<<registration->getTargetDimensions()<<")."; |
| 138 | throw mitk::AccessByItkException(str.str()); |
| 139 | } |
| 140 | |
| 141 | const ConcreteRegistrationType* castedReg = dynamic_cast<const ConcreteRegistrationType*>(registration); |
| 142 | |
| 143 | if (registration->getTargetDimensions()==2 && resultGeometry) |
| 144 | { |
| 145 | mitk::ImageMappingHelper::ResultImageGeometryType::BoundsArrayType bounds = resultGeometry->GetBounds(); |
| 146 | |
| 147 | if (bounds[4]!=0 || bounds[5]!=0) |
| 148 | { |
| 149 | //array "bounds" is constructed as [min Dim1, max Dim1, min Dim2, max Dim2, min Dim3, max Dim3] |
| 150 | //therefore [4] and [5] must be 0 |
| 151 | |
| 152 | map::core::OStringStream str; |
| 153 | str << "Dimension of defined result geometry does not equal the target dimension of the registration object ("<<registration->getTargetDimensions()<<")."; |
| 154 | throw mitk::AccessByItkException(str.str()); |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | //check/create resultDescriptor |
| 159 | ///////////////////////// |
| 160 | if (resultGeometry) |
| 161 | { |
| 162 | resultDescriptor = ResultImageDescriptorType::New(); |
| 163 | |
| 164 | typename ResultImageDescriptorType::PointType origin; |
| 165 | typename ResultImageDescriptorType::SizeType size; |
| 166 | typename ResultImageDescriptorType::SpacingType fieldSpacing; |
| 167 | typename ResultImageDescriptorType::DirectionType matrix; |
| 168 | |
| 169 | const mitk::ImageMappingHelper::ResultImageGeometryType::BoundsArrayType geoBounds = resultGeometry->GetBounds(); |
| 170 | const mitk::Vector3D geoSpacing = resultGeometry->GetSpacing(); |
| 171 | const mitk::Point3D geoOrigin = resultGeometry->GetOrigin(); |
nothing calls this directly
no test coverage detected