[Insight-users] Reading Dicom files
Hoole, Andrew
andrew.hoole at addenbrookes.nhs.uk
Thu Jun 1 12:26:46 EDT 2006
Hi All
I'm new to the ITK stuff and having been working through the User guide. I
have used the code in the guide to read a DICOM file and display it in a
window. When I read the file it doesn't appear to read the information
related to the pixel size or the origin of the image. This information is
embedded in the DICOM is there a way to make the reader get this data or is
the problem with the image which I hook onto the output of the reader. The
code I am using is as follows:
typedef signed short InputPixelType;
const unsigned int InputDimension = 2;
typedef itk::Image< InputPixelType, InputDimension >
InputImageType;
typedef itk::ImageFileReader< InputImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName("c:\\temp\\test.dcm");
typedef itk::GDCMImageIO ImageIOType;
ImageIOType::Pointer gdcmImageIO = ImageIOType::New();
reader->SetImageIO( gdcmImageIO );
try {
reader->Update();
}
catch (itk::ExceptionObject & e){
AfxMessageBox("Exception in file reader
",MB_OK,NULL);
return;
}
typedef itk::Point< double, InputImageType::ImageDimension >
PointType;
PointType point;
InputImageType::IndexType pixelIndex;
InputImageType::PixelType pixelValue;
InputImageType::Pointer image = reader->GetOutput();
InputImageType::SpacingType spacing;
spacing[0] = 0.5; // spacing along X
spacing[1] = 0.5; // spacing along Y
image->SetSpacing( spacing );
InputImageType::PointType origin;
origin[0] = -128.0; // coordinates of the
origin[1] = -128.0; // first pixel in N-D
image->SetOrigin( origin );
As you can see I am manually setting the pixel size and origin which is not
ideal.
Regards
Andrew Hoole
-------------------------------------------------------------------------
Medical Physics, Box 152
Cambridge University Hospitals NHS Trust
Addenbrooke's Hospital
Hills Rd
Cambridge Tel: (+44) (0)1223-216544
CB2 2QQ Fax: (+44) (0)1223-257137
UK Email: andrew.hoole at addenbrookes.nhs.uk
--------------------------------------------------------------------------
The information contained in this EMAIL and any attachments is confidential
and intended solely for the attention and use of the intended recipient. If
you are not the intended recipient and have received this email in error you
may not disclose, copy, distribute or retain this message or any part of it.
See Email disclaimer <http://www.addenbrookes.org.uk/email_disclaimer.html
<http://www.addenbrookes.org.uk/email_disclaimer.html> >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20060601/486ae4c6/attachment.htm
More information about the Insight-users
mailing list