C# 使用Emgu CV C时出错#

C# 使用Emgu CV C时出错#,c#,emgucv,C#,Emgucv,我是Emgu的新手,在网上学习C代码教程。在代码中,我得到某些元素,例如img[channel](第15行)和NewImage(“背景分割”,image)(第21行)没有被引用。但我已经添加了相应的DLL和引用。如果我遗漏了什么,你能告诉我吗 using Emgu; using Emgu.CV; using Emgu.Util; using Emgu.CV.CvEnum; using Emgu.CV.Util; using Emgu.CV.Structure; private void Cie

我是Emgu的新手,在网上学习C代码教程。在代码中,我得到某些元素,例如img[channel](第15行)和NewImage(“背景分割”,image)(第21行)没有被引用。但我已经添加了相应的DLL和引用。如果我遗漏了什么,你能告诉我吗

using Emgu;
using Emgu.CV;
using Emgu.Util;
using Emgu.CV.CvEnum;
using Emgu.CV.Util;
using Emgu.CV.Structure;

private void CielabChannelMaskBGSubtraction(string filename, bool displayResult)
        {
        double threshold = double.Parse(max2textBox.Text);

        Image<Bgr, byte> rgb = new Image<Bgr, byte>(filename);
        Image<Lab, Byte> img = rgb.Convert<Lab, Byte>();

        //get the a* channel 
        Image<Gray, Byte> gray = img[channel];

        //threshold and invert
        gray = gray.ThresholdBinary(new Gray(threshold), new Gray(255)).Not();

        // display the result
        if (displayResult) this.NewImage("Background segmented", image);
    }
使用Emgu;
使用Emgu.CV;
使用Emgu.Util;
使用Emgu.CV.CvEnum;
使用Emgu.CV.Util;
使用Emgu.CV.Structure;
私有void CielabChannelMaskBGSubtraction(字符串文件名,bool显示结果)
{
double threshold=double.Parse(max2textBox.Text);
图像rgb=新图像(文件名);
图像img=rgb.Convert();
//获得a*频道
图像灰度=img[通道];
//阈值和反转
gray=gray.ThresholdBinary(新灰度(阈值),新灰度(255)).Not();
//显示结果
如果(显示结果)此.NewImage(“背景分割”,图像);
}

问题是您试图传入变量
频道
图像
,但这些变量不存在

例如,它看起来像通道应该访问数组中的一个元素,所以您必须定义它。差不多

int channel = 0; // this would get you the first channel in the img array

图像也从未声明过。您不能使用未定义的变量

谢谢,我会试试的。。我还有一个问题。。在代码的最后一行中,我引用了NewImage()。但它显示了一个错误,指出找不到该方法,并且我可能缺少引用或程序集。有什么建议吗??