Knowledge / Artificial Intelligence and Data Science / Computer vision basics

Computer vision basics

Artificial Intelligence and Data Science (B.E./B.Tech) · AI applications · free study notes for exams, placements and interviews

In short

Computer vision is the branch of artificial intelligence that makes a machine extract meaning from images and video — a 2-D or 3-D array of numbers in, a label, measurement or description out. It spans classical image processing (filtering, edges, thresholding, morphology, features) and learned representations (convolutional neural networks, vision transformers), and the two are still used together in industry. It is examined in AI&DS and CSE syllabi as "Digital Image Processing"/"Computer Vision", and in GATE DA/CS through convolution arithmetic, filtering and CNN parameter counts. In India it is applied at scale in UIDAI's Aadhaar face and fingerprint pipelines, FASTag/ANPR tolling on NHAI highways, DigiYatra airport boarding, UPI cheque and KYC document reading, and quality inspection lines at Tata, Bosch and Wipro PARI.

Explained

What an image is, and how it is represented

Point operations and histograms

Spatial filtering and convolution

Morphology, geometry and classical features

Learned vision: CNNs and beyond

Cameras, pipeline and the Indian compliance picture

Key points

Formulas and examples

Grayscale luma: Y = 0.299R + 0.587G + 0.114B (R, G, B = channel values 0–255; Y in the same scale)
Bit depth: levels = 2b; uncompressed size (bytes) = H × W × C × b/8 (H, W = pixels; C = channels; b = bits per channel)
Gamma / power law: s = c·rγ (r = input intensity, s = output; γ < 1 brightens)
Histogram equalisation: s_k = round[(L−1) · Σ_{j=0..k} n_j /(M·N)] (L = levels, n_j = count at level j, M·N = total pixels)
Convolution: g(x,y) = Σ_i Σ_j w(i,j)·f(x−i, y−j) (w = kernel of size m×n)
Output size: O = floor[(W − K + 2P)/S] + 1 (W = input side, K = kernel, P = padding, S = stride)
Conv layer parameters = (K_h × K_w × C_in + 1) × C_out (the +1 is the bias per filter)
Gradient: |∇f| = √(Gx² + Gy²), θ = atan2(Gy, Gx) in degrees or radians
Pinhole projection: u = f_x·X/Z + c_x, v = f_y·Y/Z + c_y (f in pixels, X, Y, Z in metres)
Stereo depth: Z = f·B/d (f in pixels, B = baseline in m, d = disparity in pixels → Z in m)
Overlap metrics: IoU = Area(∩)/Area(∪); F1 = 2PR/(P+R)

1. Image size and storage cost. A 1920 × 1080 RGB frame at 8 bits per channel:

2. Grayscale and gamma. A pixel is R = 200, G = 100, B = 50.

3. Histogram equalisation on a 3-bit image. 64 pixels, L = 8, counts n_0…n_7 = 8, 10, 12, 14, 10, 6, 3, 1.

4. Sobel gradient at a pixel. Neighbourhood (rows top→bottom) = [[10, 10, 10], [10, 50, 90], [90, 90, 90]], with Gx kernel [[−1,0,1],[−2,0,2],[−1,0,1]] and Gy [[−1,−2,−1],[0,0,0],[1,2,1]].

5. CNN output sizes and parameter count. Input 224 × 224 × 3. Conv1: 64 filters, 7 × 7, stride 2, padding 3; then max-pool 3 × 3, stride 2, padding 1.

6. Stereo depth and error. f = 800 px, baseline B = 0.12 m, measured disparity d = 16 px.

TaskClassical methodLearned methodWhen classical still wins
Thresholding a scanned formOtsu / adaptiveU-Net segmentationControlled lighting, needs no labels, runs in ms
Finding a logo or templateSIFT/ORB + RANSACSiamese or embedding modelFew examples, exact rigid object
Counting parts on a beltThreshold + connected componentsCNN detectorFixed camera, high contrast, CPU-only
Classifying a defect typeHand features + SVMFine-tuned ResNet/EfficientNetRarely — learned wins with enough labels
FilterTypeBest forSide effect
Mean (box)Linear LPFQuick smoothingBlurs edges, boxy artefacts
GaussianLinear LPFAdditive Gaussian noiseBlurs edges
MedianNon-linearSalt-and-pepperRemoves thin lines, slower
BilateralNon-linearDenoise, keep edgesExpensive, can look "cartoon"
LaplacianLinear HPFSharpening, blob detectionAmplifies noise
import cv2, numpy as np
img  = cv2.imread("plate.jpg")                 # BGR, uint8
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
blur = cv2.GaussianBlur(gray, (5, 5), 1.4)     # kernel odd, sigma 1.4
edges = cv2.Canny(blur, 80, 160)               # low:high ≈ 1:2
_, bw = cv2.threshold(gray, 0, 255,
                      cv2.THRESH_BINARY + cv2.THRESH_OTSU)
k  = cv2.getStructuringElement(cv2.MORPH_RECT, (3, 3))
bw = cv2.morphologyEx(bw, cv2.MORPH_CLOSE, k)  # fill character gaps
n, lbl, stats, cent = cv2.connectedComponentsWithStats(bw)
print(n - 1, "blobs")                          # minus the background label

Where it is used

Interview questions

Common mistakes

Related topics

Object detection and segmentation · Edge AI and model optimisation · Natural language processing basics · Text embeddings and semantic search · Speech recognition and audio AI · Time series forecasting

Open in the Knowledge reader →Find jobs →