Emgu CV - 将灰度图像组合成单个 Bgr 图像

Emgu CV - Combining greyscale images into single Bgr image

我正在尝试将灰度图像转换为 Hsv 图像,但 S 和 V 通道设置为预设值。以下代码有效,但需要大约 400 毫秒才能执行。

public void ToHueImage(this Image<Gray, double> image, Image<Hsv, double> output)
{
        for (int i = 0; i < image.Width; i++)
        {
            for (int j = 0; j < image.Height; j++)
            {
                output.Data[j, i, 0] = image.Data[j, i, 0];
                output.Data[j, i, 1] = 255;
                output.Data[j, i, 2] = 255;
            }
        }           
    }
}

我希望能够在一次操作中为每个 H、S 和 V 平面分配一个灰度图像通道,以避免单独复制像素,类似于

public void ToHueImage(this Image<Gray, double> image, Image<Hsv, double>     output)
{
    output.Data.H = image; 
    output.Data.S = WHITE_IMAGE; // These are static
    output.Data.V = WHITE_IMAGE; // These are static            
}

不求助于字节复制等。我试图将执行时间缩短到 ~30 毫秒左右。有什么直接的方法可以做到这一点?

感谢 Miki 排序:只需要使用 CVInvoke 调用 opencv 函数合并:

CvInvoke.Merge(new VectorOfMat(image.Mat, whiteImage.Mat, whiteImage.Mat), heatMap.Mat);