From: srit Date: Mon, 12 Jul 2010 17:39:16 +0000 (+0000) Subject: Added png support with window/level options to clitkSplitImage X-Git-Tag: v1.2.0~534 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=9a6ef2295cd58d339233b533dee384e1d138c8c0;p=clitk.git Added png support with window/level options to clitkSplitImage --- diff --git a/filters/clitkSplitImageGenericFilter.cxx b/filters/clitkSplitImageGenericFilter.cxx index 2b95024..433fb93 100644 --- a/filters/clitkSplitImageGenericFilter.cxx +++ b/filters/clitkSplitImageGenericFilter.cxx @@ -25,8 +25,8 @@ -------------------------------------------------------------------*/ #include "clitkSplitImageGenericFilter.h" - #include "clitkSplitImageGenericFilter.txx" +#include //-------------------------------------------------------------------- clitk::SplitImageGenericFilter::SplitImageGenericFilter(): clitk::ImageToImageGenericFilter("SplitImage") @@ -43,7 +43,7 @@ template void clitk::SplitImageGenericFilter::InitializeImageType() { ADD_DEFAULT_IMAGE_TYPES(Dim); - ADD_VEC_IMAGE_TYPE(Dim, 3,float); + //ADD_VEC_IMAGE_TYPE(Dim, 3,float); } //-------------------------------------------------------------------- @@ -72,14 +72,24 @@ void clitk::SplitImageGenericFilter::UpdateWithInputImageType() unsigned int number_of_output_images=input->GetLargestPossibleRegion().GetSize()[mSplitDimension]; for (unsigned int i=0; iSetExtractionRegion(extracted_region); filter->Update(); - SetOutputFilename(base_filename+"_"+ss.str()+".mhd"); - typename OutputImageType::Pointer output=filter->GetOutput(); - SetNextOutput(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(cast->GetOutput()); + } + else { + SetOutputFilename(base_filename+"_"+ss.str()+".mhd"); + SetNextOutput(filter->GetOutput()); + } } } //-------------------------------------------------------------------- diff --git a/filters/clitkSplitImageGenericFilter.h b/filters/clitkSplitImageGenericFilter.h index e72eba1..a325301 100644 --- a/filters/clitkSplitImageGenericFilter.h +++ b/filters/clitkSplitImageGenericFilter.h @@ -57,6 +57,8 @@ namespace clitk { // 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 @@ -67,6 +69,8 @@ namespace clitk { template void InitializeImageType(); int mSplitDimension; bool m_Verbose; + bool m_Png; + double m_Window, m_Level; }; // end class SplitImageGenericFilter //-------------------------------------------------------------------- diff --git a/tools/clitkSplitImage.cxx b/tools/clitkSplitImage.cxx index a76f88c..4b52cee 100644 --- a/tools/clitkSplitImage.cxx +++ b/tools/clitkSplitImage.cxx @@ -53,6 +53,8 @@ int main(int argc, char * argv[]) 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(); diff --git a/tools/clitkSplitImage.ggo b/tools/clitkSplitImage.ggo index b68eddf..e9b4b3f 100644 --- a/tools/clitkSplitImage.ggo +++ b/tools/clitkSplitImage.ggo @@ -10,3 +10,6 @@ option "output" o "Output image base filename" string yes option "verbose" v "Verbose" flag off option "dimension" d "Dimension to split on" int yes +option "png" p "Png file format" flag off +option "window" w "Window" double no +option "level" l "Level" double no