2015-11-15 61 views
2

我还有一个问题。 Idk发生了什么事buti试图使Canny边缘检测器。问题是,当我想检测像方形这样的简单形状的边缘时,程序能够检测到它。但是当我想要在不是很简单的图像程序上检测形状时,只会给我填充只有黑色的图像。你们有什么想法吗?EmguCV Canny黑色窗口

我用下面这段代码:

public Bitmap CannyEdge(Bitmap bmp) 
    { 
     Image<Gray, Byte> Cannybmp; 
     Image<Gray, Byte> GrayBmp; 
     Image<Bgr, Byte> orig = new Image<Bgr, Byte>(bmp); 
     Image<Bgr, Byte> imgSmooth; 
     Bitmap output; 

     imgSmooth = orig.PyrDown().PyrUp(); 
     imgSmooth._SmoothGaussian(3); 
     GrayBmp = imgSmooth.Convert<Gray, byte>(); 

     Gray grayCannyThreshold = new Gray(160.0); 
     Gray grayThreshLinking = new Gray(80.0); 

     Cannybmp = GrayBmp.Canny(grayCannyThreshold.Intensity, grayThreshLinking.Intensity); 
     output = Cannybmp.ToBitmap(); 

     //int a = 5; 
     return output; 

    } 

private void button1_Click(object sender, EventArgs e) 
    { 
     Bitmap bmp = new Bitmap(pictureBox1.Image); 
     pictureBox2.Image = CannyEdge(bmp); 
    } 

回答

1

你尝试设置您的grayCannyThreshold成为较小的grayThreshLinking的价值?

Gray grayCannyThreshold = new Gray(80.0); 
Gray grayThreshLinking = new Gray(160.0); 
+0

是的,我试过了......但是我发现EmguCV 3.0已经破解了pyrDown()函数......所以我只用了pyrUp(),对我来说应该没问题:) – Apuna12