Identifying Largest Submatrices in a 0/1 Matrix?

  • Thread starter pablrodr
  • Start date
In summary, the problem is to identify the largest submatrices formed by 1's in a given 0/1 matrix, with certain constraints on the dimensions of the submatrices. One-dimensional submatrices can be found by scanning rows and columns, while two-dimensional submatrices may require a more complex tracking system.
  • #1
pablrodr
1
0
In the following 0/1 matrix I'm trying to identify every largest submatrices formed by 1's as shown in the picture.
Submatrices can have just one row only if they have more than 3 columns.
Submatrices can have just one column only if they have more than 3 rows.
Submatrices should have less than maxcol columns and maxrow rows and more than mincol and minrow. In the picture mincol=minrow=2. maxrow=maxcolumn=6.
I've been searching for this problem, looks like an already solved problem but couldn't find it elsewhere.
 

Attachments

  • rectangles.png
    rectangles.png
    2.3 KB · Views: 431
Physics news on Phys.org
  • #2
pablrodr said:
In the following 0/1 matrix I'm trying to identify every largest submatrices formed by 1's as shown in the picture.
Submatrices can have just one row only if they have more than 3 columns.
Submatrices can have just one column only if they have more than 3 rows.
Submatrices should have less than maxcol columns and maxrow rows and more than mincol and minrow. In the picture mincol=minrow=2. maxrow=maxcolumn=6.
From your picture, a submatrix should have at least minrow rows and at least mincol columns. This is different from what you said, which would imply that a two-dimensional submatrix would have to be 3 X 3 or larger.

Also, it should be possible for a submatrix to have at most minrow rows and at most mincol columns for a matrix all of whose entries are 1's.
pablrodr said:
I've been searching for this problem, looks like an already solved problem but couldn't find it elsewhere.
Presumably this is a problem that you want to automate; otherwise you could visually inspect the matrix and pick out the submatrices.

Finding the one-dimensional submatrices shouldn't be too hard, but finding the two-dimensional submatrices will be harder, I believe. For the the horizontal 1D submatrices, for each row, scan across it until you reach a 1. From this cell, continue scanning for 1's. If you encounter three or more in that row, you have a submatrix. You'll need to remember where the submatrix started, and how many 1 cells there were in it.

For the vertical 1D submatrices, for each column do essentially the same as described above, but scan downward. Again, if you hit a submatrix, you need to keep track of its starting cell and how many cells are in it.

Finding the 2D submatrices is harder. I have several ideas, but none of them are fully thought out.

I mentioned earlier about the need for keeping track of the starting cells and lengths of the 1D submatrices. One possibility would be to create a tracking matrix of the same size as the one you're working with, but whose cells contain a pair of numbers. Here are some examples of a cell entry in this tracking matrix (T) that I envision:
T(1, 2) = (3, 0)
The cell at row 1, column 2 is the start of a horizontal submatrix of length 3.

T(2, 1) = (0, 3)
The cell at row 2, column 1 is the start of a vertical submatrix of length 3.

T(2, 1) = (3, 4)
The cell at row 2, column 1 is the start of a horizontal submatrix of length 3 and a vertical submatrix of length 4.

All other entries in the tracking matrix would be (0, 0).
 

FAQ: Identifying Largest Submatrices in a 0/1 Matrix?

What is a submatrix?

A submatrix is a smaller matrix that is extracted from a larger matrix by selecting a specific set of rows and columns.

How do you identify every 1 submatrix in a matrix?

To identify every 1 submatrix in a matrix, you need to systematically scan through the matrix and check for patterns of 1s. This can be done by starting at the top left corner and moving across each row, checking for consecutive 1s in each column. Once a 1 is found, you can then check the adjacent rows and columns to determine the size of the submatrix.

Why is it important to identify every 1 submatrix?

Identifying every 1 submatrix is important because it can help with data analysis and pattern recognition. It can also be useful in machine learning and image processing tasks.

Can a matrix have more than one 1 submatrix?

Yes, a matrix can have multiple 1 submatrices. This is because a matrix can have multiple patterns of 1s that can be extracted as separate submatrices.

What is the difference between a submatrix and a subarray?

A submatrix is a subset of a matrix, while a subarray is a subset of an array. A submatrix retains the 2-dimensional structure of a matrix, while a subarray may not necessarily have this structure. Additionally, operations on a submatrix can affect the original matrix, while operations on a subarray generally do not affect the original array.

Similar threads

Back
Top