Image processing &
Computer Vision
Dr. Abhishek Anand
Computer Vision
• Building machines that see
• Machines can interact with world
• Input is digital images and videos
• Modeling biological perception
Computer vision is a field of computer science that works on
enabling computers to see, identify and process images in the
same way that human vision does and then provide appropriate
output.
Human vs Computer Vision
What is Computer Vision..?
• Computer Vision
• Input : Image Output : Interpretation
• Image Analysis, Image Interpretation, Scene Understanding
• Image Processing
• Input : Image Output : Image
• Image recovery, reconstruction, filtering, compression,
visualization
• Computer Graphics
• Input : Scene representation Output: Image
Computer Vision Applications
Digital Image Processing
Digital Image processing means processing of digital images on
digital hardware usually on computer.
Components of a general-purpose
Image processing system
Types of Digital Image
• Digital photo
• Image sequences used for video broadcasting and playback
• Multi-sensor data like satellite images in the visible, infrared
and microwave bands.
• Medical images like ultra-sound, Gamma-ray images, X-ray
images and radio-band images like MRI etc.
• Astronomical images.
• Electron-microscope images used to study material structure
Types of Digital Image…
Applications of Image
Processing
What is an Analog image?
• Electrical Signal, for example, the output of a video camera,
that gives the eclectic voltage at locations in an image.
Representation of a Digital
Image
Image Sampling and
Quantization
What is a Digital Image?
• Sample the 2D space on a regular grid
• Quantize each sample (round to nearest integer)
If our samples are Δ apart, we can write this as:
f( i, j ) = Quantize{ f(iΔ, jΔ)}
Coordinate Conversion
Neighborhood of a Pixel
What is a digital Image…?
• 2D array of numbers representing the sampled version of an
image.
• The image defined over grid location being called a pixel
• Represented by a finite grid and each intensity data is
represented a finite number of bits.
• A binary image is represented by one bit. Gray –level image is
represented by 8 bits.
Pixels and Intensities
16 18 19 20
255 19 18 20
21 21 22 30
21 33 22 23
Digital Image Definitions
Dimensionality and Resolution
of an Image
Resolution of an Image
Different Gray Level Resolution
False Contouring in image
Image Types
Binary Image
• Efficient in terms of storage
• Document processing, handwriting, fingerprinting
Grayscale Image
• The range is usually a power of 2
• 256 levels are sufficient for most applications
What is color Image?
• Three components:
• R,G,B each usually represented by 8 bits. In total 24 bits.
• These three primary are mixed in different proportions to get
different colors
• For different processing applications other formats (YIQ, HIS etc)
are used.
• A color image is just a three component function. We can write
this as a “vector-valued” function.
True Color Image
• RGB image (red-green-blue)
• 16,777,216 different possible colors.
Indexed Image
• The image has an associated color map, which is simply a list
of all the colors used in that image
• GIF, PNG formats, etc.
R G B
Look up Table
Types of Digital Images
• Binary image – 1 bit/pixel
• Grayscale image – 8 bits/pixel
• True color or RGB image – 24 bits/pixel
• Indexed image – 8 bits/pixel
Characteristics of Light
• Radiance (Watts-W) : Total amount of energy coming out of
light source
• Luminance (Lumens-lm) : Measure of amount of energy an
observer perceives from light source.
• Brightness (no unit) : It is subjective measure.
Question
• An image is of 512 X 512 dimension. The number of bits needs
to store the file size of this image.
a. If image is binary
b. If image is Gray scale
c. If image is RGB.
Image Processing
• Digital Image processing deals with manipulation and analysis
of the digital image by a digital hardware, usually a computer.
• Emphasizing certain pictorial information for better clarity
(human interpretation)
• Automatic machine processing of the scene data.
• Compressing the image data for efficient utilization of storage
space and transmission bandwidth.
Image Enhancement
• Image enhancement is a preprocessing technique in digital
image processing that improves the visual quality of an image
or prepares it for further analysis. Enhancement can be done
in two major ways:
• Point Processing
• Neighborhood Processing
Point Processing
• Point processing techniques operate on individual pixels, where the
new value of a pixel depends only on its original value and a
transformation function.
• Mathematical form:
s=T(r)
where:
• r = input pixel gray level
• s = output pixel gray level
• T = transformation function
Examples:
• Image Negatives: Enhance white or gray details in dark regions.
• Contrast Stretching: Expands the range of intensity levels.
• Thresholding: Converts grayscale image into binary image.
Neighborhood Processing
• Neighborhood (or spatial) processing uses a pixel and its
neighbors to determine the output pixel value.
Mathematical form:
g(x,y)=T[f(x,y) for all (x,y)∈ neighborhood]
Types:
• Linear filtering: Convolution using masks (smoothing,
sharpening).
• Non-linear filtering: Median filtering, morphological
operations.
Applications:
• Noise Reduction: Averaging, Gaussian smoothing.
• Edge Enhancement: Laplacian or high-pass filtering.
• Detail Enhancement: Local contrast adjustment.
Neighborhoods of a Pixel
• A pixel p at location (x,y) has two horizontal and two vertical
neighbors.
(x-1,y)
(x,y-1) P(x,y) (x,y+1)
(x+1, y)
• This set of four pixels is called 4-neighbors of p=N4(p).
• Each of these neighbors is at a unit distance from p.
• If p is a boundary pixel then it will have less number of
neighbors.
Diagonal & 8-neighbour
• A pixel p has four diagonal neighbors = ND(p)
(x-1,y-1) (x-1,y+1)
P(x,y)
(x+1,y-1) (x+1,y+1)
• The point of N4(p) and ND(p) together are called 8-neighbors
of p.
N8(p) = N4(p) U ND(p)
• If p is boundary pixel then both ND(p) and N8(p) will have less
number of pixels.
Connectivity
• Connectivity between pixels is a very important concept
• It is very useful for
• Establishing object boundaries
• Defining image components\regions etc
• If F(x,y) > Th
(x,y) ε Object
Else
(x,y) ε
background
What is connectivity
• Two pixels are said to be connected if they are adjacent in
some sense.
• They are neighbors (N4, ND or N8) and
• Their intensity values (gray levels) are similar
• Ex: For a binary image B, two points p and q will be connected
if q ∈ N(p) or p ∈ N(q) and B(p) = B(q).
q q
p p p q
Connectivity
• Let V be the set of gray levels used to define connectivity for
two points f(p),f(q) ∈ v, three types of connectivity are defined
• 4-connectivity p,q ∈ v & p ∈ N4(q)
• 8-connectivity p,q ∈ v & p ∈ N8(q)
• M-connectivity (mixed connectivity)
p,q ∈ v are m-connected if
1. q ∈ N4(p) or
2. q ∈ ND(p) and N4(p) ∩ N4(q) = φ
N4(p) ∩ N4(q) set of pixels that are 4-neighbour of both p and
q whose values are from v.
Connectivity
• Mixed connectivity is a modification of 8-connectivity
• Eliminates multiple path connections that often arise with 8-
coonectivity.
O 1 1 0 1 1 0 1 1
0 1 0 0 1 0 0 1 0
0 0 1 0 0 1 0 0 1
4-connected 8-connected M-connected
Adjacency (regions)
• Two pixels p and q are adjacent if they are connected
• 4-adjacency
• 8-adjacency
• M-adjacency
• Depending on type of connectivity used
• Two image subsets (image regions) Si and Sj are adjacent if ∃ p
∈ Si and ∃ q ∈ Sj such that p and q are adjacent.
Path
• A path from p(x,y) to q(s,t) is a sequence of distinct pixels.
(x0,y0), (x1,y1)……………….. (xn,yn)
Where
(x0,y0) = (x,y), (xn,yn) = (s,t)
(xi,yj) is adjacent to (xi-1,yi-1)
for 1 <= I <= n
N Length of the path
Connected Component
Let
S ⊆ l and p,q ∈ S ; here S is a subset of image I.
Then p is connected to q in S if there is a path from p to q
consisting entirely of pixels in S
For any p ∈ S, the set of pixels is S that are connected to p is call
a connected component of S.
Any two pixels of a connected component are connected to
each other
Distinct connected components are disjoint.
Connected component labeling
• Ability to assign different labels to various disjoint connected
components of an image
• Connected component labeling is a fundamental step in
automated image analysis
• Shape
• Area
• Boundary
• Shape/Area/Boundary based features
Algorithm
• Algorithm for Group Identification of a region or Pixels
belonging to a particular region.
1. Scan an image from left to right and from top to bottom.
2. Assume 4-connectivity
3. P be a pixel at any step in the scanning process
r
t p
4. Before p, points r and t are scanned
Steps
• I(p) Pixel value of at position p.
• L(p) Label assigned to pixel location p.
• If I(p) = 0, move to next scanning position.
• If I(p) = 1 and I(r) = I(t) = 0
• Then assign a new label to position p
• If I(p) = 1 and only one of the two neighbor is 1
• Then assign its label to p.
• If I(p) =1 and both r and t are 1’s, then
• If L(r) = L(t) then L(p)=L(r)
• If L(r) ≠ L(t) then assign one of the labels of p and make a note
that the two labels are equivalent.
Connected component labeling
• At end of the scam all pixels with value 1 are labeled.
• Some labels are equivalent
• During second pass process equivalent pairs to from
equivalence classes.
• Assign a different label to each class.
• In the second pass through the image replace each label by
the label assigned to its equivalence class