Saral Shiksha Yojna
Courses/Computer Vision

Computer Vision

CSE471
Prof. Makarand Tapaswi + Prof. Charu SharmaSpring 2025-264 credits

DIP — Filters, Histograms, Fourier/DCT, Morphology, Geometric Ops, Hough, Templates

NotesStoryCaveman
Unit 2 — Digital Image Processing Recap

Ugg fix picture with rock-tricks, before thinking-machine ever look

Digital Image Processing (DIP) — all the rock-tricks Ugg do TO the picture, before the tribe's thinking-machine start guessing. Every new trick the thinking-machine do, it stole from these old fire-side tricks.

Picture is just dots on cave wall

A digital image is a rule : point at spot on wall, it hand back brightness . One color = gray. Three colors = RGB. "8 bits per dot" mean each dot pick from brightness steps.

Picture born two ways: sampling (how many dots on wall) and quantisation (how many berry-shades per dot). More dots = sharper, more shades = smoother.

Ugg count-magic: MB for ONE raw picture; 30 heartbeats of moving-picture GB! Too big for cave. So tribe squeeze it — compression — because near dots look alike (spatial redundancy) and next frame look like last (temporal redundancy).

Three ways to touch dots

Point-to-point — touch one lonely dot. Negative flip dark and light. Log brighten shadow. Gamma : Ugg WARN — BRIGHTEN, DARKEN, no mix up! Always squash into first or number go crazy.

Neighbourhood-to-point — touch a dot using its neighbor-dots. Most rock-tricks live here.

Global-to-point — stare at WHOLE picture. Tally-stick magic.

Ugg's stamp-rock zoo

Convolution — take small stamp-rock, flip it, slide over big picture, press-press-sum, make new picture: .

Mean filter — all-same-weight stamp, mush 9 dots to their average. Blur everything, even edge. Gaussian — smart mush, , middle dot matter most. Is separable: do one row-pass then one column-pass, cost not . Big = more blur.

Sobel stamp find edge — the place where light jump. Sobel-x catch up-down edges, Sobel-y catch side-ways edges. Laplacian find edge by second-jump, but shake bad with noise. LoG = smooth first, THEN Laplacian — steady edge-finder.

Big rule: smoothing stamp sum to 1 (flat stay flat), edge stamp sum to 0 (flat give nothing).

The gradient is an arrow pointing dark-to-light. Strength , way . Ugg WARN: edge run SIDEWAYS to the arrow, not along it! Arrow stab ACROSS the edge.

Unsharp / highboost sharpen: detail = picture − blur, add detail back, . also brighten.

Median filter — line up the 9 dots, grab middle. Kill salt-pepper speck (crazy dot sit at line's far end, never reach middle). Mean would smear the speck around — wrong! But median also eat thin 1-dot lines.

Bilateral filter — two-Gaussian stamp: one for distance, one for same-brightness. Across an edge, a different-brightness neighbor get weight near 0 → no smear across edge, so edge stay sharp while flat gets smooth.

Ugg WARN: cross-correlation (, no flip) and convolution (flip) give SAME answer for symmetric stamp but DIFFERENT for Sobel. The thinking-machine's nn.Conv2d really do cross-correlation! And the convolution theorem: mush-in-space = plain multiply-in-wave-land.

Padding at the wall's edge: zero-pad make dark halo + fake edges; replicate-pad copy the border, no halo. Same-size pad = .

Tally-stick and spreading

A histogram tally how many dots at each brightness. It tell contrast, NOT where dots sit (checkerboard and half-black-half-white have SAME histogram!).

Histogram equalisation spread the tally even for most contrast: count → make PDF → make CDF → map . The CDF flatten any pile to even, but also boost noise in flat spots. Contrast stretching is the gentle cousin, — same shape, just pull wide.

Wave-land (turn picture into pile of ripples)

Why go wave-land? Big-stamp mush faster there (), picture squeeze small (energy hide in low ripples — JPEG!), and scanline-noise show as one spike, easy to zap. 2D DFT turn dots into ripples; FFT is the fast way. Ideal low-pass cut sharp → ring-ring wobble. Gaussian low-pass cut soft → no ring. High-pass = edges, low-pass = smooth.

DCT is cousin — real cosine only, mirror the edge so no boundary jump. Ugg WARN: JPEG use DCT not DFT — better energy-squeeze. JPEG road: RGB→YCbCr→shrink color→8×8 block→DCT→divide by quant-table (the lossy step!)→zigzag→pack.

Grow-shrink blob magic

Morphology — set-tricks on black-white picture with a structuring element (tiny stamp). Erosion : stamp must fit FULLY inside → MIN → SHRINK blob. Dilation : stamp just touch → MAX → GROW blob. Ugg WARN: erosion is MIN-shrink, dilation is MAX-grow — no swap! Opening = erode-then-dilate, kill lone speck. Closing = dilate-then-erode, fill small hole. Boundary .

Otsu pick the best cut between two tally-hills: MAXIMISE between-class spread . One global cut fail under uneven light; use local cut then.

Bend picture, vote line, match stamp

Geometric transform — all matrix in homogeneous coords. DoF ladder: move(2)→rigid(3)→similar(4)→affine(6, keep parallel lines)→projective(8, keep only straight lines). Ugg WARN: inverse warping is GOOD — walk destination, pull from , every dot filled once, need interpolation at in-between spots. Forward warping push dots and leave HOLES.

Colour: RGB add-light for screen, CMYK subtract-ink for print (K = black), Lab even-to-eye, YCbCr for JPEG.

Hough transform — every edge-dot VOTE for all lines through it. Use polar (not slope — vertical line make slope go infinite!). Big peak in the vote-box = a line.

Template matching — slide a small known picture over the big one. SSD (brightness-touchy), NCC (brightness-proof, range ), correlation-coefficient (brightness AND contrast proof). Ugg WARN: NO rotate/scale proof — spin the template a little, it fail. This is why tribe later make SIFT and thinking-machine features.

Ugg remember

  • Edge run SIDEWAYS to the gradient arrow. Smoothing stamp sum to 1, edge stamp sum to 0.
  • **Gamma brighten, darken.** Median kill salt-pepper; bilateral keep edge sharp.
  • Erosion MIN-shrink, dilation MAX-grow. Opening kill speck, closing fill hole, boundary .
  • JPEG use DCT not DFT. Otsu MAXIMISE between-class spread. Inverse warping good, forward leave holes.
  • **Hough use polar ** to dodge the vertical-line-infinity trap.
End of storyUnit 2 — Digital Image Processing Recap · DIP — Filters, Histograms, Fourier/DCT, Morphology, Geometric Ops, Hough, Templates