Hi, i need to implement Skeletonization in Emgu CV but i not have success.
I have a code mentioned on the website below but it does not work :
http://stackoverflow.com/questions/24226871/skeletonization-using-emgucv[
^]
This code below DONT work:
Image<Gray, Byte> eroded = new Image<Gray, byte>(img2.Size);
Image<Gray, Byte> temp = new Image<Gray, byte>(img2.Size);
Image<Gray, Byte> skel = new Image<Gray, byte>(img2.Size);
skel.SetValue(0);
CvInvoke.cvThreshold(img2, img2, 127, 256, 0);
StructuringElementEx element = new StructuringElementEx(3, 3, 1, 1, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_CROSS);
bool done = false;
while (!done)
{
CvInvoke.cvErode(img2, eroded, element,1);
CvInvoke.cvDilate(eroded, temp, element,1);
temp = img2.Sub(temp);
skel = skel | temp;
img2 = eroded;
if (CvInvoke.cvCountNonZero(img2) == 0) done = true;
}
This code WORK but is very slow in video (sequential frames)
Image<Gray, byte> Skeleton(Image<Gray, byte> orgImg)
{
Image<Gray, byte> skel = new Image<Gray, byte>(orgImg.Size);
for (int y = 0; y < skel.Height; y++)
for (int x = 0; x < skel.Width; x++)
skel.Data[y, x, 0] = 0;
imageBoxOutputROI.Image = skel;
Image<Gray, byte> img = skel.Copy();
for (int y = 0; y < skel.Height; y++)
for (int x = 0; x < skel.Width; x++)
img.Data[y, x, 0] = orgImg.Data[y, x, 0];
StructuringElementEx element;
element = new StructuringElementEx(3, 3, 1, 1, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_CROSS);
Image<Gray, byte> temp;
bool done = false;
do
{
temp = img.MorphologyEx(element, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_OPEN, 1);
temp = temp.Not();
temp = temp.And(img);
skel = skel.Or(temp);
img = img.Erode(1);
double[] min, max;
Point[] pmin, pmax;
img.MinMax(out min, out max, out pmin, out pmax);
done = (max[0] == 0);
} while (!done);
return skel;
}
This is a image of result of skeletonization:
https://dl.dropboxusercontent.com/u/80529956/EmguCV/skeleton.png[
^]
I need a help to implement the skeletonization code.
A research in below sites but i not hace success:
http://felix.abecassis.me/2011/09/opencv-morphological-skeleton/[
^]
http://stackoverflow.com/questions/26850944/skeleton-of-an-image-in-emgucv[
^]
http://stackoverflow.com/questions/26850944/skeleton-of-an-image-in-emgucv[
^]
I am grateful for any help .
Richard J. Algarve