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>