19 #include <itkImageRegionIterator.h>
20 #include <itkLaplacianImageFilter.h>
22 #include <vtkPolyVertex.h>
23 #include <vtkUnstructuredGrid.h>
24 #include <vtkSmartPointer.h>
28 #include <mitkImageStatisticsCalculator.h>
35 this->SetNumberOfRequiredInputs(1);
37 this->SetNumberOfIndexedOutputs(1);
47 m_Geometry = image->GetGeometry();
51 MITK_ERROR <<
"mitk::ImageToContourFilter: No input available. "
52 "Please set the input!"
62 AccessByItk_1(notConstImage.GetPointer(), StdDeviations, 2)
break;
65 AccessByItk_1(notConstImage.GetPointer(), StdDeviations, 3)
break;
68 AccessByItk_1(notConstImage.GetPointer(), StdDeviations, 4)
break;
71 AccessByItk_1(notConstImage.GetPointer(), StdDeviations, 2)
break;
75 template <
typename TPixel,
unsigned int VImageDimension>
76 void mitk::ImageToPointCloudFilter::StdDeviations(itk::Image<TPixel, VImageDimension> *image,
int amount)
79 typedef itk::CastImageFilter<InputImageType, FloatImageType> ImagePTypeToFloatPTypeCasterType;
80 typedef itk::LaplacianImageFilter<FloatImageType, FloatImageType> LaplacianFilterType;
84 caster->SetInput(image);
88 lapFilter->SetInput(fImage);
89 lapFilter->UpdateLargestPossibleRegion();
94 statCalc->SetInputImage(edgeImage);
96 double mean = stats->GetMean();
97 double stdDev = stats->GetStd();
99 double upperThreshold = mean + stdDev * amount;
100 double lowerThreshold = mean - stdDev * amount;
102 typename itk::ImageRegionIterator<FloatImageType> it(lapFilter->GetOutput(),
103 lapFilter->GetOutput()->GetRequestedRegion());
107 double greatX = 0, greatY = 0, greatZ = 0;
110 while (!it.IsAtEnd())
112 if (it.Get() > lowerThreshold && it.Get() < upperThreshold)
123 imagePoint[0] = it.GetIndex()[0];
124 imagePoint[1] = it.GetIndex()[1];
125 imagePoint[2] = it.GetIndex()[2];
127 m_Geometry->IndexToWorld(imagePoint, worldPoint);
129 if (worldPoint[0] > greatX)
130 greatX = worldPoint[0];
131 if (worldPoint[1] > greatY)
132 greatY = worldPoint[1];
133 if (worldPoint[2] > greatZ)
134 greatZ = worldPoint[2];
136 points->InsertNextPoint(worldPoint[0], worldPoint[1], worldPoint[2]);
137 m_NumberOfExtractedPoints++;
146 verts->GetPointIds()->SetNumberOfIds(m_NumberOfExtractedPoints);
147 for (
int i = 0; i < m_NumberOfExtractedPoints; i++)
149 verts->GetPointIds()->SetId(i, i);
155 uGrid->InsertNextCell(verts->GetCellType(), verts->GetPointIds());
156 uGrid->SetPoints(points);
159 outputGrid->SetVtkUnstructuredGrid(uGrid);
160 this->SetNthOutput(0, outputGrid);
165 Superclass::GenerateOutputInformation();
itk::SmartPointer< Self > Pointer
virtual void GenerateOutputInformation()
itk::SmartPointer< Self > Pointer
#define AccessByItk_1(mitkImage, itkImageTypeFunction, arg1)
const mitk::Image * GetInput(void) const
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...
DetectionMethod
The method which calculates and extracts the edge pixels/points. For the edge detection the laplacian...
itk::Image< double, 3 > InputImageType
virtual ~ImageToPointCloudFilter()
Image class for storing images.
virtual void GenerateData()
ImageToPointCloudFilter()
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.