Functions

mitkItkPictureWrite.cpp File Reference

#include "mitkItkPictureWrite.h"
#include "mitkImageAccessByItk.h"
#include <itkNumericSeriesFileNames.h>
#include <itkImageSeriesWriter.h>
#include <itkRescaleIntensityImageFilter.h>

Go to the source code of this file.

Functions

template<typename TPixel , unsigned int VImageDimension>
void _mitkItkPictureWrite (itk::Image< TPixel, VImageDimension > *itkImage, const std::string &fileName)
template void _mitkItkPictureWrite< double, 2 > (itk::Image< double, 2 > *, const std::string &)
template void _mitkItkPictureWrite< float, 2 > (itk::Image< float, 2 > *, const std::string &)
template void _mitkItkPictureWrite< int, 2 > (itk::Image< int, 2 > *, const std::string &)
template void _mitkItkPictureWrite< unsigned int, 2 > (itk::Image< unsigned int, 2 > *, const std::string &)
template void _mitkItkPictureWrite< short, 2 > (itk::Image< short, 2 > *, const std::string &)
template void _mitkItkPictureWrite< unsigned short, 2 > (itk::Image< unsigned short, 2 > *, const std::string &)
template void _mitkItkPictureWrite< char, 2 > (itk::Image< char, 2 > *, const std::string &)
template void _mitkItkPictureWrite< unsigned char, 2 > (itk::Image< unsigned char, 2 > *, const std::string &)
template void _mitkItkPictureWrite< double, 3 > (itk::Image< double, 3 > *, const std::string &)
template void _mitkItkPictureWrite< float, 3 > (itk::Image< float, 3 > *, const std::string &)
template void _mitkItkPictureWrite< int, 3 > (itk::Image< int, 3 > *, const std::string &)
template void _mitkItkPictureWrite< unsigned int, 3 > (itk::Image< unsigned int, 3 > *, const std::string &)
template void _mitkItkPictureWrite< short, 3 > (itk::Image< short, 3 > *, const std::string &)
template void _mitkItkPictureWrite< unsigned short, 3 > (itk::Image< unsigned short, 3 > *, const std::string &)
template void _mitkItkPictureWrite< char, 3 > (itk::Image< char, 3 > *, const std::string &)
template void _mitkItkPictureWrite< unsigned char, 3 > (itk::Image< unsigned char, 3 > *, const std::string &)

Function Documentation

template<typename TPixel , unsigned int VImageDimension>
void _mitkItkPictureWrite ( itk::Image< TPixel, VImageDimension > *  itkImage,
const std::string &  fileName 
)

Definition at line 27 of file mitkItkPictureWrite.cpp.

Referenced by mitk::ImageWriter::WriteByITK().

{
  typedef itk::Image< TPixel, VImageDimension > TImageType;

  typedef itk::Image<unsigned char,3> OutputImage3DType;
  typedef itk::Image<unsigned char,2> OutputImage2DType;
  typename itk::RescaleIntensityImageFilter<TImageType, OutputImage3DType>::Pointer rescaler = itk::RescaleIntensityImageFilter<TImageType, OutputImage3DType>::New();
  rescaler->SetInput(itkImage);
  rescaler->SetOutputMinimum(0);
  rescaler->SetOutputMaximum(255);
  itk::NumericSeriesFileNames::Pointer numericFileNameWriter = itk::NumericSeriesFileNames::New();
  itk::ImageSeriesWriter<OutputImage3DType, OutputImage2DType>::Pointer writer = itk::ImageSeriesWriter<OutputImage3DType, OutputImage2DType >::New();

  int numberOfSlices = itkImage->GetLargestPossibleRegion().GetSize()[2];
  std::string finalFileName = fileName;
  std::string::size_type pos = fileName.find_last_of(".",fileName.length()-1);
  if(pos==std::string::npos)
    finalFileName.append(".%d.png");
  else
    finalFileName.insert(pos,".%d");

  numericFileNameWriter->SetEndIndex(numberOfSlices);
  numericFileNameWriter->SetSeriesFormat(finalFileName.c_str());
  numericFileNameWriter->Modified();

  writer->SetInput( rescaler->GetOutput() );
  writer->SetFileNames(numericFileNameWriter->GetFileNames());
  writer->Update();
}
template void _mitkItkPictureWrite< char, 2 > ( itk::Image< char, 2 > *  ,
const std::string &   
)
template void _mitkItkPictureWrite< char, 3 > ( itk::Image< char, 3 > *  ,
const std::string &   
)
template void _mitkItkPictureWrite< double, 2 > ( itk::Image< double, 2 > *  ,
const std::string &   
)
template void _mitkItkPictureWrite< double, 3 > ( itk::Image< double, 3 > *  ,
const std::string &   
)
template void _mitkItkPictureWrite< float, 2 > ( itk::Image< float, 2 > *  ,
const std::string &   
)
template void _mitkItkPictureWrite< float, 3 > ( itk::Image< float, 3 > *  ,
const std::string &   
)
template void _mitkItkPictureWrite< int, 2 > ( itk::Image< int, 2 > *  ,
const std::string &   
)
template void _mitkItkPictureWrite< int, 3 > ( itk::Image< int, 3 > *  ,
const std::string &   
)
template void _mitkItkPictureWrite< short, 2 > ( itk::Image< short, 2 > *  ,
const std::string &   
)
template void _mitkItkPictureWrite< short, 3 > ( itk::Image< short, 3 > *  ,
const std::string &   
)
template void _mitkItkPictureWrite< unsigned char, 2 > ( itk::Image< unsigned char, 2 > *  ,
const std::string &   
)
template void _mitkItkPictureWrite< unsigned char, 3 > ( itk::Image< unsigned char, 3 > *  ,
const std::string &   
)
template void _mitkItkPictureWrite< unsigned int, 2 > ( itk::Image< unsigned int, 2 > *  ,
const std::string &   
)
template void _mitkItkPictureWrite< unsigned int, 3 > ( itk::Image< unsigned int, 3 > *  ,
const std::string &   
)
template void _mitkItkPictureWrite< unsigned short, 2 > ( itk::Image< unsigned short, 2 > *  ,
const std::string &   
)
template void _mitkItkPictureWrite< unsigned short, 3 > ( itk::Image< unsigned short, 3 > *  ,
const std::string &   
)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines