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

HanJongChul madness78 at pusan.ac.kr
Tue Feb 9 13:43:20 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?

               

               

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100210/bdb65d08/attachment.htm>


More information about the vtkusers mailing list