[vtkusers] Reading vtkImageData in C++

Yi-Yu Chou chouyiyu at hotmail.com
Mon Jan 19 07:44:05 EST 2004


Hi ,

I am trying to read the image information (vtkImageData) in my own vtk 
class (C++).
The code is like :

void vtkLocalExample::SetOriImg(vtkImageData *img) 
{ 
int dimtemp[3]; 
int *dim; 
dim = dimtemp; 
dim = img->GetDimensions(); 
printf("Dimensions %d %d %d \n",dim[0], dim[1], dim[2]); 
float spctemp[3]; 
float *spc; 
spc = spctemp; 
spc = img->GetSpacing(); 
printf("Spcing %f %f %f \n",spc[0], spc[1], spc[2]); 
} 

When checking the output values, the the value of the image size (dim)  is 
correct. However, the the value
of the voxel size (spc) is wrong.
Therefore, I did one more test in this code. I set : 
..................................................................................................................................

float spctemp[3]={1,2,3}; 
float *spc; 
spc = spctemp; 
printf("Spc value before running GetSpacing %f %f %f \n",spc[0], spc[1], 
spc[2]); 
spc = img->GetSpacing(); 
printf("Spc value after running GetSpacing %f %f %f \n",spc[0], spc[1], 
spc[2]); 
......................................................... 
The outputs are : 
Spc value before running GetSpacing 1.000000 2.000000 3.000000 
Spc value after running GetSpacing 1.000000 2.000000 3.000000 

It seems that the function of GetSpacing isn't working. 
( but the function of GetDimensions is correct.) 
Could anyone tell me what's wrong with my code ? 
I had a hard time debuging this problem.
Thanks a lot !!!!! 

Best,
YY

_________________________________________________________________
想戀愛?交朋友?MSN 線上交友:由 Match.com 提供,全世界最受歡迎的線上交友服
務 http://match.msn.com.tw 




More information about the vtkusers mailing list