1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18 #ifndef clitkProfileImageGenericFilter_cxx
19 #define clitkProfileImageGenericFilter_cxx
21 /* =================================================
22 * @file clitkProfileImageGenericFilter.cxx
23 * @author Thomas Baudier <thomas.baudier@creatis.insa-lyon.fr>
28 ===================================================*/
30 #include "clitkProfileImageGenericFilter.h"
33 #include <itkLineIterator.h>
36 #include <clitkCommon.h>
43 //--------------------------------------------------------------------
44 ProfileImageGenericFilter::ProfileImageGenericFilter():
45 ImageToImageGenericFilter<Self>("ProfileImage")
47 InitializeImageType<2>();
48 InitializeImageType<3>();
49 InitializeImageType<4>();
51 //--------------------------------------------------------------------
54 //--------------------------------------------------------------------
55 template<unsigned int Dim>
56 void ProfileImageGenericFilter::InitializeImageType()
58 ADD_DEFAULT_IMAGE_TYPES(Dim);
60 //--------------------------------------------------------------------
63 //--------------------------------------------------------------------
64 vtkFloatArray* ProfileImageGenericFilter::GetArrayX()
68 //--------------------------------------------------------------------
71 //--------------------------------------------------------------------
72 vtkFloatArray* ProfileImageGenericFilter::GetArrayY()
76 //--------------------------------------------------------------------
79 //--------------------------------------------------------------------
80 vtkFloatArray* ProfileImageGenericFilter::GetCoord()
84 //--------------------------------------------------------------------
87 //--------------------------------------------------------------------
88 void ProfileImageGenericFilter::SetArgsInfo(const args_info_type & a)
91 if (mArgsInfo.verbose_given)
92 SetIOVerbose(mArgsInfo.verbose_flag);
93 if (mArgsInfo.imagetypes_given && mArgsInfo.imagetypes_flag)
94 this->PrintAvailableImageTypes();
96 if (mArgsInfo.input_given) {
97 SetInputFilename(mArgsInfo.input_arg);
99 if (mArgsInfo.output_given) {
100 SetOutputFilename(mArgsInfo.output_arg);
103 //--------------------------------------------------------------------
106 //--------------------------------------------------------------------
107 // Update with the number of dimensions and the pixeltype
108 //--------------------------------------------------------------------
109 template<class InputImageType>
111 ProfileImageGenericFilter::UpdateWithInputImageType()
115 typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
116 typedef typename InputImageType::PixelType PixelType;
117 typedef typename InputImageType::IndexType IndexType;
119 mArrayX = vtkSmartPointer<vtkFloatArray>::New();
120 mArrayY = vtkSmartPointer<vtkFloatArray>::New();
121 mCoord = vtkSmartPointer<vtkFloatArray>::New();
122 mCoord->SetNumberOfComponents(InputImageType::ImageDimension);
124 /*typename InputImageType::Pointer outputImage;
125 outputImage = InputImageType::New();
127 outputImage->SetRegions(input->GetLargestPossibleRegion());
128 outputImage->Allocate();
129 outputImage->FillBuffer(0); */
132 IndexType pointBegin, pointEnd;
134 for (int i = 0; i < mArgsInfo.point1_given; ++i) {
135 pointBegin[i] = mArgsInfo.point1_arg[i];
136 pointEnd[i] = mArgsInfo.point2_arg[i];
139 itk::LineConstIterator<InputImageType> itProfile(input, pointBegin, pointEnd);
140 itProfile.GoToBegin();
144 tuple = new double[InputImageType::ImageDimension];
145 itk::Point<double, InputImageType::ImageDimension> transformedFirstPoint;
146 itk::Point<double, InputImageType::ImageDimension> transformedCurrentPoint;
148 input->TransformIndexToPhysicalPoint(itProfile.GetIndex(), transformedFirstPoint);
150 while (!itProfile.IsAtEnd())
152 // Fill in the table the intensity value
153 mArrayY->InsertNextTuple1(itProfile.Get());
155 for (int i=0; i<InputImageType::ImageDimension; ++i) {
156 tuple[i] = itProfile.GetIndex()[i];
159 input->TransformIndexToPhysicalPoint(itProfile.GetIndex(), transformedCurrentPoint);
160 distance = transformedFirstPoint.EuclideanDistanceTo(transformedCurrentPoint);
162 // Fill in the table the distance value
163 mArrayX->InsertNextTuple1(distance);
165 // Fille in the table the voxel coordinate value
166 mCoord->InsertNextTuple(tuple);
172 itk::LineIterator<InputImageType> otProfile(outputImage, pointBegin, pointEnd);
173 otProfile.GoToBegin();
174 while (!otProfile.IsAtEnd())
180 this->template SetNextOutput<InputImageType>(outputImage): */
184 //--------------------------------------------------------------------
189 #endif //#define clitkProfileImageGenericFilter_cxx