Basically I have a 2 dimensional numpy array filled with boolean values.
For example:
[[0,0,0,1],
[0,0,0,1],
[1,1,1,1],
[1,1,1,1],
[1,0,0,0],
[1,0,1,1]]
I need to figure out where the largest rectangular boxes of zeroes exists. I say largest in the sense that I want all the boxes except the ones that are fully contained by another box.
As shown below, some information about each box is needed as well...
So the full output for the array above would have this data:
- box #1: upper_left_vert = (0,0), x_size = 3, y_size = 2, sq_area = 6
- box #2: upper_left_vert = (5,2), x_size = 3, y_size = 1, sq_area = 3
- box #3: upper_left_vert = (5,2), x_size = 1, y_size = 2, sq_area = 2
The arrays I'm dealing with are big and there are a lot of them, so efficiency is important. If a pandas dataframe would be faster I'm open to that option.
I'm pretty sure I can figure out some really inefficient ways to do this, but it seems like a problem that would have some faster options.