*
===================================================*/
+#include "itkMaskImageFilter.h"
+
namespace clitk
{
template<class args_info_type>
BinarizeImageGenericFilter<args_info_type>::BinarizeImageGenericFilter():
ImageToImageGenericFilter<Self>("Binarize") {
- InitializeImageType<2>();
+ // InitializeImageType<2>();
InitializeImageType<3>();
- InitializeImageType<4>();
+ //InitializeImageType<4>();
}
//--------------------------------------------------------------------
template<class args_info_type>
template<unsigned int Dim>
void BinarizeImageGenericFilter<args_info_type>::InitializeImageType() {
- ADD_IMAGE_TYPE(Dim, char);
+ //ADD_IMAGE_TYPE(Dim, char);
ADD_IMAGE_TYPE(Dim, short);
- ADD_IMAGE_TYPE(Dim, int);
- ADD_IMAGE_TYPE(Dim, float);
+ //ADD_IMAGE_TYPE(Dim, int);
+ //ADD_IMAGE_TYPE(Dim, float);
}
//--------------------------------------------------------------------
typedef itk::BinaryThresholdImageFilter<InputImageType, OutputImageType> BinaryThresholdImageFilterType;
typename BinaryThresholdImageFilterType::Pointer thresholdFilter=BinaryThresholdImageFilterType::New();
thresholdFilter->SetInput(input);
+
+ if (mArgsInfo.setFG_flag) {
+ double fg = mArgsInfo.fg_arg;
+ mArgsInfo.fg_arg = mArgsInfo.bg_arg;
+ mArgsInfo.bg_arg = fg;
+ }
+
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_arg);
DD(mArgsInfo.upper_arg);
- DD(mArgsInfo.inside_arg);
- DD(mArgsInfo.outside_arg);
- DD(mArgsInfo.inside_given);
- DD(mArgsInfo.outside_given);
+ DD(mArgsInfo.fg_arg);
+ DD(mArgsInfo.bg_arg);
+ DD(mArgsInfo.fg_given);
+ DD(mArgsInfo.bg_given);
- thresholdFilter->SetInsideValue(mArgsInfo.inside_arg);
- thresholdFilter->SetOutsideValue(mArgsInfo.outside_arg);
+ thresholdFilter->SetInsideValue(mArgsInfo.fg_arg);
+ thresholdFilter->SetOutsideValue(mArgsInfo.bg_arg);
thresholdFilter->Update();
-
- // Write/Save results
- typename OutputImageType::Pointer outputImage = thresholdFilter->GetOutput();
- this->template SetNextOutput<OutputImageType>(outputImage);
+
+ // If no BG or no FG : new image, copy input with MaskImageFilter
+ // If setFG -> FG BG have been changed
+ if (0) {
+ if (mArgsInfo.setBG_flag || mArgsInfo.setFG_flag) {
+ DD("set BG!!!!");
+ //if ()
+ typedef itk::MaskImageFilter<InputImageType,OutputImageType> maskFilterType;
+ typename maskFilterType::Pointer maskFilter = maskFilterType::New();
+ maskFilter->SetInput1(input);
+ maskFilter->SetInput2(thresholdFilter->GetOutput());
+ maskFilter->Update();
+ typename InputImageType::Pointer outputImage = maskFilter->GetOutput();
+ // Write/Save results
+ this->template SetNextOutput<InputImageType>(outputImage);
+ }
+ }
+ else {
+ typename OutputImageType::Pointer outputImage = thresholdFilter->GetOutput();
+ // Write/Save results
+ this->template SetNextOutput<OutputImageType>(outputImage);
+ }
}
//--------------------------------------------------------------------
+++ /dev/null
-#File clitkBinarizeImage.ggo
-Package "clitkBinarizeImage"
-version "1.0"
-purpose ""
-
-option "config" - "Config file" string no
-option "imagetypes" - "Verbose available image type" flag off
-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"
Program: vv
Module: $RCSfile: vvToolBinarize.cxx,v $
Language: C++
- Date: $Date: 2010/01/29 13:54:37 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2010/02/01 15:54:25 $
+ Version: $Revision: 1.2 $
Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
Copyright (C) 2008
}
}
- mArgsInfo.inside_arg = mFGSlider->GetValue();
- mArgsInfo.outside_arg = mBGSlider->GetValue();
+ mArgsInfo.fg_arg = mFGSlider->GetValue();
+ mArgsInfo.bg_arg = mBGSlider->GetValue();
if (inverseBGandFG) {
- mArgsInfo.inside_arg = mBGSlider->GetValue();
- mArgsInfo.outside_arg = mFGSlider->GetValue();
+ mArgsInfo.fg_arg = mBGSlider->GetValue();
+ mArgsInfo.bg_arg = mFGSlider->GetValue();
}
- mArgsInfo.inside_given = 1;
- mArgsInfo.outside_given = 1;
+ mArgsInfo.fg_given = 1;
+ mArgsInfo.bg_given = 1;
+
+ mArgsInfo.setBG_flag = true;
mArgsInfo.verbose_flag = true;