Question

Visual representation of the Point array (zoom to 800%): http://i.cubeupload.com/2Y3JPf.png

Please do not reupload to Imgur. Imgur's compression makes the image too blurry at high zooms.

(a zoomed in part of the image with the relevant dots highlighted:)
enter image description here

In the image, each red dot represents a Point. All the red dots combined represent the Point array. FYI, the Point array is ordered left to right, top to bottom. So pointArray[0] is in the top-left, pointArray[1] is in the top right, pointArray[2] is in the top-left but is also one line below pointArray[0] and pointArray[1].

As you can see, the majority of the red dots are in a grid but there are a couple of outliers in the top-left of the window and in the bottom-right where the number of mines are displayed. How would I get rid of the outliers? I've thought of parsing each point one by one to see if they are a constant number of pixels away from each other but at which point do I start? pointArray[0] is in the top-left so it's not even part of the grid which would mean that finding a constant pixel gap isn't going to work.

Any ideas?

Was it helpful?

Solution

Here is a method that should work for all grid sizes:

Count the number of dots in each row, and the number of dots in each column.
Then remove all dots in rows and columns that have less than the average number of dots.

You can construct such a histogram efficiently with a dictionary:

var numDotsPerRow = new Dictionary<int,int>();
var numDotsPerColumn = new Dictionary<int,int>();

foreach (var point in pointArray)
{
    int count;
    numDotsPerRow.TryGetValue(point.X, out count);
    numDotsPerRow[point.X] = count+1;
    numDotsPerColumn.TryGetValue(point.Y, out count);
    numDotsPerColumn[point.Y] = count+1;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top