[Insight-users] Help on reading DICOM image
Xuejun
sd2usa at gmail.com
Wed Aug 23 12:36:49 EDT 2006
Dear Robert:
I very appreciate your prompt response, and I ask for your favor for another
problem I encountered in reading DICOM image.
I followed your instructions in getting image sizes. Because all sizes of
the image displayed 0, I checked the code and found that an exception
happened in reading the DICOM image. I copied exactly the code in the ItkApp
file DicomImageReadWrite.cxx as follows and tested it using the testing
DICOM image image0075.dcm in the ItkApp.
typedef signed short InputPixelType;
const unsigned int InputDimension = 2;
typedef itk::Image< InputPixelType, InputDimension > InputImageType;
typedef itk::ImageFileReader< InputImageType > ReaderType;
typedef InputImageType::SizeType SizeType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( "cFileName );
typedef itk::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;
}
InputImageType::Pointer image = reader->GetOutput() ;
unsigned long lwidth = image->GetLargestPossibleRegion().GetSize()[0]
;
unsigned long lheight = image->GetLargestPossibleRegion().GetSize()[1]
;
The information about the exception is:
itk::ImageFileReaderException at 0x0122f17c.
Would you please tell me what is wrong in the code and how to fix it? I very
appreciate your kind help.
Best regards,
Sam
_____
From: Robert Tamburo [mailto:robert.tamburo at gmail.com]
Sent: Wednesday, August 23, 2006 11:43 AM
To: Xuejun; insight-users at itk.org
Subject: Re: [Insight-users] Help on image size
The image base class has the functionality to return image regions as well
as the size of these regions. To retrieve the size of the image, you can use
the following:
itkSize<imageDimension> imageSize =
image->GetLargestPossibleRegion().GetSize()
or you can just get each dimension individually, i.e., for 3D:
unsigned long x = image->GetLargestPossibleRegion().GetSize()[0]
unsigned long y = image->GetLargestPossibleRegion().GetSize()[1]
unsigned long z = image->GetLargestPossibleRegion().GetSize()[2]
-Rob
----- Original Message -----
From: Xuejun <mailto:sd2usa at gmail.com>
To: insight-users at itk.org
Sent: Wednesday, August 23, 2006 10:46 AM
Subject: [Insight-users] Help on image size
Can anybody tell me how to get the image size, including the height and the
width of an image? Your kind help is greatly appreciated.
Sam
_____
_______________________________________________
Insight-users mailing list
Insight-users at itk.org
http://www.itk.org/mailman/listinfo/insight-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20060823/3027ecbc/attachment.html
More information about the Insight-users
mailing list