如何计算弹簧圈转数? [英] How to count spring coil turns?

查看:901
本文介绍了如何计算弹簧圈转数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在参考: C# WPF EMGU:如何检测和计数螺旋的圈

我MOT能够得到即使在基于像素的计算也算

I am mot able to get count even in the pixel based calculation also.

如果我重视形象如何启动与计数匝数

If I have attached image how to start with the counting the turns.

我试过FindContours()。但不安静得到隔离圈,它不能。 。另外,matchshape()我有相似性因素,但对于整个线圈

I tried the FindContours(); but doesn't quiet get the turns segregated which it can't. Also the matchshape() I have the similarity factor but for whole coil.

所以,我想如下轮到计数:

So I tried as follows for turn count :

 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;
    }



任何帮助将是有益的。我接下来想冲浪。

Any help will be helpful. I am next trying surf.

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

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

编辑:添加样品。如果妳喜欢这样做。





Adding samples. If u like it do it.

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

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

编辑:尝试另一种算法中:

Tried another algo:


  1. 投资回报率,然后旋转(最大的稀淡蓝色矩形)

  2. GetMoments()缩小ROI的高度和position.Y使用的那一刻。

  3. 将萎缩的投资回报率和._And()它与一个空白图像。 (带有绿色矩形灰色区域)

  4. 切开图像成半的一半。

  5. 轮廓和合适的椭圆。

  6. 得到拟合椭圆的最大数量。

  1. ROI then Rotate ( biggest thin light blue rectangle )
  2. GetMoments() shrink ROI height and position.Y using the moment.
  3. Set the shrinked ROI and ._And() it with a blank image. ( Gray region with green rectangle )
  4. cut the image into half-half.
  5. contour and fit ellipse.
  6. get maximum number of fitted ellipses.

后来将工作更好的交易算法和结果。

Later will work on better algos and results.

推荐答案

假设白色的大集群是春天

Assuming the bigger cluster of white colour is the spring

- EDIT--

--EDIT--


  1. 应用反阈值的图片,并填写洪水填充算法的角落。

  2. 找到旋转边界最大的白色集群中使用findContours和minAreaRect

  3. 的箱式跟踪框长轴做以下

  4. 沿轴心轨迹轴心线的每个像素垂直通过当前像素

  5. 要去
  6. 这条线将穿越弹簧至少两个百分点。

  7. 找到从轴
  8. 这将类似于正弦函数点创建集合

  9. 计数这个集合的峰值或群集,这将得到循环数的两倍。

  1. Apply inverse threshold to the picture and fill corners with flood fill algorithm.
  2. Find the rotated bounding box of the biggest white cluster using findContours and minAreaRect
  3. Trace the box longer axis doing the following
  4. for each pixel along the axis trace axis line perpendicular going through current pixel
  5. This line will cross the spring in minimum two points.
  6. Find the point with the bigger distane from the axis
  7. This will create collection on points similar to sine function
  8. Count the peaks or clusters of this collection this will get twice the number of loops.

这一切假设你没有在图片中高噪声。

All this assuming you don't have high noise in the picture.

这篇关于如何计算弹簧圈转数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