[vtkusers] Access the direct data values of 3D CT data, GetScalarPointer() problem!

madness78 madness78 at pusan.ac.kr
Tue Feb 9 13:44:26 EST 2010


Hello,
Can anybody help me? Please~~!!
I’m in trouble to access the direct data values of 3D CT data.
I tried many things, but it dosen’t work.
Please, please help me.
My code is, 

this->pvtkImageReader = vtkImageReader::New();       
               this->pvtkImageReader->SetFileName("Image.bin");
               
               this->pvtkImageReader->SetDataExtent(0,255,0,255,0,255);
               this->pvtkImageReader->SetDataSpacing(1,1,1);
               this->pvtkImageReader->SetFileDimensionality(3);
               this->pvtkImageReader->SetDataOrigin(0,0,0);
               this->pvtkImageReader-> SetDataByteOrderToLittleEndian();    

               this->ImageData->SetScalarTypeToUnsignedShort();
               this->ImageData->SetDimensions(256,256,256);
               this->ImageData->SetSpacing(1,1,1);   
               this->ImageData->SetOrigin(0,0,0);
               this->ImageData->AllocateScalars();
               this->ImageData->SetNumberOfScalarComponents(1);
               int* dims = this->ImageData->GetDimensions(); 

               this->ImageData=pvtkImageReader->GetOutput();
               unsigned short *ptr=(unsigned
short*)(this->ImageData)->GetScalarPointer();

                CString b;
                b.Format("%d,", dims[2]);
                ::MessageBox(NULL, b, "dims[0]", MB_OK |
MB_ICONINFORMATION); 

               for(int k=0;k<dims[0];k++)
               {
                       for(int j=0;j<dims[1];j++)
                       {
                              for(int i=0;i<dims[2];i++)
                              {
                                      TempVolume[i] =
ptr[256*256*i+256*j+k];
                              }
                       }
               }

If I put this code “TempVolume[i] = ptr[256*256*i+256*j+k];”
The program stopped.
What do I have to do?? 
Did I made a mistake while using GetScalarPointer() method?
               
               

-- 
View this message in context: http://old.nabble.com/Access-the-direct-data-values-of-3D-CT-data%2C-GetScalarPointer%28%29-problem%21-tp27520065p27520065.html
Sent from the VTK - Users mailing list archive at Nabble.com.




More information about the vtkusers mailing list