Hi<br>
<br>
I am trying to read a 3D volume and write into a file. My code should
take any kind of pixel type and change it to specified type. I am
losing the data. Can any one tell me what is not working? here is my
code:<br>
<br>
#include "itkImageFileReader.h"<br>
#include "itkImageFileWriter.h"<br>
#include "itkRescaleIntensityImageFilter.h"<br>
<br>
int main(int argc, char *argv[])<br>
{<br>
//Check number of commandline parameters<br>
if( argc < 3)<br>
{<br>
std:: cerr << "Incorrect
number of parameters, check the usage: " << std::endl;<br>
std:: cerr << "inputFile outputFile " << std::endl;<br>
return EXIT_FAILURE;<br>
}<br>
<br>
//Input pixel type and output pixel type<br>
typedef unsigned short InputPixelType; //My data type is unsigned short<br>
typedef unsigned short OutputPixelType;<br>
<br>
//Dimension of the image<br>
const unsigned int Dimension = 3;<br>
<br>
const char* inputFilename = argv[1];<br>
const char* outputFilename = argv[2];<br>
<br>
typedef itk::Image< InputPixelType, Dimension > InputImageType;<br>
typedef itk::Image< OutputPixelType, Dimension > OutputImageType;<br>
<br>
typedef itk::ImageFileReader< InputImageType > ReaderType;<br>
typedef itk::ImageFileWriter< OutputImageType > WriterType;<br>
<br>
typedef itk::RescaleIntensityImageFilter<
InputImageType, OutputImageType >
RescaleFilterType;<br>
<br>
RescaleFilterType::Pointer rescalefilter = RescaleFilterType::New();<br>
<br>
rescalefilter->SetOutputMinimum( 0 );<br>
rescalefilter->SetOutputMaximum( 2019 );<br>
<br>
//Create reader and writer, update the pipeline<br>
ReaderType::Pointer reader = ReaderType::New();<br>
WriterType::Pointer writer = WriterType::New();<br>
<br>
<br>
reader->SetFileName( inputFilename );<br>
writer->SetFileName( outputFilename );<br>
<br>
rescalefilter->SetInput( reader->GetOutput() );<br>
writer->SetInput( rescalefilter->GetOutput() );<br>
<br>
try<br>
{<br>
writer->Update();<br>
}<br>
catch( itk::ExceptionObject & err )<br>
{<br>
std::cerr << "ExceptionObject caught !" << std::endl;<br>
std::cerr << err << std::endl;<br>
return EXIT_FAILURE;<br>
}<br>
<br>
return EXIT_SUCCESS;<br>
}<br>