Image Processing (KCS-062):
Unit-5: Image compression, Representation, Pattern
classes and Matching
Dr. Radhey Shyam
Professor
Department of Computer Science and Engineering
BIET Lucknow
(Affiliated to Dr. A.P.J. Abdul Kalam Technical University
Unit-5 have been compiled/prepared by Dr. Radhey Shyam, with grateful acknowledgment who made their
course contents freely available. Feel free to use this study material for your own academic purposes. For
any query, the communication can be made through my mail shyam0058@gmail.com.
Course Outcome of Unit-5, the students will be able to explain the basic concepts of Image
compression,Representation, and Pattern classes and Matching.
Date: July 17, 2021
01/12/2020
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
Representation & Description
Representation & Description
The results of segmentation is a set of regions. Regions are then
represented (often univocally) and described (often non-univocally)
Two main ways of representing a region:
- external characteristics (its boundary): focus on shape and size
- internal characteristics (its internal pixels): focus on color, textures…
The next step: description
E.g.: a region may be represented by its boundary, and its boundary
described by some features such as length, regularity…
- Features should be insensitive to translation, rotation, and scaling.
- Both boundary and regional descriptors are often used together.
Copyright notice: Most images in these slides are
© Gonzalez and Woods, Digital Image Processing, Prentice-Hall
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
Representation of boundaries
Representation of boundaries
Hypotheses: binary images, objects do not touch the image border
(padding if necessary), one object at a time
To represent a boundary, it is useful to compact the raw data (list of
boundary pixels coordinates) 
Boundary following: start at the first boundary position in (e.g.)
lexicographic ordering and build a chain code
Chain codes: list of segments with defined length and direction
• 4-directional chain codes
• 8-directional chain codes
- At each boundary pixel,
circularly inspect the
neighbourhood until a new
boundary pixel is found
- Stop when contour closes
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
Representation of boundaries
Representation of boundaries
Simplify
It may be useful to downsample the border image before computing
the chain code
• to reduce the code size
• to remove useless details along the boundary
Can be conveniently done during the boundary following process: at
each step the large-grid node is selected which is closest to a boundary
point
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
Representation of boundaries
Representation of boundaries
• To make the code independent of the starting point:
the code is a circular sequence; the starting point is defined as the
one which yields a sequence of numbers that together represent
the smallest possible integer
E.g., 10103322  01033221
• To normalize wrt rotation (in 90 deg. or 45 deg. steps):
first differences (no. of direction changes) can be used
E.g., 10103322  3133030 (counting ccw)
and pre-pending the last transition (circular sequence: 2  1 = 3)
 33133030
(shape number, see later)
01/12/2020
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
Representation of a shape
Representation of a shape
Skeletons represent (non-univocally) a shape by reducing it to a graph
Medial axis transform (Blum 1967):
points that have more than one closest boundary points.
Also built using a prairie fire process
• object is a field of dry grass
• fire is simultaneously lit along the boundary
• fire propagates at uniform velocity
• skeleton is the set of quench points, where two independent fire-fronts
meet
Highly sensitive
to small details
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
Representation of a shape
Representation of a shape
Skeletons represent (non-univocally) a shape by reducing it to a graph
Digital approaches can simulate the grassfire propagation using
• iterative constrained erosion process
• centers of maximal balls in distance-transform domain (together with
their radii, they permit exact reconstruction of the object)
• centers of the enclosed balls that touch the object boundary at two or
more disjoint locations.
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
Boundary descriptors
Boundary descriptors
Simple descriptors:
• length
e.g., for 8-connected chain code:
horiz. components + vert. components + 21/2 diag. components
• order
no. ef elements in the code (same as above without 21/2 factor)
• diameter
length of the major axis: max(D(pi,pj)) where D is a distance and
pi , pj are points on the boundary. The minor axis is orthogonal to
the major axis, and has length [no matter its position] that permits
to determine the
• basic rectangle that minimally encloses the boundary
• eccentricity of the basic rectangle (major/minor axes ratio)
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
Boundary descriptors
Boundary descriptors
• shape number: first-difference code of smallest magnitude
(treating the chain code as a circular sequence)
All the shapes of
order 4, 6, 8
The dot is the
starting point
01/12/2020
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
Boundary descriptors
Boundary descriptors
Steps in the
generation of a shape
number
It is advisable to
normalize the grid
orientation by aligning
the chain code grid to
the basic rectangle
(note: poor drawing of
the basic rectangle in
this fig., or may indicate
small set of available
discrete orientations)
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
Boundary descriptors
Boundary descriptors
• 1-D Fourier descriptors
the sequence of boundary points is treated as a sequence of points in
the complex plane
- It becomes a complex 1-D descriptor
- Can be DFT-transformed
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
Boundary descriptors
Boundary descriptors
Different approximated descriptions are obtained by dropping some
DFT coefficients
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
Boundary descriptors
Boundary descriptors
01/12/2020
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
Boundary descriptors
Boundary descriptors
Fourier descriptors are not insensitive to translation etc.,
but their effects on the transform coefficients are known:
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
Boundary descriptors
Boundary descriptors
• Statistical moments
A portion of a boundary can be described as a 1-D function
(stopping when the distance from the origin stops growing)
Then, statistical moments (mean, variance, skewness, kurtosis, …)
can be used to describe it
• Treat g(r) as a discrete r.v. v in the range [0, A-1] (quantized
levels on the g(r) axis above), having a pdf p(vi)
• Its n-th central moment is
mn(v)=Si (vi-m)n p(vi)
where m = Si vi p(vi)
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
Regional descriptors
Regional descriptors
Some simple descriptors
• area
• compactness = perimeter2/area
(dimensionless  insensitive to
scale)
- In this figure:
(white area) / (total light area)
gives an idea of relative electrical
energy consumption
(should be normalized by land/sea
fraction in image, or by population
density)
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
Regional descriptors
Regional descriptors
Topology (maths) is the study of the region properties which are
unaffected by rubber-sheet deformations (non-Euclidean geometry)
[like in many subway maps]
[http://www.rrb.wayne.edu/topology.html]
• number of holes H
• number of connected components C
• Euler number, E = C - H
01/12/2020
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
Regional descriptors
Regional descriptors
Textures can be analyzed by statistical descriptors in terms of
smoothness, coarseness, regularity …
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
Regional descriptors:
some statistical descriptors
Regional descriptors:
some statistical descriptors
- Statistical (central) moments mn(z) = Si (zi-m)np(zi)
of the gray-level histogram p(zi)
- Activity index R R = 1 - 1/(1+s 2)
(R=0 in flat areas,  1 in very active ones)
- Uniformity U U = Si p2(zi)
(max. if gray levels are equally distributed)
- Entropy e e = - Si p(zi) log2 p(zi)
(is 0 for a constant image)
[R, U, and e provide approx. the same information]
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
Regional descriptors
Regional descriptors
Moments of the image as a 2-D function
Moment: mpq= SxSy xp yq f (x,y)
Central moment: mpq= SxSy (x-x’)p (y-y’)q f(x,y)
with x’= m10 / m00 and y’= m01 / m00
If we define the normalized central moments
hpq = mpq / m00
g with g = (p+q)/2 + 1
seven invariant moments can be defined, e.g.
f1 = h20h02
f2 = (h20-h02)2 + 4h11
2
…
which are invariant to translation, rotation, scaling, and mirroring
(but for a sign change)
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
Regional descriptors
Regional descriptors
01/12/2020
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
Regional descriptors
Regional descriptors
Fourier spectrum features:
- amplitude of peaks gives principal directions of the patterns
- location of maximum peak(s) gives the fundamental period(s)
- periodic components can be removed via filtering; the remaining
non-periodic image can be analyzed using statistical techniques
The spectrum can be also studied in polar coordinates: S(r,q)
For each pair r,q we can have two descriptors:
S(r) = Sq Sq(r) S(q ) = Sr Sr(q )
see also:
z11_Shape-based image retrieval using generic Fourier descriptor
Matlab Central 2016:
FD = gfd(bw,m,n) - Implementation of the Generic Fourier Descriptors
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
Regional descriptors
Regional descriptors
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
Next step: use features for segmentation / classification
Next step: use features for segmentation / classification
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
Next step: use features for segmentation / classification
Next step: use features for segmentation / classification
01/12/2020
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
…or use Deep Learning for segmentation / classification
…or use Deep Learning for segmentation / classification
Gianni Ramponi
http://www.units.it/ramponi Digital Image Processing
…or use Deep Learning for segmentation / classification
…or use Deep Learning for segmentation / classification
 Dip11a, b
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5
Ip unit 5

Ip unit 5

  • 1.
    Image Processing (KCS-062): Unit-5:Image compression, Representation, Pattern classes and Matching Dr. Radhey Shyam Professor Department of Computer Science and Engineering BIET Lucknow (Affiliated to Dr. A.P.J. Abdul Kalam Technical University Unit-5 have been compiled/prepared by Dr. Radhey Shyam, with grateful acknowledgment who made their course contents freely available. Feel free to use this study material for your own academic purposes. For any query, the communication can be made through my mail shyam0058@gmail.com. Course Outcome of Unit-5, the students will be able to explain the basic concepts of Image compression,Representation, and Pattern classes and Matching. Date: July 17, 2021
  • 16.
    01/12/2020 Gianni Ramponi http://www.units.it/ramponi DigitalImage Processing Representation & Description Representation & Description The results of segmentation is a set of regions. Regions are then represented (often univocally) and described (often non-univocally) Two main ways of representing a region: - external characteristics (its boundary): focus on shape and size - internal characteristics (its internal pixels): focus on color, textures… The next step: description E.g.: a region may be represented by its boundary, and its boundary described by some features such as length, regularity… - Features should be insensitive to translation, rotation, and scaling. - Both boundary and regional descriptors are often used together. Copyright notice: Most images in these slides are © Gonzalez and Woods, Digital Image Processing, Prentice-Hall Gianni Ramponi http://www.units.it/ramponi Digital Image Processing Representation of boundaries Representation of boundaries Hypotheses: binary images, objects do not touch the image border (padding if necessary), one object at a time To represent a boundary, it is useful to compact the raw data (list of boundary pixels coordinates)  Boundary following: start at the first boundary position in (e.g.) lexicographic ordering and build a chain code Chain codes: list of segments with defined length and direction • 4-directional chain codes • 8-directional chain codes - At each boundary pixel, circularly inspect the neighbourhood until a new boundary pixel is found - Stop when contour closes Gianni Ramponi http://www.units.it/ramponi Digital Image Processing Representation of boundaries Representation of boundaries Simplify It may be useful to downsample the border image before computing the chain code • to reduce the code size • to remove useless details along the boundary Can be conveniently done during the boundary following process: at each step the large-grid node is selected which is closest to a boundary point Gianni Ramponi http://www.units.it/ramponi Digital Image Processing Representation of boundaries Representation of boundaries • To make the code independent of the starting point: the code is a circular sequence; the starting point is defined as the one which yields a sequence of numbers that together represent the smallest possible integer E.g., 10103322  01033221 • To normalize wrt rotation (in 90 deg. or 45 deg. steps): first differences (no. of direction changes) can be used E.g., 10103322  3133030 (counting ccw) and pre-pending the last transition (circular sequence: 2  1 = 3)  33133030 (shape number, see later)
  • 17.
    01/12/2020 Gianni Ramponi http://www.units.it/ramponi DigitalImage Processing Representation of a shape Representation of a shape Skeletons represent (non-univocally) a shape by reducing it to a graph Medial axis transform (Blum 1967): points that have more than one closest boundary points. Also built using a prairie fire process • object is a field of dry grass • fire is simultaneously lit along the boundary • fire propagates at uniform velocity • skeleton is the set of quench points, where two independent fire-fronts meet Highly sensitive to small details Gianni Ramponi http://www.units.it/ramponi Digital Image Processing Representation of a shape Representation of a shape Skeletons represent (non-univocally) a shape by reducing it to a graph Digital approaches can simulate the grassfire propagation using • iterative constrained erosion process • centers of maximal balls in distance-transform domain (together with their radii, they permit exact reconstruction of the object) • centers of the enclosed balls that touch the object boundary at two or more disjoint locations. Gianni Ramponi http://www.units.it/ramponi Digital Image Processing Boundary descriptors Boundary descriptors Simple descriptors: • length e.g., for 8-connected chain code: horiz. components + vert. components + 21/2 diag. components • order no. ef elements in the code (same as above without 21/2 factor) • diameter length of the major axis: max(D(pi,pj)) where D is a distance and pi , pj are points on the boundary. The minor axis is orthogonal to the major axis, and has length [no matter its position] that permits to determine the • basic rectangle that minimally encloses the boundary • eccentricity of the basic rectangle (major/minor axes ratio) Gianni Ramponi http://www.units.it/ramponi Digital Image Processing Boundary descriptors Boundary descriptors • shape number: first-difference code of smallest magnitude (treating the chain code as a circular sequence) All the shapes of order 4, 6, 8 The dot is the starting point
  • 18.
    01/12/2020 Gianni Ramponi http://www.units.it/ramponi DigitalImage Processing Boundary descriptors Boundary descriptors Steps in the generation of a shape number It is advisable to normalize the grid orientation by aligning the chain code grid to the basic rectangle (note: poor drawing of the basic rectangle in this fig., or may indicate small set of available discrete orientations) Gianni Ramponi http://www.units.it/ramponi Digital Image Processing Boundary descriptors Boundary descriptors • 1-D Fourier descriptors the sequence of boundary points is treated as a sequence of points in the complex plane - It becomes a complex 1-D descriptor - Can be DFT-transformed Gianni Ramponi http://www.units.it/ramponi Digital Image Processing Boundary descriptors Boundary descriptors Different approximated descriptions are obtained by dropping some DFT coefficients Gianni Ramponi http://www.units.it/ramponi Digital Image Processing Boundary descriptors Boundary descriptors
  • 19.
    01/12/2020 Gianni Ramponi http://www.units.it/ramponi DigitalImage Processing Boundary descriptors Boundary descriptors Fourier descriptors are not insensitive to translation etc., but their effects on the transform coefficients are known: Gianni Ramponi http://www.units.it/ramponi Digital Image Processing Boundary descriptors Boundary descriptors • Statistical moments A portion of a boundary can be described as a 1-D function (stopping when the distance from the origin stops growing) Then, statistical moments (mean, variance, skewness, kurtosis, …) can be used to describe it • Treat g(r) as a discrete r.v. v in the range [0, A-1] (quantized levels on the g(r) axis above), having a pdf p(vi) • Its n-th central moment is mn(v)=Si (vi-m)n p(vi) where m = Si vi p(vi) Gianni Ramponi http://www.units.it/ramponi Digital Image Processing Regional descriptors Regional descriptors Some simple descriptors • area • compactness = perimeter2/area (dimensionless  insensitive to scale) - In this figure: (white area) / (total light area) gives an idea of relative electrical energy consumption (should be normalized by land/sea fraction in image, or by population density) Gianni Ramponi http://www.units.it/ramponi Digital Image Processing Regional descriptors Regional descriptors Topology (maths) is the study of the region properties which are unaffected by rubber-sheet deformations (non-Euclidean geometry) [like in many subway maps] [http://www.rrb.wayne.edu/topology.html] • number of holes H • number of connected components C • Euler number, E = C - H
  • 20.
    01/12/2020 Gianni Ramponi http://www.units.it/ramponi DigitalImage Processing Regional descriptors Regional descriptors Textures can be analyzed by statistical descriptors in terms of smoothness, coarseness, regularity … Gianni Ramponi http://www.units.it/ramponi Digital Image Processing Regional descriptors: some statistical descriptors Regional descriptors: some statistical descriptors - Statistical (central) moments mn(z) = Si (zi-m)np(zi) of the gray-level histogram p(zi) - Activity index R R = 1 - 1/(1+s 2) (R=0 in flat areas,  1 in very active ones) - Uniformity U U = Si p2(zi) (max. if gray levels are equally distributed) - Entropy e e = - Si p(zi) log2 p(zi) (is 0 for a constant image) [R, U, and e provide approx. the same information] Gianni Ramponi http://www.units.it/ramponi Digital Image Processing Regional descriptors Regional descriptors Moments of the image as a 2-D function Moment: mpq= SxSy xp yq f (x,y) Central moment: mpq= SxSy (x-x’)p (y-y’)q f(x,y) with x’= m10 / m00 and y’= m01 / m00 If we define the normalized central moments hpq = mpq / m00 g with g = (p+q)/2 + 1 seven invariant moments can be defined, e.g. f1 = h20h02 f2 = (h20-h02)2 + 4h11 2 … which are invariant to translation, rotation, scaling, and mirroring (but for a sign change) Gianni Ramponi http://www.units.it/ramponi Digital Image Processing Regional descriptors Regional descriptors
  • 21.
    01/12/2020 Gianni Ramponi http://www.units.it/ramponi DigitalImage Processing Regional descriptors Regional descriptors Fourier spectrum features: - amplitude of peaks gives principal directions of the patterns - location of maximum peak(s) gives the fundamental period(s) - periodic components can be removed via filtering; the remaining non-periodic image can be analyzed using statistical techniques The spectrum can be also studied in polar coordinates: S(r,q) For each pair r,q we can have two descriptors: S(r) = Sq Sq(r) S(q ) = Sr Sr(q ) see also: z11_Shape-based image retrieval using generic Fourier descriptor Matlab Central 2016: FD = gfd(bw,m,n) - Implementation of the Generic Fourier Descriptors Gianni Ramponi http://www.units.it/ramponi Digital Image Processing Regional descriptors Regional descriptors Gianni Ramponi http://www.units.it/ramponi Digital Image Processing Next step: use features for segmentation / classification Next step: use features for segmentation / classification Gianni Ramponi http://www.units.it/ramponi Digital Image Processing Next step: use features for segmentation / classification Next step: use features for segmentation / classification
  • 22.
    01/12/2020 Gianni Ramponi http://www.units.it/ramponi DigitalImage Processing …or use Deep Learning for segmentation / classification …or use Deep Learning for segmentation / classification Gianni Ramponi http://www.units.it/ramponi Digital Image Processing …or use Deep Learning for segmentation / classification …or use Deep Learning for segmentation / classification  Dip11a, b