Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include <itkRescaleIntensityImageFilter.h>
18 #include <itkCastImageFilter.h>
19 
20 #include <mitkImageAccessByItk.h>
21 #include <mitkImageCast.h>
22 
24 
25 #include <mapExceptionObjectMacros.h>
26 
27 namespace mitk
28 {
29 
31  {
32  }
33 
35  {
36  }
37 
39  {
40  //nothing to do
41  }
42 
44  {
45  return false;
46  }
47 
49  {
50  return true;
51  }
52 
53  void RegEvaluationObject::SetRequestedRegion(const itk::DataObject*)
54  {
55  //nothing to do
56  }
57 
59  {
60  itkDebugMacro("setting TargetNode to " << tNode);
61 
62  m_TargetNode = tNode;
63 
64  if (tNode)
65  {
66  this->m_TargetImage = dynamic_cast<mitk::Image*>(tNode->GetData());
67  }
68 
69  this->Modified();
70  };
71 
73  {
74  itkDebugMacro("setting MovingNode to " << mNode);
75 
76  m_MovingNode = mNode;
77 
78  if (mNode)
79  {
80  this->m_MovingImage = dynamic_cast<mitk::Image*>(mNode->GetData());
81  }
82 
83  this->Modified();
84  };
85 
87  {
88  itkDebugMacro("setting TargetImage to " << tImg);
89 
91 
92  this->Modified();
93  };
94 
96  {
97  itkDebugMacro("setting MovingImage to " << mImg);
98 
100 
101  this->Modified();
102  };
103 
104  template <typename TPixelType, unsigned int VImageDimension >
105  void RegEvaluationObject::doConversion(const ::itk::Image<TPixelType,VImageDimension>* input, mitk::Image::Pointer& result) const
106  {
107  typedef ::itk::Image<TPixelType, VImageDimension> InputImageType;
108  typedef itk::CastImageFilter<InputImageType, InternalImageType> CastFilterType;
109  typedef itk::RescaleIntensityImageFilter<InputImageType, InputImageType> RescaleFilterType;
110 
111  typename CastFilterType::Pointer caster = CastFilterType::New();
113 
114  rescaler->SetInput(input);
115  rescaler->SetOutputMinimum(0);
116  rescaler->SetOutputMaximum(255);
117  caster->SetInput(rescaler->GetOutput());
118  caster->Update();
119  InternalImageType::Pointer internalImage = caster->GetOutput();
120 
121  mitk::CastToMitkImage<>(internalImage,result);
122  }
123 
124 
125  void RegEvaluationObject::PrintSelf (std::ostream &os, itk::Indent indent) const
126  {
127  Superclass::PrintSelf(os,indent);
128  if (m_Registration.IsNull())
129  {
130  os<< "Error. Eval object points to invalid registration (NULL).";
131  }
132  else
133  {
134  os<<std::endl<<indent<<"MatchPoint registration instance:";
135  m_Registration->Print(os,indent.GetNextIndent());
136  }
137 
138  if (m_TargetImage.IsNull())
139  {
140  os<< "Error. Eval object points to invalid target image (NULL).";
141  }
142  else
143  {
144  os<<std::endl<<indent<<"Target image instance:";
145  m_TargetImage->Print(os,indent.GetNextIndent());
146  }
147 
148  if (m_MovingImage.IsNull())
149  {
150  os<< "Error. Eval object points to invalid moving image (NULL).";
151  }
152  else
153  {
154  os<<std::endl<<indent<<"Moving image instance:";
155  m_MovingImage->Print(os,indent.GetNextIndent());
156  }
157 
158  }
159 
160 }
161 
virtual bool RequestedRegionIsOutsideOfTheBufferedRegion()
itk::SmartPointer< Self > Pointer
virtual void SetRequestedRegionToLargestPossibleRegion()
mitk::DataNode::ConstPointer m_MovingNode
mitk::DataNode::ConstPointer m_TargetNode
mitk::Image::Pointer m_TargetImage
#define AccessFixedDimensionByItk_n(mitkImage, itkImageTypeFunction, dimension, va_tuple)
Access a mitk-image with known dimension by an itk-image with one or more parameters.
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.
virtual void PrintSelf(std::ostream &os, itk::Indent indent) const
itk::Image< double, 3 > InputImageType
void SetTargetNode(const mitk::DataNode *tNode)
Image class for storing images.
Definition: mitkImage.h:76
void doConversion(const ::itk::Image< TPixelType, VImageDimension > *input, mitk::Image::Pointer &result) const
virtual void SetRequestedRegion(const itk::DataObject *)
void SetMovingNode(const mitk::DataNode *mNode)
void SetMovingImage(const mitk::Image *mImg)
mitk::MAPRegistrationWrapper::Pointer m_Registration
mitk::Image::Pointer m_MovingImage
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.