Sem 7

Cheat Sheet

One dense page for the night before the CBE412 exam: formulas and numbers, text compression, JPEG and PNG pipelines, audio and video facts, QoS, image forensic techniques, steganography, steganalysis and watermarking.

Formulas marked (std) are standard definitions that are not written on the slides. Use them for numerical questions; everything else is from the decks.

Formulas and numbersSearch on YouTube

QuantityFormulaSlide or exam numberLecture
Compression ratio (std)CR=original sizecompressed sizeCR = \dfrac{\text{original size}}{\text{compressed size}}JPEG example: 40 MB → 4 MB, so CR=10:1CR = 10:1L02
Space saving (std)1−compressedoriginal1 - \dfrac{\text{compressed}}{\text{original}}40 MB → 4 MB saves 90%L02
Uncompressed textcharacters × 8 bits (ASCII)"Mississippi": 11×8=8811 \times 8 = 88 bitsL01
Fixed-length codecharacters × ⌈log⁡2(symbols)⌉\lceil \log_2(\text{symbols}) \rceil4 symbols → 2 bits: 11×2=2211 \times 2 = 22 bitsL01
Huffman total bits∑fi ℓi\sum f_i \, \ell_iMississippi: 1⋅3+2⋅3+4⋅2+4⋅1=211 \cdot 3 + 2 \cdot 3 + 4 \cdot 2 + 4 \cdot 1 = 21 bitsL01
Average code lengthtotal bits / characters21/11=1.90921/11 = 1.909 bits/charL01
Entropy (std)H=−∑pilog⁡2piH = -\sum p_i \log_2 p_iMississippi: H≈1.823H \approx 1.823 bits/char (Huffman 1.909 ≥ H)L01
Huffman on pixelsbits per pixel64 pixels, 4 values: (25+42+42+12)/64=1.89(25 + 42 + 42 + 12)/64 = 1.89 bpp vs 2 bpp fixedL02
Nyquist ratefs≥2fmaxf_s \ge 2 f_{max}500 Hz and 750 Hz tones → fs≥1500f_s \ge 1500 HzL03
Nyquist frequencyfs/2f_s / 244.1 kHz → 22.05 kHz; 48 kHz → 24 kHz; 96 kHz → 48 kHzL03
Quantization levels2n2^{n} for nn bits3 bits → 8; 8 bits → 256; 16 bits → 65,536; 24 bits → 16,777,216L03
Audio bitrate (std)fs×bit depth×channelsf_s \times \text{bit depth} \times \text{channels}CD: 44,100×16×2=1,411,20044{,}100 \times 16 \times 2 = 1{,}411{,}200 bit/sL03
Audio file size (std)bitrate × seconds / 81 min of CD audio: 1,411,200×60/8=10,584,0001{,}411{,}200 \times 60 / 8 = 10{,}584{,}000 B ≈ 10.6 MBL03
Video bitrate (std)samples per frame × bits × fpsPAL MPEG: (352⋅288+2⋅176⋅144)×8×25≈30.4(352 \cdot 288 + 2 \cdot 176 \cdot 144) \times 8 \times 25 \approx 30.4 Mbit/sL05
Image size (std)width × height × bytes per pixel512×512512 \times 512 gray LSB stego holds 262,144262{,}144 bits = 32 KBL06
MSE (std)MSE=1MN∑i,j(Iij−Kij)2MSE = \frac{1}{MN}\sum_{i,j} (I_{ij} - K_{ij})^2LSB on half the pixels (each ±1): MSE=0.5MSE = 0.5L06
PSNR (std)PSNR=10log⁡102552MSEPSNR = 10 \log_{10} \dfrac{255^2}{MSE} dBMSE=0.5MSE = 0.5 → 51.14 dB; MSE=1MSE = 1 → 48.13 dBL06
Deterministic QoSQoS:T→RQoS : T \rightarrow RTT = duration, RR = positive realsL05
Pair of valuesQoSmin≤QoS(t)≤QoSmaxQoS_{min} \le QoS(t) \le QoS_{max}15 to 30 fps; unacceptable if QoS(t)<QoSminQoS(t) < QoS_{min}L05
Predictable classBp=1L∑i=n−LnBiB^{p} = \frac{1}{L}\sum_{i=n-L}^{n} B_i(8+11+9)/3=9.33≈9(8 + 11 + 9)/3 = 9.33 \approx 9 Mbit/s with L=3L = 3L05
Motion vector(dx, dy) of a macroblockBlock moves 5 right and 3 down → (+5,+3)(+5, +3)L03

