0% found this document useful (0 votes)
10 views2 pages

Computer Vision 1628768300

This document provides a summary of key concepts in computer vision and image processing, including: 1) Image formats such as BMP, which stores pixel data in reverse RGB order in the file header and info header, followed by an optional color palette and pixel data. 2) Common operations on images like division, blending, logical operations, conversions between data types, and filtering techniques like thresholding. 3) Geometric transformations including translation, reflection, rotation, and affine transformations, which are used for tasks like image registration. 4) Methods for resizing images like scaling, subsampling, upsampling, and filling empty space.

Uploaded by

Bhavik Upadhyay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Computer Vision 1628768300

This document provides a summary of key concepts in computer vision and image processing, including: 1) Image formats such as BMP, which stores pixel data in reverse RGB order in the file header and info header, followed by an optional color palette and pixel data. 2) Common operations on images like division, blending, logical operations, conversions between data types, and filtering techniques like thresholding. 3) Geometric transformations including translation, reflection, rotation, and affine transformations, which are used for tasks like image registration. 4) Methods for resizing images like scaling, subsampling, upsampling, and filling empty space.

Uploaded by

Bhavik Upadhyay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CV Cheat Sheet

Images Division Scaling


• color depth = bit depth = bits per pixel = I(x, y) = I1 (x, y) ÷ I2 (x, y) • inverse scaling prefered (from dest. to source)
bbp OR to avoid gaps.
• dithering: putting 2 colors close to give I(x, y) = I1 (x, y) ÷ C
illusion of a 3rd color. inhomogeneous
• grayscale img: 8 bpp, black = 0 & white = Blending     
x2 s 0 x1
255. I(x, y) = I1 (x, y) ∗ C + I2 (x, y) ∗ (1 − C) = x
y2 0 sy y1
• color: 24 bpp, 8 bits for each channel of
RGB, & possible alpha channel. α = 0 =⇒
Logical Operations
homogeneous
fully transp., α = 1 =⇒ fully opaque. NOT, AND/NAND, OR/NOR, XOR/XNOR
  
sx 0 0 x1
 
Conversion x2
BMP Format 1. Bitwise: convert values to binary base and 0
 y2  =  sy 0   y1 

