| 317 | |
| 318 | |
| 319 | mitk::ImageMappingHelper::ResultImageType::Pointer |
| 320 | mitk::ImageMappingHelper::map(const InputImageType* input, const RegistrationType* registration, |
| 321 | bool throwOnOutOfInputAreaError, const double& paddingValue, const ResultImageGeometryType* resultGeometry, |
| 322 | bool throwOnMappingError, const double& errorValue, mitk::ImageMappingInterpolator::Type interpolatorType) |
| 323 | { |
| 324 | if (!registration) |
| 325 | { |
| 326 | mitkThrow() << "Cannot map image. Passed registration wrapper pointer is nullptr."; |
| 327 | } |
| 328 | if (!input) |
| 329 | { |
| 330 | mitkThrow() << "Cannot map image. Passed image pointer is nullptr."; |
| 331 | } |
| 332 | |
| 333 | ResultImageType::Pointer result; |
| 334 | |
| 335 | if (input->GetTimeSteps() > 1) |
| 336 | { |
| 337 | // Multiple time steps: pre-allocate the result image and map each time step |
| 338 | // individually. doMapTimesteps internally dispatches between scalar and |
| 339 | // composite pixel types per time step. |
| 340 | auto mappedTimeGeometry = CreateResultTimeGeometry(input, resultGeometry); |
| 341 | result = mitk::Image::New(); |
| 342 | result->Initialize(input->GetPixelType(), *mappedTimeGeometry, 1, input->GetTimeSteps()); |
| 343 | |
| 344 | doMapTimesteps(input, result, registration, throwOnOutOfInputAreaError, |
| 345 | paddingValue, resultGeometry, throwOnMappingError, errorValue, interpolatorType); |
| 346 | } |
| 347 | else if (input->GetPixelType().GetNumberOfComponents() > 1) |
| 348 | { |
| 349 | AccessFixedTypeByItk_n(input, doMITKMap, |
| 350 | MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES_SEQ, (3), |
| 351 | (result, registration, throwOnOutOfInputAreaError, paddingValue, |
| 352 | resultGeometry, throwOnMappingError, errorValue, interpolatorType)); |
| 353 | } |
| 354 | else |
| 355 | { |
| 356 | AccessByItk_n(input, doMITKMap, |
| 357 | (result, registration, throwOnOutOfInputAreaError, paddingValue, |
| 358 | resultGeometry, throwOnMappingError, errorValue, interpolatorType)); |
| 359 | } |
| 360 | |
| 361 | return result; |
| 362 | } |
| 363 | |
| 364 | mitk::ImageMappingHelper::ResultImageType::Pointer |
| 365 | mitk::ImageMappingHelper::map(const InputImageType* input, const MITKRegistrationType* registration, |