Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# OpenCV
Hi
Please, if anyone has an example of how to implement skeletonization using OpenCV in C#.
 
thank you
Posted 8-May-12 9:22am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Here is the sample code:
 
cv::Mat skel(img.size(), CV_8UC1, cv::Scalar(0));
cv::Mat temp;
cv::Mat eroded;
 
cv::Mat element = cv::getStructuringElement(cv::MORPH_CROSS, cv::Size(3, 3));
 
bool done;
do
{
  cv::erode(img, eroded, element);
  cv::dilate(eroded, temp, element); // temp = open(img)
  cv::subtract(img, temp, temp);
  cv::bitwise_or(skel, temp, skel);
  eroded.copyTo(img);
 
  done = (cv::norm(img) == 0);
} while (!done);
 

More details at: http://felix.abecassis.me/2011/09/opencv-morphological-skeleton/[^]
  Permalink  
Comments
Member 9534551 at 20-Jan-13 21:36pm
   
I appreciated your source. I've question about the result of it. The result images show not only 1-fit line. How can I fix it?, I need just one line to check whole line has connected.
Best regards to you
Member 9534551 at 20-Jan-13 21:36pm
   
I appreciated your source. I've question about the result of it. The result images show not only 1-fit line. How can I fix it?, I need just one line to check whole line has connected.
Best regards to you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 7,853
1 Sergey Alexandrovich Kryukov 7,107
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,790


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 8 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100