X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=filters%2FclitkImageConvertGenericFilter.cxx;h=944ec8cf8eaec2400f0af676877b18a6a28076d5;hb=9d6949060d302078e7a06fc9b0fbdcf96091b29a;hp=9f35379c0e1a59d71d8354e31ada484370e9aae9;hpb=4ea2c946973c570cbe540a27cf44d6acdf44867c;p=clitk.git diff --git a/filters/clitkImageConvertGenericFilter.cxx b/filters/clitkImageConvertGenericFilter.cxx index 9f35379..944ec8c 100644 --- a/filters/clitkImageConvertGenericFilter.cxx +++ b/filters/clitkImageConvertGenericFilter.cxx @@ -1,7 +1,7 @@ /*========================================================================= Program: vv http://www.creatis.insa-lyon.fr/rio/vv - Authors belong to: + Authors belong to: - University of LYON http://www.universite-lyon.fr/ - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr @@ -22,35 +22,32 @@ //-------------------------------------------------------------------- clitk::ImageConvertGenericFilter::ImageConvertGenericFilter(): - clitk::ImageToImageGenericFilter("ImageConvert") { + clitk::ImageToImageGenericFilter("ImageConvert") +{ mOutputPixelTypeName = "NotSpecified"; mWarningOccur = false; mWarning = ""; mDisplayWarning = true; InitializeImageType<2>(); - InitializeImageType<3>(); - InitializeImageType<4>(); + InitializeImageType<3>(); + InitializeImageType<4>(); } //-------------------------------------------------------------------- //-------------------------------------------------------------------- template -void clitk::ImageConvertGenericFilter::InitializeImageType() { - ADD_IMAGE_TYPE(Dim, char); - ADD_IMAGE_TYPE(Dim, unsigned char); - ADD_IMAGE_TYPE(Dim, short); - ADD_IMAGE_TYPE(Dim, unsigned short); - ADD_IMAGE_TYPE(Dim, int); - ADD_IMAGE_TYPE(Dim, float); - ADD_IMAGE_TYPE(Dim, double); +void clitk::ImageConvertGenericFilter::InitializeImageType() +{ + ADD_DEFAULT_IMAGE_TYPES(Dim); } //-------------------------------------------------------------------- //-------------------------------------------------------------------- template -void clitk::ImageConvertGenericFilter::UpdateWithInputImageType() { +void clitk::ImageConvertGenericFilter::UpdateWithInputImageType() +{ // Verbose stuff if (mIOVerbose) { @@ -59,13 +56,12 @@ void clitk::ImageConvertGenericFilter::UpdateWithInputImageType() { itk::ImageIOBase::Pointer header = clitk::readImageHeader(mInputFilenames[0]); printImageHeader(header, std::cout); std::cout << std::endl; - } - else { + } else { for(unsigned int i=0; i is "; - itk::ImageIOBase::Pointer h = clitk::readImageHeader(mInputFilenames[i]); - printImageHeader(h, std::cout); - std::cout << std::endl; + std::cout << "Input image " << i << " <" << mInputFilenames[i] << "> is "; + itk::ImageIOBase::Pointer h = clitk::readImageHeader(mInputFilenames[i]); + printImageHeader(h, std::cout); + std::cout << std::endl; } } } @@ -76,8 +72,7 @@ void clitk::ImageConvertGenericFilter::UpdateWithInputImageType() { typename InputImageType::Pointer input = this->template GetInput(0); //clitk::writeImage(input, mOutputFilename, mIOVerbose); this->SetNextOutput(input); - } - else { + } else { #define TRY_TYPE(TYPE) \ if (IsSameType(mOutputPixelTypeName)) { UpdateWithOutputType(); return; } TRY_TYPE(char); @@ -91,16 +86,17 @@ void clitk::ImageConvertGenericFilter::UpdateWithInputImageType() { #undef TRY_TYPE std::string list = CreateListOfTypes(); - std::cerr << "Error, I don't know the output type '" << mOutputPixelTypeName - << "'. " << std::endl << "Known types are " << list << "." << std::endl; + std::cerr << "Error, I don't know the output type '" << mOutputPixelTypeName + << "'. " << std::endl << "Known types are " << list << "." << std::endl; exit(0); - } + } } //==================================================================== //==================================================================== template -void clitk::ImageConvertGenericFilter::UpdateWithOutputType() { +void clitk::ImageConvertGenericFilter::UpdateWithOutputType() +{ // Read typename InputImageType::Pointer input =this->template GetInput(0); @@ -111,15 +107,15 @@ void clitk::ImageConvertGenericFilter::UpdateWithOutputType() { std::ostringstream osstream; if (std::numeric_limits::is_signed) { if (!std::numeric_limits::is_signed) { - osstream << "Warning, input type is signed (" << mPixelTypeName << ") while output type is not (" - << mOutputPixelTypeName << "), use at your own responsability." << std::endl; - mWarningOccur = true; + osstream << "Warning, input type is signed (" << mPixelTypeName << ") while output type is not (" + << mOutputPixelTypeName << "), use at your own responsability." << std::endl; + mWarningOccur = true; } } if (!std::numeric_limits::is_integer) { if (std::numeric_limits::is_integer) { - osstream << "Warning, input type is not integer (" << mPixelTypeName << ") while output type is (" - << mOutputPixelTypeName << "), use at your own responsability." << std::endl; + osstream << "Warning, input type is not integer (" << mPixelTypeName << ") while output type is (" + << mOutputPixelTypeName << "), use at your own responsability." << std::endl; mWarningOccur = true; } } @@ -127,14 +123,14 @@ void clitk::ImageConvertGenericFilter::UpdateWithOutputType() { // DD(std::numeric_limits::digits10); if (!std::numeric_limits::is_integer) { if (std::numeric_limits::is_integer) { - osstream << "Warning, input type is not integer (" << mPixelTypeName << ") while output type is (" - << mOutputPixelTypeName << "), use at your own responsability." << std::endl; + osstream << "Warning, input type is not integer (" << mPixelTypeName << ") while output type is (" + << mOutputPixelTypeName << "), use at your own responsability." << std::endl; mWarningOccur = true; } } if (std::numeric_limits::digits10 > std::numeric_limits::digits10) { - osstream << "Warning, possible loss of precision : input type is (" << mPixelTypeName << ") while output type is (" - << mOutputPixelTypeName << "), use at your own responsability." << std::endl; + osstream << "Warning, possible loss of precision : input type is (" << mPixelTypeName << ") while output type is (" + << mOutputPixelTypeName << "), use at your own responsability." << std::endl; mWarningOccur = true; }