Skip to content

Technical Info

Juliette Regimbal edited this page Apr 8, 2020 · 1 revision

Technical Information

Calculation of the Background Layer

The background layer is calculated using the CanvasRenderingContext2D.globalCompositeOperation of the Canvas API.

The selected region(s) are put onto a blank canvas. Then the destination-out composition type is used to remove where each layer overlaps the selected region(s). At this stage, only masks are produced.

Applying source image to masks

OpenCV is used to apply the source image to the mask within Rodan after the interactive phase ends. This is done on the server since the full source image is needed and sending it to the browser would defeat the whole point of using a viewer like Diva.js.

The masks are RGBA PNG images. The parts outside of the layer are fully transparent, meaning that the alpha channel can be used to form a binary mask. This mask is applied to the source image resulting in a RGB image where the area outside of the layer is black. Then the alpha channel is added in again, resulting in the region outside of the layer also being transparent while the region inside the layer is opaque with the contents of the source image. The resulting RGBA image is written as the result.

Clone this wiki locally