gpt4 book ai didi

c++ - 将一个 channel 数据复制到Opencv中的另一个 channel

转载 作者:太空宇宙 更新时间:2023-11-03 23:16:41 24 4
gpt4 key购买 nike

如何使用 opencv 将 mat 图像的红色 channel 值复制到蓝色 channel 。提前致谢。

最佳答案

cv::Mat Image =cv::imread("image.jpg");
uint8_t * orig_ptr = (uint8_t*)Image.data;
for (int y = 0; y < Image.rows; y++)
{
for (int x = 0; x < Image.cols; x++)
{
int R = orig_ptr[x * 3 + y*Image.step + 2];
orig_ptr[x * 3 + y*Image.step + 1] = R;
orig_ptr[x * 3 + y*Image.step] = R;
}
}

关于c++ - 将一个 channel 数据复制到Opencv中的另一个 channel ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37938554/

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