<div>Hi Lassi,</div>
<div> </div>
<div>I add</div>
<div> </div>
<div> try<br> {<br> reader->Update();<br> }<br> catch (itk::ExceptionObject & e)<br> {<br> std::cerr << "exception in file reader " << std::endl;<br> std::cerr << e << std::endl;<br>
return EXIT_FAILURE;<br> }</div>
<div> </div>
<div>after </div>
<div>reader->SetFileName( argv[1] );</div>
<div> </div>
<div>Now the results look reasonable.</div>
<div> </div>
<div>Thanks for your help.</div>
<div> </div>
<div>Howard<br><br></div>
<div class="gmail_quote">On Tue, Dec 22, 2009 at 6:15 AM, Lassi Paavolainen <span dir="ltr"><<a href="mailto:lassi.paavolainen@jyu.fi" target="_blank">lassi.paavolainen@jyu.fi</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>Hi Hsiang-Chi,<br><br>Maybe adding: image->Update; between these lines would work<br></div>
<div> image = reader->GetOutput();<br> IteratorType it( image, image->GetLargestPossibleRegion() );<br><br></div>
<div>I think you can also change<br></div>
<div> InputImageType::Pointer image = InputImageType::New();<br></div>
<div>to<br> InputImageType::Pointer image;<br><br>There is no need to create new image as you get it from reader.<br><br>Lassi<br><br>On Mon, 21 Dec 2009, Hsiang-Chi Kuo wrote:<br><br></div>
<div>
<div></div>
<div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hi,<br><br>I am trying to access the maximum and minimum pixel value of a 3D image with<br>the following code, however, the result dose not look right (maximum 0,<br>
minimum 1000). Can anyone give me a hint why this code dose not work?<br><br>Thanks a lot,<br><br>Howard<br><br> <br><br> typedef unsigned int InputPixelType;<br> const unsigned int Dimension = 3;<br> <br> typedef unsigned int OutputPixelType;<br>
<br> typedef itk::Image< OutputPixelType, Dimension > OutputImageType;<br><br> typedef itk::Image< InputPixelType, Dimension > InputImageType;<br><br> typedef itk::ImageFileReader< InputImageType > ReaderType;<br>
<br> ReaderType::Pointer reader = ReaderType::New();<br> reader->SetFileName( argv[1] );<br> <br> typedef itk::ImageRegionIterator< InputImageType > IteratorType;<br> InputImageType::Pointer image = InputImageType::New();<br>
image = reader->GetOutput();<br> IteratorType it( image, image->GetLargestPossibleRegion() );<br> int max=0;<br> int min=10000;<br> <br> for (it.GoToBegin();!it.IsAtEnd();++it)<br> {<br> int temp = it.Get();<br>
if (temp>max)<br> max=temp;<br> if (temp<min)<br> min=temp;<br> }<br> std::cout << "min=" << min <<std::endl;<br> std::cout << "max=" << max <<std::endl;<br>
<br> <br><br><br><br></blockquote><br></div></div>
<div>-- <br>Lassi Paavolainen, M.Sc<br>Software Engineer, PhD Student in Computer Science<br>BioImageXD (<a href="http://www.bioimagexd.net/" target="_blank">http://www.bioimagexd.net</a>)<br></div>University of Jyväskylä<br>
<font color="#888888"><a href="mailto:lassi.paavolainen@jyu.fi" target="_blank">lassi.paavolainen@jyu.fi</a></font></blockquote></div><br>