diff --git a/Modules/AlgorithmsExt/test/mitkImageToUnstructuredGridFilterTest.cpp b/Modules/AlgorithmsExt/test/mitkImageToUnstructuredGridFilterTest.cpp index fc27e7a298..232a879bab 100644 --- a/Modules/AlgorithmsExt/test/mitkImageToUnstructuredGridFilterTest.cpp +++ b/Modules/AlgorithmsExt/test/mitkImageToUnstructuredGridFilterTest.cpp @@ -1,89 +1,89 @@ /*=================================================================== 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 "mitkTestingMacros.h" #include #include #include class mitkImageToUnstructuredGridFilterTestSuite : public mitk::TestFixture { CPPUNIT_TEST_SUITE(mitkImageToUnstructuredGridFilterTestSuite); MITK_TEST(testImageToUnstructuredGridFilterInitialization); MITK_TEST(testInput); MITK_TEST(testUnstructuredGridGeneration); MITK_TEST(testThreshold); CPPUNIT_TEST_SUITE_END(); private: /** Members used inside the different test methods. All members are initialized via setUp().*/ mitk::Image::Pointer m_BallImage; public: /** * @brief Setup Always call this method before each Test-case to ensure correct and new intialization of the used members for a new test case. (If the members are not used in a test, the method does not need to be called). */ void setUp() { m_BallImage = mitk::IOUtil::LoadImage(GetTestDataFilePath("BallBinary30x30x30.nrrd")); } void testImageToUnstructuredGridFilterInitialization() { mitk::ImageToUnstructuredGridFilter::Pointer testFilter = mitk::ImageToUnstructuredGridFilter::New(); CPPUNIT_ASSERT_MESSAGE("Testing instantiation of test object", testFilter.IsNotNull()); CPPUNIT_ASSERT_MESSAGE("Testing initialization of threshold member variable",testFilter->GetThreshold() == -0.1); } void testInput() { mitk::ImageToUnstructuredGridFilter::Pointer testFilter = mitk::ImageToUnstructuredGridFilter::New(); testFilter->SetInput(m_BallImage); CPPUNIT_ASSERT_MESSAGE("Testing set / get input!", testFilter->GetInput() == m_BallImage); } void testUnstructuredGridGeneration() { mitk::ImageToUnstructuredGridFilter::Pointer testFilter = mitk::ImageToUnstructuredGridFilter::New(); testFilter->SetInput(m_BallImage); testFilter->Update(); - CPPUNIT_ASSERT_MESSAGE("Testing surface generation!", testFilter->GetOutput() != NULL); + CPPUNIT_ASSERT_MESSAGE("Testing UnstructuredGrid generation!", testFilter->GetOutput() != NULL); } void testThreshold() { mitk::ImageToUnstructuredGridFilter::Pointer testFilter1 = mitk::ImageToUnstructuredGridFilter::New(); testFilter1->SetInput(m_BallImage); testFilter1->Update(); int numberOfPoints1 = testFilter1->GetNumberOfExtractedPoints(); mitk::ImageToUnstructuredGridFilter::Pointer testFilter2 = mitk::ImageToUnstructuredGridFilter::New(); testFilter2->SetInput(m_BallImage); testFilter2->SetThreshold(1.0); testFilter2->Update(); int numberOfPoints2 = testFilter2->GetNumberOfExtractedPoints(); CPPUNIT_ASSERT_MESSAGE("Testing Threshold", numberOfPoints1 > numberOfPoints2); } }; MITK_TEST_SUITE_REGISTRATION(mitkImageToUnstructuredGridFilter) diff --git a/Modules/Segmentation/Algorithms/mitkFeatureBasedEdgeDetectionFilter.h b/Modules/Segmentation/Algorithms/mitkFeatureBasedEdgeDetectionFilter.h index 5fbbaea82b..a3bd95c4be 100644 --- a/Modules/Segmentation/Algorithms/mitkFeatureBasedEdgeDetectionFilter.h +++ b/Modules/Segmentation/Algorithms/mitkFeatureBasedEdgeDetectionFilter.h @@ -1,77 +1,104 @@ /*=================================================================== 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 mitkFeatureBasedEdgeDetectionFilter_h_Included #define mitkFeatureBasedEdgeDetectionFilter_h_Included #include #include #include #include #include namespace mitk { +/** + * @brief Calculates edges and extracts them as an UnstructuredGrid with respect + * to the given segmentation. + * + * At first the statistic of the grey values within the segmentation is + * calculated. Based on this statistic a thresholding is executed. The + * thresholded image will be processed by morphological filters. The resulting + * image will be used for masking the input image. The masked image is used as + * input for the ImageToPointCloudFilter, which output is an UnstructuredGrid. + */ class MITKSEGMENTATION_EXPORT FeatureBasedEdgeDetectionFilter: public ImageToUnstructuredGridFilter { public: mitkClassMacro( FeatureBasedEdgeDetectionFilter, ImageToUnstructuredGridFilter) itkFactorylessNewMacro(Self) itkCloneMacro(Self) itkGetMacro(EdgeImage,mitk::Image::Pointer) itkGetMacro(EdgePoints,mitk::Image::Pointer) itkGetMacro(SegmentationMask, mitk::Image::Pointer) itkGetMacro(thresholdImage, mitk::Image::Pointer) itkGetMacro(morphThreshold, mitk::Image::Pointer) itkGetMacro(MaskedImage, mitk::Image::Pointer) + /** Sets the segmentation for calculating the statistics within that */ void SetSegmentationMask(mitk::Image::Pointer); protected: + /** This method is called by Update(). */ virtual void GenerateData(); + /** Initializes the output information */ virtual void GenerateOutputInformation(); + /** Constructor */ FeatureBasedEdgeDetectionFilter(); + /** Destructor */ virtual ~FeatureBasedEdgeDetectionFilter(); + /** Execute a thresholding filter with the given lower and upper bound */ template void ITKThresholding( itk::Image* originalImage, double lower, double upper); private: mitk::UnstructuredGrid::Pointer m_PointGrid; + + /** The used mask given by the segmentation*/ mitk::Image::Pointer m_SegmentationMask; + + /** The thesholded image */ mitk::Image::Pointer m_thresholdImage; + + /** The thesholded image after the morphological filters*/ mitk::Image::Pointer m_morphThreshold; + + /** The masked image */ mitk::Image::Pointer m_MaskedImage; + /** The generated image from the laplace filter */ mitk::Image::Pointer m_EdgeImage; + + /** The extracted pixels/points */ mitk::Image::Pointer m_EdgePoints; }; } #endif diff --git a/Modules/Segmentation/Testing/files.cmake b/Modules/Segmentation/Testing/files.cmake index b7d0da917d..c9b707401d 100644 --- a/Modules/Segmentation/Testing/files.cmake +++ b/Modules/Segmentation/Testing/files.cmake @@ -1,34 +1,35 @@ set(MODULE_TESTS mitkContourMapper2DTest.cpp mitkContourTest.cpp mitkContourModelSetToImageFilterTest.cpp mitkDataNodeSegmentationTest.cpp + mitkFeatureBasedEdgeDetectionFilterTest.cpp mitkImageToContourFilterTest.cpp # mitkSegmentationInterpolationTest.cpp mitkOverwriteSliceFilterTest.cpp mitkOverwriteSliceFilterObliquePlaneTest.cpp # mitkToolManagerTest.cpp mitkToolManagerProviderTest.cpp mitkManualSegmentationToSurfaceFilterTest.cpp #new cpp unit style ) if(MITK_ENABLE_RENDERING_TESTING) #since mitkInteractionTestHelper is currently creating a vtkRenderWindow set(MODULE_TESTS ${MODULE_TESTS} mitkToolInteractionTest.cpp ) endif() set(MODULE_IMAGE_TESTS mitkOverwriteSliceImageFilterTest.cpp #only runs on images ) set(MODULE_CUSTOM_TESTS ) set(MODULE_TESTIMAGES US4DCyl.nrrd Pic3D.nrrd Pic2DplusT.nrrd BallBinary30x30x30.nrrd Png2D-bw.png ) diff --git a/Modules/Segmentation/Testing/mitkFeatureBasedEdgeDetectionFilterTest.cpp b/Modules/Segmentation/Testing/mitkFeatureBasedEdgeDetectionFilterTest.cpp new file mode 100644 index 0000000000..0ce758e1e2 --- /dev/null +++ b/Modules/Segmentation/Testing/mitkFeatureBasedEdgeDetectionFilterTest.cpp @@ -0,0 +1,91 @@ +/*=================================================================== + +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 "mitkTestingMacros.h" +#include +#include + +#include + +class mitkFeatureBasedEdgeDetectionFilterTestSuite : public mitk::TestFixture +{ + CPPUNIT_TEST_SUITE(mitkFeatureBasedEdgeDetectionFilterTestSuite); + MITK_TEST(testFeatureBasedEdgeDetectionFilterInitialization); + MITK_TEST(testInput); + MITK_TEST(testUnstructuredGridGeneration); + CPPUNIT_TEST_SUITE_END(); + +private: + + /** Members used inside the different test methods. All members are initialized via setUp().*/ + mitk::Image::Pointer m_Pic3D; + mitk::Image::Pointer m_Segmentation; + +public: + + /** + * @brief Setup Always call this method before each Test-case to ensure correct and new intialization of the used members for a new test case. (If the members are not used in a test, the method does not need to be called). + */ + void setUp() + { + m_Pic3D = mitk::IOUtil::LoadImage(GetTestDataFilePath("Pic3D.nrrd")); + m_Segmentation = mitk::IOUtil::LoadImage(GetTestDataFilePath("PlaneSuggestion/pic3D_segmentation.nrrd")); + } + + void testFeatureBasedEdgeDetectionFilterInitialization() + { + mitk::FeatureBasedEdgeDetectionFilter::Pointer testFilter = mitk::FeatureBasedEdgeDetectionFilter::New(); + CPPUNIT_ASSERT_MESSAGE("Testing instantiation of test object", testFilter.IsNotNull()); + } + + void testInput() + { + mitk::FeatureBasedEdgeDetectionFilter::Pointer testFilter = mitk::FeatureBasedEdgeDetectionFilter::New(); + testFilter->SetInput(m_Pic3D); + CPPUNIT_ASSERT_MESSAGE("Testing set / get input!", testFilter->GetInput() == m_Pic3D); + } + + void testUnstructuredGridGeneration() + { + mitk::FeatureBasedEdgeDetectionFilter::Pointer testFilter = mitk::FeatureBasedEdgeDetectionFilter::New(); + testFilter->SetInput(m_Pic3D); + testFilter->SetSegmentationMask(m_Segmentation); + testFilter->Update(); + + mitk::Image::Pointer thresholdImage = testFilter->GetthresholdImage(); + mitk::Image::Pointer morphedThreshImage = testFilter->GetmorphThreshold(); + mitk::Image::Pointer maskedImage = testFilter->GetMaskedImage(); + mitk::Image::Pointer edge_image = testFilter->GetEdgeImage(); + mitk::Image::Pointer edge_points = testFilter->GetEdgePoints(); + + mitk::Image::Pointer ref_thresholdImage = mitk::IOUtil::LoadImage(GetTestDataFilePath("PlaneSuggestion/Threshold_Image.nrrd")); + mitk::Image::Pointer ref_morphedThreshImage = mitk::IOUtil::LoadImage(GetTestDataFilePath("PlaneSuggestion/MorphThreshold_Image.nrrd")); + mitk::Image::Pointer ref_maskedImage = mitk::IOUtil::LoadImage(GetTestDataFilePath("PlaneSuggestion/Masked_Image.nrrd")); + mitk::Image::Pointer ref_edge_image = mitk::IOUtil::LoadImage(GetTestDataFilePath("PlaneSuggestion/Edge_Image.nrrd")); + mitk::Image::Pointer ref_edge_points = mitk::IOUtil::LoadImage(GetTestDataFilePath("PlaneSuggestion/Edge_Points.nrrd")); + + MITK_ASSERT_EQUAL(thresholdImage, ref_thresholdImage, "Testing thresholded image!"); + MITK_ASSERT_EQUAL(morphedThreshImage, ref_morphedThreshImage, "Testing morphological thresholded image!"); + MITK_ASSERT_EQUAL(maskedImage, ref_maskedImage, "Testing masked image!"); + MITK_ASSERT_EQUAL(edge_image, ref_edge_image, "Testing edge image!"); + MITK_ASSERT_EQUAL(edge_points, ref_edge_points, "Testing extracted edge points!"); + + CPPUNIT_ASSERT_MESSAGE("Testing surface generation!", testFilter->GetOutput() != NULL); + } + +}; + +MITK_TEST_SUITE_REGISTRATION(mitkFeatureBasedEdgeDetectionFilter) diff --git a/Modules/SurfaceInterpolation/Testing/files.cmake b/Modules/SurfaceInterpolation/Testing/files.cmake index 79c0696ef9..673575b576 100644 --- a/Modules/SurfaceInterpolation/Testing/files.cmake +++ b/Modules/SurfaceInterpolation/Testing/files.cmake @@ -1,10 +1,11 @@ set(MODULE_TESTS mitkComputeContourSetNormalsFilterTest.cpp + mitkImageToPointCloudFilterTest.cpp mitkPointCloudScoringFilterTest mitkReduceContourSetFilterTest.cpp mitkSurfaceInterpolationControllerTest.cpp ) if(NOT WIN32) set(MODULE_TESTS ${MODULE_TESTS} mitkCreateDistanceImageFromSurfaceFilterTest.cpp) endif() diff --git a/Modules/AlgorithmsExt/test/mitkImageToUnstructuredGridFilterTest.cpp b/Modules/SurfaceInterpolation/Testing/mitkImageToPointCloudFilterTest.cpp similarity index 66% copy from Modules/AlgorithmsExt/test/mitkImageToUnstructuredGridFilterTest.cpp copy to Modules/SurfaceInterpolation/Testing/mitkImageToPointCloudFilterTest.cpp index fc27e7a298..e5d1c30fd7 100644 --- a/Modules/AlgorithmsExt/test/mitkImageToUnstructuredGridFilterTest.cpp +++ b/Modules/SurfaceInterpolation/Testing/mitkImageToPointCloudFilterTest.cpp @@ -1,89 +1,88 @@ /*=================================================================== 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 "mitkTestingMacros.h" -#include +#include #include #include -class mitkImageToUnstructuredGridFilterTestSuite : public mitk::TestFixture +class mitkImageToPointCloudFilterTestSuite : public mitk::TestFixture { - CPPUNIT_TEST_SUITE(mitkImageToUnstructuredGridFilterTestSuite); - MITK_TEST(testImageToUnstructuredGridFilterInitialization); + CPPUNIT_TEST_SUITE(mitkImageToPointCloudFilterTestSuite); + MITK_TEST(testImageToPointCloudFilterInitialization); MITK_TEST(testInput); MITK_TEST(testUnstructuredGridGeneration); MITK_TEST(testThreshold); CPPUNIT_TEST_SUITE_END(); private: /** Members used inside the different test methods. All members are initialized via setUp().*/ mitk::Image::Pointer m_BallImage; public: /** * @brief Setup Always call this method before each Test-case to ensure correct and new intialization of the used members for a new test case. (If the members are not used in a test, the method does not need to be called). */ void setUp() { m_BallImage = mitk::IOUtil::LoadImage(GetTestDataFilePath("BallBinary30x30x30.nrrd")); } - void testImageToUnstructuredGridFilterInitialization() + void testImageToPointCloudFilterInitialization() { mitk::ImageToUnstructuredGridFilter::Pointer testFilter = mitk::ImageToUnstructuredGridFilter::New(); CPPUNIT_ASSERT_MESSAGE("Testing instantiation of test object", testFilter.IsNotNull()); - CPPUNIT_ASSERT_MESSAGE("Testing initialization of threshold member variable",testFilter->GetThreshold() == -0.1); } void testInput() { - mitk::ImageToUnstructuredGridFilter::Pointer testFilter = mitk::ImageToUnstructuredGridFilter::New(); + mitk::ImageToPointCloudFilter::Pointer testFilter = mitk::ImageToPointCloudFilter::New(); testFilter->SetInput(m_BallImage); CPPUNIT_ASSERT_MESSAGE("Testing set / get input!", testFilter->GetInput() == m_BallImage); } void testUnstructuredGridGeneration() { - mitk::ImageToUnstructuredGridFilter::Pointer testFilter = mitk::ImageToUnstructuredGridFilter::New(); + mitk::ImageToPointCloudFilter::Pointer testFilter = mitk::ImageToPointCloudFilter::New(); testFilter->SetInput(m_BallImage); testFilter->Update(); - CPPUNIT_ASSERT_MESSAGE("Testing surface generation!", testFilter->GetOutput() != NULL); + CPPUNIT_ASSERT_MESSAGE("Testing UnstructuredGrid generation!", testFilter->GetOutput() != NULL); } void testThreshold() { - mitk::ImageToUnstructuredGridFilter::Pointer testFilter1 = mitk::ImageToUnstructuredGridFilter::New(); + mitk::ImageToPointCloudFilter::Pointer testFilter1 = mitk::ImageToPointCloudFilter::New(); testFilter1->SetInput(m_BallImage); testFilter1->Update(); int numberOfPoints1 = testFilter1->GetNumberOfExtractedPoints(); - mitk::ImageToUnstructuredGridFilter::Pointer testFilter2 = mitk::ImageToUnstructuredGridFilter::New(); + mitk::ImageToPointCloudFilter::Pointer testFilter2 = mitk::ImageToPointCloudFilter::New(); testFilter2->SetInput(m_BallImage); - testFilter2->SetThreshold(1.0); + testFilter2->SetMethod(mitk::ImageToPointCloudFilter::LAPLACIAN_STD_DEV3); testFilter2->Update(); int numberOfPoints2 = testFilter2->GetNumberOfExtractedPoints(); CPPUNIT_ASSERT_MESSAGE("Testing Threshold", numberOfPoints1 > numberOfPoints2); } }; -MITK_TEST_SUITE_REGISTRATION(mitkImageToUnstructuredGridFilter) +MITK_TEST_SUITE_REGISTRATION(mitkImageToPointCloudFilter) diff --git a/Modules/SurfaceInterpolation/mitkImageToPointCloudFilter.cpp b/Modules/SurfaceInterpolation/mitkImageToPointCloudFilter.cpp index a24aa48843..3ba05de2ab 100644 --- a/Modules/SurfaceInterpolation/mitkImageToPointCloudFilter.cpp +++ b/Modules/SurfaceInterpolation/mitkImageToPointCloudFilter.cpp @@ -1,180 +1,177 @@ /*=================================================================== 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 #include #include #include #include mitk::ImageToPointCloudFilter::ImageToPointCloudFilter(): m_NumberOfExtractedPoints(0) { m_PointGrid = mitk::UnstructuredGrid::New(); - m_Method = DetectConstant(1); + m_Method = DetectConstant(0); m_EdgeImage = mitk::Image::New(); m_EdgePoints = mitk::Image::New(); this->SetNumberOfRequiredInputs(1); this->SetNumberOfRequiredOutputs(1); this->SetNthOutput(0, m_PointGrid); } mitk::ImageToPointCloudFilter::~ImageToPointCloudFilter(){} void mitk::ImageToPointCloudFilter::GenerateData() { mitk::Image::ConstPointer image = ImageToUnstructuredGridFilter::GetInput(); m_Geometry = image->GetGeometry(); if ( image.IsNull() ) { MITK_ERROR << "mitk::ImageToContourFilter: No input available. " "Please set the input!" << std::endl; return; } + mitk::Image::Pointer notConstImage = image->Clone(); + switch(m_Method) { case 0: - this->LaplacianStdDev(image, 2); + AccessByItk_1(notConstImage.GetPointer(), StdDeviations, 2) break; case 1: - this->LaplacianStdDev(image, 3); + AccessByItk_1(notConstImage.GetPointer(), StdDeviations, 3) break; case 2: - this->LaplacianStdDev(image, 4); + AccessByItk_1(notConstImage.GetPointer(), StdDeviations, 4) break; default: - this->LaplacianStdDev(image, 3); + AccessByItk_1(notConstImage.GetPointer(), StdDeviations, 2) break; } } -void mitk::ImageToPointCloudFilter:: - LaplacianStdDev(mitk::Image::ConstPointer image, int amount) -{ - mitk::Image::Pointer notConstImage = image->Clone(); - AccessByItk_1(notConstImage.GetPointer(), StdDeviations, amount) -} - template void mitk::ImageToPointCloudFilter:: StdDeviations(itk::Image* image, int amount) { typedef itk::Image InputImageType; typedef itk::CastImageFilter< InputImageType, FloatImageType > ImagePTypeToFloatPTypeCasterType; typename LaplacianFilterType::Pointer lapFilter = LaplacianFilterType::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(); 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()); vtkSmartPointer points = vtkSmartPointer::New(); double greatX=0, greatY=0, greatZ=0; 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); if(worldPoint[0]>greatX) greatX=worldPoint[0]; if(worldPoint[1]>greatY) greatY=worldPoint[1]; if(worldPoint[2]>greatZ) greatZ=worldPoint[2]; points->InsertNextPoint(worldPoint[0],worldPoint[1],worldPoint[2]); m_NumberOfExtractedPoints++; } ++it; } m_EdgePoints = mitk::ImportItkImage(lapFilter->GetOutput())->Clone(); + /*need to build the UnstructuredGrid with at least one vertex otherwise its + not visible*/ vtkSmartPointer verts = vtkSmartPointer::New(); verts->GetPointIds()->SetNumberOfIds(m_NumberOfExtractedPoints); for(int i=0; iGetPointIds()->SetId(i,i); } vtkSmartPointer uGrid = vtkSmartPointer::New(); uGrid->Allocate(1); uGrid->InsertNextCell(verts->GetCellType(), verts->GetPointIds()); uGrid->SetPoints(points); m_PointGrid->SetVtkUnstructuredGrid(uGrid); } void mitk::ImageToPointCloudFilter::GenerateOutputInformation() { Superclass::GenerateOutputInformation(); } diff --git a/Modules/SurfaceInterpolation/mitkImageToPointCloudFilter.h b/Modules/SurfaceInterpolation/mitkImageToPointCloudFilter.h index 1c6bc114b2..9cdfb38694 100644 --- a/Modules/SurfaceInterpolation/mitkImageToPointCloudFilter.h +++ b/Modules/SurfaceInterpolation/mitkImageToPointCloudFilter.h @@ -1,93 +1,106 @@ /*=================================================================== 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 #include namespace mitk { -enum MITKSURFACEINTERPOLATION_EXPORT DetectConstant -{ - LAPLACIAN_STD_DEV2 = 0, - LAPLACIAN_STD_DEV3 = 1, - LAPLACIAN_STD_DEV4 = 2 -}; - +/** +* @brief The filter extracts the edge pixels of an image as points and stores +* them in an UnstructuredGrid. Every pixel which grey value is between the +* mean +- standard deviation * (2 or 3), will be extracted as point. The +* DetectionMethod can be set to choose if the doubled or tripled standard +* deviation is used. +*/ class MITKSURFACEINTERPOLATION_EXPORT ImageToPointCloudFilter: public ImageToUnstructuredGridFilter { public: + enum DetectConstant + { + LAPLACIAN_STD_DEV2 = 0, + LAPLACIAN_STD_DEV3 = 1, + LAPLACIAN_STD_DEV4 = 2 + }; + mitkClassMacro( ImageToPointCloudFilter, ImageToUnstructuredGridFilter) itkFactorylessNewMacro(Self) itkCloneMacro(Self) - typedef itk::Image ImageType; - typedef itk::Image DoubleImageType; typedef itk::Image FloatImageType; typedef itk::LaplacianImageFilter< FloatImageType, FloatImageType > LaplacianFilterType; typedef DetectConstant DetectionMethod; itkGetMacro(Method,DetectionMethod) itkGetMacro(EdgeImage,mitk::Image::Pointer) itkGetMacro(EdgePoints,mitk::Image::Pointer) itkGetMacro(NumberOfExtractedPoints,int) itkSetMacro(Method,DetectionMethod) protected: + /** This method is called by Update(). */ virtual void GenerateData(); + /** Initializes the output information */ virtual void GenerateOutputInformation(); + /** Constructor */ ImageToPointCloudFilter(); + /** Destructor */ virtual ~ImageToPointCloudFilter(); private: + /** Uses the laplace filter to create an image and extracts a pixel as point + * if the grey value is between the mean +- standard deviation * (2 or 3) */ template void StdDeviations(itk::Image* image, int amount); - void LaplacianStdDev(Image::ConstPointer image, int amount); - mitk::UnstructuredGrid::Pointer m_PointGrid; - mitk::BaseGeometry* m_Geometry; + /** The generated image from the laplace filter */ mitk::Image::Pointer m_EdgeImage; + + /** The extracted pixels/points */ mitk::Image::Pointer m_EdgePoints; + /** The number of extracted points */ int m_NumberOfExtractedPoints; + /** The selected detection method */ DetectionMethod m_Method; }; } #endif