← Computer Vision vault · formula sheet · CV1–CV7 (mid-sem)

Computer Vision — formula sheet, learn these by heart.

computer-vision formula-sheet AIMLCZG525 mid-sem

Every equation likely to matter for the AIMLCZG525 Computer Vision mid-sem, grouped by concept. Each card gives the display equation and defines every symbol in plain words immediately after it. Use this with the cheatsheet: formulas here, intuition there.

Symbol key

SymbolMeaning
\(f(x,y), I(x,y)\)image intensity at spatial coordinates \((x,y)\)
\(F[x,y]\)discrete digital image value at row/column location
\(M,N\)image height/rows and width/columns; total pixels \(MN\)
\(L\)number of gray levels; for 8-bit images \(L=256\)
\(r,s\)input intensity and output transformed intensity
\(G_x,G_y\)horizontal and vertical derivative responses
\(\sigma\)Gaussian standard deviation / scale
\(\theta\)angle or orientation, usually in radians unless degrees are stated

Convolution & correlation

Linear spatial filtering / convolution
\[ g(x,y)=\sum_{s=-a}^{a}\sum_{t=-b}^{b} w(s,t)\,f(x-s,y-t) \]

\(g(x,y)\) is the output pixel. \(f\) is the input image. \(w(s,t)\) is the kernel coefficient at offset \((s,t)\). \(2a+1\) and \(2b+1\) are kernel height and width. The minus signs mean the kernel is flipped as in convolution.

Correlation
\[ g(x,y)=\sum_{s=-a}^{a}\sum_{t=-b}^{b} w(s,t)\,f(x+s,y+t) \]

Correlation uses the same neighborhood sum but does not flip the kernel. For symmetric masks such as box and Gaussian filters, correlation and convolution produce the same numerical result.

Normalized box filter
\[ w(i,j)=\frac{1}{mn},\qquad \sum_{i=1}^{m}\sum_{j=1}^{n}w(i,j)=1 \]

\(m,n\) are kernel dimensions. Every neighbor has equal weight. Sum equal to one preserves average brightness in flat regions.

Gaussian & Laplacian kernels

2D Gaussian
\[ G(x,y;\sigma)=\frac{1}{2\pi\sigma^2}\exp\!\left(-\frac{x^2+y^2}{2\sigma^2}\right) \]

\(x,y\) are offsets from kernel center. \(\sigma\) controls spread/blur. Larger \(\sigma\) means stronger smoothing. The constant normalizes continuous Gaussian area to one.

Discrete Gaussian sample
\[ w(s,t)=K\exp\!\left(-\frac{s^2+t^2}{2\sigma^2}\right),\qquad w \leftarrow \frac{w}{\sum_{s,t}w(s,t)} \]

\(s,t\) are integer cell offsets in the mask. \(K\) is a scale constant; after sampling we usually normalize by the sum so the kernel sums to one.

Laplacian of an image
\[ \nabla^2 f=\frac{\partial^2 f}{\partial x^2}+\frac{\partial^2 f}{\partial y^2} \]

\(\nabla^2 f\) is the second-derivative response. It is isotropic but noise-sensitive. It is used for zero-crossing edge detection after smoothing.

Laplacian of Gaussian (LoG)
\[ \operatorname{LoG}(I)=\nabla^2(G_\sigma * I)=(\nabla^2G_\sigma)*I \]

\(I\) is the image. \(*\) means convolution. Smooth first with Gaussian \(G_\sigma\), then take the Laplacian; by associativity this equals convolving with the LoG kernel.

Gradient magnitude/direction

Image gradient vector
\[ \nabla f(x,y)=\begin{bmatrix}G_x\\G_y\end{bmatrix}=\begin{bmatrix}\dfrac{\partial f}{\partial x}\\[4pt]\dfrac{\partial f}{\partial y}\end{bmatrix} \]

\(G_x\) is horizontal derivative response. \(G_y\) is vertical derivative response. The vector points in the direction of fastest intensity increase.

Gradient magnitude
\[ g=\lVert \nabla f\rVert=\sqrt{G_x^2+G_y^2}\qquad\text{or}\qquad g\approx |G_x|+|G_y| \]

\(g\) is edge strength. The square-root expression is exact Euclidean magnitude; the absolute-sum expression is a common fast approximation.

Gradient orientation
\[ \theta=\tan^{-1}\!\left(\frac{G_y}{G_x}\right)\qquad\text{preferably}\qquad \theta=\operatorname{atan2}(G_y,G_x) \]

\(\theta\) is gradient direction. atan2 handles signs and quadrants correctly. The edge direction itself is perpendicular to the gradient direction.

