<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:m="http://schemas.microsoft.com/office/2004/12/omml" 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 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
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 lang=NL link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Hi,<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Your size_x, size_y and size_z are not representing the actual &nbsp;size
of the image.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Add:<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>size = inputRegion-&gt;GetSize();<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Before <o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>size_x = &#8230;<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>size_y = &#8230;<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>size_z = &#8230;<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>I would however also suggest to use an imageIterator.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Regards,<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Brecht Heyde<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>

<p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:
"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'> insight-users-bounces@itk.org
[mailto:insight-users-bounces@itk.org] <b>On Behalf Of </b>john smith<br>
<b>Sent:</b> dinsdag 7 juni 2011 15:27<br>
<b>To:</b> robert tamburo; insight-users@itk.org<br>
<b>Subject:</b> Re: [Insight-users] get the maximum pixel value using
GetPixel() for 3D image<o:p></o:p></span></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='margin-bottom:12.0pt'>Thanks for your reply.I have
used the MinimumMaximumImageCalculator, but know I want to take the result
playing with the raw data.But I am trying to do that without using iterators,
just with using for loop. I have added the largest possible area from reader,
but when I am debuging my code, it seems that I cannot get inside the loop. Do
you know why? Here is my code:<br>
<br>
&nbsp;ReaderType::Pointer reader = ReaderType::New();<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp; reader-&gt;SetFileName( fileName.toStdString()&nbsp;
);<br>
&nbsp;&nbsp;&nbsp; &nbsp;reader-&gt;Update();<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp; InputImageType::RegionType inputRegion =<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
reader-&gt;GetOutput()-&gt;GetLargestPossibleRegion();<br>
<br>
&nbsp; <br>
&nbsp;&nbsp;&nbsp; //typedef itk::Image&lt; short, 3 &gt; InputImageType;<br>
&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;InputImageType::Pointer image =
reader-&gt;GetOutput();<br>
<br>
&nbsp; <br>
<br>
&nbsp; InputImageType::IndexType start;<br>
&nbsp; InputImageType::SizeType&nbsp; size;<br>
<br>
&nbsp; // get the size of the hole 3D image<br>
&nbsp; size_x = size[0];<br>
&nbsp; size_y = size[1];<br>
&nbsp; size_z = size[2];<br>
<br>
&nbsp; start[0] =&nbsp;&nbsp; 0;&nbsp; // first index on X<br>
&nbsp; start[1] =&nbsp;&nbsp; 0;&nbsp; // first index on Y<br>
&nbsp; start[2] =&nbsp;&nbsp; 0;&nbsp; // first index on Z<br>
<br>
&nbsp; InputImageType::RegionType region;<br>
&nbsp; region.SetSize( size );<br>
&nbsp; region.SetIndex( start );<br>
&nbsp; <br>
&nbsp; // Pixel data is allocated<br>
&nbsp; image-&gt;SetRegions( region );<br>
&nbsp; image-&gt;Allocate();<br>
<br>
&nbsp;&nbsp; int i,j,k;<br>
&nbsp;int max_value=0;<br>
<br>
&nbsp; for ( i=0;i&lt;size_x;i++) {<br>
&nbsp;&nbsp;&nbsp; &nbsp; for ( j=0;i&lt;size_y;j++){<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; for ( k=0;i&lt;size_z;k++){<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;
InputImageType::IndexType pixelIndex;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
pixelIndex[0] = i; // x position<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
pixelIndex[1] = j; // y position<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
pixelIndex[2] = k; // z position<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
InputImageType::PixelType pixelValue = image-&gt;GetPixel( pixelIndex );<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
if(pixelValue&gt;max_value){max_value=pixelValue;}<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; }<br>
&nbsp;&nbsp;&nbsp; &nbsp; }<br>
&nbsp; }<br>
<br>
&nbsp;&nbsp;
ui-&gt;label_22-&gt;setText(QString(&quot;maximum_value_raw%1&quot;).arg(max_value));<o:p></o:p></p>

<div>

<p class=MsoNormal>2011/6/7 robert tamburo &lt;<a
href="mailto:robert.tamburo@gmail.com">robert.tamburo@gmail.com</a>&gt;<o:p></o:p></p>

<p class=MsoNormal>GetPixel() belongs to itkImage, not the reader. Try
reader-&gt;GetOutput()-&gt;GetPixel(index). &nbsp;<o:p></o:p></p>

