MCPcopy Create free account
hub / github.com/tensorflow/tfjs-examples / draw

Function draw

webcam-transfer-learning/ui.js:109–122  ·  view source on GitHub ↗
(image, canvas)

Source from the content-addressed store, hash-verified

107}
108
109export function draw(image, canvas) {
110 const [width, height] = [224, 224];
111 const ctx = canvas.getContext('2d');
112 const imageData = new ImageData(width, height);
113 const data = image.dataSync();
114 for (let i = 0; i < height * width; ++i) {
115 const j = i * 4;
116 imageData.data[j + 0] = (data[i * 3 + 0] + 1) * 127;
117 imageData.data[j + 1] = (data[i * 3 + 1] + 1) * 127;
118 imageData.data[j + 2] = (data[i * 3 + 2] + 1) * 127;
119 imageData.data[j + 3] = 255;
120 }
121 ctx.putImageData(imageData, 0, 0);
122}

Callers 1

drawThumbFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected