MCPcopy Create free account
hub / github.com/MITK/MITK / DoSetImages

Method DoSetImages

Modules/MatchPointRegistration/src/Helper/mitkMAPAlgorithmHelper.cpp:281–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

279 template<typename TPixelType1, unsigned int VImageDimension1,
280 typename TPixelType2, unsigned int VImageDimension2>
281 void MAPAlgorithmHelper::DoSetImages(const itk::Image<TPixelType1, VImageDimension1>* moving,
282 const itk::Image<TPixelType2, VImageDimension2>* target)
283 {
284 typedef itk::Image<TPixelType1, VImageDimension1> MovingImageType;
285 typedef itk::Image<TPixelType2, VImageDimension2> TargetImageType;
286 typedef itk::Image<map::core::discrete::InternalPixelType, VImageDimension1>
287 InternalDefaultMovingImageType;
288 typedef itk::Image<map::core::discrete::InternalPixelType, VImageDimension2>
289 InternalDefaultTargetImageType;
290
291 typedef ::map::algorithm::facet::ImageRegistrationAlgorithmInterface<MovingImageType, TargetImageType>
292 ImageRegInterface;
293 typedef ::map::algorithm::facet::ImageRegistrationAlgorithmInterface<InternalDefaultMovingImageType, InternalDefaultTargetImageType>
294 DefaultImageRegInterface;
295
296
297 ImageRegInterface* pImageInterface = dynamic_cast<ImageRegInterface*>(m_AlgorithmBase.GetPointer());
298 DefaultImageRegInterface* pDefaultImageInterface = dynamic_cast<DefaultImageRegInterface*>
299 (m_AlgorithmBase.GetPointer());
300
301 if (pImageInterface)
302 {
303 //just set directly and you are done
304
305 /**@todo the duplication work around is needed due to a insufficuence
306 in the AccessTwoImagesFixedDimensionByItk macro. The macro always cast
307 the passed image into non const (even if that image was passed as const).
308 This behavior enforces the unnecessary use of an writeaccessor, which as a consequence
309 will lead to redundant access exceptions as long as the algorithm exists;
310 e.g. in the typical scenario with the MatchPoint Plugins*/
311 typedef itk::ImageDuplicator< MovingImageType > MovingDuplicatorType;
312 typedef itk::ImageDuplicator< TargetImageType > TargetDuplicatorType;
313 typename MovingDuplicatorType::Pointer mDuplicator = MovingDuplicatorType::New();
314 mDuplicator->SetInputImage(moving);
315 mDuplicator->Update();
316
317 typename TargetDuplicatorType::Pointer tDuplicator = TargetDuplicatorType::New();
318 tDuplicator->SetInputImage(target);
319 tDuplicator->Update();
320
321 typename MovingImageType::Pointer clonedMoving = mDuplicator->GetOutput();
322 typename TargetImageType::Pointer clonedTarget = tDuplicator->GetOutput();
323
324 pImageInterface->setTargetImage(clonedTarget);
325 pImageInterface->setMovingImage(clonedMoving);
326 }
327 else if (pDefaultImageInterface)
328 {
329 //you may convert it to the default image type and use it then
330 if (! m_AllowImageCasting)
331 {
332 mapDefaultExceptionStaticMacro( <<
333 "Error, cannot set images. MAPAlgorithmHelper has to convert them into MatchPoint default images, but is not allowed. Please reconfigure helper.");
334 }
335
336 typename InternalDefaultTargetImageType::Pointer spCastedTarget =
337 CastImage<TargetImageType, InternalDefaultTargetImageType>(target);
338 typename InternalDefaultMovingImageType::Pointer spCastedMoving =

Callers

nothing calls this directly

Calls 5

GetPointerMethod · 0.80
SetInputImageMethod · 0.80
NewFunction · 0.50
UpdateMethod · 0.45
GetOutputMethod · 0.45

Tested by

no test coverage detected