From: dsarrut Date: Thu, 21 Apr 2011 07:24:41 +0000 (+0200) Subject: remove untracked file X-Git-Tag: v1.2.0~24^2~1 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=4dbf0ef8a94769c463bccd7ea8ea7a4ac7c700fd;p=clitk.git remove untracked file --- diff --git a/segmentation/clitkTestFilter.cxx b/segmentation/clitkTestFilter.cxx deleted file mode 100644 index 64716ed..0000000 --- a/segmentation/clitkTestFilter.cxx +++ /dev/null @@ -1,523 +0,0 @@ - -/*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv - - Authors belong to: - - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr - - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. - - It is distributed under dual licence - - - BSD See included LICENSE.txt file - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html - ======================================================================-====*/ - -// clitk -#include "clitkTestFilter_ggo.h" -#include "clitkImageCommon.h" -#include "clitkBooleanOperatorLabelImageFilter.h" -#include "clitkAutoCropFilter.h" -//#include "clitkRelativePositionConstraintLabelImageFilter.h" -#include "clitkResampleImageWithOptionsFilter.h" -#include "clitkAddRelativePositionConstraintToLabelImageFilter.h" -#include "clitkExtractLungFilter.h" -#include "clitkExtractPatientFilter.h" -#include "clitkExtractMediastinumFilter.h" -//#include "clitkTestStation7.h" -#include "clitkSegmentationUtils.h" -#include "clitkMorphoMathFilter.h" - -// ITK ENST -#include "RelativePositionPropImageFilter.h" - -// VTK -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - - -template -class comparePointsX { -public: - bool operator() (PointType i, PointType j) { return (i[0] -void HypercubeCorners(std::vector > & out) { - std::vector > previous; - HypercubeCorners(previous); - out.resize(previous.size()*2); - for(uint i=0; i p; - if (i -void HypercubeCorners<1>(std::vector > & out) { - out.resize(2); - out[0][0] = 0; - out[1][0] = 1; -} - - -//-------------------------------------------------------------------- -int main(int argc, char * argv[]) { - - // Init command line - GGO(clitkTestFilter, args_info); - - // Image types - //typedef unsigned char PixelType; - typedef short PixelType; - static const int Dim=3; - typedef itk::Image InputImageType; - - // Read inputs - InputImageType::Pointer input1; - InputImageType::Pointer input2; - InputImageType::Pointer input3; - if (args_info.input1_given) input1 = clitk::readImage(args_info.input1_arg, true); - if (args_info.input2_given) input2 = clitk::readImage(args_info.input2_arg, true); - if (args_info.input3_given) input3 = clitk::readImage(args_info.input3_arg, true); - - // Declare output - InputImageType::Pointer output; - - //-------------------------------------------------------------------- - // Filter test BooleanOperatorLabelImageFilter - if (0) { - typedef clitk::BooleanOperatorLabelImageFilter FilterType; - FilterType::Pointer filter = FilterType::New(); - filter->SetInput1(input1); - filter->SetInput2(input2); - output = clitk::NewImageLike(input1); - filter->GraftOutput(output); /// TO VERIFY !!! - filter->Update(); - filter->SetInput2(input3); - filter->Update(); - output = filter->GetOutput(); - clitk::writeImage(output, args_info.output_arg); - } - - //-------------------------------------------------------------------- - // Filter test AutoCropLabelImageFilter - if (0) { - typedef clitk::AutoCropFilter FilterType; - FilterType::Pointer filter = FilterType::New(); - filter->SetInput(input1); - filter->Update(); - output = filter->GetOutput(); - clitk::writeImage(output, args_info.output_arg); - } - - //-------------------------------------------------------------------- - // Filter test RelativePositionPropImageFilter - if (0) { - typedef itk::Image OutputImageType; - OutputImageType::Pointer outputf; - typedef itk::RelativePositionPropImageFilter FilterType; - FilterType::Pointer filter = FilterType::New(); - filter->SetInput(input1); - - filter->SetAlpha1(clitk::deg2rad(args_info.angle1_arg)); // xy plane - filter->SetAlpha2(clitk::deg2rad(args_info.angle2_arg)); - filter->SetK1(M_PI/2.0); // Opening parameter, default = pi/2 - filter->SetFast(true); - filter->SetRadius(2); - filter->SetVerboseProgress(true); - - /* A1 A2 - Left 0 0 - Right 180 0 - Ant 90 0 - Post -90 0 - Inf 0 90 - Sup 0 -90 - */ - - filter->Update(); - clitk::writeImage(filter->GetOutput(), args_info.output_arg); - } - - //-------------------------------------------------------------------- - // Filter test - if (0) { - typedef itk::Image OutputImageType; - typedef clitk::ResampleImageWithOptionsFilter FilterType; - FilterType::Pointer filter = FilterType::New(); - filter->SetInput(input1); - filter->SetOutputIsoSpacing(1); - //filter->SetNumberOfThreads(4); // auto - filter->SetGaussianFilteringEnabled(false); - filter->Update(); - clitk::writeImage(filter->GetOutput(), args_info.output_arg); - } - - //-------------------------------------------------------------------- - // Filter AddRelativePositionConstraintToLabelImageFilter test - if (0) { - /* - typedef clitk::AddRelativePositionConstraintToLabelImageFilter FilterType; - FilterType::Pointer filter = FilterType::New(); - filter->SetInput(input1); - filter->SetInputObject(input2); - filter->SetOrientationType(FilterType::LeftTo); - filter->SetIntermediateSpacing(5); - filter->SetFuzzyThreshold(0.5); - filter->VerboseStepOn(); - filter->WriteStepOff(); - filter->Update(); - - filter->SetInput(filter->GetOutput()); - filter->SetInputObject(input2); - filter->SetOrientationType(FilterType::RightTo); - filter->SetIntermediateSpacing(5); - filter->SetFuzzyThreshold(0.5); - filter->Update(); - - clitk::writeImage(filter->GetOutput(), args_info.output_arg); - */ - } - - //-------------------------------------------------------------------- - // Filter test ExtractPatientFilter - if (0) { - /* - typedef itk::Image OutputImageType; - typedef clitk::ExtractPatientFilter FilterType; - FilterType::Pointer filter = FilterType::New(); - filter->SetInput(input1); - filter->VerboseStepOn(); - filter->WriteStepOn(); - // options (default) - filter->SetUpperThreshold(-300); - filter->FinalOpenCloseOff(); // default=on (not rezally needed ?) - filter->Update(); - OutputImageType::Pointer output = filter->GetOutput(); - clitk::writeImage(output, args_info.output_arg); - */ - } - - //-------------------------------------------------------------------- - // Filter test ExtractLungsFilter - if (0) { - /* - typedef itk::Image OutputImageType; // to change into char - typedef clitk::ExtractLungFilter FilterType; - FilterType::Pointer filter = FilterType::New(); - // DD(filter->GetNumberOfSteps()); - filter->SetInput(input1); // CT - filter->SetInputPatientMask(input2, 0); // Patient mask and BG value - filter->VerboseStepOn(); - filter->WriteStepOn(); - // options (default) - //filter->SetBackgroundValue(0); - filter->SetUpperThreshold(-300); - // filter->SetMinimumComponentSize(100); - - filter->Update(); - OutputImageType::Pointer output = filter->GetOutput(); - clitk::writeImage(output, args_info.output_arg); - */ - } - - //-------------------------------------------------------------------- - // Filter test ExtractMediastinumFilter - if (0) { - /* - typedef clitk::ExtractMediastinumFilter FilterType; - FilterType::Pointer filter = FilterType::New(); - filter->SetInputPatientLabelImage(input1); - filter->SetInputLungLabelImage(input2, 0, 1, 2); // BG, FG Left Lung, FG Right Lung - filter->SetInputBonesLabelImage(input3); - filter->VerboseStepOn(); - filter->WriteStepOn(); - filter->Update(); - output = filter->GetOutput(); - clitk::writeImage(output, args_info.output_arg); - */ - } - - //-------------------------------------------------------------------- - // Test for auto register sub-task in a segmentation process - if (0) { - // ExtractLymphStation_7 * s7 = new ExtractLymphStation_7; - // s7->SetArgsInfo(args_info); - // GetParent->SetArgsInfo<> - //s7->StartSegmentation(); - } - - //-------------------------------------------------------------------- - // Test for biinary image from a contour set - if (0) { - DD("here"); - - // Type of a slice - typedef itk::Image SliceType; - - // Build the list of slices - std::vector slices; - clitk::ExtractSlices(input1, 2, slices); - DD(slices.size()); - - // HOW TO DO SEVERAL BY SLICE !!! not a map ? - - // Compute centroids 3D centroids by slices - int BG = 0; - std::map > centroids3D; - for(uint i=0; i(slices[i], BG, true, 1); - // ComputeCentroids - std::vector temp; - clitk::ComputeCentroids(slices[i], BG, temp); - for(uint j=1; j::Convert2DTo3D(temp[j], input1, i, a); - centroids3D[i].push_back(a); - } - } - - // REPRENDRE POUR TOUT FAIRE BY SLICE (pas de i); - - // Take a given slice i=29 - int index=29; - SliceType::Pointer slice = slices[index]; - std::vector points = centroids3D[index]; - - // Sort points from R to L - std::sort(points.begin(), points.end(), - comparePointsX()); - - // Slice corners (quel sens ?) - - // Compute min and max coordinates - const uint dim=3; - typedef InputImageType::PointType PointType; - typedef InputImageType::IndexType IndexType; - PointType min_c, max_c; - IndexType min_i, max_i; - min_i = input1->GetLargestPossibleRegion().GetIndex(); - for(uint i=0; iGetLargestPossibleRegion().GetSize()[i] + min_i[i]; - input1->TransformIndexToPhysicalPoint(min_i, min_c); - input1->TransformIndexToPhysicalPoint(max_i, max_c); - - // Compute the corners coordinates - std::vector > l; - HypercubeCorners(l); - for(uint i=0; i mesh = vtkSmartPointer::New(); - mesh->Allocate(); //for cell structures - mesh->SetPoints(vtkPoints::New()); - vtkIdType ids[2]; - int point_number = points.size(); - for (unsigned int i=0; iGetPoints()->InsertNextPoint(points[i][0],points[i][1],points[i][2]); - ids[0]=i; - ids[1]=(ids[0]+1)%point_number; //0-1,1-2,...,n-1-0 - mesh->GetLines()->InsertNextCell(2,ids); - } - - vtkSmartPointer w = vtkSmartPointer::New(); - w->SetInput(mesh); - w->SetFileName("bidon.vtk"); - w->Write(); - - // binarize - DD("binarize"); - double *bounds=mesh->GetBounds(); - DDV(bounds, 6); - - DD("create image"); - vtkSmartPointer binary_image=vtkSmartPointer::New(); - binary_image->SetScalarTypeToUnsignedChar(); - ///Use the smallest mask in which the mesh fits - // Add two voxels on each side to make sure the mesh fits - // double * samp_origin= - InputImageType::PointType samp_origin = input1->GetOrigin(); - // double * - InputImageType::SpacingType spacing=input1->GetSpacing(); - double * spacing2 = new double[3]; - spacing2[0] = spacing[0]; - spacing2[1] = spacing[1]; - spacing2[2] = spacing[2]; - DD(spacing2[0]); - binary_image->SetSpacing(spacing2); - /// Put the origin on a voxel to avoid small skips - DD(floor((bounds[0]-samp_origin[0])/spacing[0]-2)*spacing[0]); - DD(bounds[0]); - DD(samp_origin[0]); - DD(spacing[0]); - binary_image->SetOrigin(//samp_origin[0], samp_origin[1], samp_origin[2]); - floor((bounds[0]-samp_origin[0])/spacing[0]-2)*spacing[0]+samp_origin[0], - floor((bounds[2]-samp_origin[1])/spacing[1]-2)*spacing[1]+samp_origin[1], - floor((bounds[4]-samp_origin[2])/spacing[2]-2)*spacing[2]+samp_origin[2]); - double * origin=binary_image->GetOrigin(); - binary_image->SetExtent(0,ceil((bounds[1]-origin[0])/spacing[0]+4), // Joel used +4 here (?) - 0,ceil((bounds[3]-origin[1])/spacing[1]+4), - 0,ceil((bounds[5]-origin[2])/spacing[2]+4)); - binary_image->AllocateScalars(); - memset(binary_image->GetScalarPointer(),0, - binary_image->GetDimensions()[0]*binary_image->GetDimensions()[1]*binary_image->GetDimensions()[2]*sizeof(unsigned char)); - - vtkSmartPointer sts=vtkSmartPointer::New(); - //The following line is extremely important - //http://www.nabble.com/Bug-in-vtkPolyDataToImageStencil--td23368312.html#a23370933 - sts->SetTolerance(0); - sts->SetInformationInput(binary_image); - - bool extrude=true; - if (extrude) { - vtkSmartPointer extrude=vtkSmartPointer::New(); - extrude->SetInput(mesh); - - /// NO ????We extrude in the -slice_spacing direction to respect the FOCAL convention ??? - - extrude->SetVector(0, 0, input1->GetSpacing()[2]);//slice_spacing); // 2* ? yes use a single one - sts->SetInput(extrude->GetOutput()); - } else - sts->SetInput(mesh); - - DD("stencil"); - vtkSmartPointer stencil=vtkSmartPointer::New(); - stencil->SetStencil(sts->GetOutput()); - stencil->SetInput(binary_image); - stencil->Update(); - - DD("write"); - vtkSmartPointer ww = vtkSmartPointer::New(); - ww->SetInput(stencil->GetOutput()); - ww->SetFileName("binary.mhd"); - ww->Write(); - } - //-------------------------------------------------------------------- - - //-------------------------------------------------------------------- - // Test for vessels ReconstructionByDilatation - if (1) { - // Read input CT (already croped) - // treshold 3D - // erode n times (or in 2D ?) - // slices extract - // SBS - // - CCL (keep mask) - // - for all CCL, ReconstructionByDilatation in initial mask - // joint for output - - // input1 - DD("binarize") - int BG = 0; - int FG = 1; - typedef itk::Image MaskImageType; - typedef itk::BinaryThresholdImageFilter BinarizeFilterType; - BinarizeFilterType::Pointer binarizeFilter = BinarizeFilterType::New(); - binarizeFilter->SetInput(input1); - binarizeFilter->SetLowerThreshold(150); - binarizeFilter->SetInsideValue(FG); - binarizeFilter->SetOutsideValue(BG); - binarizeFilter->Update(); - MaskImageType::Pointer mask = binarizeFilter->GetOutput(); - clitk::writeImage(mask, "m.mhd"); - - // Extract slices - typedef itk::Image SliceType; - std::vector slices_mask; - clitk::ExtractSlices(mask, 2, slices_mask); - DD(slices_mask.size()); - - std::vector debug_eroded; - std::vector debug_labeled; - - // Loop - for(uint i=0; i::Pointer f = clitk::MorphoMathFilter::New(); - f->SetInput(slices_mask[i]); - f->SetBackgroundValue(BG); - f->SetForegroundValue(FG); - f->SetRadius(1); - f->SetOperationType(0); // Erode - f->Update(); - SliceType::Pointer eroded = f->GetOutput(); - debug_eroded.push_back(eroded); - - // CCL - DD("CCL"); - SliceType::Pointer labeled = Labelize(slices_mask[i], 0, false, 10); - debug_labeled.push_back(labeled); - - // ReconstructionByDilatation - - - } // end loop - - MaskImageType::Pointer eroded = clitk::JoinSlices(debug_eroded, mask, 2); - clitk::writeImage(eroded, "eroded.mhd"); - - MaskImageType::Pointer labeled = clitk::JoinSlices(debug_labeled, mask, 2); - clitk::writeImage(labeled, "labeled.mhd"); - - } - //-------------------------------------------------------------------- - - // This is the end my friend - return EXIT_SUCCESS; -}// end main -//--------------------------------------------------------------------