[vtkusers] vtkImageMapper3D, vtkInteractorStyleImage - inverting luminance images
Dean Inglis
dean.inglis at camris.ca
Tue Jun 14 20:33:53 EDT 2011
I commented on this issue earlier when the new vtkImageSlice
and associated classes were contributed:
http://www.vtk.org/pipermail/vtk-developers/2011-April/009631.html
I found I can bypass the limitation on negative window/level
to invert images in vtkInteractorStyleImage by adding observers
to handle Start/End/Reset/WindowLevel events. Even so,
however, vtkImageMapper3D prohibits this from working
because of the restriction that the range computed from the window
and level obtained from vtkImageProperty must be ordered
min to max for a valid scale in the following method:
void vtkImageMapper3D::ConvertImageScalarsToRGBA(
void *inPtr, unsigned char *outPtr, const int extent[6],
int numComp, int inIncY, int inIncZ, int outIncY, int outIncZ,
int scalarType, double scalarRange[2])
{
double shift = -scalarRange[0];
double scale = 255.0;
//if (scalarRange[0] < scalarRange[1])
// {
scale /= (scalarRange[1] - scalarRange[0]);
// }
// else
// {
// scale = 1e+32;
// }
Commenting out the lines as shown allows for inverting an
image without having to use a user supplied lut.
What are the reasons for restricting the scale to be a positive
value? Can the above edits be incorporated into the mapper,
or is there an alternative approach that could be suggested to
allow interactive window/level with inversion?
I have tried vtkImageMapToWindowLevelColors between
say a reader and a vtkImageMapper3D but this significantly affects
performance.
Dean
More information about the vtkusers
mailing list