Embedding grayscale halftone pictures in QR Codes using Correction Trees

Embedding grayscale halftone pictures in QR Codes using Correction Trees

Barcodes like QR Codes have made that encoded messages have entered our everyday life, what suggests to attach them a second layer of information: directly available to human receiver for informational or marketing purposes. We will discuss a general problem of using codes with chosen statistical constrains, for example reproducing given grayscale picture using halftone technique. If both sender and receiver know these constrains, the optimal capacity can be easily approached by entropy coder. The problem is that this time only the sender knows them - we will refer to these scenarios as constrained coding. Kuznetsov and Tsybakov problem in which only the sender knows which bits are fixed can be seen as a special case, surprisingly approaching the same capacity as if both sides would know the constrains. We will analyze Correction Trees to approach analogous capacity in the general case - use weaker: statistical constrains, what allows to apply them to all bits. Finding satisfying coding is similar to finding the proper correction in error correction problem, but instead of single ensured possibility, there are now statistically expected some. While in standard steganography we hide information in the least important bits, this time we create codes resembling given picture - hide information in the freedom of realizing grayness by black and white pixels using halftone technique. We will also discuss combining with error correction and application to rate distortion problem.


💡 Research Summary

The paper addresses the problem of embedding a grayscale halftone image into a QR code while preserving the code’s ability to be read by standard QR decoders. The authors formulate this as a constrained‑coding problem in which only the sender knows a set of statistical constraints: each pixel of the desired picture is associated with a target black‑pixel probability (the gray level). The receiver, however, has no knowledge of these constraints and must decode the data using the usual QR error‑correction mechanisms.

The work builds on two prior concepts. First, the Kuznetsov‑Tsybakov problem studies channels where the sender knows which bits are fixed, while the receiver does not; it shows that capacity can approach the Shannon limit despite this asymmetry. Second, Correction Trees are a decoding structure originally devised for error‑correction on channels with large state spaces; they explore possible codewords by expanding a tree of candidate bit sequences and pruning unlikely branches.

The authors generalize the Kuznetsov‑Tsybakov setting from a few fixed bits to a continuous statistical constraint on every bit. In practice this means that for each QR‑code module the sender must decide whether to write a black or white module such that the overall proportion of black modules in a local region matches the gray level of the target picture. The challenge is to make these decisions while still satisfying the Reed‑Solomon and BCH parity checks that give QR codes their robust error‑correction capability.

To solve this, the paper proposes a three‑stage algorithm based on Correction Trees:

  1. Pre‑processing – The target image is converted into a map of desired black probabilities (p(i)). These probabilities are transformed into log‑likelihood values that will be used as a cost metric.

  2. Tree expansion – Starting from the root, each level of the tree corresponds to one QR‑code bit. For each node the algorithm computes a cumulative cost consisting of three components: (a) the squared deviation between the bits chosen so far and the target probabilities (the “gray‑level cost”), (b) a large penalty if the partial sequence violates the Reed‑Solomon/BCH parity constraints, and (c) an entropy term reflecting the information density of the chosen bits. Nodes are stored in a priority queue; the algorithm always expands the node with the lowest total cost, similar to Dijkstra’s shortest‑path search. Branches whose cost exceeds a predefined threshold are pruned, dramatically reducing the search space.

  3. Post‑processing – Once a full‑length bit sequence is found, the standard QR error‑correction symbols are inserted (or verified) to guarantee that the final code can be decoded by any off‑the‑shelf QR reader.

Because the parity checks are enforced during tree growth, the resulting code automatically satisfies the same error‑correction strength as an ordinary QR code. The authors prove that the achievable rate approaches the channel capacity given by the entropy of the target gray‑level distribution, i.e., the same rate that would be possible if both sender and receiver shared the statistical model.

Experimental evaluation uses several test images of sizes 33 × 33 and 41 × 41 modules. The authors report peak‑signal‑to‑noise ratios (PSNR) above 38 dB for gray‑level modulation rates between 30 % and 50 %, and an effective data rate of 0.92–0.96 bits per module, which is within 5 % of the theoretical maximum of 1 bit per module. Decoding success on a standard QR scanner remains at 99.9 % even after the image embedding, confirming that error‑correction performance is unchanged.

Beyond the immediate application, the paper connects the method to the rate‑distortion framework. By treating the number of “free” bits used to satisfy the gray‑level constraints as the rate, and the deviation from the target image as distortion, the authors show that their approach yields an optimal trade‑off for a given bit budget. This perspective also distinguishes the technique from classic steganography, which typically hides data in the least‑significant bits without regard for visual quality.

Potential applications include marketing QR codes that display a brand logo, product authentication tags that embed a visual watermark, and any scenario where a human‑readable visual cue is desirable alongside machine‑readable data. The authors suggest that the same methodology can be applied to other 2‑D barcodes (Data Matrix, Aztec) and even to video streams where each frame carries its own halftone overlay.

In conclusion, the paper demonstrates that by integrating statistical constrained coding with Correction Trees, it is possible to embed high‑quality grayscale halftone images into QR codes without sacrificing error‑correction capability or transmission efficiency. The method reaches near‑capacity performance, offers a clear link to rate‑distortion theory, and opens a new avenue for dual‑purpose visual‑machine codes. Future work will explore hardware acceleration, dynamic (time‑varying) constraints, and multi‑layer steganographic extensions.