# How can I filter my coordinates system?

Following up with this, I have a bunch of coordinates and I draw them on a bitmap image as a coordinate system. Now, I would like to get rid of all the noise, and filter coordinates to give a "clearer" or "cleaner" path and "less" or "better" data to work on. To explain more, I will need to expose my awesome painting skills as follows:

Current:

Desired:

Notice:

• I might need to delete coordinates

• I might need to add coordinates

• I might need to ignore shortest neighbor in some cases

The only thing I can think of, is to use a shortest path algorithm such as A* and Dijkstra. And populate data in some sort of data structure to contain neighbors and costs for every node and then to execute the algorithm. I don't want to start something that might be wrong or waste. I would love to see a pseudo code if possible on how could I solve such a problem?

P.S I am currently on Wpf C# but I am open to use C# or C++ for any task. Thanks

• You're probably looking for curve fitting. Commented Jul 21, 2016 at 21:18
• @RobertHarvey Thanks! Please allow me sometime to research it Commented Jul 21, 2016 at 21:22
• Your description is lacking in detail. There are many cases I can imagine where it is no obvious what result should be? What if there are two groups that are separated by large empty space? What if the group is roughly circular? Commented Jul 22, 2016 at 5:59
• Do those samples arrive in any particular order? Are they sampled at some interval? Or is that all of the information that you receive? Can you possibly get a time-stamp for each sample?
– Mark
Commented Jul 22, 2016 at 6:31
• Also posted on SO. Please do not post the same question on multiple sites. Each community should have an honest shot at answering without anybody's time being wasted.
– D.W.
Commented Jul 22, 2016 at 17:32

## 1 Answer

I have little mathematical background but I do see an approach that might work.

I would assign a value to each coordinate in the grid that is determined by the amount and closeness of dotted neighbors. Then apply a threshold: only keep the coordinates that exceed the threshold value. Those will form the result path.

• Hi Martin and thanks. So I need to go to every node, and calculate its distance from ALL other nodes, and then choose a threshold to calculate a Value that represents this node with respect to "some neighborhood". And then, base my filtering on the value of every node, ignore nodes that have a value above some other certain threshold? Commented Jul 21, 2016 at 22:57
• You would check every coordinate in the area of interest (not just the ones that have nodes) and look around for nodes to calculate the "crowdiness factor". This could result in an empty point in between several nodes to get a higher value which is what you want, you want a path through the crowdiest parts of the coordinate system. Commented Jul 22, 2016 at 5:32
• You will have to fiddle with the algorithm to calculate the crowdiness, it would incorporate distance and numbers and closer nodes would get the value up more but how far you want to look around and how quick the significance of nearby nodes should degrade with distance depends on scale and distribution of your nodes. Commented Jul 22, 2016 at 5:39