X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tools%2FclitkProfileImageGenericFilter.cxx;h=02394d3ca60231943e534a5d036dcf0911cd224a;hb=8ff622baaf93b0751a723c19d59e74a7f949c245;hp=3c6d6b79ff1f1d4084ddf5cb46a1639b77d73819;hpb=e01ff4c52156fd3827d8aed581a21cc236d9ac43;p=clitk.git diff --git a/tools/clitkProfileImageGenericFilter.cxx b/tools/clitkProfileImageGenericFilter.cxx index 3c6d6b7..02394d3 100644 --- a/tools/clitkProfileImageGenericFilter.cxx +++ b/tools/clitkProfileImageGenericFilter.cxx @@ -31,9 +31,12 @@ // itk include #include +#include #include + + namespace clitk { @@ -57,6 +60,30 @@ void ProfileImageGenericFilter::InitializeImageType() //-------------------------------------------------------------------- +//-------------------------------------------------------------------- +vtkFloatArray* ProfileImageGenericFilter::GetArrayX() +{ + return(mArrayX); +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +vtkFloatArray* ProfileImageGenericFilter::GetArrayY() +{ + return(mArrayY); +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +vtkFloatArray* ProfileImageGenericFilter::GetCoord() +{ + return(mCoord); +} +//-------------------------------------------------------------------- + + //-------------------------------------------------------------------- void ProfileImageGenericFilter::SetArgsInfo(const args_info_type & a) { @@ -88,7 +115,18 @@ ProfileImageGenericFilter::UpdateWithInputImageType() typename InputImageType::Pointer input = this->template GetInput(0); typedef typename InputImageType::PixelType PixelType; typedef typename InputImageType::IndexType IndexType; - typedef itk::Image OutputImageType; + + mArrayX = vtkSmartPointer::New(); + mArrayY = vtkSmartPointer::New(); + mCoord = vtkSmartPointer::New(); + mCoord->SetNumberOfComponents(InputImageType::ImageDimension); + + /*typename InputImageType::Pointer outputImage; + outputImage = InputImageType::New(); + + outputImage->SetRegions(input->GetLargestPossibleRegion()); + outputImage->Allocate(); + outputImage->FillBuffer(0); */ //Iterator IndexType pointBegin, pointEnd; @@ -100,54 +138,48 @@ ProfileImageGenericFilter::UpdateWithInputImageType() itk::LineConstIterator itProfile(input, pointBegin, pointEnd); 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 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); + // Fille in the table the voxel coordinate value + mCoord->InsertNextTuple(tuple); + ++lineNumber; ++itProfile; } - - // Filter - //typedef itk::BinaryThresholdImageFilter BinaryThresholdImageFilterType; - //typename BinaryThresholdImageFilterType::Pointer thresholdFilter=BinaryThresholdImageFilterType::New(); - //thresholdFilter->SetInput(input); - /*thresholdFilter->SetInsideValue(mArgsInfo.fg_arg); - - if (mArgsInfo.lower_given) thresholdFilter->SetLowerThreshold(static_cast(mArgsInfo.lower_arg)); - if (mArgsInfo.upper_given) thresholdFilter->SetUpperThreshold(static_cast(mArgsInfo.upper_arg)); - - Three modes : - - FG -> only use FG value for pixel in the Foreground (or Inside), keep input values for outside - - BG -> only use BG value for pixel in the Background (or Outside), keep input values for inside - - both -> use FG and BG (real binary image) - if (mArgsInfo.mode_arg == std::string("both")) { - thresholdFilter->SetOutsideValue(mArgsInfo.bg_arg); - thresholdFilter->Update(); - typename OutputImageType::Pointer outputImage = thresholdFilter->GetOutput(); - this->template SetNextOutput(outputImage); - } else { - typename InputImageType::Pointer outputImage; - thresholdFilter->SetOutsideValue(0); - if (mArgsInfo.mode_arg == std::string("BG")) { - typedef itk::MaskImageFilter maskFilterType; - typename maskFilterType::Pointer maskFilter = maskFilterType::New(); - maskFilter->SetInput1(input); - maskFilter->SetInput2(thresholdFilter->GetOutput()); - maskFilter->SetOutsideValue(mArgsInfo.bg_arg); - maskFilter->Update(); - outputImage = maskFilter->GetOutput(); - } else { - typedef itk::MaskNegatedImageFilter maskFilterType; - typename maskFilterType::Pointer maskFilter = maskFilterType::New(); - maskFilter->SetInput1(input); - maskFilter->SetInput2(thresholdFilter->GetOutput()); - maskFilter->SetOutsideValue(mArgsInfo.fg_arg); - maskFilter->Update(); - outputImage = maskFilter->GetOutput(); - } - // Write/Save results - this->template SetNextOutput(outputImage); - }*/ + /* + itk::LineIterator otProfile(outputImage, pointBegin, pointEnd); + otProfile.GoToBegin(); + while (!otProfile.IsAtEnd()) + { + otProfile.Set(1.0); + ++otProfile; + } + + this->template SetNextOutput(outputImage): */ + + delete [] tuple; } //--------------------------------------------------------------------