Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
typeExtension.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 // MITK
18 #include <mitkImageAccessByItk.h>
19 #include <mitkImageCast.h>
20 #include <mitkImageToItk.h>
21 #include <mitkPixelType.h>
22 
23 // ITK
24 #include <itkRGBPixel.h>
25 
26 namespace mitk
27 {
28  typedef itk::Image<itk::RGBPixel<unsigned short>, 3> itkImageRGBUS3;
29 
30  template void _CastToItkImage2Access(const itkImageRGBUS3 *, itk::SmartPointer<itkImageRGBUS3> &);
31 
32  template <typename TPixel, unsigned int VImageDimension, class ItkOutputImageType>
33  void _CastToItkImage2Access(const itk::Image<TPixel, VImageDimension> *itkInputImage,
35  {
36  typedef itk::Image<TPixel, VImageDimension> ItkInputImageType;
37  if (typeid(ItkInputImageType) == typeid(ItkOutputImageType))
38  {
39  itkOutputImage = const_cast<ItkOutputImageType *>(reinterpret_cast<const ItkOutputImageType *>(itkInputImage));
40  return;
41  }
42  typedef itk::CastImageFilter<ItkInputImageType, ItkOutputImageType> CastImageFilterType;
43  typename CastImageFilterType::Pointer castImageFilter = CastImageFilterType::New();
44  castImageFilter->SetInput(itkInputImage);
45  castImageFilter->Update();
46  itkOutputImage = castImageFilter->GetOutput();
47  }
48 
49  template <>
51  {
52  typedef itkImageRGBUS3 ItkOutputImageType;
53  AccessFixedTypeByItk_1(mitkImage,
55  (itk::RGBPixel<unsigned short>),
56  (ItkOutputImageType::ImageDimension),
57  itkOutputImage);
58  }
59 }
itk::SmartPointer< Self > Pointer
DataCollection - Class to facilitate loading/accessing structured data.
void CastToItkImage< itkImageRGBUS3 >(const mitk::Image *mitkImage, itk::SmartPointer< itkImageRGBUS3 > &itkOutputImage)
Definition: typeExtension.h:50
#define AccessFixedTypeByItk_1(mitkImage, itkImageTypeFunction, pixelTypeSeq, dimSeq, arg1)
Image class for storing images.
Definition: mitkImage.h:76
void _CastToItkImage2Access(const itk::Image< TPixel, VImageDimension > *itkInputImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Definition: typeExtension.h:33
itk::Image< itk::RGBPixel< unsigned short >, 3 > itkImageRGBUS3
Definition: typeExtension.h:28
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.