[Insight-users] ResampleDICOM
Brenno Ribeiro
brennobr at gmail.com
Thu Sep 6 11:10:59 EDT 2012
Attached a snippet of the function I use to read and make some
transformations in the DICOM file read.
--
Brenno Bernardes Ribeiro
Engenharia da Computação
Universidade Federal do Pará
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120906/9cb18c8d/attachment.htm>
-------------- next part --------------
//Getting the file's name from the QDialog
QByteArray byteArray = fileName.toUtf8();
const char* inputDicomFilename1 = byteArray.constData();
QVTKWidget *vtkWidget = new QVTKWidget;
//Declarations
typedef signed short InputPixelType;
const unsigned int InputDimension = 2;
typedef itk::Image< InputPixelType, InputDimension > InputImageType;
typedef itk::Image< InputPixelType, InputDimension > GaussianImageType;
typedef itk::Image< InputPixelType, InputDimension > WriteImageType;
typedef itk::Image<unsigned char, 2> ImageType;
typedef itk::ImageFileReader< InputImageType > ReaderTypeSeries;//declarao do cabecalho da imagem do parametro de entrada
typedef itk::GDCMImageIO ImageIOTypeGDCM;//declaracao do filtro para imagem dicom do tipo itk
typedef itk::FlipImageFilter <InputImageType> FlipImageFilterType;//filtro flip
typedef itk::ImageToVTKImageFilter<InputImageType> FilterType;//declaracao do filtro de transformacao itk para vtk
ReaderTypeSeries::Pointer reader = ReaderTypeSeries::New();//instanciacao do cabecalho do arquivo de entrada
ImageIOTypeGDCM::Pointer gdcmImageIO = ImageIOTypeGDCM::New();//instanciacao da imagem dicom do tipo itk
FlipImageFilterType::Pointer flipFilter = FlipImageFilterType::New ();//instanciacao da imagem invertida
FilterType::Pointer connector = FilterType::New();//instanciacao do conector de transformacao itk para vtk
//read the dicom file
reader->SetFileName( inputDicomFilename1 );//reader the file's nome from the QDialog
reader->SetImageIO( gdcmImageIO );
try
{
reader->Update();//inicia o processo
}
catch (itk::ExceptionObject & e)//caso gere alguma excessao
{
std::cerr << "exception in file reader " << std::endl;
std::cerr << e << std::endl;
}
//making some transformation
flipFilter->SetInput(reader->GetOutput());
itk::FixedArray<bool, 2> flipAxes;
flipAxes[0] = false;
flipAxes[1] = true;
flipFilter->SetFlipAxes(flipAxes);
try
{
flipFilter->Update(); //I'd like to pass this result into a new dicom file with the same tags from the input
}
catch( itk::ExceptionObject & err )
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
}
connector->SetInput( flipFilter->GetOutput() ); //export to vtk
try
{
connector->Update();
}
catch( itk::ExceptionObject & err )
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
// return ;//EXIT_FAILURE;
}
More information about the Insight-users
mailing list