<div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

<div>

<p class=MsoNormal>Two other things: 1) You may want to consider using an
ImageRegionIterator instead of for loops, and 2) You can use the
MinimumMaximumImageCalculator to get the maximum intensity in an image.<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

<div>

<p class=MsoNormal>There are examples on how to use each class at&nbsp;<a
href="http://www.itk.org/Wiki/ITK/Examples" target="_blank">http://www.itk.org/Wiki/ITK/Examples</a><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

<div>

<p class=MsoNormal style='margin-bottom:12.0pt'><o:p>&nbsp;</o:p></p>

<div>

<div>

<div>

<p class=MsoNormal>On Tue, Jun 7, 2011 at 8:36 AM, john smith &lt;<a
href="mailto:mkitkinsightuser@gmail.com" target="_blank">mkitkinsightuser@gmail.com</a>&gt;
wrote:<o:p></o:p></p>

</div>

</div>

<blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;
margin-left:4.8pt;margin-right:0cm'>

<div>

<div>

<p class=MsoNormal style='margin-bottom:12.0pt'>Hello,<br>
<br>
I am trying to find the maximum pixel value of a 3D&nbsp; image, and I am using
the GetPixel method with 3 loops.I want to load my image from a file so I
created a reader pointer.Does this pointer include the raw data of my image? I
have created the following code but I get an error: GetPixel() method is not a
member of reader. Could somebody tell me what I am doing wrong? How I could
find the maximum pixel value of a loaded image with the method of GetPixel()?<br>
<br>
Thanks<br>
<br>
&nbsp; typedef
short&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
InputPixelType;<br>
&nbsp; const&nbsp;&nbsp; unsigned int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Dimension = 3;<br>
<br>
&nbsp; typedef itk::Image&lt; InputPixelType,&nbsp; Dimension
&gt;&nbsp;&nbsp;&nbsp; InputImageType;<br>
&nbsp; typedef itk::ImageFileReader&lt; InputImageType&nbsp; &gt;&nbsp;
ReaderType;<br>
<br>
<br>
&nbsp; ReaderType::Pointer reader = ReaderType::New();<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp; reader-&gt;SetFileName( fileName.toStdString()&nbsp;
);<br>
&nbsp;&nbsp;&nbsp; &nbsp;reader-&gt;Update();<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; InputImageType::RegionType inputRegion =<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
reader-&gt;GetOutput()-&gt;GetLargestPossibleRegion();<br>
<br>
&nbsp; InputImageType::SizeType size = inputRegion.GetSize();<br>
&nbsp;<br>
&nbsp; // get the size of the hole 3D image<br>
&nbsp; size_x = size[0];<br>
&nbsp; size_y = size[1];<br>
&nbsp; size_z = size[2];<br>
<br>
&nbsp;&nbsp; InputImageType::IndexType start = inputRegion.GetIndex();<br>
&nbsp; start[0] =&nbsp;&nbsp; 0;&nbsp; // first index on X<br>
&nbsp; start[1] =&nbsp;&nbsp; 0;&nbsp; // first index on Y<br>
&nbsp; start[2] =&nbsp;&nbsp; 0;&nbsp; // first index on Z<br>
<br>
&nbsp;int i,j,k;<br>
&nbsp;int max_value=0;<br>
&nbsp; for ( i=0;i&lt;size_x;i++) {<br>
&nbsp;&nbsp;&nbsp; &nbsp; for ( j=0;i&lt;size_y;j++){<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; for ( k=0;i&lt;size_z;k++){<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; InputImageType::IndexType
pixelIndex;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
pixelIndex[0] = i; // x position<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
pixelIndex[1] = j; // y position<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
pixelIndex[2] = k; // z position<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
InputImageType::PixelType pixelValue = reader-&gt;GetPixel( pixelIndex );<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
if(pixelValue&gt;max_value){max_value=pixelValue;}<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; }<br>
&nbsp;&nbsp;&nbsp; &nbsp; }<br>
&nbsp; }<o:p></o:p></p>

</div>

</div>

<p class=MsoNormal>_____________________________________<o:p></o:p></p>

<div>

<p class=MsoNormal style='margin-bottom:12.0pt'><br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><o:p></o:p></p>

</div>

</blockquote>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</body>

</html>