Embed a Polyomino in a Region

POLYOMINO_EMBED, a MATLAB library which is given matrices defining a region R and a polyomino P, and determines the number of possible embeddings of the polyomino into the region, and the translations necessary to achieve them.

A region R is a subset of an MRxNR grid of squares.

A polyomino P is a subset of an MPxNP grid of squares.

Both objects are represented by binary matrices, with the property that there are no initial or final zero rows or columns.

For this computation, we regard P as a "fixed" polyomino; in other words, no reflections or rotations will be allowed.

An "embedding" of P into R is an offset (MI,NJ) such that

  P(I,J) = R(I+MI,J+NJ) 
  for 1 <=  I <=    MP, 1 <=  J <=    NP, and 
  for 0 <= MI <= MR-MP, 0 <= MJ <= NR-NP.
We can detect an embedding simply by taking what amounts to a kind of dot product of P with a corresponding subregion of R.


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.


polyomino_embed is available in a MATLAB version.

Related Data and Programs:


Source Code:

Last revised on 27 February 2019.