Central finite difference
\[ \frac{\partial f}{\partial x}\approx \frac{f(x+d,y)-f(x-d,y)}{2d},\qquad \frac{\partial f}{\partial y}\approx \frac{f(x,y+d)-f(x,y-d)}{2d} \]

\(d\) is a small spacing, one pixel for most discrete image masks. This approximates derivatives by subtracting opposite neighbors.

Histogram equalization transform \(s=(L-1)\cdot\mathrm{CDF}(r)\)

Normalized histogram
\[ p(r_k)=\frac{n_k}{MN},\qquad \sum_{k=0}^{L-1}p(r_k)=1 \]

\(r_k\) is gray level \(k\). \(n_k\) is number of pixels with that gray level. \(M,N\) are image dimensions. \(p(r_k)\) is probability/frequency.

Discrete histogram equalization
\[ s_k=(L-1)\sum_{j=0}^{k}p(r_j)=(L-1)\operatorname{CDF}(r_k) \]

\(s_k\) is mapped output gray level for input \(r_k\). \(L-1\) is maximum gray value. CDF is cumulative sum of histogram probabilities up to \(k\). Round \(s_k\) to a legal integer gray level.

Continuous equalization transform
\[ s=T(r)=(L-1)\int_0^r p_r(w)\,dw \]

\(p_r(w)\) is the probability density of input intensity. \(T(r)\) is the CDF scaled to gray range. It spreads probability mass across output levels.

Intensity transforms: log and gamma

Image negative
\[ s=L-1-r \]

\(r\) is input gray level, \(s\) is output gray level, \(L-1\) is maximum intensity. Dark becomes bright; bright becomes dark.

Log transform
\[ s=c\log(1+r) \]

\(c\) is a positive scaling constant. \(1+r\) avoids \(\log 0\). Log expands low intensities and compresses high intensities; useful for Fourier magnitude display.

Power-law / gamma transform
\[ s=cr^\gamma \]

\(c\) and \(\gamma\) are positive constants. If \(r\in[0,1]\), \(\gamma<1\) brightens and \(\gamma>1\) darkens. Used for gamma correction and medical/aerial image enhancement.

