<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: Times New Roman; font-size: 12pt; color: #000000'>That's the best, I agree.<br><br>Vicnent<br><br><hr id="zwchr"><blockquote style="border-left:2px solid rgb(16, 16, 255);margin-left:5px;padding-left:5px;"><b>From: </b>"robert tamburo" <robert.tamburo@gmail.com><br><b>To: </b>"john smith" <mkitkinsightuser@gmail.com><br><b>Cc: </b>insight-users@itk.org<br><b>Sent: </b>Tuesday, 7 June, 2011 3:24:21 PM<br><b>Subject: </b>Re: [Insight-users] get the maximum pixel value using GetPixel() for 3D image<br><br>GetPixel() belongs to itkImage, not the reader. Try reader->GetOutput()->GetPixel(index). <div><br></div><div>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.</div>
<div><br></div><div>There are examples on how to use each class at <a href="http://www.itk.org/Wiki/ITK/Examples" target="_blank">http://www.itk.org/Wiki/ITK/Examples</a></div><div><br></div><div><a href="http://www.itk.org/Wiki/ITK/Examples" target="_blank"></a><br>
<br><div class="gmail_quote">On Tue, Jun 7, 2011 at 8:36 AM, john smith <span dir="ltr"><<a href="mailto:mkitkinsightuser@gmail.com" target="_blank">mkitkinsightuser@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hello,<br><br>I am trying to find the maximum pixel value of a 3D 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> typedef short InputPixelType;<br> const unsigned int Dimension = 3;<br><br> typedef itk::Image< InputPixelType, Dimension > InputImageType;<br> typedef itk::ImageFileReader< InputImageType > ReaderType;<br>
<br><br> ReaderType::Pointer reader = ReaderType::New();<br><br> reader->SetFileName( fileName.toStdString() );<br> reader->Update();<br><br> InputImageType::RegionType inputRegion =<br> reader->GetOutput()->GetLargestPossibleRegion();<br>
<br> InputImageType::SizeType size = inputRegion.GetSize();<br> <br> // get the size of the hole 3D image<br> size_x = size[0];<br> size_y = size[1];<br> size_z = size[2];<br><br> InputImageType::IndexType start = inputRegion.GetIndex();<br>
start[0] = 0; // first index on X<br> start[1] = 0; // first index on Y<br> start[2] = 0; // first index on Z<br><br> int i,j,k;<br> int max_value=0;<br> for ( i=0;i<size_x;i++) {<br> for ( j=0;i<size_y;j++){<br>
for ( k=0;i<size_z;k++){<br><br> InputImageType::IndexType pixelIndex;<br> pixelIndex[0] = i; // x position<br> pixelIndex[1] = j; // y position<br> pixelIndex[2] = k; // z position<br>
<br> InputImageType::PixelType pixelValue = reader->GetPixel( pixelIndex );<br><br> if(pixelValue>max_value){max_value=pixelValue;}<br> <br> }<br> }<br> }<br>
<br>_____________________________________<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><br>
<br></blockquote></div><br></div>
<br>_____________________________________<br>Powered by www.kitware.com<br><br>Visit other Kitware open-source projects at<br>http://www.kitware.com/opensource/opensource.html<br><br>Kitware offers ITK Training Courses, for more information visit:<br>http://www.kitware.com/products/protraining.html<br><br>Please keep messages on-topic and check the ITK FAQ at:<br>http://www.itk.org/Wiki/ITK_FAQ<br><br>Follow this link to subscribe/unsubscribe:<br>http://www.itk.org/mailman/listinfo/insight-users<br></blockquote><br></div></body></html>