Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkImageToItk.h
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 #ifndef IMAGETOITK_H_HEADER_INCLUDED_C1C2FCD2
18 #define IMAGETOITK_H_HEADER_INCLUDED_C1C2FCD2
19 
20 #include "mitkImage.h"
21 #include "mitkImageDataItem.h"
22 #include "mitkImageWriteAccessor.h"
23 
24 #include <itkImage.h>
25 #include <itkImageSource.h>
26 
27 namespace mitk
28 {
36  template <class TOutputImage>
37  class ImageToItk : public itk::ImageSource<TOutputImage>
38  {
39  protected:
42 
43  public:
44  typedef ImageToItk Self;
45  typedef itk::ImageSource<TOutputImage> Superclass;
48 
50  itkFactorylessNewMacro(Self) itkCloneMacro(Self)
51 
53  typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
54 
57  typedef InputImageType::Pointer InputImagePointer;
58  typedef InputImageType::ConstPointer InputImageConstPointer;
60  typedef typename TOutputImage::SizeType SizeType;
61  typedef typename TOutputImage::IndexType IndexType;
62  typedef typename TOutputImage::RegionType RegionType;
63  typedef typename TOutputImage::PixelType PixelType;
64  typedef typename TOutputImage::InternalPixelType InternalPixelType;
65  typedef typename TOutputImage::PixelContainer PixelContainer;
66 
67  virtual void SetInput(mitk::Image *input);
68  virtual void SetInput(const mitk::Image *input);
69  // virtual void SetInput(unsigned int index, mitk::Image * image);
70  // virtual void SetInput(unsigned int index, const mitk::Image * image);
71 
72  virtual void UpdateOutputInformation() override;
73 
74  itkGetMacro(Channel, int);
75  itkSetMacro(Channel, int);
76 
77  itkSetMacro(CopyMemFlag, bool);
78  itkGetMacro(CopyMemFlag, bool);
79  itkBooleanMacro(CopyMemFlag);
80 
81  itkSetMacro(Options, int);
82  itkGetMacro(Options, int);
83 
84  protected:
85  using itk::ProcessObject::SetInput;
86  mitk::Image *GetInput(void);
87  const mitk::Image *GetInput() const;
88 
89  ImageToItk() : m_CopyMemFlag(false), m_Channel(0), m_Options(mitk::ImageAccessorBase::DefaultBehavior) {}
90  virtual ~ImageToItk() {}
91  void PrintSelf(std::ostream &os, itk::Indent indent) const override;
92 
93  virtual void GenerateData() override;
94 
95  virtual void GenerateOutputInformation() override;
96 
97  private:
98  bool m_CopyMemFlag;
99  int m_Channel;
100  int m_Options;
101 
102  bool m_ConstInput;
103 
104  // ImageToItk(const Self&); //purposely not implemented
105  void operator=(const Self &); // purposely not implemented
106 
107  void CheckInput(const mitk::Image *image) const;
108  };
109 
134  template <typename TPixel, unsigned int VDimension>
136  {
138  typedef mitk::ImageToItk<ImageType> ImageToItkType;
140  imagetoitk->SetInput(mitkImage);
141  imagetoitk->Update();
142  return imagetoitk->GetOutput();
143  }
144 
169  template <typename TPixel, unsigned int VDimension>
171  {
173  typedef mitk::ImageToItk<ImageType> ImageToItkType;
175  imagetoitk->SetInput(mitkImage);
176  imagetoitk->Update();
177  return imagetoitk->GetOutput();
178  }
179 
180 } // end namespace mitk
181 
182 #ifndef ITK_MANUAL_INSTANTIATION
183 #include "mitkImageToItk.txx"
184 #endif
185 
186 #endif // IMAGETOITK_H_HEADER_INCLUDED_C1C2FCD2
TOutputImage::SizeType SizeType
virtual void GenerateOutputInformation() override
ImageTypeTrait< TPixel, VDimension >::ImageType::Pointer ImageToItkImage(mitk::Image *mitkImage)
Convert a MITK image to an ITK image.
TOutputImage::RegionType RegionType
itk::SmartPointer< const Self > ConstPointer
TOutputImage::InternalPixelType InternalPixelType
DataCollection - Class to facilitate loading/accessing structured data.
itk::Image< TPixelType, VDimension > ImageType
mitk::Image * GetInput(void)
map::core::discrete::Elements< 3 >::InternalImageType ImageType
virtual void GenerateData() override
Super class of data objects consisting of slices.
virtual void UpdateOutputInformation() override
mitk::Image::Pointer m_MitkImage
itk::SmartPointer< Self > Pointer
Image class for storing images.
Definition: mitkImage.h:76
TOutputImage::PixelType PixelType
mitk::ImageDataItem::Pointer m_ImageDataItem
void PrintSelf(std::ostream &os, itk::Indent indent) const override
TOutputImage::IndexType IndexType
TOutputImage::PixelContainer PixelContainer
virtual void SetInput(mitk::Image *input)
SlicedData::RegionType InputImageRegionType
itk::ImageSource< TOutputImage > Superclass
virtual ~ImageToItk()
Superclass::OutputImageRegionType OutputImageRegionType
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.