Binary threshold
\[ s=\begin{cases} 0, & r

\(T\) is the threshold. Values below threshold become background; values at/above threshold become foreground.

Sobel/Prewitt masks

Prewitt masks
\[ P_x=\begin{bmatrix}-1&0&1\\-1&0&1\\-1&0&1\end{bmatrix},\qquad P_y=\begin{bmatrix}-1&-1&-1\\0&0&0\\1&1&1\end{bmatrix} \]

\(P_x\) estimates horizontal intensity change. \(P_y\) estimates vertical intensity change. Apply each mask to the 3×3 neighborhood and sum products.

Sobel masks
\[ S_x=\begin{bmatrix}-1&0&1\\-2&0&2\\-1&0&1\end{bmatrix},\qquad S_y=\begin{bmatrix}-1&-2&-1\\0&0&0\\1&2&1\end{bmatrix} \]

Sobel adds weight 2 to the center row/column, combining differentiation with mild smoothing. Use responses as \(G_x\) and \(G_y\).

Canny: Gaussian \(\sigma\), NMS and hysteresis

Gaussian smoothing step
\[ I_s=G_\sigma*I \]

\(I\) is original image. \(I_s\) is smoothed image. \(G_\sigma\) is Gaussian with scale \(\sigma\). Larger \(\sigma\) removes more noise but blurs edge location.

Non-maximum suppression condition
\[ \text{keep }(x,y)\text{ if }g(x,y)\ge g(x_+,y_+)\text{ and }g(x,y)\ge g(x_-,y_-) \]

\(g(x,y)\) is gradient magnitude. \((x_+,y_+)\) and \((x_-,y_-)\) are the two neighboring samples along the gradient direction. This thins edges to local maxima.

Double threshold and hysteresis
\[ \text{strong}: g\ge T_H,\qquad \text{weak}: T_L\le g

\(T_H\) is high threshold. \(T_L\) is low threshold. Strong pixels start edge curves; weak pixels survive only if connected to a strong pixel, usually in an 8-neighborhood. Typical \(T_H:T_L\) ratio is 2:1 to 3:1.

Hough normal form

Slope-intercept point vote
\[ y=mx+b,\qquad b=-x_0m+y_0 \]

\((x_0,y_0)\) is an edge point. \(m\) is slope and \(b\) is intercept. One image point maps to a line of possible \((m,b)\) parameters.

Polar/normal line form
\[ \rho=x\cos\theta+y\sin\theta \]

\(\rho\) is perpendicular distance from origin to the line. \(\theta\) is angle of that perpendicular with the x-axis. \((x,y)\) is an edge point voting for line parameters.

Circle Hough model
\[ (x-a)^2+(y-b)^2=R^2 \]

\((a,b)\) is circle center. \(R\) is radius. If \(R\) is known, vote over centers; if unknown, vote over \((a,b,R)\).

Harris structure tensor, response and Shi-Tomasi

Window shift energy
\[ E(u,v)=\sum_{x,y}w(x,y)\,[I(x+u,y+v)-I(x,y)]^2 \]

\((u,v)\) is a small shift of the window. \(w(x,y)\) is a window weight, often Gaussian. Corners make this energy large for shifts in all directions.

Second-moment / structure tensor
\[ M=\sum_{x,y}w(x,y)\begin{bmatrix}I_x^2&I_xI_y\\I_xI_y&I_y^2\end{bmatrix} \]

\(I_x,I_y\) are image gradients. \(M\) summarizes gradient variation inside the window. Its eigenvalues decide whether the region is flat, edge or corner.

Trace and determinant
\[ \operatorname{trace}(M)=\lambda_1+\lambda_2, \qquad \det(M)=\lambda_1\lambda_2 \]

\(\lambda_1,\lambda_2\) are eigenvalues of \(M\). Both large means strong change in two directions; one large means edge; both small means flat.

Harris response
\[ R=\det(M)-k\,[\operatorname{trace}(M)]^2, \qquad k\approx0.04\text{ to }0.06 \]

\(R\) is corner score. \(k\) is empirical constant. Large positive \(R\) means corner; negative large magnitude means edge; near zero means flat.

Shi-Tomasi score
\[ R_{ST}=\min(\lambda_1,\lambda_2) \]

Shi-Tomasi calls a point good if the smaller eigenvalue is large. It directly enforces large change in both principal directions.

HoG: cell histograms and block normalization L2

Orientation-bin vote
\[ h_b \leftarrow h_b + g(x,y)\,\omega_b(\theta(x,y)) \]

\(h_b\) is histogram bin \(b\). \(g(x,y)\) is gradient magnitude. \(\theta(x,y)\) is orientation. \(\omega_b\) is the binning/interpolation weight for that orientation.

Block L2 normalization
\[ v'=\frac{v}{\sqrt{\lVert v\rVert_2^2+\varepsilon^2}} \]

\(v\) is concatenated histogram vector for a block. \(v'\) is normalized vector. \(\varepsilon\) avoids division by zero. This reduces effects of contrast and lighting.

Classic HoG dimensionality
\[ 64\times128\text{ window}\Rightarrow 8\times16\text{ cells}\Rightarrow 7\times15\text{ blocks}\Rightarrow 7\cdot15\cdot4\cdot9=3780 \]

8×8 pixels per cell, 2×2 cells per block, 9 orientation bins per cell, and overlapping blocks sliding by one cell.

SIFT DoG and descriptor

Gaussian scale space
\[ L(x,y,\sigma)=G(x,y,\sigma)*I(x,y) \]

\(L\) is the blurred image at scale \(\sigma\). \(G\) is Gaussian. \(I\) is input image. SIFT detects features across \((x,y,\sigma)\).

Difference of Gaussian
\[ D(x,y,\sigma)=\bigl(G(x,y,k\sigma)-G(x,y,\sigma)\bigr)*I(x,y)=L(x,y,k\sigma)-L(x,y,\sigma) \]

\(D\) is DoG response. \(k\) is multiplicative scale step. DoG approximates LoG and finds blob-like extrema efficiently.

SIFT local gradient for orientation
\[ m(x,y)=\sqrt{(L(x+1,y)-L(x-1,y))^2+(L(x,y+1)-L(x,y-1))^2} \]
\[ \theta(x,y)=\operatorname{atan2}\bigl(L(x,y+1)-L(x,y-1),\;L(x+1,y)-L(x-1,y)\bigr) \]

\(m\) is local gradient magnitude in the scale image. \(\theta\) is local orientation. Dominant orientation gives rotation invariance.

SIFT descriptor size
\[ 4\times4\text{ cells}\times 8\text{ orientation bins}=128\text{ dimensions} \]

A keypoint neighborhood is divided into 16 cells; each cell stores an 8-bin orientation histogram. The 128 numbers are normalized and used for descriptor matching.

Descriptor matching ratio test
\[ \frac{d_1}{d_2}<\tau \]

\(d_1\) is distance to nearest descriptor. \(d_2\) is distance to second-nearest descriptor. \(\tau\) is a threshold, often around 0.8 in Lowe-style matching. Accept only distinctive matches.

Revision order. Memorize histogram equalization, Sobel/Prewitt, Canny steps, Hough normal form, Harris \(M\) and \(R\), HoG 3780 and SIFT DoG/128-D descriptor first. Those formulas connect directly to likely numericals.
← Computer Vision vault
© cvam — written in plaintext, served warm