2014-06-25 5 views

답변

2

다음 코드를 사용하여 Emgucv에서 등고선 계층 구조를 얻을 수 있습니다. 상기 기준 여기 사용이 Online Tutor! 들어

Image<Bgr, byte> Img_Result_Bgr = Img_Source_Bgr.Copy(); 
Image<Gray, byte> Img_Org_Gray = Img_Source_Bgr.Convert<Gray, byte>(); 
Image<Gray, byte> Img_CannyEdge_Gray = new Image<Gray, byte>(Img_Source_Bgr.Width,Img_Source_Bgr.Height); 

Img_CannyEdge_Gray = Img_Org_Gray.Canny(10, 50); 
Img_Org_Gray.Dispose(); 

Random Rnd = new Random(); 

#region Finding Contours 
using (MemStorage storage = new MemStorage()) //allocate storage for contour approximation 
    for (Contour<Point> contours = Img_CannyEdge_Gray.FindContours(); contours != null; contours = contours.HNext) 
    { 
     Contour<Point> currentContour = contours.ApproxPoly(contours.Perimeter * 0.05, storage);//if you want to Approximate the contours into a polygon play with this function(). 

     if (contours.Area > 100) //only consider contours with area greater than 100 
     { 
      Img_Result_Bgr.Draw(contours, new Bgr(Rnd.Next(255),Rnd.Next(255),Rnd.Next(255)), 2); 
     } 
    } 
#endregion 
Img_CannyEdge_Gray.Dispose(); 

imageBox1.Image = Img_Result_Bgr; 

이 코드의 출력이다. http://s18.postimg.org/511xwpm15/Forum_Contour.jpg

+0

감사합니다. 감사하지만이 코드가 나를 도울 수있는 이미지의 구멍을 찾고 싶습니다. – user2922251

+0

아니야 내게 바깥 윤곽 만 줄거야 – user2922251

+0

http://i.stack.imgur.com/qLZ6w.png 이 이미지는 내면의 구멍을 찾고 싶습니까 ?? – user2922251

관련 문제