Dicom Header Example For Essay

#include "itkImageFileReader.h"

#include "itkImageFileWriter.h"

#include "itkRescaleIntensityImageFilter.h"

#include "itkGDCMImageIO.h"

#include <list>

#include <fstream>

int main( int argc, char* argv[] )

{

if( argc < 5 )

{

std::cerr << "Usage: " << std::endl;

std::cerr << argv[0] << " DicomImage OutputDicomImage ";

std::cerr << " OutputImage RescaleDicomImage\n";

return EXIT_FAILURE;

}

typedefsignedshort InputPixelType;

constunsignedint InputDimension = 2;

typedefitk::Image< InputPixelType, InputDimension > InputImageType;

typedefitk::ImageFileReader< InputImageType > ReaderType;

ReaderType::Pointer reader = ReaderType::New();

reader->SetFileName( argv[1] );

typedefitk::GDCMImageIO ImageIOType;

ImageIOType::Pointer gdcmImageIO = ImageIOType::New();

reader->SetImageIO( gdcmImageIO );

try

{

reader->Update();

}

catch (itk::ExceptionObject & e)

{

std::cerr << "exception in file reader " << std::endl;

std::cerr << e << std::endl;

return EXIT_FAILURE;

}

typedefitk::ImageFileWriter< InputImageType > Writer1Type;

Writer1Type::Pointer writer1 = Writer1Type::New();

writer1->SetFileName( argv[2] );

writer1->SetInput( reader->GetOutput() );

writer1->SetImageIO( gdcmImageIO );

try

{

writer1->Update();

}

catch (itk::ExceptionObject & e)

{

std::cerr << "exception in file writer " << std::endl;

std::cerr << e << std::endl;

return EXIT_FAILURE;

}

typedefunsignedchar WritePixelType;

typedefitk::Image< WritePixelType, 2 > WriteImageType;

typedefitk::RescaleIntensityImageFilter<

InputImageType, WriteImageType > RescaleFilterType;

RescaleFilterType::Pointer rescaler = RescaleFilterType::New();

rescaler->SetOutputMinimum( 0 );

rescaler->SetOutputMaximum( 255 );

typedefitk::ImageFileWriter< WriteImageType > Writer2Type;

Writer2Type::Pointer writer2 = Writer2Type::New();

writer2->SetFileName( argv[3] );

rescaler->SetInput( reader->GetOutput() );

writer2->SetInput( rescaler->GetOutput() );

try

{

writer2->Update();

}

catch (itk::ExceptionObject & e)

{

std::cerr << "exception in file writer " << std::endl;

std::cerr << e << std::endl;

return EXIT_FAILURE;

}

typedefitk::ImageFileWriter< WriteImageType > Writer3Type;

Writer3Type::Pointer writer3 = Writer3Type::New();

writer3->SetFileName( argv[4] );

writer3->SetInput( rescaler->GetOutput() );

writer3->UseInputMetaDataDictionaryOff ();

writer3->SetImageIO( gdcmImageIO );

try

{

writer3->Update();

}

catch (itk::ExceptionObject & e)

{

std::cerr << "Exception in file writer " << std::endl;

std::cerr << e << std::endl;

return EXIT_FAILURE;

}

return EXIT_SUCCESS;

}


Main | Search | Add Download | New Downloads | Random

Featured download: A Practical Guide to TG-142 QA
This is a Word document and XLS file designed to assist clinical physicists with implementing AAPM TG-142 recommendations for linear accelerator QA. It provides examples of tests that can be performed to fulfill TG-142’s recommendations.
Details - View more featured


Categories

Educational
ABR certification, graduate programs, and clinical residencies.

Linear Accelerators
Commissioning, calibration, and QA of linacs, IMRT, IGRT, treatment planning systems, etc.

Nuclear Medicine
PET, Spect, radioisotope production, internal dosimetry, etc.
Other
Anything not listed.

Presentations
Radiation safety, topic overviews, any miscellaneous presentations.

Treatment Planning
External beam treatment planning systems and MU check tools.

Unless otherwise specified, all files are distributed under the MIT open source license for research and educational use only with no fitness guarantee.
Interactive software released under GNU GPL, Code Credits, Privacy Policy

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *