Jump to content
Posted 24 November 2011 - 12:14 PM
Posted 24 November 2011 - 02:15 PM
Posted 24 November 2011 - 02:40 PM
Posted 25 November 2011 - 02:05 AM
Posted 25 November 2011 - 03:29 AM
Posted 04 December 2011 - 05:17 AM
The search term you need for googling purposes is "connected component labeling" ... The easiest way to do it is to
1. Construct a temporary blank grid.
2. Iterate over the cells of the input grid.
3. For each cell A that is not blue ( in your case ) and that hasn't been marked as discovered do the following
.......... Output A as a seed of a unique connected component.
.......... Perform a floodfill seeded at A that marks the cells of the connected component that A is part of as 'discovered' in the temporary grid.
There are more efficient ways of doing this but probably the above will suffice unless your grids are gigantic.
Posted 05 December 2011 - 05:19 AM