[vtkusers] Read RAW datas with vtkImageData?

David E DeMarle dave.demarle at kitware.com
Tue Jun 30 17:20:24 EDT 2009


Why are your arrays and extents 256x256x117, if the data is 256x256x256?

David E DeMarle
Kitware, Inc.
R&D Engineer
28 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-371-3971 x109



2009/6/29 x0_y0_0 <x0_y0_0 at 126.com>:
> hi,evryone,
>    I want to use vtkImageData read a raw datasets 256*256*256, and I
> followed an example from the internet.  I reconstruct the datasets,but it
> shows part of the 3D reconstruction. Could anyone help me? thanks.
>
> code:
>      unsigned short *buf;
>      buf = new unsigned short[256*256*117];
>      unsigned short *p=buf;
>      FILE *fp = fopen( filePath,"r");
>      fread(buf,256*256,117,fp);
>      fclose(fp);
>     vtkImageData* id = vtkImageData::New();
>      id->SetDimensions(256, 256, 117);
>   // id ->GetPointData()->SetScalars(array) ;
>      id->SetSpacing(1.0,1.0,1.0);
>      id->SetOrigin(0.0,0.0,0.0);
>       id->SetScalarTypeToUnsignedShort();
>       id->SetNumberOfScalarComponents(1);
>        id->AllocateScalars();
>       unsigned  short* a = (unsigned short*)(id->GetScalarPointer());
>                 for (i = 0; i < dims[2]; i++)
>                 {
>                     for (j = 0; j < dims[1]; j++)
>                     {
>                         for (k = 0; k < dims[0]; k++)
>                         {
>                             *a = *p;   a++;  p++;
>                         }
>                     }
>                 }
>
>
>
>
> mexiao
>
> ________________________________
> 200万种商品,最低价格,疯狂诱惑你
> _______________________________________________
> 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
>



More information about the vtkusers mailing list