Public
Edited
Oct 5, 2024
Insert cell
Insert cell
inputImage = await FileAttachment("parking.jpeg").image()
Insert cell
src = {
let src = cv.imread(inputImage);
let dst = cv.Mat.zeros(src.rows, src.cols, cv.CV_8UC3);
cv.cvtColor(src, src, cv.COLOR_RGBA2GRAY, cv.CV_8UC1); // Convert the input image to grayscale.
cv.bilateralFilter(src, dst, bf1, bf2, bf3, cv.BORDER_DEFAULT);
cv.Canny(dst, src, T1, T2, 3);
return src;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
dst = {
let dst = cv.Mat.zeros(src.rows, src.cols, cv.CV_8UC3);
let lines = new cv.Mat();
cv.HoughLinesP(src, lines, hl1, Math.PI / hl2, hl3, hl4, hl5);
for (let i = 0; i < lines.rows; ++i) {
let startPoint = new cv.Point(
lines.data32S[i * 4],
lines.data32S[i * 4 + 1]
);
let endPoint = new cv.Point(
lines.data32S[i * 4 + 2],
lines.data32S[i * 4 + 3]
);
cv.line(
dst,
startPoint,
endPoint,
new cv.Scalar(
Math.random() * 255,
Math.random() * 255,
Math.random() * 255
)
);
}
lines.delete();
return dst;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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