I am trying to sharpen an image using a sharpening convolution kernel like below:
[[0,-1,0], [-1,5,-1], [0,-1,0]];
Is it possible to define arbitrary matrices like this?
I can do this simply in OpenCV for python by declaring a numpy array like above, but in JavaScript (OpenCV.js) it seems there is no way to do this without using the Mat method and some combination of other methods.
I have tried like this:
let kdata = [[-1,-1,-1], [-1,9,-1], [-1,-1,-1]];
let M = new cv.Mat(kdata);
and by following the example here:
https://docs.opencv.org/master/dd/d6a/tutorial_js_filtering.html
But I can't find anything that allows me to create arbitrary matrices where I have control over each element in the matrix, only methods like eye() or ones() that fill the matrix with some pre-specified values.
Any help in creating arbitrary matrices that can be used with the filter2d method would be very helpful. Thank you!