X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tools%2FclitkProfileImageGenericFilter.cxx;h=6c81756fbcf7adf9a3f51bfa0ad7fd753a73431f;hb=d9c8c6e6c759655fc24d05d47b962d2ba574b95d;hp=02394d3ca60231943e534a5d036dcf0911cd224a;hpb=c45f077f35553cdc72396626ac601080093d273b;p=clitk.git diff --git a/tools/clitkProfileImageGenericFilter.cxx b/tools/clitkProfileImageGenericFilter.cxx index 02394d3..6c81756 100644 --- a/tools/clitkProfileImageGenericFilter.cxx +++ b/tools/clitkProfileImageGenericFilter.cxx @@ -120,6 +120,9 @@ ProfileImageGenericFilter::UpdateWithInputImageType() mArrayY = vtkSmartPointer::New(); mCoord = vtkSmartPointer::New(); mCoord->SetNumberOfComponents(InputImageType::ImageDimension); + mCoordmm = vtkSmartPointer::New(); + mCoordmm->SetNumberOfComponents(InputImageType::ImageDimension); + mDimension = InputImageType::ImageDimension; /*typename InputImageType::Pointer outputImage; outputImage = InputImageType::New(); @@ -162,11 +165,20 @@ ProfileImageGenericFilter::UpdateWithInputImageType() // 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; iInsertNextTuple(tuple); //mm ++lineNumber; ++itProfile; } + + if (mArgsInfo.output_given) { + std::string str(mArgsInfo.output_arg); + this->WriteOutput(str); + } /* itk::LineIterator otProfile(outputImage, pointBegin, pointEnd); @@ -184,6 +196,58 @@ ProfileImageGenericFilter::UpdateWithInputImageType() //-------------------------------------------------------------------- +//-------------------------------------------------------------------- +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 (iGetNumberOfTuples()) { + fileOpen << i << "\t" << mArrayY->GetTuple(i)[0] << "\t" ; + + mCoord->GetTuple(i, tuple); + for (int j=0; jGetTuple(i, tuple); + for (int j=0; j