-------------------------------------------------------------------*/
#include "clitkSplitImageGenericFilter.h"
-
#include "clitkSplitImageGenericFilter.txx"
+#include <itkIntensityWindowingImageFilter.h>
//--------------------------------------------------------------------
clitk::SplitImageGenericFilter::SplitImageGenericFilter():
clitk::ImageToImageGenericFilter<Self>("SplitImage")
void clitk::SplitImageGenericFilter::InitializeImageType()
{
ADD_DEFAULT_IMAGE_TYPES(Dim);
- ADD_VEC_IMAGE_TYPE(Dim, 3,float);
+ //ADD_VEC_IMAGE_TYPE(Dim, 3,float);
}
//--------------------------------------------------------------------
unsigned int number_of_output_images=input->GetLargestPossibleRegion().GetSize()[mSplitDimension];
for (unsigned int i=0; i<number_of_output_images; i++) {
std::ostringstream ss;
- ss << i;
+ ss << std::setfill('0') << std::setw((int)(log10(number_of_output_images)+1)) << i;
index[mSplitDimension]=i;
extracted_region.SetIndex(index);
filter->SetExtractionRegion(extracted_region);
filter->Update();
- SetOutputFilename(base_filename+"_"+ss.str()+".mhd");
- typename OutputImageType::Pointer output=filter->GetOutput();
- SetNextOutput<OutputImageType>(output);
+ if(this->m_Png){
+ typedef itk::Image< unsigned char, ImageType::ImageDimension-1 > OutputPngImageType;
+ typedef itk::IntensityWindowingImageFilter< OutputImageType, OutputPngImageType > CastFilterType;
+ typename CastFilterType::Pointer cast = CastFilterType::New();
+ cast->SetWindowLevel(this->m_Window, this->m_Level);
+ cast->SetInput(filter->GetOutput());
+ SetOutputFilename(base_filename+"_"+ss.str()+".png");
+ SetNextOutput<OutputPngImageType>(cast->GetOutput());
+ }
+ else {
+ SetOutputFilename(base_filename+"_"+ss.str()+".mhd");
+ SetNextOutput<OutputImageType>(filter->GetOutput());
+ }
}
}
//--------------------------------------------------------------------
// Set methods
void SetSplitDimension (int dim) { mSplitDimension = dim; }
void SetVerbose (const bool v) { m_Verbose = v; }
+ void SetPng (const bool v) { m_Png = v; }
+ void SetWindowLevel(const double w, const double l){ m_Window = w; m_Level = l;}
//--------------------------------------------------------------------
// Main function called each time the filter is updated
template<unsigned int Dim> void InitializeImageType();
int mSplitDimension;
bool m_Verbose;
+ bool m_Png;
+ double m_Window, m_Level;
}; // end class SplitImageGenericFilter
//--------------------------------------------------------------------
filter.SetInputFilename(args_info.input_arg);
filter.SetOutputFilename(args_info.output_arg);
filter.SetSplitDimension(args_info.dimension_arg);
+ filter.SetPng(args_info.png_flag);
+ filter.SetWindowLevel(args_info.window_arg, args_info.level_arg);
filter.SetVerbose(args_info.verbose_flag);
filter.Update();