option "input" i "Input image filename" string yes
option "output" o "Output texte filename" string yes
-option "point1" f "First point (mm)" double yes multiple(-4)
-option "point2" s "Second point (mm)" double yes multiple(-4)
+option "point1" f "First point (vox)" double yes multiple(-4)
+option "point2" s "Second point (vox)" double yes multiple(-4)
mArrayY = vtkSmartPointer<vtkFloatArray>::New();
mCoord = vtkSmartPointer<vtkFloatArray>::New();
mCoord->SetNumberOfComponents(InputImageType::ImageDimension);
+ mCoordmm = vtkSmartPointer<vtkFloatArray>::New();
+ mCoordmm->SetNumberOfComponents(InputImageType::ImageDimension);
+ mDimension = InputImageType::ImageDimension;
/*typename InputImageType::Pointer outputImage;
outputImage = InputImageType::New();
// Fill in the table the distance value
mArrayX->InsertNextTuple1(distance);
- // Fille in the table the voxel coordinate value
- mCoord->InsertNextTuple(tuple);
+ // Fill in the table the voxel coordinate value
+ mCoord->InsertNextTuple(tuple); //index
+ for (int i=0; i<InputImageType::ImageDimension; ++i) {
+ tuple[i] = transformedCurrentPoint[i];
+ }
+ mCoordmm->InsertNextTuple(tuple); //mm
++lineNumber;
++itProfile;
}
+
+ if (mArgsInfo.output_given) {
+ std::string str(mArgsInfo.output_arg);
+ this->WriteOutput(str);
+ }
/*
itk::LineIterator<InputImageType> otProfile(outputImage, pointBegin, pointEnd);
//--------------------------------------------------------------------
+//--------------------------------------------------------------------
+void ProfileImageGenericFilter::WriteOutput(std::string outputFilename)
+{
+ ofstream fileOpen(outputFilename.c_str(), std::ofstream::trunc);
+
+ if(!fileOpen) {
+ cerr << "Error during saving" << endl;
+ return;
+ }
+
+ double *tuple;
+ tuple = new double[mDimension];
+ int i(0);
+ fileOpen << "The Bresenham algorithm is used to travel along the line. Values represent the center of each crossed voxel (in voxel and mm)" << endl;
+ fileOpen << "Id" << "\t" << "Value" << "\t" ;
+ fileOpen << "x(vox)" << "\t" << "y(vox)" << "\t";
+ if (mDimension >=3)
+ fileOpen << "z(vox)" << "\t";
+ if (mDimension >=4)
+ fileOpen << "t" << "\t";
+ fileOpen << "x(mm)" << "\t" << "y(mm)" << "\t";
+ if (mDimension >=3)
+ fileOpen << "z(mm)" << "\t";
+ if (mDimension >=4)
+ fileOpen << "t" << "\t";
+ fileOpen << endl;
+
+ while (i<mArrayX->GetNumberOfTuples()) {
+ fileOpen << i << "\t" << mArrayY->GetTuple(i)[0] << "\t" ;
+
+ mCoord->GetTuple(i, tuple);
+ for (int j=0; j<mDimension ; ++j) {
+ fileOpen << tuple[j] << "\t" ;
+ }
+ mCoordmm->GetTuple(i, tuple);
+ for (int j=0; j<mDimension ; ++j) {
+ fileOpen << tuple[j] << "\t" ;
+ }
+ if (mDimension == 4) {
+ fileOpen << tuple[3] << "\t" ;
+ }
+ fileOpen << endl;
+ ++i;
+ }
+
+ delete [] tuple;
+
+ fileOpen.close();
+}
+//--------------------------------------------------------------------
+
+
}//end clitk
#endif //#define clitkProfileImageGenericFilter_cxx
#include "clitkImageToImageGenericFilter.h"
#include "clitkProfileImage_ggo.h"
-#include <vtkIntArray.h>
#include <vtkFloatArray.h>
//--------------------------------------------------------------------
vtkFloatArray* GetArrayY();
vtkFloatArray* GetCoord();
+ //Write the output in the txt file
+ void WriteOutput(std::string outputFilename);
+
protected:
ProfileImageGenericFilter();
template<unsigned int Dim> void InitializeImageType();
vtkSmartPointer<vtkFloatArray> mArrayX;
vtkSmartPointer<vtkFloatArray> mArrayY;
vtkSmartPointer<vtkFloatArray> mCoord;
+ vtkSmartPointer<vtkFloatArray> mCoordmm;
+ int mDimension;
}; // end class
close();
return;
}
-
- vtkSmartPointer<vtkFloatArray> arrX = vtkSmartPointer<vtkFloatArray>::New();
- vtkSmartPointer<vtkFloatArray> arrY = vtkSmartPointer<vtkFloatArray>::New();
- vtkSmartPointer<vtkFloatArray> coords = vtkSmartPointer<vtkFloatArray>::New();
- arrX = mFilter->GetArrayX();
- arrY = mFilter->GetArrayY();
- coords = mFilter->GetCoord();
- double *tuple;
- tuple = new double[mCurrentSlicerManager->GetImage()->GetNumberOfDimensions()];
- int i(0);
- fileOpen << "The Bresenham algorithm is used to travel along the line. Values represent the center of each crossed voxel (in voxel and mm)" << endl;
- fileOpen << "Id" << "\t" << "Value" << "\t" ;
- fileOpen << "x(vox)" << "\t" << "y(vox)" << "\t";
- if (mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() >=3)
- fileOpen << "z(vox)" << "\t";
- if (mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() >=4)
- fileOpen << "t" << "\t";
- fileOpen << "x(mm)" << "\t" << "y(mm)" << "\t";
- if (mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() >=3)
- fileOpen << "z(mm)" << "\t";
- if (mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() >=4)
- fileOpen << "t" << "\t";
- fileOpen << endl;
-
- while (i<arrX->GetNumberOfTuples()) {
- fileOpen << i << "\t" << arrY->GetTuple(i)[0] << "\t" ;
-
- coords->GetTuple(i, tuple);
- for (int j=0; j<mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() ; ++j) {
- fileOpen << tuple[j] << "\t" ;
- }
- int j(0);
- while (j<mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() && j<3) {
- fileOpen << tuple[j]*mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetSpacing()[j]+mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetOrigin()[j] << "\t" ;
- ++j;
- }
- if (mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() == 4) {
- fileOpen << tuple[3] << "\t" ;
- }
- fileOpen << endl;
- ++i;
- }
-
- delete [] tuple;
+
+ mFilter->WriteOutput(mTextFileName.c_str());
fileOpen.close();
QApplication::restoreOverrideCursor();