I am drawing a 2D image from the values of a transverse plane in a Uint8ClampedArray onto a canvas like this:
Code:
// Cols and Rows are always 512 in my case
var cols = 512;
var rows = 512;
// offset to specified slice
var sliceSize = cols * rows;
var sliceOffset = sliceSize * slice;
var thisSliceData = typedArray.slice(sliceOffset, sliceOffset + sliceSize);
for (var row = 0; row < rows; row++) {
var rowOffset = row * cols;
for (var col = 0; col < cols; col++) {
var offset = sliceOffset + rowOffset + col;
var value = typedArray[offset]; //
canvasImage.data[(rowOffset + col) * 4] = value;
canvasImage.data[(rowOffset + col) * 4 + 1] = value;
canvasImage.data[(rowOffset + col) * 4 + 2] = value;
canvasImage.data[(rowOffset + col) * 4 + 3] = 255;
}
}
I would like to be able to get the sagittal and coronal planes as well. I'm having a hard time wrapping my head around it. How do I tweak the code to get those?