Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
itkShCoefficientImageExporter.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 #ifndef __itkShCoefficientImageExporter_cpp
17 #define __itkShCoefficientImageExporter_cpp
18 
19 #include <time.h>
20 #include <stdio.h>
21 #include <stdlib.h>
22 
24 #include <itkImageRegionIterator.h>
25 #include <boost/math/special_functions.hpp>
26 
27 using namespace boost::math;
28 
29 namespace itk {
30 
31 template< class PixelType, int ShOrder >
33 {
34 
35 }
36 
37 template< class PixelType, int ShOrder >
40 {
41  if (m_InputImage.IsNull())
42  return;
43 
44  Vector<double, 4> spacing4;
45  Point<float, 4> origin4;
46  Matrix<double, 4, 4> direction4; direction4.SetIdentity();
47  ImageRegion<4> imageRegion4;
48 
49  Vector<double, 3> spacing3 = m_InputImage->GetSpacing();
50  Point<float, 3> origin3 = m_InputImage->GetOrigin();
51  Matrix<double, 3, 3> direction3 = m_InputImage->GetDirection();
52  ImageRegion<3> imageRegion3 = m_InputImage->GetLargestPossibleRegion();
53 
54  spacing4[0] = spacing3[0]; spacing4[1] = spacing3[1]; spacing4[2] = spacing3[2]; spacing4[3] = 1;
55  origin4[0] = origin3[0]; origin4[1] = origin3[1]; origin4[2] = origin3[2]; origin4[3] = 0;
56  for (int r=0; r<3; r++)
57  for (int c=0; c<3; c++)
58  direction4[r][c] = direction3[r][c];
59 
60  imageRegion4.SetSize(0, imageRegion3.GetSize()[0]);
61  imageRegion4.SetSize(1, imageRegion3.GetSize()[1]);
62  imageRegion4.SetSize(2, imageRegion3.GetSize()[2]);
63  imageRegion4.SetSize(3, (ShOrder*ShOrder + ShOrder + 2)/2 + ShOrder );
64 
65  m_OutputImage = CoefficientImageType::New();
66  m_OutputImage->SetSpacing( spacing4 );
67  m_OutputImage->SetOrigin( origin4 );
68  m_OutputImage->SetDirection( direction4 );
69  m_OutputImage->SetRegions( imageRegion4 );
70  m_OutputImage->Allocate();
71  m_OutputImage->FillBuffer(0.0);
72 
73  typedef ImageRegionConstIterator< InputImageType > InputIteratorType;
74  InputIteratorType it(m_InputImage, m_InputImage->GetLargestPossibleRegion());
75  int numCoeffs = imageRegion4.GetSize(3);
76 
77  while(!it.IsAtEnd())
78  {
79  CoefficientImageType::IndexType index;
80  index[0] = it.GetIndex()[0];
81  index[1] = it.GetIndex()[1];
82  index[2] = it.GetIndex()[2];
83 
84  for (int i=0; i<numCoeffs; i++)
85  {
86  index[3] = i;
87  m_OutputImage->SetPixel(index, it.Get()[i]);
88  }
89 
90  ++it;
91  }
92 }
93 
94 }
95 
96 #endif // __itkShCoefficientImageExporter_cpp
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.