C# Emgu CV-将灰度图像合并为单个Bgr图像

C# Emgu CV-将灰度图像合并为单个Bgr图像,c#,opencv,emgucv,C#,Opencv,Emgucv,我试图将灰度图像转换为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

我试图将灰度图像转换为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;
            }
        }           
    }
}
public void to hueimage(此图像,图像输出)
{
对于(int i=0;i
我希望能够在一次操作中为每个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            
}
public void to hueimage(此图像,图像输出)
{
output.Data.H=图像;
output.Data.S=WHITE\u IMAGE;//这些是静态的
output.Data.V=WHITE\u IMAGE;//这些是静态的
}

在不使用字节复制等方法的情况下,我尝试将执行时间缩短到30毫秒左右。有什么简单的方法可以做到这一点吗

感谢Miki排序:只需使用CVInvoke调用opencv函数merge:

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

为什么不使用
cv::merge
和(你的灰色图像、白色图像、白色图像)?这正是我所需要的-只需
CvInvoke.merge(新的Mat向量(image.Mat、whiteImage.Mat、whiteImage.Mat)、heatMap.Mat)Ps设置您的答案,我将关闭它;-)你自己做吧。很高兴它帮助了汉克斯·米奇——我会花一段时间找到它,谢谢