[vtkusers] how do I traverse the scalars of a vtkImageData?
Nico Vermaas
vermaas at astron.nl
Fri Jun 13 06:57:37 EDT 2003
Mathieu,
I actually got a compiler error ("invalid initializer") with that statement, so I changed it to:
float* minmax=(float*)imagedata->GetScalarRange();
Then my minmax has these values:
minmax[0]: 2.30112e-07
minmax[1]: 0.276428
(which are the correct values)
Nico
====================================================
Nico Vermaas
ASTRON - Westerbork Synthesis Radio Telescope
Schattenberg 1 - 9433 TA Zwiggelte - The Netherlands
tel: +31 593 598710
vermaas at astron.nl
====================================================
>>> Mathieu Malaterre <Mathieu.Malaterre at creatis.insa-lyon.fr> 06/13/03 11:51 AM >>>
What is the result of:
float minmax[2] = imagedata->GetScalarRange();
std::cout << "scalar range:" << minmax[0] << "," << minmax[1] << '\n';
mathieu
Nico Vermaas wrote:
> Mathieu,
>
> Thank you for pointing me in the right direction. I do not get the correct results yet (just a black cube like in Space Odyssee 2001, so the scalar data is not copied yet), but at least it is a step closer.
>
> Nico
>
> ====================================================
> Nico Vermaas
> ASTRON - Westerbork Synthesis Radio Telescope
> Schattenberg 1 - 9433 TA Zwiggelte - The Netherlands
>
> tel: +31 593 598710
> vermaas at astron.nl
> ====================================================
>
>>>>Mathieu Malaterre <Mathieu.Malaterre at creatis.insa-lyon.fr> 06/13/03 10:01 AM >>>
>
> Nico,
>
> imagedata->Update(); //important
> float minmax[2] = imagedata->GetScalarRange();
>
> vtkImageShiftScale::SetShift(-minmax[0]);
> vtkImageShiftScale::SetScale(255./(minmax[1]-minmax[0]));
> vtkImageShiftScale::SetOutputScalarTypeToUnsignedChar ()
>
> See:
> http://www.vtk.org/doc/nightly/html/classvtkImageShiftScale.html
>
>
> HTH
> mathieu
>
> Nico Vermaas wrote:
>
>>Hi,
>>
>>To make volume rendering possible I want to convert the scalars in an vtkImageData to unsigned chars. I need to change them and make them range from 0 - 255.
>>
>>I used to use SetScalar, but that doesn't seem to work any longer in VTK4. So what is the best way to traverse the scalar values in a vtkImageData? (getting, changing and setting the values?).
>>
>>Greetings,
>>
>>Nico
>>
>>
>>====================================================
>>Nico Vermaas
>>ASTRON - Westerbork Synthesis Radio Telescope
>>Schattenberg 1 - 9433 TA Zwiggelte - The Netherlands
>>
>>tel: +31 593 598710
>>vermaas at astron.nl
>>====================================================
>>_______________________________________________
>>This is the private VTK discussion list.
>>Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
>>Follow this link to subscribe/unsubscribe:
>>http://public.kitware.com/mailman/listinfo/vtkusers
>>
>
>
>
--
Mathieu Malaterre
CREATIS
28 Avenue du Doyen LEPINE
B.P. Lyon-Montchat
69394 Lyon Cedex 03
http://www.creatis.insa-lyon.fr/~malaterre/
More information about the vtkusers
mailing list