Published
Edited
Dec 8, 2021
1 star
Insert cell
Insert cell
Insert cell
Type Markdown, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
const inputImage = await FileAttachment("image.png").image();
const filtered = Object.assign(DOM.canvas(inputImage.width, inputImage.height), { id: "filteredCanvas"} );
const gray = Object.assign(DOM.canvas(inputImage.width, inputImage.height), { id: "grayCanvas" });
const out = Object.assign(DOM.canvas(inputImage.width, inputImage.height), { id: "outCanvas" });

let src = cv.imread(inputImage);

let srcWidth = src.rows;
let srcHeight = src.cols;


let dst = cv.Mat.zeros(srcWidth, srcHeight, cv.CV_8UC3);

let ksize = new cv.Size(ks,ks);
cv.GaussianBlur(src, dst,ksize, sigmaX, sigmaY, cv.BORDER_DEFAULT);

cv.imshow(filtered, dst);
cv.imshow(out, src);

src.delete();
dst.delete();

const css = "max-width:100%";
inputImage.style.cssText += css;
out.style.cssText += css;
gray.style.cssText += css;
filtered.style.cssText += css;

return html`
<div style="display:flex;max-width:${width}px">
<div style="padding-right:10px", title="input">${inputImage}</div>
<div style="padding-right:10px", title="filtered">${filtered}</div>
<div style="padding-right:10px", title="gray">${gray}</div>

<div style="padding-right:10px", title="output">${out}</div>
`;
}
Insert cell
cv = initOpenCV(opencv_js)
Insert cell
// opencv_js = FileAttachment("opencv.js").url()
opencv_js = FileAttachment("opencv@15.js").url()
Insert cell
import {handleError, registerFile, initOpenCV} from "@mootari/opencv-js"
Insert cell
console.log(cv) // used to quickly check the object for a list of functions
Insert cell
cv
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more