Apply a function to each pixel in the image.

Is there a method in OpenCV that takes an input matrix, an output matrix, and a function and applies this function to each pixel? For example, a function like "check the pixel value, if it is below a certain threshold, set the value to 0, otherwise save the value"

I know that I can iterate over the pixels of the matrix and apply this function myself, it's just interesting if there is a function that would save me from this job.

+4
source share
2 answers

If performance is a problem, the following links may interest you:

LUT, .

+2

- ( ):

std::for_each(mat.begin<uchar>(), mat.end<uchar>()
              , [](uchar& pixel) {  
                     /* do something with pixel */ 
                });

.


: remap, .

+1

Source: https://habr.com/ru/post/1531187/


All Articles