16 #ifndef __itkFslPeakImageConverter_cpp
17 #define __itkFslPeakImageConverter_cpp
24 #include <itkImageRegionConstIterator.h>
25 #include <itkImageRegionConstIteratorWithIndex.h>
26 #include <itkImageRegionIterator.h>
27 #include <itkContinuousIndex.h>
29 #include <vtkSmartPointer.h>
30 #include <vtkPolyData.h>
31 #include <vtkCellArray.h>
32 #include <vtkPoints.h>
33 #include <vtkPolyLine.h>
38 template<
class PixelType >
40 m_NormalizationMethod(NO_NORM)
45 template<
class PixelType >
53 Vector<float, 4> spacing4 = m_InputImages->GetElement(0)->GetSpacing();
54 Point<float, 4> origin4 = m_InputImages->GetElement(0)->GetOrigin();
55 Matrix<double, 4, 4> direction4 = m_InputImages->GetElement(0)->GetDirection();
56 ImageRegion<4> imageRegion4 = m_InputImages->GetElement(0)->GetLargestPossibleRegion();
58 itk::Vector<double,3> spacing3;
59 Point<float, 3> origin3;
60 Matrix<double, 3, 3> direction3;
61 ImageRegion<3> imageRegion3;
63 spacing3[0] = spacing4[0]; spacing3[1] = spacing4[1]; spacing3[2] = spacing4[2];
64 origin3[0] = origin4[0]; origin3[1] = origin4[1]; origin3[2] = origin4[2];
65 for (
int r=0; r<3; r++)
66 for (
int c=0; c<3; c++)
67 direction3[r][c] = direction4[r][c];
68 imageRegion3.SetSize(0, imageRegion4.GetSize()[0]);
69 imageRegion3.SetSize(1, imageRegion4.GetSize()[1]);
70 imageRegion3.SetSize(2, imageRegion4.GetSize()[2]);
72 double minSpacing = spacing3[0];
73 if (spacing3[1]<minSpacing)
74 minSpacing = spacing3[1];
75 if (spacing3[2]<minSpacing)
76 minSpacing = spacing3[2];
80 typedef ImageRegionConstIterator< InputImageType > InputIteratorType;
81 for (
int i=0; i<m_InputImages->Size(); i++)
84 int x = img->GetLargestPossibleRegion().GetSize(0);
85 int y = img->GetLargestPossibleRegion().GetSize(1);
86 int z = img->GetLargestPossibleRegion().GetSize(2);
89 directionImage->SetSpacing( spacing3 );
90 directionImage->SetOrigin( origin3 );
91 directionImage->SetDirection( direction3 );
92 directionImage->SetRegions( imageRegion3 );
93 directionImage->Allocate();
94 Vector< PixelType, 3 > nullVec; nullVec.Fill(0.0);
95 directionImage->FillBuffer(nullVec);
97 for (
int a=0; a<x; a++)
98 for (
int b=0; b<y; b++)
99 for (
int c=0; c<z; c++)
102 typename InputImageType::IndexType index;
103 index.SetElement(0,a);
104 index.SetElement(1,b);
105 index.SetElement(2,c);
106 vnl_vector<double> dirVec; dirVec.set_size(4);
107 for (
int k=0; k<3; k++)
109 index.SetElement(3,k);
110 dirVec[k] = img->GetPixel(index);
115 itk::ContinuousIndex<double, 4> center;
116 center[0] = index[0];
117 center[1] = index[1];
118 center[2] = index[2];
120 itk::Point<double, 4> worldCenter;
121 img->TransformContinuousIndexToPhysicalPoint( center, worldCenter );
123 switch (m_NormalizationMethod)
127 case SINGLE_VEC_NORM:
132 dirVec = img->GetDirection()*dirVec;
134 itk::Point<double> worldStart;
135 worldStart[0] = worldCenter[0]-dirVec[0]/2 * minSpacing;
136 worldStart[1] = worldCenter[1]-dirVec[1]/2 * minSpacing;
137 worldStart[2] = worldCenter[2]-dirVec[2]/2 * minSpacing;
138 vtkIdType
id = m_VtkPoints->InsertNextPoint(worldStart.GetDataPointer());
139 container->GetPointIds()->InsertNextId(
id);
140 itk::Point<double> worldEnd;
141 worldEnd[0] = worldCenter[0]+dirVec[0]/2 * minSpacing;
142 worldEnd[1] = worldCenter[1]+dirVec[1]/2 * minSpacing;
143 worldEnd[2] = worldCenter[2]+dirVec[2]/2 * minSpacing;
144 id = m_VtkPoints->InsertNextPoint(worldEnd.GetDataPointer());
145 container->GetPointIds()->InsertNextId(
id);
146 m_VtkCellArray->InsertNextCell(container);
149 typename ItkDirectionImageType::IndexType index2;
150 index2[0] = index[0]; index2[1] = index[1]; index2[2] = index[2];
153 Vector< PixelType, 3 > pixel;
154 pixel.SetElement(0, dirVec[0]);
155 pixel.SetElement(1, dirVec[1]);
156 pixel.SetElement(2, dirVec[2]);
157 directionImage->SetPixel(index2, pixel);
160 m_DirectionImageContainer->InsertElement(m_DirectionImageContainer->Size(), directionImage);
164 directionsPolyData->SetPoints(m_VtkPoints);
165 directionsPolyData->SetLines(m_VtkCellArray);
171 #endif // __itkFslPeakImageConverter_cpp
itk::SmartPointer< Self > Pointer
void GenerateData() override
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.