Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Please, if anyone has an example of how to implement skeletonization using OpenCV in C#.

thank you
Posted

1 solution

Here is the sample code:

C#
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/[^]
 
Share this answer
 
Comments
Member 9534551 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 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900