C# 如何计算弹簧圈数?
关于: 即使在基于像素的计算中,我也无法获得计数 如果我有附加的图像如何开始计数的转折点 我试过找到的蚂蚁;但并没有完全得到它不能实现的转弯隔离。还有matchshape()我有相似性因子,但对于整个线圈 因此,我尝试了以下方法进行轮次计数:C# 如何计算弹簧圈数?,c#,image-processing,emgucv,image-segmentation,C#,Image Processing,Emgucv,Image Segmentation,关于: 即使在基于像素的计算中,我也无法获得计数 如果我有附加的图像如何开始计数的转折点 我试过找到的蚂蚁;但并没有完全得到它不能实现的转弯隔离。还有matchshape()我有相似性因子,但对于整个线圈 因此,我尝试了以下方法进行轮次计数: public static int GetSpringTurnCount() { if (null == m_imageROIed) return -1; i
public static int GetSpringTurnCount()
{
if (null == m_imageROIed)
return -1;
int imageWidth = m_imageROIed.Width;
int imageHeight = m_imageROIed.Height;
if ((imageWidth <= 0) || (imageHeight <= 0))
return 0;
int turnCount = 0;
Image<Gray, float> imgGrayF = new Image<Gray, float>(imageWidth, imageHeight);
CvInvoke.cvConvert(m_imageROIed, imgGrayF);
imgGrayF = imgGrayF.Laplace(1); // For saving integer overflow.
Image<Gray, byte> imgGray = new Image<Gray, byte>(imageWidth, imageHeight);
Image<Gray, byte> cannyEdges = new Image<Gray, byte>(imageWidth, imageHeight);
CvInvoke.cvConvert(imgGrayF, imgGray);
cannyEdges = imgGray.Copy();
//cannyEdges = cannyEdges.ThresholdBinary(new Gray(1), new Gray(255));// = cannyEdges > 0 ? 1 : 0;
cannyEdges = cannyEdges.Max(0);
cannyEdges /= 255;
Double[] sumRow = new Double[cannyEdges.Cols];
//int sumRowIndex = 0;
int Rows = cannyEdges.Rows;
int Cols = cannyEdges.Cols;
for (int X = 0; X < cannyEdges.Cols; X++)
{
Double sumB = 0;
for (int Y = 0; Y < cannyEdges.Rows; Y ++)
{
//LineSegment2D lines1 = new LineSegment2D(new System.Drawing.Point(X, 0), new System.Drawing.Point(X, Y));
Double pixels = cannyEdges[Y, X].Intensity;
sumB += pixels;
}
sumRow[X] = sumB;
}
Double avg = sumRow.Average();
List<int> turnCountList = new List<int>();
int cnt = 0;
foreach(int i in sumRow)
{
sumRow[cnt] /= avg;
if(sumRow[cnt]>3.0)
turnCountList.Add((int)sumRow[cnt]);
cnt++;
}
turnCount = turnCountList.Count();
cntSmooth = cntSmooth * 0.9f + (turnCount) * 0.1f;
return (int)cntSmooth;
}
public static int GetSpringTurnCount()
{
if(null==m_ImageRoId)
返回-1;
int imageWidth=m_imageROIed.Width;
int imageHeight=m_imageROIed.Height;
如果((图像宽度3.0)
增加((int)sumRow[cnt]);
cnt++;
}
turnCount=turnCountList.Count();
cntSmooth=cntSmooth*0.9f+(转数)*0.1f;
返回(int)平滑;
}
下一步我要尝试冲浪
==================================================
编辑:添加示例。如果您喜欢,请执行此操作。
==================================================
编辑:尝试了其他算法:
假设更大的白色簇是春天 --编辑--
所有这些假设图片中没有高噪声。亲爱的@Michael Kupchick:我想我已经涵盖了除4之外的所有步骤。我该如何进行第4步?我想我的算法中的除法平均不知怎么做到了。你说什么?是的,事实上我没有注意到你在图像上运行了拉普拉斯算法。我会再次查看你的代码,然后再看一次这就是我所发现的。我要感谢你:)。我会放一些不同的图片。随便选谁都行。我今天没时间完成代码。但基本上我的想法与你在更新中所做的相似。事实上,为了计算循环,我们需要计算底部或顶部的峰值。亲爱的@Michael Kupchick,请不要花时间为其编写代码。你写算法的方式,逐点。帮助很大。谢谢如果你能用这种方式扩展你的答案,你会更加感激。:)一般来说,你的问题很难理解。考虑找一个擅长英语的人来校对你的问题,以便清楚和易懂。