[vtkusers] About vtkImageData

Marc Cotran marc at cotran.ca
Sun Jun 25 17:40:49 EDT 2006

marium ahmed wrote:
> Dear all,
>             I'm trying to manipulate vtkImageData to access its cell 
> and get, for example, the pixels grey level in order to use them in 
> making some filter. I was told that the function "GetScalarPointer" 
> returns a pointer to the cells grey levels but upon trial, this 
> doesn't seem true. So which function can I use to get the pixels grey 
> level and location?
GetScalarPointer() is indeed the method you are looking for. Here's a 
code snippet:

--- begin snippet ---

int index[3];

index[0] = 12;
index[1] = 34;
index[2] = 2;

unsigned char *scalarPointer = (unsigned char *) 

unsigned char scalarValue = scalarPointer[0];

--- end snippet ---

This code will give you the scalar value at location 12,34,2 of 
'imageData' (your vtkImageData instance) and store it in 'scalarValue'.



More information about the vtkusers mailing list