Ask Your Question
0

cv::Mat::forEach() sliding window

asked 2020-10-13 11:05:24 -0600

Is it possible to access multiple pixels at once (e.g. a 3x3 grid) in Mat::forEach()? I want to implement a simple sliding window algorithm and was wondering, if I can parallelize this (since I am only reading, not modifying the original image).

edit retag flag offensive close merge delete

Comments

can you be more explicit about your operation ? some (pseudo) code ?

berak gravatar imageberak ( 2020-10-13 11:43:35 -0600 )edit

i don't think it'll work. it's parallelized internally, so your array will be split up into ranges, and those won't respect any 2d border condition.

again, please describe your better, maybe we can find a suitable alternative (e.g., maybe it can be "vectorized" so you don't work on single pixels, but whole image rois)

berak gravatar imageberak ( 2020-10-18 05:18:14 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-10-15 09:47:17 -0600

crackwitz gravatar image

the "functor" passed to Mat::forEach receives the pixel's value first, and an array containing the indices second.

docs: "Example 2. Using the pixel's position" https://docs.opencv.org/master/d3/d63...

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-10-13 11:05:24 -0600

Seen: 598 times

Last updated: Oct 15 '20