gpt4 book ai didi

c++ - 单 channel 平均值

转载 作者:太空狗 更新时间:2023-10-29 19:37:29 27 4
gpt4 key购买 nike

我将图像从 rgb 转换为 YUV。现在我想单独找到亮度 channel 的平均值。你能告诉我如何实现这一目标吗?此外,有没有办法确定图像由多少个 channel 组成?

最佳答案

你可以这样做:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <stdio.h>

using namespace cv;

int main(void)
{
vector<Mat> channels;
Mat img = imread("Documents/forest.jpg");
split(img, channels);
Scalar m = mean(channels[0]);
printf("%f\n", m[0]);

return 0;
}

关于c++ - 单 channel 平均值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14349932/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com