如何使用 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/