Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何计算弹簧圈数?_C#_Image Processing_Emgucv_Image Segmentation - Fatal编程技术网

C# 如何计算弹簧圈数?

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

关于:

即使在基于像素的计算中,我也无法获得计数

如果我有附加的图像如何开始计数的转折点

我试过找到的蚂蚁;但并没有完全得到它不能实现的转弯隔离。还有matchshape()我有相似性因子,但对于整个线圈

因此,我尝试了以下方法进行轮次计数:

 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)平滑;
}

下一步我要尝试冲浪

==================================================

编辑:添加示例。如果您喜欢,请执行此操作。

==================================================

编辑:尝试了其他算法:

  • 然后旋转ROI(最大的淡蓝色细矩形)
  • GetMoments()使用力矩收缩ROI高度和位置.Y
  • 设置缩小的ROI,并使用空白图像对其进行处理(灰色区域,绿色矩形)
  • 将图像切成两半
  • 轮廓和拟合椭圆
  • 获取拟合椭圆的最大数量
  • 稍后将研究更好的算法和结果


    假设更大的白色簇是春天

    --编辑--

  • 对图片应用反向阈值,并使用泛光填充算法填充角点
  • 使用findContours和minarearct查找最大白色簇的旋转边界框
  • 按照以下步骤跟踪长方体的长轴
  • 对于沿轴的每个像素,跟踪穿过当前像素的垂直轴线
  • 该线将至少在两点穿过弹簧
  • 找到离轴距离较大的点
  • 这将在类似正弦函数的点上创建集合
  • 计算此集合的峰值或簇数这将得到两倍的循环数

  • 所有这些假设图片中没有高噪声。

    亲爱的@Michael Kupchick:我想我已经涵盖了除4之外的所有步骤。我该如何进行第4步?我想我的算法中的除法平均不知怎么做到了。你说什么?是的,事实上我没有注意到你在图像上运行了拉普拉斯算法。我会再次查看你的代码,然后再看一次这就是我所发现的。我要感谢你:)。我会放一些不同的图片。随便选谁都行。我今天没时间完成代码。但基本上我的想法与你在更新中所做的相似。事实上,为了计算循环,我们需要计算底部或顶部的峰值。亲爱的@Michael Kupchick,请不要花时间为其编写代码。你写算法的方式,逐点。帮助很大。谢谢如果你能用这种方式扩展你的答案,你会更加感激。:)一般来说,你的问题很难理解。考虑找一个擅长英语的人来校对你的问题,以便清楚和易懂。