Medical Imaging Interaction Toolkit  2018.4.99-b7f3afaa
Medical Imaging Interaction Toolkit
mitkRegEvaluationObject.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include <itkRescaleIntensityImageFilter.h>
14 #include <itkCastImageFilter.h>
15 
16 #include <mitkImageAccessByItk.h>
17 #include <mitkImageCast.h>
18 
20 
21 #include <mapExceptionObjectMacros.h>
22 
23 namespace mitk
24 {
25 
27  {
28  }
29 
31  {
32  }
33 
35  {
36  //nothing to do
37  }
38 
40  {
41  return false;
42  }
43 
45  {
46  return true;
47  }
48 
49  void RegEvaluationObject::SetRequestedRegion(const itk::DataObject*)
50  {
51  //nothing to do
52  }
53 
55  {
56  itkDebugMacro("setting TargetNode to " << tNode);
57 
58  m_TargetNode = tNode;
59 
60  if (tNode)
61  {
62  this->m_TargetImage = dynamic_cast<mitk::Image*>(tNode->GetData());
63  }
64 
65  this->Modified();
66  };
67 
69  {
70  itkDebugMacro("setting MovingNode to " << mNode);
71 
72  m_MovingNode = mNode;
73 
74  if (mNode)
75  {
76  this->m_MovingImage = dynamic_cast<mitk::Image*>(mNode->GetData());
77  }
78 
79  this->Modified();
80  };
81 
83  {
84  itkDebugMacro("setting TargetImage to " << tImg);
85 
87 
88  this->Modified();
89  };
90 
92  {
93  itkDebugMacro("setting MovingImage to " << mImg);
94 
96 
97  this->Modified();
98  };
99 
100  template <typename TPixelType, unsigned int VImageDimension >
101  void RegEvaluationObject::doConversion(const ::itk::Image<TPixelType,VImageDimension>* input, mitk::Image::Pointer& result) const
102  {
103  typedef ::itk::Image<TPixelType, VImageDimension> InputImageType;
104  typedef itk::CastImageFilter<InputImageType, InternalImageType> CastFilterType;
105  typedef itk::RescaleIntensityImageFilter<InputImageType, InputImageType> RescaleFilterType;
106  typedef typename RescaleFilterType::OutputImagePixelType RescaleOutputPixelType;
107 
108  typename CastFilterType::Pointer caster = CastFilterType::New();
109  typename RescaleFilterType::Pointer rescaler = RescaleFilterType::New();
110 
111  rescaler->SetInput(input);
112  rescaler->SetOutputMinimum(0);
113  rescaler->SetOutputMaximum(std::min(itk::NumericTraits<RescaleOutputPixelType>::max(), static_cast<typename RescaleFilterType::OutputPixelType>(255)));
114  caster->SetInput(rescaler->GetOutput());
115  caster->Update();
116  InternalImageType::Pointer internalImage = caster->GetOutput();
117 
118  mitk::CastToMitkImage<>(internalImage,result);
119  }
120 
121 
122  void RegEvaluationObject::PrintSelf (std::ostream &os, itk::Indent indent) const
123  {
124  Superclass::PrintSelf(os,indent);
125  if (m_Registration.IsNull())
126  {
127  os<< "Error. Eval object points to invalid registration (nullptr).";
128  }
129  else
130  {
131  os<<std::endl<<indent<<"MatchPoint registration instance:";
132  m_Registration->Print(os,indent.GetNextIndent());
133  }
134 
135  if (m_TargetImage.IsNull())
136  {
137  os<< "Error. Eval object points to invalid target image (nullptr).";
138  }
139  else
140  {
141  os<<std::endl<<indent<<"Target image instance:";
142  m_TargetImage->Print(os,indent.GetNextIndent());
143  }
144 
145  if (m_MovingImage.IsNull())
146  {
147  os<< "Error. Eval object points to invalid moving image (nullptr).";
148  }
149  else
150  {
151  os<<std::endl<<indent<<"Moving image instance:";
152  m_MovingImage->Print(os,indent.GetNextIndent());
153  }
154 
155  }
156 
157 }
158 
void SetRequestedRegionToLargestPossibleRegion() override
mitk::DataNode::ConstPointer m_MovingNode
mitk::DataNode::ConstPointer m_TargetNode
mitk::Image::Pointer m_TargetImage
void SetRequestedRegion(const itk::DataObject *) override
#define AccessFixedDimensionByItk_n(mitkImage, itkImageTypeFunction, dimension, va_tuple)
Access a mitk-image with known dimension by an itk-image with one or more parameters.
void doConversion(const ::itk::Image< TPixelType, VImageDimension > *input, mitk::Image::Pointer &result) const
DataCollection - Class to facilitate loading/accessing structured data.
void SetTargetImage(const mitk::Image *tImg)
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
void SetTargetNode(const mitk::DataNode *tNode)
Image class for storing images.
Definition: mitkImage.h:72
static T max(T x, T y)
Definition: svm.cpp:56
void SetMovingNode(const mitk::DataNode *mNode)
static T min(T x, T y)
Definition: svm.cpp:53
bool RequestedRegionIsOutsideOfTheBufferedRegion() override
void SetMovingImage(const mitk::Image *mImg)
mitk::MAPRegistrationWrapper::Pointer m_Registration
mitk::Image::Pointer m_MovingImage
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57