int main(int argc, char *argv[])
{
if ( argc < 3 )
{
std::cerr << "Missing Parameters " << std::endl;
std::cerr << "Usage: " << argv[0];
std::cerr << " visibleHumanPath outputImageFile" << std::endl;
return EXIT_FAILURE;
}
std::string visibleHumanPath = argv[1];
std::string outputImageFile = argv[2];
typedef unsigned char PixelType;
NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();
nameGenerator->SetSeriesFormat( visibleHumanPath+"a_vm%04d.raw" );
nameGenerator->SetStartIndex( 1001 );
nameGenerator->SetEndIndex( 2878 );
nameGenerator->SetIncrementIndex( 1 );
ImageIOType::Pointer rimageio = ImageIOType::New();
rimageio->SetDimensions( 0, 2048 );
rimageio->SetDimensions( 1, 1216 );
rimageio->SetSpacing( 0, .33 );
rimageio->SetSpacing( 1, .33 );
rimageio->SetHeaderSize(rimageio->GetImageSizeInPixels()*0);
ImageIOType::Pointer gimageio = ImageIOType::New();
gimageio->SetDimensions( 0, 2048 );
gimageio->SetDimensions( 1, 1216 );
gimageio->SetSpacing( 0, .33 );
gimageio->SetSpacing( 1, .33 );
gimageio->SetHeaderSize(gimageio->GetImageSizeInPixels()*1);
ImageIOType::Pointer bimageio = ImageIOType::New();
bimageio->SetDimensions( 0, 2048 );
bimageio->SetDimensions( 1, 1216 );
bimageio->SetSpacing( 0, .33 );
bimageio->SetSpacing( 1, .33 );
bimageio->SetHeaderSize(bimageio->GetImageSizeInPixels()*2);
SeriesReaderType::Pointer rreader = SeriesReaderType::New();
rreader->SetFileNames ( nameGenerator->GetFileNames() );
rreader->SetImageIO( rimageio );
SeriesReaderType::Pointer greader = SeriesReaderType::New();
greader->SetFileNames ( nameGenerator->GetFileNames() );
greader->SetImageIO( gimageio );
SeriesReaderType::Pointer breader = SeriesReaderType::New();
breader->SetFileNames ( nameGenerator->GetFileNames() );
breader->SetImageIO( bimageio );
ComposeRGBFilterType::Pointer composeRGB = ComposeRGBFilterType::New();
composeRGB->SetInput1( rreader->GetOutput() );
composeRGB->SetInput2( greader->GetOutput() );
composeRGB->SetInput3( breader->GetOutput() );
composeRGB->UpdateOutputInformation();
RGB3DImageType::RegionType coronalSlice = composeRGB->GetOutput()->GetLargestPossibleRegion();
coronalSlice.SetIndex( 1, 448 );
coronalSlice.SetSize( 1, 0 );
ExtractFilterType::Pointer extract = ExtractFilterType::New();
extract->SetDirectionCollapseToIdentity();
extract->InPlaceOn();
extract->SetInput( composeRGB->GetOutput() );
extract->SetExtractionRegion(coronalSlice);
ImageWriterType::Pointer writer = ImageWriterType::New();
writer->SetFileName( outputImageFile );
writer->SetNumberOfStreamDivisions( 200 );
writer->SetInput( extract->GetOutput() );
try
{
writer->Update();
}
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}