Checking pixels in a bound area on image

I’m working on a project where I have a camera input and then have several “panels” in this input where I check if the pixels are within a specified threshold.

Basically a 1D array of unsigned chars representing an image then I have several bounding boxes that cover specific areas of this image. I want to check the pixels within each of these rectangles to see if any are within some given threshold.

The simplest method which i’ve implemented is iterate through each pixel, then for each pixel iterate through the bounding boxes and see if the pixel meets the threshold for that box. This works fine but is a bit slow, and also won’t scale very well.

Is there some kind of clever algorithm or solution I should try that will be faster?

Hey @protonman, I’ll bet there is likely a clever way to do this with a shader. The gpu can really speed up the processing of data from images. Or if you have multiple cpu cores available, you could probably parallelize this task with the tbb library and a parallel_for loop. This should work as long as the thresholds are not changing as a result of the task(s).