Ask Your Question
0

OpenCv.js: what's the quickest way to set the pixel of an image?

asked 2018-06-26 18:14:40 -0600

habbes gravatar image

What's the quickest way for setting the pixel value of image Mat in OpenCv.js?

I'm currently doing

img.data.set([r, g, b, a], row * img.cols * img.channels() + col * img.channels());

But I'm wondering whether there's a less-verbose built-in method in opencv.js, something analogous to img.ucharPtr(row, col) when retrieving the pixel value.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-05-03 17:13:55 -0600

kpachinger gravatar image
  1. pass color as last parameter on mat creation
  2. mat.setTo([r,g,b,a])
  3. cv.rectangle for mat or roi with -1
  4. for some use case, you may consider mat.clone() to retain certain properties
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-06-26 18:14:40 -0600

Seen: 1,475 times

Last updated: May 03 '20