I'm processing RGB
images and doing the same thing for each channel (R+G+B) so I've been looking for parallel functions that could help me improve my code and run it (3*?) faster. Now Im using forEach
function like so:
unsigned char lut[256];
for (int i = 0; i < 256; i++)
lut[i] = cv::saturate_cast<uchar>(pow((float)(i / 255.0), fGamma) * 255.0f); //pow: power exponent
dst.forEach<cv::Vec3b> //dst is an RGB image
(
[&lut](cv::Vec3b &pixel, const int* po) -> void
{
pixel[0] = lut[(pixel[0])];
pixel[1] = lut[(pixel[1])];
pixel[2] = lut[(pixel[2])];
}
);
But when I use htop
to see the number of threads running, I only find one or two threads on..
Am I doing something wrong or forEach
isn't suppose to run on multi-threading
? Do you have any resources to help me with to get to multi-threading
computations?
I'm running my code on ubuntu with this:
g++ -std=c++1z -Wall -Ofast -march=native test3.cpp -o test3 `pkg-config --cflags --libs opencv`