First time here? Check out the FAQ!

Ask Your Question
0

cv::Mat::forEach() sliding window

asked Oct 13 '0

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).

Preview: (hide)

Comments

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

berak gravatar imageberak (Oct 13 '0)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 (Oct 18 '0)edit

1 answer

Sort by » oldest newest most voted
0

answered Oct 15 '0

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...

Preview: (hide)

Question Tools

1 follower

Stats

Asked: Oct 13 '0

Seen: 673 times

Last updated: Oct 15 '20