From: Simon Rit Date: Thu, 31 Oct 2013 15:45:21 +0000 (+0100) Subject: Option to save VV transform (mhd + .mat) in the new mhd X-Git-Tag: v1.4.0~155^2~2 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=c45f2910270487388742272ad54c27405a2b1b53;p=clitk.git Option to save VV transform (mhd + .mat) in the new mhd --- diff --git a/tools/clitkImageConvert.cxx b/tools/clitkImageConvert.cxx index abedc61..3a9beaf 100644 --- a/tools/clitkImageConvert.cxx +++ b/tools/clitkImageConvert.cxx @@ -67,6 +67,7 @@ int main(int argc, char * argv[]) filter->SetInputFilenames(l); filter->SetIOVerbose(args_info.verbose_flag); filter->SetOutputFilename(output); + filter->SetVV(args_info.vv_flag); filter->EnableWriteCompression(args_info.compression_flag); if (args_info.type_given) filter->SetOutputPixelType(args_info.type_arg); diff --git a/tools/clitkImageConvert.ggo b/tools/clitkImageConvert.ggo index 837ee03..b6f003c 100644 --- a/tools/clitkImageConvert.ggo +++ b/tools/clitkImageConvert.ggo @@ -3,9 +3,10 @@ package "clitkImageConvert" version "1.0" purpose "Convert an image into another image.\n\tAllow to change the file format and/or the pixel type. \n\tKnown file formats 2D: jpeg png bmp tif mhd hdr vox dcm \n\tKnown file formats 3D: mhd vox hdr dcm\n\tKnown file formats 4D: mhd \n\tKnown images: 2D 3D or 4D, schar, uchar, short, ushort, int, float and double\n\nIf the -o option is not given, the last parameter of the command line is used as output." -option "config" - "Config file" string no -option "input" i "Input image filename" string no -option "output" o "Output image filename" string no -option "type" t "Output type (float, ushort ...)" string no -option "verbose" v "Verbose" flag off -option "compression" c "Compress output" flag off +option "config" - "Config file" string no +option "input" i "Input image filename" string no +option "output" o "Output image filename" string no +option "type" t "Output type (float, ushort ...)" string no +option "verbose" v "Verbose" flag off +option "compression" c "Compress output" flag off +option "vv" - "Read image as in vv and save transform in meta information" flag off diff --git a/tools/clitkImageConvertGenericFilter.cxx b/tools/clitkImageConvertGenericFilter.cxx index e8d8efb..2783053 100644 --- a/tools/clitkImageConvertGenericFilter.cxx +++ b/tools/clitkImageConvertGenericFilter.cxx @@ -19,6 +19,8 @@ #define CLITKIMAGECONVERTGENERICFILTER_CXX #include "clitkImageConvertGenericFilter.h" +#include "vvImageReader.h" +#include "vvImageWriter.h" //-------------------------------------------------------------------- clitk::ImageConvertGenericFilter::ImageConvertGenericFilter(): @@ -70,7 +72,24 @@ void clitk::ImageConvertGenericFilter::UpdateWithInputImageType() } } - if ((m_PixelTypeName == mOutputPixelTypeName) || (mOutputPixelTypeName == "NotSpecified")) { + if(mVV) { + if (mOutputPixelTypeName != "NotSpecified" || m_WriteCompression) { + std::cerr << "--vv is not compatible with --compression and --type options." << std::endl; + exit(-1); + } + + vvImageReader::Pointer reader = vvImageReader::New(); + reader->SetInputFilenames(m_InputFilenames); + reader->Update(vvImageReader::IMAGE); + + vvImageWriter::Pointer writer = vvImageWriter::New(); + writer->SetOutputFileName(m_OutputFilenames.front()); + writer->SetSaveTransform(true); + writer->SetInput(reader->GetOutput()); + writer->Update(); + return; + } + else if ((m_PixelTypeName == mOutputPixelTypeName) || (mOutputPixelTypeName == "NotSpecified")) { typename InputImageType::Pointer input = this->template GetInput(0); this->SetNextOutput(input); } else { diff --git a/tools/clitkImageConvertGenericFilter.h b/tools/clitkImageConvertGenericFilter.h index 2071714..8ffb360 100644 --- a/tools/clitkImageConvertGenericFilter.h +++ b/tools/clitkImageConvertGenericFilter.h @@ -73,6 +73,7 @@ namespace clitk { std::string GetInputPixelTypeName() { return m_PixelTypeName; } std::string GetOutputPixelTypeName() { return mOutputPixelTypeName; } void SetOutputPixelType(std::string p) { mOutputPixelTypeName = p; } + void SetVV(bool b) { mVV = b; } bool IsWarningOccur() { return mWarningOccur; } std::string & GetWarning() { return mWarning; } void EnableDisplayWarning(bool b) { mDisplayWarning = b; } @@ -92,6 +93,7 @@ namespace clitk { std::string mWarning; bool mWarningOccur; bool mDisplayWarning; + bool mVV; private: template