From: schaerer Date: Mon, 12 Apr 2010 11:47:35 +0000 (+0000) Subject: unsharp mask (needs a symbolic link of the ggo in tools to compile, due to a gengetop... X-Git-Tag: v1.2.0~722 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=1a829c85824379cb013ca326d8c80e89a3f2c883;p=clitk.git unsharp mask (needs a symbolic link of the ggo in tools to compile, due to a gengetopt limitation) --- diff --git a/filters/CMakeLists.txt b/filters/CMakeLists.txt index 4ed133c..0b53bba 100644 --- a/filters/CMakeLists.txt +++ b/filters/CMakeLists.txt @@ -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}) diff --git a/filters/clitkFooImage.ggo b/filters/clitkFooImage.ggo index 01167b1..3d0c8db 100644 --- a/filters/clitkFooImage.ggo +++ b/filters/clitkFooImage.ggo @@ -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 diff --git a/filters/clitkFooImageGenericFilter.txx b/filters/clitkFooImageGenericFilter.txx index 1190531..b2c9c29 100644 --- a/filters/clitkFooImageGenericFilter.txx +++ b/filters/clitkFooImageGenericFilter.txx @@ -57,7 +57,6 @@ void FooImageGenericFilter::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 index 0000000..d2a8672 --- /dev/null +++ b/filters/clitkUnsharpMask.ggo @@ -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 index 0000000..0263fb4 --- /dev/null +++ b/filters/clitkUnsharpMaskGenericFilter.h @@ -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 ITK_EXPORT UnsharpMaskGenericFilter: + public ImageToImageGenericFilter > +{ + +public: + + //-------------------------------------------------------------------- + UnsharpMaskGenericFilter(); + + //-------------------------------------------------------------------- + typedef UnsharpMaskGenericFilter Self; + typedef itk::SmartPointer Pointer; + typedef itk::SmartPointer 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 + void UpdateWithInputImageType(); + +protected: + template 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 index 0000000..92aab25 --- /dev/null +++ b/filters/clitkUnsharpMaskGenericFilter.txx @@ -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 + * @date 29 june 2009 + * + * @brief + * + ===================================================*/ + +// itk include +#include "itkRecursiveGaussianImageFilter.h" +#include "itkSubtractImageFilter.h" +#include + +namespace clitk +{ + +//-------------------------------------------------------------------- +template +UnsharpMaskGenericFilter::UnsharpMaskGenericFilter(): + ImageToImageGenericFilter("UnsharpMask") { + InitializeImageType<2>(); + InitializeImageType<3>(); + //InitializeImageType<4>(); +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +template +template +void UnsharpMaskGenericFilter::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 +void UnsharpMaskGenericFilter::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 +template +void +UnsharpMaskGenericFilter::UpdateWithInputImageType() +{ + + // Reading input + typename InputImageType::Pointer input = this->template GetInput(0); + + // Main filter + typedef typename InputImageType::PixelType PixelType; + typedef itk::Image OutputImageType; + + // Filter + typedef itk::RecursiveGaussianImageFilter RecursiveGaussianImageFilterType; + typename RecursiveGaussianImageFilterType::Pointer gaussianFilter=RecursiveGaussianImageFilterType::New(); + gaussianFilter->SetInput(input); + gaussianFilter->SetSigma(mArgsInfo.sigma_arg); + + typedef itk::SubtractImageFilter SubtractFilterType; + typename SubtractFilterType::Pointer subtractFilter = SubtractFilterType::New(); + subtractFilter->SetInput1(input); + subtractFilter->SetInput2(gaussianFilter->GetOutput()); + subtractFilter->Update(); + + this->template SetNextOutput(subtractFilter->GetOutput()); +} +//-------------------------------------------------------------------- + + +}//end clitk + +#endif //#define clitkUnsharpMaskGenericFilter_txx diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index f084070..898de42 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -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 index 0000000..d222ca1 --- /dev/null +++ b/tools/clitkUnsharpMask.cxx @@ -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 + * @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 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 index 0000000..d2a8672 --- /dev/null +++ b/tools/clitkUnsharpMask.ggo @@ -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