[vtkusers] Pixel Values

brunos at lncc.br brunos at lncc.br
Tue Jun 14 20:17:21 EDT 2005


I´m a new VTK user and I want to access image pixels. For this purpose I´m using
the code below:

	vtkDICOMImageReader *reader = vtkDICOMImageReader::New();

	short *Pixels;
	int i;

	Pixels = (short *) reader->GetOutput()->GetScalarPointer();

	FILE *fp = fopen("c:/temp/pixels.txt","w");

	for(i=0; i < 512*512; i++)
		fprintf(fp, "%d ", *Pixels++);


	return 0;

However, the files generated by this code, contain values above 255 and below
0. For example -2048, 543, 1020 -1028.
Is it correct?
Is there some different standard to pixels representation in VTK ?
Or is there other way to access pixels values ?


This message was sent using IMP, the Internet Messaging Program.

More information about the vtkusers mailing list