shamantou blog site

shamantou@gmail.com

导航

关于vtkImageData的讨论

 pvtkDICOMImageReader=vtkDICOMImageReader::New();
 pvtkDICOMImageReader->SetDirectoryName(path);
 pvtkDICOMImageReader->Update();

 vtkImageData *data=pvtkDICOMImageReader->GetOutput();
 double x[3]={11.5,12.3,19.8 };
 int ijk[3];
 double pcoords[3];

 data->ComputeStructuredCoordinates(x,ijk,pcoords);//double型的x坐标处的所在的点坐标,以及该坐标下的offset pcoords
 int mm=data->ComputePointId(ijk);//ijk处的pointid号
 int nn=data->ComputeCellId(ijk);
 int pp=data->GetDataDimension();//如果是volume则返回3,如果为image则返回2
 //0.48828101158142   0.48828101158142   4.2500000000000

 int dim[3];
 data->GetDimensions(dim);
 int size=data->GetActualMemorySize();//实际的占据的内存空间,ms没什么大用处??
 int sizex=data->GetScalarSize();//返回每个标量所占的字节数
 int size1=data->GetNumberOfPoints();//返回实际的点的个数
 

 int type=data->GetScalarType();//返回数据类型
 /*
 #define VTK_VOID            0
 #define VTK_BIT             1
 #define VTK_CHAR            2
 #define VTK_SIGNED_CHAR    15
 #define VTK_UNSIGNED_CHAR   3
 #define VTK_SHORT           4
 #define VTK_UNSIGNED_SHORT  5
 #define VTK_INT             6
 #define VTK_UNSIGNED_INT    7
 #define VTK_LONG            8
 #define VTK_UNSIGNED_LONG   9
 #define VTK_FLOAT          10
 #define VTK_DOUBLE         11
 #define VTK_ID_TYPE        12
  */
 if(type==VTK_SHORT)
 {
  AfxMessageBox("");
 }

 short *buf=new short[size1];
 
 short aaa[4]={1,2,3,4};
 short bbb[4];
 memcpy(bbb,aaa,4*2);//注意memcpy的第三个参数只是Byte的个数

 memcpy(buf,data->GetScalarPointer(),size1*2);

 CFile file;
 file.Open("d:\\aa.raw",CFile::modeCreate|CFile::modeWrite|CFile::modeNoInherit,NULL);
 file.Write(buf,size1*2);
 file.Close();


 delete []buf;

 MyDataInit();

<< 计算机备份应注意的东西Dicom图像窗宽窗位快速算法 >>

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

最近发表

Powered By Z-Blog 1.8 Arwen Build 81206 Copyright 2006-2009 | ooplab.org | shamantou@gmail.com | 沪ICP备08011244号 | Some Rights Reserved.