The slide's 1 Hz example says "more than 2 samples per second, say 3 Hz". The theorem says "at least twice". If asked for the minimum, write 2fmax2 f_{max} and add that a rate slightly above it is used in practice (guard band).

Text compression (L01)Search on YouTube

MethodOutputKey rule
HuffmanVariable-length prefix codesMerge the two lowest frequencies repeatedly; frequent symbols get short codes. Lossless.
LZ77Triplets (offset, length, next symbol)Window = search buffer + look-ahead buffer. Offset counted back from the dividing line. No match → (0, 0, c).
LZSSLiteral or (offset, length) pairNo forced next symbol. Only back-references that pay off; otherwise a literal.
RLEcount + valueWWWWWWWWBBBBBBBBZWK style runs → 8W-12B-1Z-1W-1K (slide); pixels 95 95 95 95 → 4 x 95
  • LZ77 slide example: cabracadabrarrarrad, window 13, look-ahead 6, search 7 → (0,0,c)(0,0,a)(0,0,b)(0,0,r)(3,1,c)(2,1,d)(7,4,r)(3,5,d).
  • LZ77 exercise: repetitive_repeat, search 11, look-ahead 4 → (0,0,r)(0,0,e)(0,0,p)(2,1,t)(0,0,i)(2,2,v)(6,1,_)(11,4,a)(10,1,$) ($ marks end of input).
  • LZSS on the same string: r e p 2 1 t i 2 2 v 6 1 11 4 a 10 1.
  • LZSS efficiency (std): compressed bytes = literals × 1 + pointers × 2 (End Sem 2025 assumption); CRCR = original bytes / compressed bytes.
  • PNG's LZSS (DEFLATE) uses a 32 KB sliding window and a 258-byte look-ahead.

JPEG pipeline (lossy) (L02)Search on YouTube

  1. Colour space conversion: RGB → Y (luminance), Cb, Cr (chrominance). Reversible, no loss.
  2. Chrominance downsampling: keep Y; average Cb and Cr over every 2 x 2 block, so each becomes one quarter. Ratio Y : Cb : Cr = 1 : 1/4 : 1/4. First real data loss.
  3. DCT: split into 8 x 8 blocks, subtract 128 (range −128 to 127), transform to frequency coefficients. No data thrown away yet. Energy concentrates in low frequencies (top left).
  4. Quantization: divide by the quantization table and round. Small divisors for low frequencies, large for high. Actual compression happens here; most high-frequency values become 0.
  5. Run-length and Huffman coding: zigzag scan, RLE for zero runs, Huffman for the result.

C D D Q E: "Colour Down DCT Quantize Entropy-code". Loss happens at Downsampling and Quantization only.

Camera pipeline before JPEG: lens → aperture → shutter → CFA → sensor → processing unit → storage. Bayer CFA is R : G : B = 1 : 2 : 1 (25% R, 50% G, 25% B), because the eye is most sensitive to green; demosaicing fills missing colours. Rods ≈ 100 million (light), cones ≈ 6 million (colour). Faster shutter → less motion blur, less light. RAW keeps all sensor data; JPEG drops data for smaller files.

PNG pipeline (lossless) (L02)Search on YouTube

Encode: filtering → LZSS → Huffman → PNG file. Decode: Huffman decoding → reverse LZSS → reverse filtering.

Why each stage: Huffman alone ignores spatial redundancy; RLE fails when repeats are patterns, not runs; LZSS back-references handle repeated patterns but fail on smooth gradients; filtering turns gradients (0, 4, 8, ...) into repeats (0, 4, 4, 4, ...) that LZSS compresses.

Neighbours: aa = left, bb = above, cc = above-left. All results are mod 256.

FilterOutput for pixel xxSlide check
Nonexxunchanged
Subx−ax - a127 128 139 134 → 127 1 11 251
Upx−bx - b131 − 127 = 4; 129 − 139 = −10 → 246
Averagex−⌊(a+b)/2⌋x - \lfloor (a + b)/2 \rfloorslide rounds .5 up: 129 − 66 = 63
Paethx−Px - P, where PP is whichever of a,b,ca, b, c is closest to p=a+b−cp = a + b - c (ties: aa, then bb, then cc)first pixel 139 − 133 = 6; next 128 − 139 → 245

The PNG standard uses floor in the Average filter. The slide's example rounds 0.5 up (129 − 65.5 → 63). In an exam, state which rule you use.

Audio and video (L03)Search on YouTube

Media formats on the slidesSearch on YouTube

