|
|
||
|
This simulation shows how Gray coding in 16-QAM (Quadrature Amplitude Modulation) limits damage from noise compared to natural binary mapping. In a high-SNR environment, a single bit error with binary ordering can cause a large jump in the decoded value; with Gray coding, adjacent constellation points differ by only one bit, so errors usually change the pixel by a small amount. 16-QAMEach pixel is 8 bits (0–255), sent as two 4-bit symbols (high and low nibbles)—so one pixel uses two constellation points. Each symbol is mapped to a point in the I–Q plane (In-phase and Quadrature). We use a 4×4 grid with levels −3, −1, 1, 3 on both axes. Gaussian noise is added to simulate the channel; the receiver picks the nearest constellation point and decodes back to 4 bits. Noise is seeded from the SNR so the same SNR gives reproducible results and a fair Gray vs Binary comparison. Binary vs Gray mappingNatural binary: Symbols 0–15 map in order (00, 01, 10, 11 on the two 2-bit axes). Adjacent points can differ by two or more bits (e.g. 01 next to 10). A small noise push across a decision boundary can flip the MSB and cause a big change in the decoded pixel. Gray coding: The same 4×4 grid is labeled so that neighbors differ by exactly one bit (e.g. 00, 01, 11, 10). So What to observeLower the SNR (more noise). The Natural Binary image will show strong “salt and pepper” errors; the Gray Coded image will look noticeably cleaner because errors are mostly single-bit and thus smaller in magnitude. Click or drag on the original image to select a pixel: the two corresponding constellation points are highlighted on both diagrams (yellow = correct symbol, red = symbol received in error). The selection box on the original is red when that pixel has a bit error.
20
Original image (grayscale)
Gray Coded (1-bit diff between neighbors)Constellation (IQ) + noise cloud Demodulated imageBit Error Rate: —
Adjacent symbols differ by 1 bit → smaller errors Natural Binary (sequential 00, 01, 10, 11)Constellation (IQ) + noise cloud Demodulated imageBit Error Rate: —
Boundary crossing can flip multiple bits → salt & pepper Usage
Visualizations
Controls
|
||