Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Efficient, generic scan image


Is there any generic OpenCV function/algorithm (like C++ std::transform) to perform pixel modification. I know that I can write i.e. below code. But is neither generic nor efficient.

cv::Mat image;
cv::Mat new_image;

for( int y = 0; y < image.rows; y++ )
   { for( int x = 0; x < image.cols; x++ )
        { for( int c = 0; c < 3; c++ )
             {<Vec3b>(y,x)[c] =
                         saturate_cast<uchar>( alpha*(<Vec3b>(y,x)[c] ) + beta ); }

I would like to use it like i.e.

cv::Mat src;
cv::Mat dst;
transform(src, dst, pixelUnaryFunctor);

cv::Mat src1;
cv::Mat src2;
cv::Mat dst;
transform(src1, src2, dst, pixelBinaryFunctor);