POLYOMINO_CONDENSE, a MATLAB program which cleans up a matrix that represents a polyomino by setting all nonzero entries to 1, and removing initial and final rows and columns of zeros.
A polyomino is a shape formed by connecting unit squares edgewise.
A polyomino can be represented by an MxN matrix, whose entries are 1 for squares that are part of the polyomino, and 0 otherwise.
This program is given an MxN matrix that is meant to represent a polyomino. It first replaces all nonzero entries by the value 1. It then "condenses" the matrix, if possible, by removing initial and final rows and columns that are entirely zero.
While this procedure might save a slight amount of space, its purpose is to simplify the task of manipulating polyominos, embedding them in larger shapes, and detecting whether two polyominos describe the same shape.
It is entirely possible, and usual, that the output quantities are simply copies of the input quantities.
The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.
POLYOMINO_CONDENSE is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and a Python version.