]> Creatis software - clitk.git/commitdiff
unsharp mask (needs a symbolic link of the ggo in tools to compile, due to a gengetop...
authorschaerer <schaerer>
Mon, 12 Apr 2010 11:47:35 +0000 (11:47 +0000)
committerschaerer <schaerer>
Mon, 12 Apr 2010 11:47:35 +0000 (11:47 +0000)
filters/CMakeLists.txt
filters/clitkFooImage.ggo
filters/clitkFooImageGenericFilter.txx
filters/clitkUnsharpMask.ggo [new file with mode: 0644]
filters/clitkUnsharpMaskGenericFilter.h [new file with mode: 0644]
filters/clitkUnsharpMaskGenericFilter.txx [new file with mode: 0644]
tools/CMakeLists.txt
tools/clitkUnsharpMask.cxx [new file with mode: 0644]
tools/clitkUnsharpMask.ggo [new file with mode: 0644]

index 4ed133c235c5c031ef0dfd7a22365761246b13fe..0b53bba5842bbe86109e8a03cd967317a8a2905b 100644 (file)
@@ -17,9 +17,8 @@ SET(clitkFilters_SRC
   clitkBinarizeImage_ggo.c
   clitkMedianImageGenericFilter.cxx
   clitkMedianImageFilter_ggo.c
+  clitkUnsharpMask_ggo.c
   clitkFooImage_ggo.c
-  
-
   )  
 
 ADD_LIBRARY(clitkFilters STATIC ${clitkFilters_SRC})
index 01167b1a55195d89a694a43dc80497b3e6a37964..3d0c8dbf97d92ef173713193fba0761dcbf7a9a5 100644 (file)
@@ -3,17 +3,16 @@ package "clitkFooImage"
 version "1.0"
 purpose ""
 
-option "config"                -       "Config file"                     string        no
+option "config"                -       "Config file"                     string        optional
 option "verbose"       v       "Verbose"                         flag          off
 
 option "imagetypes"    -       "Display allowed image types"     flag          off
 
-option "input"         i       "Input image filename"            string        yes
-option "output"        o       "Output image filename"           string        yes
-option "lower"         l       "Lower intensity (default=min), fg is greater than this value"    double        no
-option "upper"         u       "Upper intensity (default=max), fg is lower than this value"      double        no
-
-option "fg"                    -       "Foreground (FG) or 'inside' value"               double        no      default="1"
-        option "bg"                    -       "Background (BG) or 'ouside' value"               double        no      default="0"
-                    option "mode"              -       "Use FG and/or BG values (if FG, the BG is replaced by the input image values)" values="FG","BG","both"  default="both" no
+option "input"         i       "Input image filename"            string        required
+option "output"        o       "Output image filename"           string        required
+option "lower"         l       "Lower intensity (default=min), fg is greater than this value"    double        optional
+option "upper"         u       "Upper intensity (default=max), fg is lower than this value"      double        optional
 
+option "fg"                    -       "Foreground (FG) or 'inside' value"               double        optional        default="1"
+option "bg"                    -       "Background (BG) or 'ouside' value"               double        optional        default="0"
+option "mode"          -       "Use FG and/or BG values (if FG, the BG is replaced by the input image values)" values="FG","BG","both"  default="both" optional
index 11905314a6b4467a6a6512d62f6b984d95547372..b2c9c293a2ad23ce1818794512907b246076dd10 100644 (file)
@@ -57,7 +57,6 @@ void FooImageGenericFilter<args_info_type>::InitializeImageType() {
     ADD_IMAGE_TYPE(Dim, short);
     ADD_IMAGE_TYPE(Dim, ushort);
     ADD_IMAGE_TYPE(Dim, int);
-    ADD_IMAGE_TYPE(Dim, uint16);
     ADD_IMAGE_TYPE(Dim, float);
     ADD_IMAGE_TYPE(Dim, double);
 }
diff --git a/filters/clitkUnsharpMask.ggo b/filters/clitkUnsharpMask.ggo
new file mode 100644 (file)
index 0000000..d2a8672
--- /dev/null
@@ -0,0 +1,13 @@
+#File clitkUnsharpMask.ggo
+package "clitkUnsharpMask"
+version "1.0"
+purpose ""
+
+option "config"                -       "Config file"                     string        no
+option "verbose"       v       "Verbose"                         flag          off
+
+option "imagetypes"    -       "Display allowed image types"     flag          off
+
+option "input"         i       "Input image filename"            string        yes
+option "output"        o       "Output image filename"           string        yes
+option "sigma"         s       "Sigma of the gaussian"           double        required
diff --git a/filters/clitkUnsharpMaskGenericFilter.h b/filters/clitkUnsharpMaskGenericFilter.h
new file mode 100644 (file)
index 0000000..0263fb4
--- /dev/null
@@ -0,0 +1,69 @@
+/*=========================================================================
+  Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
+
+  Authors belong to:
+  - University of LYON              http://www.universite-lyon.fr/
+  - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
+  - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
+
+  This software is distributed WITHOUT ANY WARRANTY; without even
+  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+  PURPOSE.  See the copyright notices for more information.
+
+  It is distributed under dual licence
+
+  - BSD        See included LICENSE.txt file
+  - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+======================================================================-====*/
+#ifndef CLITKUnsharpMaskGENERICFILTER_H
+#define CLITKUnsharpMaskGENERICFILTER_H
+#include "clitkIO.h"
+#include "clitkImageToImageGenericFilter.h"
+
+//--------------------------------------------------------------------
+namespace clitk
+{
+
+template<class args_info_type>
+class ITK_EXPORT UnsharpMaskGenericFilter:
+        public ImageToImageGenericFilter<UnsharpMaskGenericFilter<args_info_type> >
+{
+
+public:
+
+    //--------------------------------------------------------------------
+    UnsharpMaskGenericFilter();
+
+    //--------------------------------------------------------------------
+    typedef UnsharpMaskGenericFilter         Self;
+    typedef itk::SmartPointer<Self>            Pointer;
+    typedef itk::SmartPointer<const Self>      ConstPointer;
+
+    //--------------------------------------------------------------------
+    // Method for creation through the object factory
+    // and Run-time type information (and related methods)
+    itkNewMacro(Self);
+    itkTypeMacro(UnsharpMaskGenericFilter, LightObject);
+
+    //--------------------------------------------------------------------
+    void SetArgsInfo(const args_info_type & a);
+
+    //--------------------------------------------------------------------
+    // Main function called each time the filter is updated
+    template<class InputImageType>
+    void UpdateWithInputImageType();
+
+protected:
+    template<unsigned int Dim> void InitializeImageType();
+    args_info_type mArgsInfo;
+
+}; // end class
+//--------------------------------------------------------------------
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkUnsharpMaskGenericFilter.txx"
+#endif
+
+#endif // #define clitkUnsharpMaskGenericFilter_h
diff --git a/filters/clitkUnsharpMaskGenericFilter.txx b/filters/clitkUnsharpMaskGenericFilter.txx
new file mode 100644 (file)
index 0000000..92aab25
--- /dev/null
@@ -0,0 +1,115 @@
+/*=========================================================================
+  Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
+
+  Authors belong to:
+  - University of LYON              http://www.universite-lyon.fr/
+  - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
+  - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
+
+  This software is distributed WITHOUT ANY WARRANTY; without even
+  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+  PURPOSE.  See the copyright notices for more information.
+
+  It is distributed under dual licence
+
+  - BSD        See included LICENSE.txt file
+  - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+======================================================================-====*/
+#ifndef clitkUnsharpMaskGenericFilter_txx
+#define clitkUnsharpMaskGenericFilter_txx
+
+/* =================================================
+ * @file   clitkUnsharpMaskGenericFilter.txx
+ * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
+ * @date   29 june 2009
+ *
+ * @brief
+ *
+ ===================================================*/
+
+// itk include
+#include "itkRecursiveGaussianImageFilter.h"
+#include "itkSubtractImageFilter.h"
+#include <clitkCommon.h>
+
+namespace clitk
+{
+
+//--------------------------------------------------------------------
+template<class args_info_type>
+UnsharpMaskGenericFilter<args_info_type>::UnsharpMaskGenericFilter():
+        ImageToImageGenericFilter<Self>("UnsharpMask") {
+    InitializeImageType<2>();
+    InitializeImageType<3>();
+    //InitializeImageType<4>();
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class args_info_type>
+template<unsigned int Dim>
+void UnsharpMaskGenericFilter<args_info_type>::InitializeImageType() {
+    ADD_IMAGE_TYPE(Dim, char);
+    ADD_IMAGE_TYPE(Dim, uchar);
+    ADD_IMAGE_TYPE(Dim, short);
+    ADD_IMAGE_TYPE(Dim, ushort);
+    ADD_IMAGE_TYPE(Dim, int);
+    ADD_IMAGE_TYPE(Dim, float);
+    ADD_IMAGE_TYPE(Dim, double);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class args_info_type>
+void UnsharpMaskGenericFilter<args_info_type>::SetArgsInfo(const args_info_type & a) {
+    mArgsInfo=a;
+    SetIOVerbose(mArgsInfo.verbose_flag);
+    if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
+
+    if (mArgsInfo.input_given) {
+        SetInputFilename(mArgsInfo.input_arg);
+    }
+    if (mArgsInfo.output_given) {
+        SetOutputFilename(mArgsInfo.output_arg);
+    }
+}
+//--------------------------------------------------------------------
+
+//--------------------------------------------------------------------
+// Update with the number of dimensions and the pixeltype
+//--------------------------------------------------------------------
+template<class args_info_type>
+template<class InputImageType>
+void
+UnsharpMaskGenericFilter<args_info_type>::UpdateWithInputImageType()
+{
+
+    // Reading input
+    typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
+
+    // Main filter
+    typedef typename InputImageType::PixelType PixelType;
+    typedef itk::Image<float, InputImageType::ImageDimension> OutputImageType;
+
+    // Filter
+    typedef itk::RecursiveGaussianImageFilter<InputImageType, OutputImageType> RecursiveGaussianImageFilterType;
+    typename RecursiveGaussianImageFilterType::Pointer gaussianFilter=RecursiveGaussianImageFilterType::New();
+    gaussianFilter->SetInput(input);
+    gaussianFilter->SetSigma(mArgsInfo.sigma_arg);
+
+    typedef itk::SubtractImageFilter<InputImageType, OutputImageType, OutputImageType> SubtractFilterType;
+    typename SubtractFilterType::Pointer subtractFilter = SubtractFilterType::New();
+    subtractFilter->SetInput1(input);
+    subtractFilter->SetInput2(gaussianFilter->GetOutput());
+    subtractFilter->Update();
+
+    this->template SetNextOutput<OutputImageType>(subtractFilter->GetOutput());
+}
+//--------------------------------------------------------------------
+
+
+}//end clitk
+
+#endif //#define clitkUnsharpMaskGenericFilter_txx
index f08407040610695935c9cc6cf778844320f2c99c..898de4243d1fe048668df11709a364eae9533dd8 100644 (file)
@@ -72,6 +72,9 @@ clitkFilters)
 ADD_EXECUTABLE(clitkImageArithm clitkImageArithm.cxx)
 TARGET_LINK_LIBRARIES(clitkImageArithm clitkCommon ITKIO ITKStatistics clitkFilters)
 
+ADD_EXECUTABLE(clitkUnsharpMask clitkUnsharpMask.cxx clitkUnsharpMask_ggo.c)
+TARGET_LINK_LIBRARIES(clitkUnsharpMask clitkCommon ITKIO) 
+
 ADD_EXECUTABLE(clitkFooImage clitkFooImage.cxx)
 TARGET_LINK_LIBRARIES(clitkFooImage clitkCommon ITKIO clitkFilters) 
 
diff --git a/tools/clitkUnsharpMask.cxx b/tools/clitkUnsharpMask.cxx
new file mode 100644 (file)
index 0000000..d222ca1
--- /dev/null
@@ -0,0 +1,49 @@
+/*=========================================================================
+  Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
+
+  Authors belong to:
+  - University of LYON              http://www.universite-lyon.fr/
+  - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
+  - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
+
+  This software is distributed WITHOUT ANY WARRANTY; without even
+  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+  PURPOSE.  See the copyright notices for more information.
+
+  It is distributed under dual licence
+
+  - BSD        See included LICENSE.txt file
+  - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+======================================================================-====*/
+
+/* =================================================
+ * @file   clitkUnsharpMaskGenericFilter.txx
+ * @author xxx <xxx@creatis.insa-lyon.fr>
+ * @date   29 June 2029
+ *
+ * @brief UnsharpMask an image
+ *
+ ===================================================*/
+
+// clitk
+#include "clitkUnsharpMask_ggo.h"
+#include "clitkUnsharpMaskGenericFilter.h"
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+    // Init command line
+    GGO(clitkUnsharpMask, args_info);
+    CLITK_INIT;
+
+    // Filter
+    typedef clitk::UnsharpMaskGenericFilter<args_info_clitkUnsharpMask> FilterType;
+    FilterType::Pointer filter = FilterType::New();
+
+    filter->SetArgsInfo(args_info);
+    filter->Update();
+
+    return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
diff --git a/tools/clitkUnsharpMask.ggo b/tools/clitkUnsharpMask.ggo
new file mode 100644 (file)
index 0000000..d2a8672
--- /dev/null
@@ -0,0 +1,13 @@
+#File clitkUnsharpMask.ggo
+package "clitkUnsharpMask"
+version "1.0"
+purpose ""
+
+option "config"                -       "Config file"                     string        no
+option "verbose"       v       "Verbose"                         flag          off
+
+option "imagetypes"    -       "Display allowed image types"     flag          off
+
+option "input"         i       "Input image filename"            string        yes
+option "output"        o       "Output image filename"           string        yes
+option "sigma"         s       "Sigma of the gaussian"           double        required