diff --git a/Modules/SurfaceInterpolation/mitkImageToPointCloudFilter.cpp b/Modules/SurfaceInterpolation/mitkImageToPointCloudFilter.cpp index 56b2dc85d6..6f743f2fae 100644 --- a/Modules/SurfaceInterpolation/mitkImageToPointCloudFilter.cpp +++ b/Modules/SurfaceInterpolation/mitkImageToPointCloudFilter.cpp @@ -1,170 +1,153 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkImageToPointCloudFilter.h" #include #include #include #include #include #include #include mitk::ImageToPointCloudFilter::ImageToPointCloudFilter(): m_NumberOfExtractedPoints(0) { m_PointSurface = mitk::Surface::New(); - m_method = DetectConstant(0); + m_Method = DetectConstant(0); m_EdgeImage = mitk::Image::New(); m_EdgePoints = mitk::Image::New(); this->SetNumberOfRequiredInputs(1); this->SetNumberOfRequiredOutputs(1); this->SetNthOutput(0, m_PointSurface); } mitk::ImageToPointCloudFilter::~ImageToPointCloudFilter(){} -void mitk::ImageToPointCloudFilter::SetDetectionMethod(DetectionMethod method) -{ - this->m_method = method; -} - void mitk::ImageToPointCloudFilter::GenerateData() { mitk::Image::ConstPointer image = ImageToSurfaceFilter::GetInput(); m_Geometry = image->GetGeometry(); if ( image.IsNull() ) { - MITK_ERROR << "mitk::ImageToContourFilter: No input available. Please set the input!" << std::endl; + MITK_ERROR << "mitk::ImageToContourFilter: No input available. " + "Please set the input!" << std::endl; return; } - switch(m_method) + switch(m_Method) { case 0: this->LaplacianStdDev(image, 2); break; case 1: this->LaplacianStdDev(image, 3); break; default: this->LaplacianStdDev(image, 2); break; } } - -//! TODO GetEdgeImage und Bildkoordinaten in weltkoodinaten - -void mitk::ImageToPointCloudFilter::LaplacianStdDev(mitk::Image::ConstPointer image, int amount) +void mitk::ImageToPointCloudFilter:: + LaplacianStdDev(mitk::Image::ConstPointer image, int amount) { mitk::Image::Pointer notConstImage = image->Clone(); - AccessByItk_1(notConstImage.GetPointer(), StdDeviations, amount); + AccessByItk_1(notConstImage.GetPointer(), StdDeviations, amount) } template -void mitk::ImageToPointCloudFilter::StdDeviations(itk::Image* image, int amount) +void mitk::ImageToPointCloudFilter:: + StdDeviations(itk::Image* image, int amount) { typedef itk::Image InputImageType; - typedef itk::CastImageFilter< InputImageType, FloatImageType > ImagePTypeToFloatPTypeCasterType; - typename itk::LaplacianImageFilter< FloatImageType, FloatImageType >::Pointer lapFilter = itk::LaplacianImageFilter< FloatImageType, FloatImageType >::New(); + typedef itk::CastImageFilter< InputImageType, FloatImageType > + ImagePTypeToFloatPTypeCasterType; + typename LaplacianFilterType::Pointer lapFilter = LaplacianFilterType::New(); - typename ImagePTypeToFloatPTypeCasterType::Pointer caster = ImagePTypeToFloatPTypeCasterType::New(); + typename ImagePTypeToFloatPTypeCasterType::Pointer caster = + ImagePTypeToFloatPTypeCasterType::New(); caster->SetInput( image ); caster->Update(); FloatImageType::Pointer fImage = caster->GetOutput(); lapFilter->SetInput(fImage); lapFilter->UpdateLargestPossibleRegion(); m_EdgeImage = mitk::ImportItkImage(lapFilter->GetOutput())->Clone(); - mitk::ImageStatisticsCalculator::Pointer statCalc = mitk::ImageStatisticsCalculator::New(); + mitk::ImageStatisticsCalculator::Pointer statCalc = + mitk::ImageStatisticsCalculator::New(); statCalc->SetImage(m_EdgeImage); statCalc->ComputeStatistics(); mitk::ImageStatisticsCalculator::Statistics stats = statCalc->GetStatistics(); double mean = stats.GetMean(); double stdDev = stats.GetSigma(); double upperThreshold = mean + stdDev * amount; double lowerThreshold = mean - stdDev * amount; typename itk::ImageRegionIterator it(lapFilter->GetOutput(), - lapFilter->GetOutput()->GetRequestedRegion()); + lapFilter->GetOutput()->GetRequestedRegion()); vtkSmartPointer points = vtkSmartPointer::New(); it.GoToBegin(); while( !it.IsAtEnd() ) { if(it.Get() > lowerThreshold && it.Get() < upperThreshold) { it.Set(0); } else { it.Set(1); mitk::Point3D imagePoint; mitk::Point3D worldPoint; imagePoint[0] = it.GetIndex()[0]; imagePoint[1] = it.GetIndex()[1]; imagePoint[2] = it.GetIndex()[2]; m_Geometry->IndexToWorld(imagePoint, worldPoint); points->InsertNextPoint(worldPoint[0],worldPoint[1],worldPoint[2]); m_NumberOfExtractedPoints++; } ++it; } m_EdgePoints = mitk::ImportItkImage(lapFilter->GetOutput())->Clone(); vtkSmartPointer polyData = vtkSmartPointer::New(); polyData->SetPoints(points); polyData->BuildCells(); polyData->BuildLinks(); m_PointSurface->SetVtkPolyData(polyData); } void mitk::ImageToPointCloudFilter::GenerateOutputInformation() { Superclass::GenerateOutputInformation(); } - -mitk::Image::Pointer mitk::ImageToPointCloudFilter::GetEdgeImage() -{ - return this->m_EdgeImage; -} - -mitk::Image::Pointer mitk::ImageToPointCloudFilter::GetEdgePoints() -{ - return this->m_EdgePoints; -} - -int mitk::ImageToPointCloudFilter::GetNumberOfExtractedPoints() -{ - return this->m_NumberOfExtractedPoints; -} diff --git a/Modules/SurfaceInterpolation/mitkImageToPointCloudFilter.h b/Modules/SurfaceInterpolation/mitkImageToPointCloudFilter.h index 2a34996421..3583fb1427 100644 --- a/Modules/SurfaceInterpolation/mitkImageToPointCloudFilter.h +++ b/Modules/SurfaceInterpolation/mitkImageToPointCloudFilter.h @@ -1,90 +1,93 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef mitkImageToPointCloudFilter_h_Included #define mitkImageToPointCloudFilter_h_Included #include #include #include #include namespace mitk { enum MitkSurfaceInterpolation_EXPORT DetectConstant { LAPLACIAN_STD_DEV2, LAPLACIAN_STD_DEV3, CANNY_EDGE, THRESHOLD }; -class MitkSurfaceInterpolation_EXPORT ImageToPointCloudFilter: public ImageToSurfaceFilter +class MitkSurfaceInterpolation_EXPORT ImageToPointCloudFilter: + public ImageToSurfaceFilter { public: - mitkClassMacro( ImageToPointCloudFilter, ImageToSurfaceFilter); + mitkClassMacro( ImageToPointCloudFilter, ImageToSurfaceFilter) itkFactorylessNewMacro(Self) itkCloneMacro(Self) typedef itk::Image ImageType; typedef itk::Image DoubleImageType; typedef itk::Image FloatImageType; - typedef itk::LaplacianImageFilter< FloatImageType, FloatImageType > LaplacianFilterType; + typedef itk::LaplacianImageFilter< FloatImageType, FloatImageType > + LaplacianFilterType; typedef DetectConstant DetectionMethod; - void SetDetectionMethod(DetectionMethod method); + itkGetMacro(Method,DetectionMethod) + itkGetMacro(EdgeImage,mitk::Image::Pointer) + itkGetMacro(EdgePoints,mitk::Image::Pointer) + itkGetMacro(NumberOfExtractedPoints,int) - mitk::Image::Pointer GetEdgeImage(); - mitk::Image::Pointer GetEdgePoints(); - int GetNumberOfExtractedPoints(); + itkSetMacro(Method,DetectionMethod) protected: virtual void GenerateData(); virtual void GenerateOutputInformation(); ImageToPointCloudFilter(); virtual ~ImageToPointCloudFilter(); private: template void StdDeviations(itk::Image* image, int amount); void LaplacianStdDev(Image::ConstPointer image, int amount); mitk::Surface::Pointer m_PointSurface; mitk::BaseGeometry* m_Geometry; mitk::Image::Pointer m_EdgeImage; mitk::Image::Pointer m_EdgePoints; int m_NumberOfExtractedPoints; - DetectionMethod m_method; + DetectionMethod m_Method; }; } #endif