5

This is a problem which I found to be quite challenging. I ask this because I want to be able to losslessly compress simply connected shapes (connected shapes without holes) with fewer bits than $n^2$, which can have many downstream applications.

By connectedness, I do not restrict it to be either 4-connectedness or 8-connectedness, I just would like an answer that gets us to the approximately correct order of magnitude of the number of connected shapes, so an answer may be given for either definition of connectedness, if one of the definitions proves to be easier to work with.

I consider two connected shapes to be the same if and only if the two n by n images on which the shapes are represented are exactly the same pixel-wise. Hence, translation and rotation of a shape will likely result in a new shape under my definition.

Finally, if an exact, or approximate solution is difficult to come by, I am willing to accept a good upper bound estimate of the form $O(2^{c\times n^k})$ where k should ideally be less than 2, and c is some constant. (If it turns out that the minimum of k must be 2, it is fine, too, if there is a proof.)

  • 1
    We definitely can't make $k$ less than $2$, and with $k = 2$ we can't make $c$ less than $1/4$: add all even rows and all even columns to your figure, this will ensure connectedness and you still have free choice for every cell with odd coordinates - and there are $1/4 n^2$ such cells. – mihaild Jun 05 '23 at 12:27
  • You are correct. I believe a more interesting case I am interested in is one that does not allow "holes" within the shape. Let me refine the question to focus on simply connected shapes. – Jingjin Wang Jun 05 '23 at 13:34
  • 2
    Actually, even with simply connected shapes we can get lower bound $k = 2, c \geq 1/2$: add lines $y = 0$ and $x = 0 \pmod 4$ (shape like Ш with more vertical lines), then we are free to add any cells with $y > 0, x = 1 \pmod 2$ - there are slightly less than $n^2 / 2$ such cells. – mihaild Jun 05 '23 at 13:44
  • Wow, don't know what to say, you are correct. I will award the answer to you if you may kindly provide an official answer below. – Jingjin Wang Jun 05 '23 at 13:57
  • Added. Although I think exact number, or at least some upper bound stronger than $2^{n^2(1 - o(1))}$ is much more interesting question, for which I have no idea how to search the answer. – mihaild Jun 05 '23 at 18:06

1 Answers1

2

I don't know exact number, but we can show that number of such figures is at least $2^{(n - 1)^2 / 4}$, thus best $k$ we can get is $2$, and corresponding $c$ is at least $1/4$.

Consider $n$ of form $4m + 1$. Add all cells with coordinate $y = 0$ to the shape, as well as all cells with $x \equiv 0 \pmod 4$. This allow for every cell with coordinates $y \neq 0, x \equiv 1 \pmod 2$ to choose if add it or not, thus giving as $(n - 1)^2 / 4$ (if $n = 4m+1$) cells that can be chosen independently.

plot

(black cells we add always, each of green we can choose if add or not)

mihaild
  • 17,674