Public
Edited
May 4, 2023
Paused
Importers
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
canvasFromImageData(solidColorImageDataGenerator("blue"))
Insert cell
canvasFromImageData(
solidColorImageDataGenerator([128, 128, 128], { width: 256, height: 256 })
)
Insert cell
Insert cell
Insert cell
canvasFromImageData(duotonePatternImageDataGenerator())
Insert cell
canvasFromImageData(
duotonePatternImageDataGenerator({
toneA: "yellow",
toneB: "blue"
})
)
Insert cell
Insert cell
Insert cell
function integerBufferToColorizedImageData(
eUint32,
lutBuffer,
{ stretch = true, colorSpace = DEFAULT_IMAGEDATA_COLOR_SPACE } = {}
) {
let { width, height, buffer, min, max, bitDepth } = eUint32;
let range = stretch ? max - min : 1 << bitDepth;
let scaleSteps = lutBuffer.length / 4;
let factor = range / scaleSteps;
let rgb = new ImageData(width, height, { colorSpace });
buffer.forEach((v, i) => {
const colorIndex =
Math.floor(stretch ? (v - min) / factor : v / factor) * 4;
const vRGB = lutBuffer.subarray(colorIndex, colorIndex + 4);
rgb.data.set(vRGB, i * 4);
});
return rgb;
}
Insert cell
Insert cell
canvasChannelsFromImageData(
duotonePatternImageDataGenerator({
toneA: "purple",
toneB: "turquoise"
}),
{ channels: [0, 2, 1] }
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more