0%

Problem 287


Problem 287


Quadtree encoding (a simple compression algorithm)

The quadtree encoding allows us to describe a 2N×2N black and white image as a sequence of bits (0 and 1). Those sequences are to be read from left to right like this:

  • the first bit deals with the complete 2N×2N region;
  • “0” denotes a split:
    the current 2n×2n region is divided into 4 sub-regions of dimension 2n-1×2n-1,
    the next bits contains the description of the top left, top right, bottom left and bottom right sub-regions - in that order;
  • “10” indicates that the current region contains only black pixels;
  • “11” indicates that the current region contains only white pixels.

Consider the following 4×4 image (colored marks denote places where a split can occur):

This image can be described by several sequences, for example:
001010101001011111011010101010”, of length 30, or
0100101111101110”, of length 16, which is the minimal sequence for this image.

For a positive integer N, define DN as the 2N×2N image with the following coloring scheme:

  • the pixel with coordinates x = 0, y = 0 corresponds to the bottom left pixel,
  • if (x - 2N-1)2 + (y - 2N-1)2 ≤ 22N-2 then the pixel is black,
  • otherwise the pixel is white.

What is the length of the minimal sequence describing D24 ?


四分树编码(一个简单的压缩算法)

四分树编码使我们能够将一个2N×2N的黑白图片表示为一个比特串(0和1)。该比特串可以从左到右解读为:

  • 第一个比特位描述完整的2N×2N区域;
  • “0”表示对当前区域进行分割:
    将当前的2n×2n区域分割为4个2n-1×2n-1区域,
    接下来的比特位按照左上、右上、左下、右下的顺序分别描述这四个区域;
  • “10”表示当前区域只包含黑色像素;
  • “11”表示当前区域只包含白色像素。

考虑如下的4×4图象(彩色标记意味着需要进行分割的位置):

这个图像可以用多个不同的比特串表示,例如:
001010101001011111011010101010”,长度为30,或者
0100101111101110”,长度为16,后者是描述这幅图象的最短比特串。

对于一个正整数N,记DN是按照如下染色方案得到的2N×2N图象:

  • 左下角的像素其坐标为x = 0,y = 0,
  • 如果(x - 2N-1)2 + (y - 2N-1)2 ≤ 22N-2,那么该坐标的像素为黑色,
  • 否则该坐标的像素为白色。

描述D24的最短比特串长度是多少?