#include "vtkImageData.h"
#include "vtkImageCast.h"
int main(int, char *[])
{
if(!directory) return 1;
std::string file = std::string(directory) + "/012345.002.050.dcm";
std::cout << file << std::endl;
reader->SetFileName( file.c_str() );
reader->Update();
vtkImageCast *cast = vtkImageCast::New();
#if (VTK_MAJOR_VERSION >= 6)
cast->SetInputConnection( reader->GetOutputPort() );
#else
cast->SetInput( reader->GetOutput() );
#endif
cast->SetOutputScalarTypeToUnsignedChar();
writer->SetFileName( "/tmp/cast.dcm" );
#if (VTK_MAJOR_VERSION >= 6)
writer->SetInputConnection( cast->GetOutputPort() );
#else
writer->SetInput( cast->GetOutput() );
#endif
writer->SetImageFormat( reader->GetImageFormat() );
writer->SetShift( reader->GetShift() );
writer->SetScale( reader->GetScale() );
reader->Delete();
cast->Delete();
writer->Delete();
return 0;
}