[vtk-developers] Speeding up raycasting on x86

David Gobbi dgobbi at imaging.robarts.ca
Thu Jul 11 17:39:22 EDT 2002


Hi Lisa,

Yes, the 'correct to within 1/65536' is a little bit of an issue.
In some of my own reconstruction code (and also in my in-house
version of vtkImageReslice) I made a fixed-point type in C++
to avoid float->int conversion altogether.

I've committed the change already; at the very least the code looks
a bit better with the (int) casts replaced with the vtkFloorFuncMacro().
I will definitely also look into making Chris' code into a suitable
macro, but you have the final word on whether the macro does fancy
bit-twiddling or whether it simply does an (int) cast.

 - David


On Thu, 11 Jul 2002, Lisa Avila wrote:

>
>
>
> >2) It's not completely correct. Tests I ran not too long ago show that the
> >process causes the value
> >to be *rounded*, but this is not readily apparent because the rounding is,
> >in this case, not to the
> >nearest int but to the nearest fraction of 1/2**16. So, for example, a
> >value greater than (3.0 -
> >1/2**16), but less than 3.0,  will be rounded up to 3. This problem
> >becomes very readily apparent if
> >you tweak the values so that you use the full 32 bits for the integer
> >portion and don't reserve any
> >bits for fixed point fractional values, thus causing rounding to the
> >nearest integer.
>
> Being "not completely correct" may cause big problems in the ray caster. It
> relies on the fact that at the far boundary of the ray the coordinates
> along the ray cannot meet or exceed the dimensions of the data minus one.
> For example, if your data is 512 samples in x, the x coordinate can never
> be 511 or greater (since this will cause a neighboring voxel that doesn't
> exist to be visited for trilinear interpolation). We ensure that we never
> reach 511 by subtracting a bit off of it (to avoid precision issues) Now it
> may be that the bit that we subtract off is sufficiently larger than
> 1/65536 that this won't be a problem, but we'd better check into this
> before making the change. I don't think the VTK tests of ray casting
> exercise this class enough to say that everything is fine just because the
> tests pass....
>
> Lisa
>
>






More information about the vtk-developers mailing list