<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PersonName"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Fixedsys;
        panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"\@Fixedsys";
        panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
p
        {mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman";}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:Arial;
        color:windowtext;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor=white lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Dear Robert: <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>I very appreciate your prompt response,
and I ask for your favor for another problem I encountered in reading DICOM
image.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>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. <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-indent:.5in;text-autospace:none'><font size=2
color=blue face=Fixedsys><span style='font-size:10.0pt;font-family:Fixedsys;
color:blue'>typedef</span></font><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> <font color=blue><span
style='color:blue'>signed</span></font> <font color=blue><span
style='color:blue'>short</span></font> InputPixelType;<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> <font
color=blue><span style='color:blue'>const</span></font> <font color=blue><span
style='color:blue'>unsigned</span></font> <font color=blue><span
style='color:blue'>int</span></font> InputDimension = 2;<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> <o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> <font
color=blue><span style='color:blue'>typedef</span></font> itk::Image<
InputPixelType, InputDimension > InputImageType;<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> <font
color=blue><span style='color:blue'>typedef</span></font>
itk::ImageFileReader< InputImageType > ReaderType;<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> <font
color=blue><span style='color:blue'>typedef</span></font>
InputImageType::SizeType
SizeType;<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> ReaderType::Pointer
reader = ReaderType::New();<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> reader->SetFileName(
</span></font><font size=2><span style='font-size:10.0pt'>“</span></font><font
size=2 face=Fixedsys><span style='font-size:10.0pt;font-family:Fixedsys'>cFileName
);<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> <o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> <font
color=blue><span style='color:blue'>typedef</span></font>
itk::GDCMImageIO
ImageIOType;<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> ImageIOType::Pointer
gdcmImageIO = ImageIOType::New();<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> reader->SetImageIO(
gdcmImageIO );<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> <font
color=blue><span style='color:blue'>try<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> {<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> reader->Update();<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> }<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> <font
color=blue><span style='color:blue'>catch</span></font> (itk::ExceptionObject
& e)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> {<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> std::cerr
<< "exception in file reader " << std::endl;<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> std::cerr
<< e << std::endl;<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=green
face=Fixedsys><span style='font-size:10.0pt;font-family:Fixedsys;color:green'>// return
EXIT_FAILURE;<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> }<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> InputImageType::Pointer
image = reader->GetOutput() ;<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> <font
color=green><span style='color:green'><o:p></o:p></span></font></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> <font
color=blue><span style='color:blue'>unsigned</span></font> <font color=blue><span
style='color:blue'>long</span></font> lwidth =
image->GetLargestPossibleRegion().GetSize()[0] ;<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'> <font
color=blue><span style='color:blue'>unsigned</span></font> <font color=blue><span
style='color:blue'>long</span></font> lheight =
image->GetLargestPossibleRegion().GetSize()[1] ;<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>The information about the exception is:
itk::ImageFileReaderException@0x0122f17c.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Would you please tell me what is wrong in
the code and how to fix it? I very appreciate your kind help.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Best regards,<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Sam<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<div>
<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
<hr size=2 width="100%" align=center tabindex=-1>
</span></font></div>
<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> Robert Tamburo
[mailto:robert.tamburo@gmail.com] <br>
<b><span style='font-weight:bold'>Sent:</span></b> Wednesday, August 23, 2006
11:43 AM<br>
<b><span style='font-weight:bold'>To:</span></b> Xuejun; <st1:PersonName w:st="on">insight-users@itk.org</st1:PersonName><br>
<b><span style='font-weight:bold'>Subject:</span></b> Re: [Insight-users] Help
on image size</span></font><o:p></o:p></p>
</div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>
<div>
<p class=MsoNormal><font size=3 face=Arial><span style='font-size:12.0pt;
font-family:Arial'>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:</span></font><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> <o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 face=Arial><span style='font-size:12.0pt;
font-family:Arial'>itkSize<imageDimension> imageSize =
image->GetLargestPossibleRegion().GetSize()</span></font><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> <o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 face=Arial><span style='font-size:12.0pt;
font-family:Arial'>or you can just get each dimension individually, i.e., for
3D: </span></font><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> <o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 face=Arial><span style='font-size:12.0pt;
font-family:Arial'>unsigned long x =
image->GetLargestPossibleRegion().GetSize()[0]</span></font><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><font size=3 face=Arial><span style='font-size:12.0pt;
font-family:Arial'>unsigned long y =
image->GetLargestPossibleRegion().GetSize()[1]</span></font><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><font size=3 face=Arial><span style='font-size:12.0pt;
font-family:Arial'>unsigned long z =
image->GetLargestPossibleRegion().GetSize()[2]</span></font><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> <o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 face=Arial><span style='font-size:12.0pt;
font-family:Arial'>-Rob</span></font><o:p></o:p></p>
</div>
<blockquote style='border:none;border-left:solid black 1.5pt;padding:0in 0in 0in 4.0pt;
margin-left:3.75pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt'>
<div>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>----- Original Message ----- <o:p></o:p></span></font></p>
</div>
<div style='font-color:black'>
<p class=MsoNormal style='background:#E4E4E4'><b><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-weight:bold'>From:</span></font></b><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'> <a
href="mailto:sd2usa@gmail.com" title="sd2usa@gmail.com">Xuejun</a> <o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><b><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial;font-weight:bold'>To:</span></font></b><font size=2
face=Arial><span style='font-size:10.0pt;font-family:Arial'> <a
href="mailto:insight-users@itk.org" title="insight-users@itk.org">insight-users@itk.org</a>
<o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><b><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial;font-weight:bold'>Sent:</span></font></b><font size=2
face=Arial><span style='font-size:10.0pt;font-family:Arial'> Wednesday, August
23, 2006 10:46 AM<o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><b><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial;font-weight:bold'>Subject:</span></font></b><font size=2
face=Arial><span style='font-size:10.0pt;font-family:Arial'> [Insight-users]
Help on image size<o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>
</div>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>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.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Sam<o:p></o:p></span></font></p>
<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
<hr size=2 width="100%" align=center>
</span></font></div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>_______________________________________________<br>
Insight-users mailing list<br>
<a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><br>
<a href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a><o:p></o:p></span></font></p>
</blockquote>
</div>
</body>
</html>