]> Creatis software - clitk.git/commitdiff
added the possibility to compute the Laplacian of Gaussian (LoG) of an image
authorBenoît Presles <benoit.presles@creatis.insa-lyon.fr>
Tue, 29 Oct 2013 17:56:40 +0000 (18:56 +0100)
committerBenoît Presles <benoit.presles@creatis.insa-lyon.fr>
Tue, 29 Oct 2013 17:56:40 +0000 (18:56 +0100)
tools/clitkImageLaplacian.ggo
tools/clitkImageLaplacianGenericFilter.txx

index 2066df93dad9678f8d8f5e41102f73c59a05ff7a..f97ef9b2957ad5f41753b67a5b4a70de050fbc61 100644 (file)
@@ -12,3 +12,4 @@ option "input"                i       "Input image filename"            string        required
 option "mask"          m       "Mask input image filename"       string        optional
 option "output"        o       "Output image filename"           string        required
 option "normalize"      n       "Normalize the output image between 0 and 1"    flag off
+option "gaussian_filter" g      "Gaussian filtering"              flag          on
index 2ffa43b246edcf43c3cbca279eef5c21889cea24..940e9fcd8514217aef707a9d8d954e81c06fe273 100644 (file)
@@ -30,6 +30,7 @@
 // itk include
 #include "itkCastImageFilter.h"
 #include "itkLaplacianImageFilter.h"
+#include "itkLaplacianRecursiveGaussianImageFilter.h"
 #include "itkLabelStatisticsImageFilter.h"
 #include "itkMaskImageFilter.h"
 #include "itkMaskNegatedImageFilter.h"
@@ -127,13 +128,26 @@ ImageLaplacianGenericFilter<args_info_type>::UpdateWithInputImageType()
     IteratorOutputType ito = IteratorOutputType(outputImage, outputImage->GetLargestPossibleRegion());
 
     // Filter
-    typedef itk::LaplacianImageFilter<FloatImageType, FloatImageType> LaplacianImageFilterType;
-    typename LaplacianImageFilterType::Pointer laplacianFilter=LaplacianImageFilterType::New();
-    laplacianFilter->SetInput(castFilter->GetOutput());
-    laplacianFilter->Update();
+    typename FloatImageType::Pointer outputLaplacianFilter;
+    if (mArgsInfo.gaussian_filter_flag == 0) {
+        //std::cout<<"gaussian filter flag == 0"<<std::endl;
+        typedef itk::LaplacianImageFilter<FloatImageType, FloatImageType> LaplacianImageFilterType;
+        typename LaplacianImageFilterType::Pointer laplacianFilter=LaplacianImageFilterType::New();
+        laplacianFilter->SetInput(castFilter->GetOutput());
+        laplacianFilter->Update();
+        outputLaplacianFilter = laplacianFilter->GetOutput();
+    }
+    else {
+        //std::cout<<"gaussian filter flag == 1"<<std::endl;
+        typedef itk::LaplacianRecursiveGaussianImageFilter< FloatImageType, FloatImageType >  LaplacianImageFilterType;
+        typename LaplacianImageFilterType::Pointer laplacianFilter=LaplacianImageFilterType::New();
+        laplacianFilter->SetInput(castFilter->GetOutput());
+        laplacianFilter->Update();
+        outputLaplacianFilter = laplacianFilter->GetOutput();
+    }
     // Set iterator
     typedef itk::ImageRegionIterator<FloatImageType> IteratorType;
-    IteratorType it(laplacianFilter->GetOutput(), laplacianFilter->GetOutput()->GetLargestPossibleRegion());
+    IteratorType it(outputLaplacianFilter, outputLaplacianFilter->GetLargestPossibleRegion());
 
     // Set mask iterator
     typedef itk::ImageRegionIterator<MaskImageType> IteratorMaskType;
@@ -146,7 +160,7 @@ ImageLaplacianGenericFilter<args_info_type>::UpdateWithInputImageType()
     typedef itk::LabelStatisticsImageFilter< FloatImageType, MaskImageType > LabelStatisticsImageFilterType;
     typename LabelStatisticsImageFilterType::Pointer labelStatisticsImageFilter = LabelStatisticsImageFilterType::New();
     labelStatisticsImageFilter->SetLabelInput( mask );
-    labelStatisticsImageFilter->SetInput(laplacianFilter->GetOutput());
+    labelStatisticsImageFilter->SetInput(outputLaplacianFilter);
     labelStatisticsImageFilter->Update();
 
     //std::cout << "Number of labels: " << labelStatisticsImageFilter->GetNumberOfLabels() << std::endl;