ImageProperty

Introduction

vtkImageProperty – image display properties

vtkImageProperty is an object that allows control of the display
of an image slice.

See Also

vtkImageMapper
vtkImageProperty

Methods

getInterpolationType

getInterpolationTypeAsString

setInterpolationTypeToNearest

setInterpolationTypeToLinear

Set/Get the interpolation type for sampling a volume. The initial
value is LINEAR. NEAREST interpolation will snap to the closest
voxel, LINEAR will perform bilinear interpolation to compute a
scalar value from surrounding voxels.

colorWindow

Controls the window in a window level mapping of the input image. Window
level mapping is a technique to map the raw data values of an image
into screen intensities in a manner akin to

pixelIntensity = (inputValue - level)/window;

colorLevel

Controls the level in a window level mapping of the input image. Window
level mapping is a technique to map the raw data values of an image
into screen intensities in a manner akin to

pixelIntensity = (inputValue - level)/window;

ambient

Control the ambient lighting intensity for this image.

diffuse

Control the diffuse lighting intensity of this image.

opacity

Control the opacity of this image.

rGBTransferFunction

Specify vtkColorTransferFunction to map scalars to colors. If set, then
colorWindow and colorLevel are not used.

scalarOpacity

Specify a vtkPiecewiseFunction to map image intensities to opacities. This
will only work on single-component images. The overall image opacity can
still be affected by the opacity property.

Source

Constants.js
export const InterpolationType = {
NEAREST: 0,
LINEAR: 1,
};

export default {
InterpolationType,
};
index.js
import macro from 'vtk.js/Sources/macro';
import Constants from 'vtk.js/Sources/Rendering/Core/ImageProperty/Constants';

const { InterpolationType } = Constants;

// ----------------------------------------------------------------------------
// vtkImageProperty methods
// ----------------------------------------------------------------------------

function vtkImageProperty(publicAPI, model) {
// Set our className
model.classHierarchy.push('vtkImageProperty');

publicAPI.setInterpolationTypeToNearest = () => {
publicAPI.setInterpolationType(InterpolationType.NEAREST);
};

publicAPI.setInterpolationTypeToLinear = () => {
publicAPI.setInterpolationType(InterpolationType.LINEAR);
};

publicAPI.getInterpolationTypeAsString = () =>
macro.enumToString(InterpolationType, model.interpolationType);
}

// ----------------------------------------------------------------------------
// Object factory
// ----------------------------------------------------------------------------
const DEFAULT_VALUES = {
interpolationType: InterpolationType.LINEAR,
colorWindow: 255,
colorLevel: 127.5,
ambient: 1.0,
diffuse: 0.0,
opacity: 1.0,
rGBTransferFunction: null,
scalarOpacity: null,
};

// ----------------------------------------------------------------------------

export function extend(publicAPI, model, initialValues = {}) {
Object.assign(model, DEFAULT_VALUES, initialValues);

// Build VTK API
macro.obj(publicAPI, model);

macro.setGet(publicAPI, model, [
'interpolationType',
'colorWindow',
'colorLevel',
'ambient',
'diffuse',
'opacity',
'rGBTransferFunction',
'scalarOpacity',
]);

publicAPI.getMTime = () => {
let mTime = model.mtime;
if (model.rGBTransferFunction) {
const time = model.rGBTransferFunction.getMTime();
mTime = time > mTime ? time : mTime;
}

return mTime;
};

// Object methods
vtkImageProperty(publicAPI, model);
}

// ----------------------------------------------------------------------------

export const newInstance = macro.newInstance(extend, 'vtkImageProperty');

// ----------------------------------------------------------------------------

export default { newInstance, extend };