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

michiel mentink michael.mentink at st-hughs.ox.ac.uk
Fri Feb 12 10:19:46 EST 2010


Hi HanJong,

maybe this example will help you:

http://www.cmake.org/Wiki/VTK/Examples/Developers/vtkImageAlgorithm_Source

The method you're looking for might be
imageData->GetScalarComponentAsDouble(x,y,z,0);


cheers,

Michael




On Tue, Feb 9, 2010 at 6:43 PM, HanJongChul <madness78 at pusan.ac.kr> wrote:

>  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?
>
>
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100212/b68105ef/attachment.htm>


More information about the vtkusers mailing list