2015-04-18 88 views
0

我是Emgu新手,正在使用C#代码教程在Internet上进行学习。在代码中,我发现某些元素如img [channel](第15行)和NewImage(“Background segmented”,图像)(第21行)未被引用。但是我添加了合适的DLL和引用。如果我在这里丢失任何东西,你能让我知道吗?使用Emgu CV C时发生错误#

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); 
    } 

回答

0

的问题是,你正试图在变量传递channelimage但这些变量不存在。

看起来,例如像频道应该访问数组中的elemnt,所以你必须定义它。类似于

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

并且图像从未被声明。你不能使用未定义的变量

+0

谢谢我试试看..我有一个更多的查询..在代码的最后一行,我有一个对NewImage()的引用。但它显示一个错误,指出该方法未找到,并且可能缺少引用或程序集。对此有何建议? – Blitzkreig1990