file header apply operators bitwise. 1 0 0 1 1
(size, offset, . . . ) 2. Thresholding:
info header (DIB) ( convert each pixel value to 1
0, I > 127,
(width, height, . . . ) bit: Inew = Subsampling (shrink)
optional color palette 1, I ≤ 127.
1. Replacement: replace a group of pixel by a
image data Applications chosen one (upper left).
File Header • AND/NAND: intersection bet. 2 images. 2. Interpolation: mean value of group.
14 bytes • OR/NOR: union bet. 2 images. Upsampling (magnify)
• NOT: negative of input image.
• magic identifier: 2 bytes 1. Replication: fill group of pixels with same
• file size : 4 bytes Logical NOT value of original pixel.
• 2 reserved places: 2 bytes each Ways to apply NOT: 2. Interpolation: get missing values at
• offset to image data: 4 bytes boundaries, then interpolate by distance.
• normal boolean NOT.
Info Header • grayscale: I 0 (x, y) = 255 − I(x, y).
• float pixel format: I 0 (x, y) = −I(x, y),
Reflection
40 bytes
followed by normalization. About x − axis:
• header size in bytes: 4 bytes    
Bitshift Operations 1 0 0 x1

• width and height : 4 bytes each x2
• 0
 y2  =  −1 0   y1 

number of color planes: 2 bytes usage: fast multiplication and division
• number of bits per pixel: 2 bytes 1 0 0 1 1
• Shift left i bits = ∗2i (multiplication)
• compression (0 to 3): 4 bytes, 0 = none • Shift right i bits = ÷2i (division)
• image size in bytes: 4 bytes About y − axis:
Empty Places
Note that the order is B → G → R, & all bytes    
−1 0 0 x1

1. fill with zeros. x2
are written in reverse order.
 0
 y2  =  1 0  y1 

2. fill with ones.
Color Palette 3. fill with bits from other side (rotate). 1 0 0 1 1
• If present, then a pixel is stored in ≤ 1 bytes.
Geometric Operations About a general axis:
• Each color entry is in RGBA format with 4
bytes. Translation 1. Translate to origin.
• If not present, of f set = 14 + 40 = 54, else 2. Rotate abt origin to fit on x- or y-axis.
inhomogeneous
of f set = 54 + 4 ∗ nColors. 3. Reflect about this axis.
4. Rotate back.
     
x2 x t
= 1 + x
Arithmetic Operations y2 y1 ty 5. Translate back.

Addition homogeneous Affine Transformation


I(x, y) = I1 (x, y) + I2 (x, y)     • 6 degrees of freedom.
1 0 t x x1

OR x2 • needs 3 pairs of points to estimate.
0
 y2  =  1 t y   y1 

I(x, y) = I1 (x, y) + C
1 0 0 1 1 inhomogeneous
Overflow       
x2 a a12 x1 t
I(x, y) > max (255)? = 11 + x
Rotation y2 a21 a22 y1 ty
1. Wrapping: I 0 (x, y) = I(x, y) − (max + 1)
• inverse rotation prefered (from dest. to
2. Saturation: I 0 (x, y) = max homogeneous
source) to avoid gaps.
• y upwards =⇒ counterclockwise is +ve,  0   
Subtraction x a11 a12 a13 x
y downwards =⇒ clockwise is +ve. y 0  = 
a21 a22 a23  y 

usage: detect changes between 2 images.
I(x, y) = I1 (x, y) − I2 (x, y) Rotate about origin: 1 a31 a32 a33 1
OR inhomogeneous
I(x, y) = I1 (x, y) − C      How to get matrix A from 3 pairs of points?
x2 cos θ − sin θ x1
Underflow =    −1  0 
y2 sin θ cos θ y1 a11 x1 y1 1 x1
I(x, y) < 0? a12  = x2 y2 1 x0 
2
homogeneous a13 x3 y3 1 x03
1. Wrapping: I 0 (x, y) = I(x, y) + (max + 1)    
cos θ − sin θ 0 x1

2. Saturation: I 0 (x, y) = 0 x2    −1  0 
3. Absolute: I 0 (x, y) = |I(x, y)| a21 x1 y1 1 y1
 sin θ
 y2  =  cos θ 0   y1 

1 1
a22  = x2 y2 1 y20 
0 0 1 a23 x3 y3 1 y30
Multiplication
usage: enhance contrast Rotate about arbitrary pt:    −1  
a31 x1 y1 1 1
I(x, y) = I1 (x, y) ∗ I2 (x, y) 1. Translate to origin. a32  = x2 y2 1 1
OR 2. Rotate about origin. a33 x3 y3 1 1
I(x, y) = I1 (x, y) ∗ C 3. Translate back.
Homography Transformation Triangular Filter
• 8 degrees of freedom. • similar to mean filter, but weights are diff.
• needs 4 pairs of points to estimate. • filter is always normalized (divide by sum of
 0    weights).
x h11 h12 h13 x
y 0  = h21 h22 h23 

 y  1 2 3 2 1
1 h31 h32 h33 1 2 4 6 4 2
1
3 6 9 6 3 ∗ 5 × 5 pyramid. kernel
h11 x + h12 y + h13
0
81
x = 2 4 6 4 2
h31 x + h32 y + h33
1 2 3 2 1
h21 x + h22 y + h23
y0 = 0 0 1 0 0
h31 x + h32 y + h33 0 2 2 2 0
How to get matrix H from 4 pairs of points? 1 2 5 2 1 ∗ 1
5 × 5 cone kernel (R = 2.5)
25
Let h33 = 1, M = 0 2 2 2 0
x1 y1 1 0 0 0 −x01 x1 −x01 y1
 
0 0 1 0 0
0 0 0 x1 y1 1 −y10 x1 −y10 y1 
x2 y2 1 0 0 0 −x02 x2 −x02 y1  Gaussian Filter (Blur)
 
0 0 0 x2 y2 1 −y20 x2 −y20 y2 
 
Gaussian in 1D:
x3 y3 1 0 0 0 −x03 x3 −x03 y3 
 
2
0 x3 y3 1 −y30 x3 0
−y3 y3  1 − x2
0 0
 
G(x) = √ e 2σ
x
4 y4 1 0 0 0 −x04 x4 −x04 y4  2πσ
0 0 0 x4 y4 1 −y40 x4 −y40 y4 Gaussian in 2D:
  0
h11 x1
 2 2
1 − x +y
h12   y10  G(x, y) = √ e 2σ2

h13  x02 
    2πσ
h21   y20 
   
M =  1 4 7 4 1
h22  x03  4 16 26 16 4
h23   y30 
    1
h  x0  7 26 40 26 7 ∗ 272
5 × 5 Gauss. (σ = 1)
31 4 4 16 26 16 4
h32 y40 1 4 7 4 1
Digital Filters Median Filter
Convolution • reduces noise, but preserves details.
• replace each pixel with the median of its
For an n × m kernel K:
m n
neighbourhood.
2
X 2
X • sort values (keep duplicates) and pick the
I(x, y) = I1 (x + k, y + l)K(k, l) middle one (or average of two middles if
k=− m
2
l=− n
2 even).
• median(I1 + I2 ) 6= median(I1 ) + median(I2 ).
Noise
Kuwahara Filter
1. Salt & pepper noise: the color of a noisy
pixel has no relation to surrounding pixels. • edge-preserving filter, doesn’t disturb
2. Gaussian noise: each pixel is changed from sharpness and position of edges.
PN
its original value by a small amount. 2
i=1 (I(xi ) − mean)
Variance: σ 2 =
Smoothing Filters N
Linear Filters
1. Calculate mean and variance of each 3 × 3
LF ilter(I1 + I2 ) = LF ilter(I1 ) + LF ilter(I2 ) region (upper left, upper right, lower left, &
1. Uniform (mean) filter lower right).
2. Triangular filter 2. Output value of center pixel = mean value of
3. Gaussian filter region of smallest variance.
Non-linear Filters
1. Median filter
2. Kuwahara filter
Uniform (Mean) Filter
• replace each pixel with the mean of its
neighbourhood.
• all coeffs. in kernel have same weights.
• smoothing effect increases with kernel size.
• filter is always normalized (divide by sum of
weights).
1 1 1
1
1 1 1 ∗ 9
3 × 3 rectang. OR circ. kernel (R = 1.5)
1 1 1
1 1 1 1 1
1 1 1 1 1
1
1 1 1 1 1 ∗ 25
5 × 5 rectang. kernel
1 1 1 1 1
1 1 1 1 1
0 1 1 1 0
1 1 1 1 1
1
1 1 1 1 1 ∗ 21
5 × 5 circ. kernel (R = 2.5)
1 1 1 1 1
0 1 1 1 0

You might also like