code: function getRenderCanvas (enabledElement, image, invalidated, useAlphaChannel = true) {
    const canvasWasColor = enabledElement.renderingTools.lastRenderedIsColor === true;
  
    if (!enabledElement.renderingTools.renderCanvas || canvasWasColor) {
      enabledElement.renderingTools.renderCanvas = document.createElement('canvas');
      initializeRenderCanvas(enabledElement, image);
    }
  
    const renderCanvas = enabledElement.renderingTools.renderCanvas;
  
    if (doesImageNeedToBeRendered(enabledElement, image) === false && invalidated !== true) {
      return renderCanvas;
    }
  
    // If our render canvas does not match the size of this image reset it
    // NOTE: This might be inefficient if we are updating multiple images of different
    // Sizes frequently.
    if (renderCanvas.width !== image.width || renderCanvas.height !== image.height) {
      initializeRenderCanvas(enabledElement, image);
    }
  
    // Get the lut to use
    let start = now();
    const lut = getLut(image, enabledElement.viewport, invalidated);
  
    image.stats = image.stats || {};
    image.stats.lastLutGenerateTime = now() - start;
  
    const renderCanvasData = enabledElement.renderingTools.renderCanvasData;
    const renderCanvasContext = enabledElement.renderingTools.renderCanvasContext;
  
    // Gray scale image - apply the lut and put the resulting image onto the render canvas
    if (useAlphaChannel) {
      storedPixelDataToCanvasImageData(image, lut, renderCanvasData.data);
    } else {
      storedPixelDataToCanvasImageDataRGBA(image, lut, renderCanvasData.data);
    }
  
    start = now();
    renderCanvasContext.putImageData(renderCanvasData, 0, 0);
    image.stats.lastPutImageDataTime = now() - start;
  
    return renderCanvas;
  }
docs: Returns an appropriate canvas to render the Image. If the canvas available in the cache is appropriate
  it is returned, otherwise adjustments are made. It also sets the color transfer functions.
  
  @param {Object} enabledElement The cornerstone enabled element
  @param {Object} image The image to be rendered
  @param {Boolean} invalidated Is pixel data valid
  @param {Boolean} [useAlphaChannel = true] Will an alpha channel be used
  @returns {HTMLCanvasElement} An appropriate canvas for rendering the image
  @memberof rendering