--- /dev/null
+#File clitkBinarizeImage.ggo
+Package "clitkBinarizeImage"
+version "1.0"
+purpose ""
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" 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)" double no
+option "upper" u "Upper intensity (default=max)" double no
+option "inside" - "Inside value" double no default="1"
+option "outside" - "Outside value" double no default="0"
--- /dev/null
+#ifndef clitkBinarizeImageGenericFilter_cxx
+#define clitkBinarizeImageGenericFilter_cxx
+
+/* =================================================
+ * @file clitkBinarizeImageGenericFilter.cxx
+ * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
+ * @date 29 june 2009
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkBinarizeImageGenericFilter.h"
+
+#endif //#define clitkBinarizeImageGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+
+ Program: clitk
+ Module: $RCSfile: clitkBinarizeImageGenericFilter.h,v $
+ Language: C++
+ Date: $Date: 2010/01/29 07:28:33 $
+ Version: $Revision: 1.1 $
+ Author : Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
+ David Sarrut (david.sarrut@creatis.insa-lyon.fr)
+
+ Copyright (C) 2008
+ Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+ CREATIS http://www.creatis.insa-lyon.fr
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, version 3 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ =========================================================================*/
+
+#ifndef CLITKBINARIZEIMAGEGENERICFILTER_H
+#define CLITKBINARIZEIMAGEGENERICFILTER_H
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageToImageGenericFilter.h"
+
+// itk include
+#include "itkBinaryThresholdImageFilter.h"
+
+// std include
+#include <map>
+
+//--------------------------------------------------------------------
+namespace clitk
+{
+
+ template<class args_info_type>
+ class ITK_EXPORT BinarizeImageGenericFilter:
+ public ImageToImageGenericFilter<BinarizeImageGenericFilter<args_info_type> >
+ {
+
+ public:
+
+ //--------------------------------------------------------------------
+ BinarizeImageGenericFilter();
+
+ //--------------------------------------------------------------------
+ typedef BinarizeImageGenericFilter 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(BinarizeImageGenericFilter, 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 "clitkBinarizeImageGenericFilter.txx"
+#endif
+
+#endif // #define clitkBinarizeImageGenericFilter_h
--- /dev/null
+#ifndef clitkBinarizeImageGenericFilter_txx
+#define clitkBinarizeImageGenericFilter_txx
+
+/* =================================================
+ * @file clitkBinarizeImageGenericFilter.txx
+ * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
+ * @date 29 june 2009
+ *
+ * @brief
+ *
+ ===================================================*/
+
+namespace clitk
+{
+
+ //--------------------------------------------------------------------
+ template<class args_info_type>
+ BinarizeImageGenericFilter<args_info_type>::BinarizeImageGenericFilter():
+ ImageToImageGenericFilter<Self>("Binarize") {
+ InitializeImageType<2>();
+ InitializeImageType<3>();
+ }
+ //--------------------------------------------------------------------
+
+
+ //--------------------------------------------------------------------
+ template<class args_info_type>
+ template<unsigned int Dim>
+ void BinarizeImageGenericFilter<args_info_type>::InitializeImageType() {
+ ADD_IMAGE_TYPE(Dim, char);
+ ADD_IMAGE_TYPE(Dim, short);
+ }
+ //--------------------------------------------------------------------
+
+
+ //--------------------------------------------------------------------
+ template<class args_info_type>
+ void BinarizeImageGenericFilter<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
+ BinarizeImageGenericFilter<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<int, InputImageType::ImageDimension> OutputImageType;
+
+ // Filter
+ typedef itk::BinaryThresholdImageFilter<InputImageType, OutputImageType> BinaryThresholdImageFilterType;
+ typename BinaryThresholdImageFilterType::Pointer thresholdFilter=BinaryThresholdImageFilterType::New();
+ thresholdFilter->SetInput(input);
+ if(mArgsInfo.lower_given) thresholdFilter->SetLowerThreshold(static_cast<PixelType>(mArgsInfo.lower_arg));
+ if(mArgsInfo.upper_given) thresholdFilter->SetUpperThreshold(static_cast<PixelType>(mArgsInfo.upper_arg));
+
+ DD(mArgsInfo.lower_given);
+ DD(mArgsInfo.upper_given);
+ DD(mArgsInfo.lower_arg);
+ DD(mArgsInfo.upper_arg);
+
+ DD(mArgsInfo.inside_arg);
+ DD(mArgsInfo.outside_arg);
+ DD(mArgsInfo.inside_given);
+ DD(mArgsInfo.outside_given);
+
+ thresholdFilter->SetInsideValue(mArgsInfo.inside_arg);
+ thresholdFilter->SetOutsideValue(mArgsInfo.outside_arg);
+
+ thresholdFilter->Update();
+
+ // Write/Save results
+ typename OutputImageType::Pointer outputImage = thresholdFilter->GetOutput();
+ this->template SetNextOutput<OutputImageType>(outputImage);
+ }
+ //--------------------------------------------------------------------
+
+
+}//end clitk
+
+#endif //#define clitkBinarizeImageGenericFilter_txx