Format or standardMediaTypeNotes
RAWImageUnprocessedAll sensor RGB intensity per pixel; most detail, most storage
JPEGImageLossyDCT + quantization; 40 MB → 4 MB example
PNGImageLosslessFiltering + LZSS + Huffman; good for graphics
BMP, PPMImageUncompressedStego size does not change (lab)
PCMAudioLossless encodingSampling → quantization → encoding into a bitstream
WAV, AUAudioUsually uncompressed PCMSteghide supports them
MPEG-2VideoLossyDVD and broadcast; GOP 12 to 18
MPEG-4 / H.264 (AVC)VideoLossyStreaming GOP 30 to 60; editing GOP 12 to 15
H.265VideoLossyReal-time GOP 10 to 15 (IPPP...); archival GOP 60 to 120

Video numbersSearch on YouTube

ItemValue
Frame rates30 fps TV; 60 fps games and smooth video; slow motion = capture 240, display 24
Fluid motion from12 to 15 fps
Flicker-free refreshat least 50 Hz
Resolutions720p 1280x720 (HD); 1080p 1920x1080 (Full HD); 2K 2048x1080; 4K 3840x2160 (UHD)
Aspect ratios4:3 (1.33) SD; 16:9 (1.78) HD; 21:9 (2.39) CinemaScope; 1.85 theatrical; 1:1 square; 9:16 vertical
Component codingY sampled at 13.5 MHz, chroma at 6.75 MHz, 8 bits (256 levels)
MPEG sampling4:1:1 (Y:Cb:Cr); blocks 16x16 for Y, 8x8 for Cb and Cr
MPEG PAL / NTSCY 352x288, chroma 176x144 / Y 352x240, chroma 176x120
NTSCPAL
Resolution720 x 480720 x 576
Frame rate29.97 (≈30) fps25 fps
Scan lines525625
Lines per field262.5312.5
Fields per second59.9450
Mains grid60 Hz (US, Canada, Japan)50 Hz (Europe, Australia, parts of Asia and Africa)

MPEG flow: input frames and colour conversion → motion estimation and compensation (temporal) → spatial compression (8x8 DCT, quantization) → entropy coding (RLE, Huffman). JPEG uses spatial redundancy only; MPEG = spatial + temporal.

FrameCoded fromSize
I (intra)Itself only; anchor and random-access pointLargest
P (predicted)Previous I or P (forward prediction)Medium
B (bi-directional)Previous and next I or PSmallest

Long GOP (30+): better compression, worse seeking and error resilience. Short GOP (≤12): better random access and resilience. Motion search uses 16x16 macroblocks and SAD.

Audio numbersSearch on YouTube

RangeFrequency
Infrasound0 to 20 Hz (earthquakes, elephants, whales)
Audible20 Hz to 20 kHz (most multimedia)
Ultrasound20 kHz to 1 GHz (fetal imaging, bats, dolphins)
Hypersound1 GHz to 10 THz (non-destructive testing, acoustic microscopy)
Sample rateNyquist frequencyGuard band above 20 kHz cut-off
44.1 kHz22.05 kHz2.05 kHz
48 kHz24 kHz4 kHz
96 kHz48 kHz28 kHz
  • Wave parameters: frequency (cycles per second, pitch), amplitude (loudness), phase (start position).
  • Sampling is lossless (mathematically, with band-limiting by a low-pass filter); quantization is lossy and adds quantization noise. More bits → smaller error.
  • A higher sampling rate is not the same as better quality. Sampling 4 kHz at 8 kHz puts every sample at 0.
  • Pulse modulation: width (PWM), position (PPM), amplitude (PAM), code (PCM: each sample as an 8-bit code).

QoS and resource management (L05)Search on YouTube

TopicKey items
Stream handlingScaling/adaptation (ABR, Netflix) vs resource reservation (VoIP)
DeadlinesSoft (some misses tolerated) vs hard (miss = system failure)
Real-time traitsPredictably fast response, high schedulability, stability under transient overload
ConstraintsData movement, segmentation and reassembly, error recovery
QoS layersPerceptual, application, system, device, network
Service objectsMedia sources, connections, virtual circuits
ParameterizationISO, Tenet, METS, RSVP, OS, middleware
Spec approachesScript, parameter, process, control logic, aspect, object
Service classesGuaranteed (single, pair, triple values), predictable (BpB^p), best effort
ResourcesActive/passive, exclusive/shared, single/multiple
PhasesEstablishment, runtime
RequirementsThroughput, delay (local, end-to-end), jitter, reliability
Network load / performanceInter-arrival time, burstiness, packet size, service time / delay, loss, jitter (traffic envelope)
Media serverSequential access, real time, high bandwidth, buffering; pull (client, YouTube) vs push (server, live TV)

