2
我需要在Emgu CV中实现框架,但是我没有成功。 我有下面的网站上提到的一个代码,但它不工作: Skeletonization using EmguCV ^]Emgu CV - EmguCV中的图像框架(Skeletonization)
下面不工作这码:
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;
}
此代码的工作,但在视频很慢(连续的帧)
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;
}
输入图像:
我需要一个帮助来实现骨架代码。
的研究在下面的网站,但我不是脑水肿的成功: http://felix.abecassis.me/2011/09/opencv-morphological-skeleton/[ ^]
https://stackoverflow.com/questions/26850944/skeleton-of-an-image-in-emgucv[ ^]
https://stackoverflow.com/questions/26850944/skeleton-of-an-image-in-emgucv[ ^]
我感谢任何帮助。
Richard J. Algarve
而你的输入图像? – kkuilla
嗨,这是我的图片https://dl.dropboxusercontent.com/u/80529956/EmguCV/skeleton.png –
感谢您的支持 –