From: Benoît Presles Date: Wed, 16 Oct 2013 14:04:59 +0000 (+0200) Subject: gradient magnitude tool X-Git-Tag: v1.4.0~150^2~10 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=2ed7351efcabad975289d52c404d5d1c6987e5e1;p=clitk.git gradient magnitude tool --- diff --git a/make_new_tool.sh b/make_new_tool.sh old mode 100644 new mode 100755 diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 7ab7971..339031f 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -304,6 +304,12 @@ IF (CLITK_BUILD_TOOLS) TARGET_LINK_LIBRARIES(clitkImageUncertainty clitkCommon ${ITK_LIBRARIES}) SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkImageUncertainty) + WRAP_GGO(clitkImageGradientMagnitude_GGO_C clitkImageGradientMagnitude.ggo) + ADD_EXECUTABLE(clitkImageGradientMagnitude clitkImageGradientMagnitude.cxx ${clitkImageGradientMagnitude_GGO_C}) + TARGET_LINK_LIBRARIES(clitkImageGradientMagnitude clitkCommon ) + SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkImageGradientMagnitude) + + #========================================================= option(CLITK_USE_ROOT "Build experimental tools using root" OFF) if (CLITK_USE_ROOT) diff --git a/tools/clitkImageGradientMagnitude.cxx b/tools/clitkImageGradientMagnitude.cxx new file mode 100644 index 0000000..7371bf0 --- /dev/null +++ b/tools/clitkImageGradientMagnitude.cxx @@ -0,0 +1,50 @@ +/*========================================================================= + 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://www.centreleonberard.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 clitkImageGradientMagnitudeGenericFilter.txx + * @author xxx + * @date 29 June 2029 + * + * @brief ImageGradientMagnitude an image + * + ===================================================*/ + +// clitk +#include "clitkImageGradientMagnitude_ggo.h" +#include "clitkImageGradientMagnitudeGenericFilter.h" + +//-------------------------------------------------------------------- +int main(int argc, char * argv[]) +{ + + // Init command line + GGO(clitkImageGradientMagnitude, args_info); + CLITK_INIT; + + // Filter + typedef clitk::ImageGradientMagnitudeGenericFilter FilterType; + FilterType::Pointer filter = FilterType::New(); + + filter->SetArgsInfo(args_info); + filter->Update(); + + return EXIT_SUCCESS; +}// end main + +//-------------------------------------------------------------------- diff --git a/tools/clitkImageGradientMagnitude.ggo b/tools/clitkImageGradientMagnitude.ggo new file mode 100644 index 0000000..ae0d84f --- /dev/null +++ b/tools/clitkImageGradientMagnitude.ggo @@ -0,0 +1,12 @@ +#File clitkImageGradientMagnitude.ggo +package "clitkImageGradientMagnitude" +version "1.0" +purpose "" + +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 required +option "output" o "Output image filename" string required diff --git a/tools/clitkImageGradientMagnitudeGenericFilter.h b/tools/clitkImageGradientMagnitudeGenericFilter.h new file mode 100644 index 0000000..9d2b5f5 --- /dev/null +++ b/tools/clitkImageGradientMagnitudeGenericFilter.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://www.centreleonberard.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 CLITKImageGradientMagnitudeGENERICFILTER_H +#define CLITKImageGradientMagnitudeGENERICFILTER_H +#include "clitkIO.h" +#include "clitkImageToImageGenericFilter.h" + +//-------------------------------------------------------------------- +namespace clitk +{ + +template +class ITK_EXPORT ImageGradientMagnitudeGenericFilter: + public ImageToImageGenericFilter > +{ + +public: + + //-------------------------------------------------------------------- + ImageGradientMagnitudeGenericFilter(); + + //-------------------------------------------------------------------- + typedef ImageGradientMagnitudeGenericFilter 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(ImageGradientMagnitudeGenericFilter, 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 "clitkImageGradientMagnitudeGenericFilter.txx" +#endif + +#endif // #define clitkImageGradientMagnitudeGenericFilter_h diff --git a/tools/clitkImageGradientMagnitudeGenericFilter.txx b/tools/clitkImageGradientMagnitudeGenericFilter.txx new file mode 100644 index 0000000..988aecb --- /dev/null +++ b/tools/clitkImageGradientMagnitudeGenericFilter.txx @@ -0,0 +1,107 @@ +/*========================================================================= + 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://www.centreleonberard.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 clitkImageGradientMagnitudeGenericFilter_txx +#define clitkImageGradientMagnitudeGenericFilter_txx + +/* ================================================= + * @file clitkImageGradientMagnitudeGenericFilter.txx + * @author Jef Vandemeulebroucke + * @date 29 june 2009 + * + * @brief + * + ===================================================*/ + +// itk include +#include "itkGradientMagnitudeImageFilter.h" +#include "itkMaskImageFilter.h" +#include "itkMaskNegatedImageFilter.h" +#include + +namespace clitk +{ + +//-------------------------------------------------------------------- +template +ImageGradientMagnitudeGenericFilter::ImageGradientMagnitudeGenericFilter(): + ImageToImageGenericFilter("ImageGradientMagnitude") +{ + InitializeImageType<2>(); + InitializeImageType<3>(); +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +template +template +void ImageGradientMagnitudeGenericFilter::InitializeImageType() +{ + ADD_DEFAULT_IMAGE_TYPES(Dim); +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +template +void ImageGradientMagnitudeGenericFilter::SetArgsInfo(const args_info_type & a) +{ + mArgsInfo=a; + this->SetIOVerbose(mArgsInfo.verbose_flag); + if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes(); + + if (mArgsInfo.input_given) { + this->SetInputFilename(mArgsInfo.input_arg); + } + if (mArgsInfo.output_given) { + this->SetOutputFilename(mArgsInfo.output_arg); + } +} +//-------------------------------------------------------------------- + +//-------------------------------------------------------------------- +// Update with the number of dimensions and the pixeltype +//-------------------------------------------------------------------- +template +template +void +ImageGradientMagnitudeGenericFilter::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::GradientMagnitudeImageFilter GradientMagnitudeImageFilterType; + typename GradientMagnitudeImageFilterType::Pointer gradientFilter=GradientMagnitudeImageFilterType::New(); + gradientFilter->SetInput(input); + gradientFilter->Update(); + + typename OutputImageType::Pointer outputImage = gradientFilter->GetOutput(); + this->template SetNextOutput(outputImage); +} +//-------------------------------------------------------------------- + + +}//end clitk + +#endif //#define clitkImageGradientMagnitudeGenericFilter_txx