1 | initial version |
please take another look at the tutorials, you can use cv.matFromArray() to create your kernel, and then:
let src = cv.imread('canvasInput'); // lena
let gray = new cv.Mat();
let dst = new cv.Mat();
cv.cvtColor(src, gray, cv.COLOR_RGB2GRAY);
let kernel = cv.matFromArray(3,3,cv.CV_32FC1, [-1, 0, 1, -2 , 0, 2, -1 ,0 ,1]);
cv.filter2D(gray, dst, -1, kernel);
let rect = new cv.Rect(100, 100, 200, 200);
cv.imshow('canvasOutput', dst);
src.delete();
gray.delete();
dst.delete();
2 | No.2 Revision |
please take another look at the tutorials, you can use cv.matFromArray() to create your kernel, and then:
let src = cv.imread('canvasInput'); // lena
let gray = new cv.Mat();
let dst = new cv.Mat();
cv.cvtColor(src, gray, cv.COLOR_RGB2GRAY);
let kernel = cv.matFromArray(3,3,cv.CV_32FC1, [-1, 0, 1, -2 , 0, 2, -1 ,0 ,1]);
cv.filter2D(gray, dst, -1, kernel);
let rect = new cv.Rect(100, 100, 200, 200);
cv.imshow('canvasOutput', dst);
src.delete();
gray.delete();
dst.delete();