X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tools%2FclitkProfileImageGenericFilter.cxx;h=6c81756fbcf7adf9a3f51bfa0ad7fd753a73431f;hb=f48c960aef6e0a5a4edea516b062197db009e25f;hp=1eb58c28ffd93f95775ff3a5d2b8d9eb3fb14923;hpb=e502d745ac4c73037ef615931db2dcbf36a94341;p=clitk.git diff --git a/tools/clitkProfileImageGenericFilter.cxx b/tools/clitkProfileImageGenericFilter.cxx index 1eb58c2..6c81756 100644 --- a/tools/clitkProfileImageGenericFilter.cxx +++ b/tools/clitkProfileImageGenericFilter.cxx @@ -31,6 +31,7 @@ // itk include #include +#include #include @@ -119,6 +120,16 @@ 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(); + + outputImage->SetRegions(input->GetLargestPossibleRegion()); + outputImage->Allocate(); + outputImage->FillBuffer(0); */ //Iterator IndexType pointBegin, pointEnd; @@ -132,28 +143,111 @@ ProfileImageGenericFilter::UpdateWithInputImageType() itProfile.GoToBegin(); int lineNumber(1); double *tuple; + double distance; tuple = new double[InputImageType::ImageDimension]; + itk::Point transformedFirstPoint; + itk::Point transformedCurrentPoint; + + input->TransformIndexToPhysicalPoint(itProfile.GetIndex(), transformedFirstPoint); while (!itProfile.IsAtEnd()) { - // Fill in the table - mArrayX->InsertNextTuple1(lineNumber); + // Fill in the table the intensity value mArrayY->InsertNextTuple1(itProfile.Get()); for (int i=0; iTransformIndexToPhysicalPoint(itProfile.GetIndex(), transformedCurrentPoint); + distance = transformedFirstPoint.EuclideanDistanceTo(transformedCurrentPoint); + + // Fill in the table the distance value + mArrayX->InsertNextTuple1(distance); - 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); + otProfile.GoToBegin(); + while (!otProfile.IsAtEnd()) + { + otProfile.Set(1.0); + ++otProfile; + } + + this->template SetNextOutput(outputImage): */ delete [] tuple; } //-------------------------------------------------------------------- +//-------------------------------------------------------------------- +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