+//====================================================================
+
+//====================================================================
+template<class InputImageType, class OutputPixelType>
+void clitk::ImageConvertGenericFilter::UpdateWithOutputType()
+{
+ // Read
+ typename InputImageType::Pointer input =this->template GetInput<InputImageType>(0);
+
+ // Typedef
+ typedef typename InputImageType::PixelType PixelType;
+
+ // Warning
+ std::ostringstream osstream;
+ if (std::numeric_limits<PixelType>::is_signed) {
+ if (!std::numeric_limits<OutputPixelType>::is_signed) {
+ osstream << "Warning, input type is signed (" << m_PixelTypeName << ") while output type is not ("
+ << mOutputPixelTypeName << "), use at your own responsability." << std::endl;
+ mWarningOccur = true;
+ }
+ }
+ if (!std::numeric_limits<PixelType>::is_integer) {
+ if (std::numeric_limits<OutputPixelType>::is_integer) {
+ osstream << "Warning, input type is not integer (" << m_PixelTypeName << ") while output type is ("
+ << mOutputPixelTypeName << "), use at your own responsability." << std::endl;
+ mWarningOccur = true;
+ }
+ }
+ // DD(std::numeric_limits<PixelType>::digits10);
+ // DD(std::numeric_limits<OutputPixelType>::digits10);
+ if (!std::numeric_limits<PixelType>::is_integer) {
+ if (std::numeric_limits<OutputPixelType>::is_integer) {
+ osstream << "Warning, input type is not integer (" << m_PixelTypeName << ") while output type is ("
+ << mOutputPixelTypeName << "), use at your own responsability." << std::endl;
+ mWarningOccur = true;
+ }
+ }
+ if (std::numeric_limits<PixelType>::digits10 > std::numeric_limits<OutputPixelType>::digits10) {
+ osstream << "Warning, possible loss of precision : input type is (" << m_PixelTypeName << ") while output type is ("
+ << mOutputPixelTypeName << "), use at your own responsability." << std::endl;
+ mWarningOccur = true;
+ }
+
+ mWarning = osstream.str();
+ if (mDisplayWarning) {
+ std::cerr << mWarning;
+ }
+
+ // Cast
+ typedef itk::Image<OutputPixelType,InputImageType::ImageDimension> OutputImageType;
+ typedef itk::CastImageFilter<InputImageType, OutputImageType> FilterType;
+ typename FilterType::Pointer filter = FilterType::New();
+ filter->SetInput(input);
+ filter->Update();
+
+ // Write
+ SetNextOutput<OutputImageType>(filter->GetOutput());
+ //clitk::writeImage<OutputImageType>(filter->GetOutput(), mOutputFilename, m_IOVerbose);
+}
+//====================================================================
+