2015-04-18 85 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