Image forensic techniques (L04)Search on YouTube

TechniquePrincipleDetectsLimits
Metadata (EXIF, IPTC, XMP)Read camera, time, GPS, software, history (exiftool)Conflicting time or GPS, editing software, altered fieldsStripped (WhatsApp), spoofed GPS, time zones
Error level analysisRe-save at known quality, subtract, normalizeSpliced or added regions with different compressionTextures and edges; poor on faces
Key point matching (SIFT, SURF)Stable keypoints + descriptors matched inside the imageCopy-move (cloning)SURF faster, SIFT more accurate
PRNUSensor noise fingerprint correlated with camera referenceSource camera, computer-generated, splicingNeeds many images from the same camera
Statistical analysisHistograms, mean/variance/correlation, noise, DCT blocks, colour channels, Fourier/waveletAny disturbance of natural statisticsNeeds a baseline
Shadow analysisSun position (SunEarthTools) or light-source geometryWrong place or time, spliced objectsNeeds visible shadows
Deepfake checksFace, movement, audio, context, eye blinkingAI face swaps (shared encoder, two decoders)Arms race

Forgery map: copy-move → SIFT/SURF; splicing → ELA, PRNU, shadows; inpainting → ELA, statistics, noise.

Steganography versus watermarking (L06)Search on YouTube

AspectSteganographyWatermarking
GoalHide that a message existsProve ownership or authenticity
DataUnrelated to the coverRelated to the cover
ValueThe message; the cover is secondaryThe cover; the mark adds information
Main propertyStatistical undetectability (Cachin: PS=PCP_S = P_C)Robustness and fidelity
PayloadAs large as possible while undetectableSmall (benchmark: 80 bits)
Success if found?NoYes, if it cannot be removed
Tools and methodsLSB, OutGuess (DCT LSB + histogram fix), Steghide, model-basedE_BLIND, side information, spread spectrum, redundant, mid-frequency DCT
  • Stego building blocks: cover work; embed/extract (symbol assignment, modification, selection rule); stego key.
  • Embedding principles: cover lookup, cover synthesis (SpamMimic), cover modification (sequential, pseudo-random, adaptive).
  • Practical methods: statistics-preserving, model-based (P(cemb∣cinv)P(c_{emb} \mid c_{inv})), masking as natural processing.
  • Watermark properties: effectiveness, fidelity, payload; blind vs informed detection, false positives, robustness; modifiability; costs; security.
  • Watermark models: basic (cover as noise, cw=co+wac_w = c_o + w_a), side information (stronger in dark areas), multiplexed (two messages).
  • Robust embedding: redundant, spread spectrum, perceptually significant (mid-frequency) coefficients, known-robust domains (Fourier magnitudes for shifts, DCT for linear filtering).
  • Applications: copy prevention, copyright protection, broadcast monitoring, transaction tracking, owner identification, proof of ownership, content authentication.

AttacksSearch on YouTube

TargetAttackEffect or counter
Stego (warden)Passive warden: inspect, drop if suspiciousBlind or targeted detection
Stego (warden)Active warden: modify every messageDestroys hidden data even if undetected
Stego (warden)Malicious warden: detect and impersonate Alice or BobNeeds the algorithm
Stego (steganalysis)Targeted: SAD feature for LSB; chi-square on pairs (2k,2k+1)(2k, 2k+1)Beaten by statistics-preserving tools (OutGuess, Steghide)
Stego (steganalysis)Blind: classifier on many algorithms or one-class on covers; universal features (noise, correlation, transforms)Fails on unseen algorithms
Stego (lab)Brightness change, crop, JPEG re-saveDestroyed Steghide and OutGuess payloads; rename did not
Watermark (hostile)Unauthorized removal, embedding, detectionKeys, content binding, redundant spread-spectrum marks
Watermark (processing)Compression, cropping, filtering, rotation, spatial shifts, D/A conversion, format changeRedundant embedding, spread spectrum, mid-frequency, Fourier/DCT domains
Images (forgery)Copy-move, splicing, inpainting, AI generation, metadata stripping or GPS spoofingSee the forensic techniques table

Trade-offs to quoteSearch on YouTube

  • Payload up → false positives up. Robustness up → fidelity down. Lower detection threshold → more robust but more false positives. Higher embedding strength → more robust but more visible.
  • Long GOP → compression up, seeking down. Short GOP → the reverse.
  • More quantization bits → less noise, larger file. Higher sampling rate ≠ better audio.
  • Guaranteed QoS → reliable but reserves resources; best effort → high utilization, no guarantee.