I haven't found a quick method for setting the pixel of an image in opencv.js, at the moment I'm doing this img.data.set([r, g, b, a], row * img.cols * img.channels() + col * img.channels());, which I find to be too verbose.
It would be good to have a utility lib in Xaval that provides shortcuts and quick wrappers for such basic operations.
In this case it could be something like util.setPixel(img, row, col, pixel) where pixel is an array with the pixel components. Or maybe it would be sensible to specify the channels: util.setPixel4(img, row, col, pixel) or util.setPixel(img, row, col, channels, pixel).
I haven't found a quick method for setting the pixel of an image in opencv.js, at the moment I'm doing this
img.data.set([r, g, b, a], row * img.cols * img.channels() + col * img.channels());
, which I find to be too verbose.It would be good to have a utility lib in Xaval that provides shortcuts and quick wrappers for such basic operations.
In this case it could be something like
util.setPixel(img, row, col, pixel)
wherepixel
is an array with the pixel components. Or maybe it would be sensible to specify the channels:util.setPixel4(img, row, col, pixel)
orutil.setPixel(img, row, col, channels, pixel)
.