Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在OpenCV中应用亮度有没有更快的方法?_C++_Opencv - Fatal编程技术网

C++ 在OpenCV中应用亮度有没有更快的方法?

C++ 在OpenCV中应用亮度有没有更快的方法?,c++,opencv,C++,Opencv,在我的应用程序中,我有以下代码,可以将像素的亮度更改20 for( int y = 0; y < src.rows; y++ ) { for( int x = 0; x < src.cols; x++ ) { for( int c = 0; c < 3; c++ ) { src.at<cv::Vec3b>(y,x)[c] = cv::s

在我的应用程序中,我有以下代码,可以将像素的亮度更改20

    for( int y = 0; y < src.rows; y++ )
    { 
        for( int x = 0; x < src.cols; x++ )
        { 
            for( int c = 0; c < 3; c++ )
            {
                src.at<cv::Vec3b>(y,x)[c] = cv::saturate_cast<uchar>( ( src.at<cv::Vec3b>(y,x)[c] ) + 20 );
            }
        }
    }
for(int y=0;y

有没有更有效的方法来应用这种效果?

我不明白为什么您不能/不简单地使用:

src = src + cv::Scalar(20,20,20);

这样做不行吗?

在某种程度上,无论如何都必须这样做。这似乎是你能达到的最有效率的目标。这也是opencv教你做这件事的方式。