algorithm to smooth curve

亡梦爱人 提交于 2020-01-15 05:44:07

问题


I have a curve with a lot of points, resulting in a slowing down at GUI level. I would like to apply an algorithm which remove adjacent points which are too close of each other (in term of values, and so can be considered useless)

Is there any famous algorithm to do this ? I'm using C# and ZedGraph


回答1:


You can use Douglas-Peucker algorithm to reduce number of points and save the curve shape. C# implementation can be found here




回答2:


I'm not a professional, but I thought that you can do this without any famous algorithm. Here is what I thought (just a principle, as I don't know in which class you stored your Points):

        Collection<float> ListOfValues = new Collection<float>();
        float minimalValueDistance = 0.5f;
        var listWithoutAdjacentPoints = ListOfValues.Where(x =>
            {
                int indexOfValue = ListOfValues.IndexOf(x);
                // only considering the distance from the left
                if (indexOfValue > 0 && Math.Abs(x - ListOfValues[indexOfValue - 1]) > minimalValueDistance)
                    return true;
                else
                    return false;

            });


来源:https://stackoverflow.com/questions/17523240/algorithm-to-smooth-curve

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!