Ok for this I am somewhat looking for suggestions on what the next step should be and how to implement the one I am currently on.
First here is the context: I am working on a project that involves finding the center of circles that have been put in a grid. The original image was 1260x683px and had 27x15 dots in a grid inside the image. The image is stored as a text file. In the text file a 0 represents a pixel that is not part of any dot, and a 1 represents a pixel that is part of a dot.
I want to figure out a way to identify the center coordinate of each dot. Below I made a few diagrams to show what I want to do.
- Fig 1. shows what the array looks like before any manipulation.
- Fig 2. shows how I want to identify all the non zero elements.
- Fig 3. Shows that I want to then narrow the identified elements to just the middle element of reach row and the middle column.
- Finally Fig 4. Shows the desired end goal to identify the center of each dot. From there once the center is identified. I want to be able to store its position as a tuple in a 27x15 array that will be used later to identify the center points.
Its worth noting that if there is a row with an even number of 1s I want to identify the right one of the two center values (Fig 0a.) and for the columns if there is an even number of 1s I want to identify the bottom one as the center (Fig 0b.)
Fig 0a.
0001111000
..........^.......
Fig 0b.
0
0
0
1
1
1 <--
1
0
0
0
Fig 1.
00011111100000000111111000...
00111111110000001111111100...
01111111111000011111111110...
01111111111000011111111110...
01111111111000011111111110...
01111111111000011111111110...
01111111111000011111111110...
01111111111000011111111110...
00111111110000001111111100...
00011111100000000111111000...
Fig 2.
00011111100000000111111000...
00111111110000001111111100...
01111111111000011111111110...
01111111111000011111111110...
01111111111000011111111110...
01111111111000011111111110...
01111111111000011111111110...
01111111111000011111111110...
00111111110000001111111100...
00011111100000000111111000...
Fig 3.
00011111100000000111111000...
00111111110000001111111100...
01111111111000011111111110...
01111111111000011111111110...
01111111111000011111111110...
01111111111000011111111110...
01111111111000011111111110...
01111111111000011111111110...
00111111110000001111111100...
00011111100000000111111000...
Fig 4.
00011111100000000111111000...
00111111110000001111111100...
01111111111000011111111110...
01111111111000011111111110...
01111111111000011111111110...
01111111111000011111111110...
01111111111000011111111110...
01111111111000011111111110...
00111111110000001111111100...
00011111100000000111111000...
Overall the tldr is that I need to find a way to determine the centers of each dot in a 27x15 grid, then store the coordinates of those centers into a separate array. I hope this makes sense, but I am happy to answer any questions to specify what I meant.