15 #include <itkImageRegionIterator.h> 16 #include <itkLaplacianImageFilter.h> 18 #include <vtkPolyVertex.h> 19 #include <vtkUnstructuredGrid.h> 20 #include <vtkSmartPointer.h> 32 this->SetNumberOfRequiredInputs(1);
34 this->SetNumberOfIndexedOutputs(1);
44 m_Geometry = image->GetGeometry();
48 MITK_ERROR <<
"mitk::ImageToContourFilter: No input available. " 49 "Please set the input!" 59 AccessByItk_1(notConstImage.GetPointer(), StdDeviations, 2)
break;
62 AccessByItk_1(notConstImage.GetPointer(), StdDeviations, 3)
break;
65 AccessByItk_1(notConstImage.GetPointer(), StdDeviations, 4)
break;
68 AccessByItk_1(notConstImage.GetPointer(), StdDeviations, 2)
break;
72 template <
typename TPixel,
unsigned int VImageDimension>
73 void mitk::ImageToPointCloudFilter::StdDeviations(itk::Image<TPixel, VImageDimension> *
image,
int amount)
76 typedef itk::CastImageFilter<InputImageType, FloatImageType> ImagePTypeToFloatPTypeCasterType;
77 typedef itk::LaplacianImageFilter<FloatImageType, FloatImageType> LaplacianFilterType;
78 typename LaplacianFilterType::Pointer lapFilter = LaplacianFilterType::New();
80 typename ImagePTypeToFloatPTypeCasterType::Pointer caster = ImagePTypeToFloatPTypeCasterType::New();
81 caster->SetInput(
image);
83 FloatImageType::Pointer fImage = caster->GetOutput();
85 lapFilter->SetInput(fImage);
86 lapFilter->UpdateLargestPossibleRegion();
91 statCalc->SetInputImage(edgeImage.GetPointer());
92 auto stats = statCalc->GetStatistics()->GetStatisticsForTimeStep(0);
96 double upperThreshold = mean + stdDev * amount;
97 double lowerThreshold = mean - stdDev * amount;
99 typename itk::ImageRegionIterator<FloatImageType> it(lapFilter->GetOutput(),
100 lapFilter->GetOutput()->GetRequestedRegion());
102 vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
104 double greatX = 0, greatY = 0, greatZ = 0;
107 while (!it.IsAtEnd())
109 if (it.Get() > lowerThreshold && it.Get() < upperThreshold)
120 imagePoint[0] = it.GetIndex()[0];
121 imagePoint[1] = it.GetIndex()[1];
122 imagePoint[2] = it.GetIndex()[2];
126 if (worldPoint[0] > greatX)
127 greatX = worldPoint[0];
128 if (worldPoint[1] > greatY)
129 greatY = worldPoint[1];
130 if (worldPoint[2] > greatZ)
131 greatZ = worldPoint[2];
133 points->InsertNextPoint(worldPoint[0], worldPoint[1], worldPoint[2]);
141 vtkSmartPointer<vtkPolyVertex> verts = vtkSmartPointer<vtkPolyVertex>::New();
146 verts->GetPointIds()->SetId(i, i);
149 vtkSmartPointer<vtkUnstructuredGrid> uGrid = vtkSmartPointer<vtkUnstructuredGrid>::New();
152 uGrid->InsertNextCell(verts->GetCellType(), verts->GetPointIds());
153 uGrid->SetPoints(points);
156 outputGrid->SetVtkUnstructuredGrid(uGrid);
157 this->SetNthOutput(0, outputGrid);
162 Superclass::GenerateOutputInformation();
void IndexToWorld(const mitk::Vector3D &vec_units, mitk::Vector3D &vec_mm) const
Convert (continuous or discrete) index coordinates of a vector vec_units to world coordinates (in mm)...
::mitk::Image InputImageType
#define AccessByItk_1(mitkImage, itkImageTypeFunction, arg1)
Image::Pointer ImportItkImage(const itk::SmartPointer< ItkOutputImageType > &itkimage, const BaseGeometry *geometry=nullptr, bool update=true)
Imports an itk::Image (with a specific type) as an mitk::Image.Instantiates instance of ITKImageImpor...
int m_NumberOfExtractedPoints
DetectionMethod
The method which calculates and extracts the edge pixels/points. For the edge detection the laplacian...
Image class for storing images.
mitk::Image::Pointer image
~ImageToPointCloudFilter() override
void GenerateData() override
static const std::string STANDARDDEVIATION()
void GenerateOutputInformation() override
const mitk::Image * GetInput(void) const
static const std::string MEAN()
ImageToPointCloudFilter()