-
Notifications
You must be signed in to change notification settings - Fork 12
Implementing the IRenderer3D interface
Benjamin Schmid edited this page Sep 15, 2020
·
2 revisions
The IRenderer3D interface defines the following methods:
public RenderingState getRenderingState();
public ImageProcessor render(RenderingState kf);
public ImagePlus getImage();An implementing class typically keeps references to the input image stack, to the 3rd party rendering engine and to a RenderingState object:
private ExtRenderingState rs;
private ImagePlus input;
// private final ThridPartyRenderer renderer;
The constructor initializes the 3rd party renderer and the RenderingState object:
public ExtRenderer(ImagePlus input) {
this.input = input;
// renderer = new ThirdPartyRenderer();
float[] pdIn = new float[] {
(float)input.getCalibration().pixelWidth,
(float)input.getCalibration().pixelHeight,
(float)input.getCalibration().pixelDepth
};
float[] pdOut = new float[] {pdIn[0], pdIn[0], pdIn[0]};
float[] rotcenter = new float[] {
input.getWidth() * pdIn[0] / 2,
input.getHeight() * pdIn[1] / 2,
input.getNSlices() * pdIn[2] / 2};
CombinedTransform transformation = new CombinedTransform(
pdIn, pdOut, rotcenter);
this.rs = new ExtRenderingState(0, transformation);
}The most important method is render(): It uses the 3rd party rendering engine to produce an output image:
public ImageProcessor render(RenderingState rs) {
double brightness = rs.getNonchannelProperty(
ExtRenderingState.BRIGHTNESS);
// renderer.setBrightness(brightness);
float[] matrix = rs.getFwdTransform().
calculateInverseTransform();
// renderer.setTransformation(matrix);
ImageProcessor output = null;
// output = renderer.render();
return output;
}