我是 Emgu 的新手,正在互联网上学习 C# 代码教程。在代码中,我得到某些元素,如img[channel](第15行)和NewImage("背景分割",图像)(第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);
}
问题是您正在尝试传入变量channel
和image
但这些变量不存在。
看起来像通道应该访问数组中的枚举,因此您必须定义它。类似的东西
int channel = 0; // this would get you the first channel in the img array
图像也从未声明过。不能使用尚未定义的变量