Scalar arithmetic and scalar data type conversion...

Charles Law charles.law at kitware.com
Tue Oct 5 06:07:14 EDT 1999


Terry,

First, vtkStructuredPoints and vtkImageData are almost interchangable.
Any filter that takes one as an input, should also take the other as
input.



Terry J. Ligocki wrote:

> I have been trying to determine how to manipulate the scalars within
> "vtkStructuredPoints" in several different ways.  I have looked at the
> examples, FAQ's, and other pointers and I haven't been able to find
> what I need.  Of course, I may just be missing something that's there!

> Basically, I'd like to do two things.  First, I need to be able to
> perform arithmetic operations on the scalar data within an instance of
> "vtkStructuredPoints".  This could be either done "in place" or using
> a filter.  For example, I read in "vtkStructuredPoints" with scalar
> values between 0.0 and 1.0 of type "float" and I'd like to multiply
> all the scalars by 255.0 and add 0.5.

vtkImageShiftScale will do this for you. First it adds a constant, it
then scales. (SetShift 0.5/255.0) (SetScale 255.0)

>
> Second, I need to be able to convert the data from one scalar type
> (e.g. "float") to another (e.g. "unsigned char").  I need this so that
> if I read in "vtkStructuredPoints" with scalars of one data type and a
> filter requires a different data type, I can convert the scalar data.

vtkImageShiftScale will do this also
(SetOutputScalarTypeToUnsignedChar).
vtkImageCast will also do this without the overhead of the arithmetic
operations.
both filters have the option "ClampOverflowOn" which will clamp values
if they exceed
the extremes of the scalar data type.

>
>
> I know I can probably do this by writing my own C++ code that "goes
> into the guts" of these objects and does what I need (in one case
> performing the arithmetic I need and in the other creating a new
> "vtkStructuredPoints" with the needed data type and copying the data
> element by element).  I was hoping that there would already be this
> type of functionality available within Vtk (thus I could simply write
> scripts for what I need to do and not include additional C++ code,
> etc.).
>
> Specifically, if you haven't already guessed :-), I'm currently
> reading in "vtkStructuredPoints" of type "float" in the range 0.0 to
> 1.0 and I'd like to do some volume rendering.  I'm using a Tcl/Tk
> script and get the error:
>
>      "vtkVolumeRayCastMapper: The scalar data type: 10 is not
>      supported when volume rendering. Please convert the  data to
>      unsigned char or unsigned short."
>
> Although this is the specific problem I'm struggling with at the
> moment, I'm sure I'll want to do the more general manipulations I've
> mentioned above in other circumstances (which is why I asked the more
> general questions first).
>
> Answers and/or hints to any or all of the above questions would be
> most welcome.  Thanks for your time, interest, and help...
>
>                                 Terry J. (Ligocki, tjligocki at lbl.gov)



-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------





More information about the vtkusers mailing list