Professional Documents
Culture Documents
UNIT-I
The Digitized Image and Its Properties
Image:
• An image is a two-dimensional function that represents a measure of
some characteristic such as brightness or color of a viewed scene.
• Image processing often deals with static images, in which time is constant.
A monochromatic static image is represented by a continuous image
function f(x, y) whose arguments are co-ordinates in the plane.
• Computerized image processing uses digital image functions which are
usually represented by matrices, so co-ordinates are natural numbers. The
domain of the image function is a region R in the plane
where xm, yn represent the maximal
co-ordinates.
Image sampling, quantization
• Image digitization: An image to be processed by computer must be
represented using an appropriate discrete data structure, for example, a
matrix.
• An image captured by a sensor is expressed as a continuous function f(x, y)
of two co-ordinates in the plane.
• Image digitization means that the function f(x, y) is sampled into a matrix
with M rows and N columns.
• Image quantization assigns to each continuous sample an integer value—the
continuous range of the image function f(x, y) is split into K intervals
• Sampling: related to coordinates values.
• Quantization : related to intensity values.
256
512
1024
• Quantization A value of the sampled image fs(j ∆x, k ∆y) is expressed as a
digital value in image processing. The transition between continuous
values of the image function (brightness) and its digital equivalent is
called quantization.
• The number of quantization levels should be high enough to permit
human perception of fine shading details in the image. Most digital image
processing devices use quantization into k equal intervals. If b bits are
used to express the values of the pixel brightness then the number of
brightness levels is k = 2𝑏 .
• The main problem in images quantized with insufficient brightness levels
is the occurrence of false contours which effect arises when the number of
brightness levels is lower than that which humans can easily distinguish.
Brightness levels.
(a) 64.
(b) 16.
(c) 4.
(d) 2.
• The main problem in images quantized with insufficient brightness levels is
the occurrence of false contours which effect arises when the number of
brightness levels is lower than that which humans can easily distinguish.
color images
• Human color perception adds a subjective layer on top of underlying
objective physical properties—the wavelength of electromagnetic radiation.
Consequently, color may be considered a psycho-physical phenomenon.
• Color has long been used in painting, photography and films to display the
surrounding world to humans in a similar way to that in which it is
perceived in reality.
• There is considerable literature on the variants in the naming of colors
across languages.
Physics of color
Manhattan distance:
Regions: a region is a set of pixels in which there is a path between any pair of
its pixels, all of whose pixels also belong to the set.
we can define a path from pixel P to pixel Q as a sequence of points A1, A2, . .
., An, where A1 = P, An = Q, and Ai+1 is a neighbor of Ai , i = 1, . . . , n − 1;
• If there is a path between two pixels in the set of pixels in the image,
these pixels are called contiguous.
• Let R be the union of all regions Ri ; Rc be the set complement of R with
respect to the image. The subset of Rc which is contiguous with the image
bounds is called the background, and the remainder of the complement Rc is
called holes.
• A region is called simple contiguous if it has no holes.
• A region with holes is called multiple contiguous.
Outer edge
• A region is described as convex if any two points within it are connected
by a straight line segment, and the whole line lies within the region.
• The property of convexity decomposes all regions into two equivalence
classes: convex and non-convex.
• A convex hull of a region is the smallest convex region containing the input
(possibly non-convex) region.
The set inside the convex hull which does not belong to an object is called the
deficit of convexity. This can be split into two subsets: lakes (dark gray) are
fully surrounded by the object; and bays (light gray) are contiguous with the
border of the convex hull of the object.
• Topological properties are not based on the distance concept. Instead, they
are invariant to homeomorphic transforms which can be illustrated for
images as rubber sheet transforms.
• ‘topological properties’ of the region to describe its qualitative properties
invariant to small changes.
Histograms
• The brightness histogram hf (z) of an image provides the frequency of the
brightness value z in the image—the histogram of an image with L gray-
levels is represented by a one-dimensional array with L elements.
• The histogram provides a natural bridge between images and a
probabilistic description. We might want to find a first-order probability
function p1(z; x, y) to indicate the probability that pixel (x, y) has
brightness z.
• The histogram of a digital image typically has many local minimum and
maximum, which may complicate its further processing. This problem can
be avoided by local smoothing of the histogram;
• The entropy of the random variable X is the sum, over all possible outcomes k of
X, of the product of the probability of outcome xk with the logarithm of the inverse
of the probability of xk.
Visual perception of the image
• digital image processing should take into account the principles of
human image perception.
• If an image is to be analyzed by a human the information should be
expressed using variables which are easy to perceive; these are
physical parameters such as contrast, border, shape, texture, color,
etc.
• Contrast
• Contrast is the local change in brightness and is defined as the ratio
between average brightness of an object and the background.
• Acuity
• Acuity is the ability to detect details in an image. The human eye is
less sensitive to slow and fast changes in brightness in the image
plane but is more sensitive to intermediate changes.
• Acuity also decreases with increasing distance from the optical axis.
• Resolution in an image is firmly bounded by the resolution ability of
the human eye;
• there is no sense in representing visual information with higher
resolution
• Human vision has the best resolution for objects which are at a
distance of about 250mm from an eye under illumination of about
500 lux; this illumination is provided by a 60W bulb from a distance of
400 mm.
Some visual illusions
Contains rows of black and white squares which are all parallel. However, the vertical zigzag
squares disrupt our horizontal perception.
Perceptual grouping
• Perceptual grouping is a principle used in computer vision to
aggregate.
• elements provided by low-level operations such as edges, which are
small blobs to bigger chunks having some meaning.
• The human ability to group items according to various properties is
illustrated in Perceived properties help people to connect elements
together based on strongly perceived properties as parallelism,
symmetry, continuity and closure taken in a loose sense as illustrated.
Image quality
• image quality can refer to the level of accuracy in which different
imaging systems capture, process, store, compress, transmit and
display the signals that form an image.
• Another definition refers to image quality as "the weighted
combination of all of the visually significant attributes of an image".
• Methods for assessing image quality can be divided into two
categories: subjective and objective. Subjective methods are often
used in television technology. where the ultimate criterion is the
perception of a selected group of professional and lay viewers.
Noise in images
• Real images are often degraded by some random errors—this
degradation is usually called noise. Noise can occur during image
capture, transmission, or processing, and may be dependent on, or
independent of, the image content.
• Noise is usually described by its probabilistic characteristics. Idealized
noise, called white noise is often used. A special case of white noise
is Gaussian noise. A random variable with a Gaussian
• (normal) distribution has its probability density function given by the
Gaussian curve.
• When an image is transmitted through some channel, noise which is usually
independent of the image signal occurs. This signal-independent degradation is
called additive noise and can be described by the model
• f(x, y) = g(x, y) + (x, y) .
• where the noise and the input image g are independent variables.
• A(x,y) = H(x,y) + B(x,y) Where, A(x,y)= function of noisy image, H(x,y)= function of
image noise , B(x,y)= function of original image
• This model describes multiplicative noise. An example of multiplicative noise is
television
• raster degradation, which depends on TV lines; in the area of a line this noise is
• maximal, and between two lines it is minimal.
• Quantization noise occurs when insufficient quantization levels are used, for example,
• 50 levels for a monochromatic image. In this case false contours appear. Quantization
• noise can be eliminated simply.
• Impulse noise means that an image is corrupted with individual noisy pixels whose
• brightness differs significantly from that of the neighborhood. The term salt-and pepper
• noise is used to describe saturated impulsive noise—an image corrupted with
• white and/or black pixels is an example. Salt-and-pepper noise can corrupt binary
images.
Unit-III
Image Pre processing
.The aim of pre-processing is an improvement of the
image data. And enhances some image features
important for further processing.
• three categories of image pre-processing methods
according to the size of the pixel neighborhood that is
used for the calculation of a new pixel brightness:
1).pixel brightness transformations,
2).geometric transformations,
3).pre-processing methods that use a local
neighborhood of the processed pixel
1.Pixel brightness transformations
• Image pre-processing methods use the considerable
redundancy( re arrangement of brightness) in images.
• Pixel brightness transformations.
• Brightness transformations modify pixel brightness --
the transformation depends on the properties of a
pixel itself. There are two type of methods.
1).Brightness corrections
2).Gray scale transformations.
• Brightness correction
– considers original brightness
– pixel position in the image.
• Gray scale transformations
– change brightness without regard to position in
the image
Brightness correction
where qi = T(pi).
• The sum in the above equation can be interpreted as discrete distribution
function
2.Geometric transformations
• Geometric transformations are common in computer
graphics, and are often used in image analysis.
• Geometric transforms permit the elimination of
geometric distortion that occurs when an image is
captured.
• example, some person is clicking pictures of the same
place at different times of the day and year to visualize
the changes. Every time he clicks the picture, it’s not
necessary that he clicks the picture at the exact same
angle. So for better visualization, he can align all the
images at the same angle using geometric transformation
Example
• A geometric transform consists of two basic steps. First is
the pixel co ordinate transformation, which maps the
co-ordinates of the input image pixel to the point in the
output image.
• Output point co-ordinates will be continuous values (real
numbers), as position are unlikely to match the digital
grid after the transform.
• The second step finds the point in the digital raster which
best matches the transformed point and determines its
brightness value.
Pixel co-ordinate transformations
• shows the general case of finding the co-ordinates of a point
in the output image after a geometric transform.
• Methods of Interpolation
There are several common methods of interpolation:
• Nearest neighbor – simplest and fastest
• Triangular – Uses three points from a bounding
triangle. Useful even when the known points are not
on a regular grid.
• Bilinear – Uses points from a bound in rectangle.
Useful when the known points are on a regular grid.
Local pre-processing
• Local pre-processing methods are divided into two groups
according to the goal of the Processing.
• Smoothing aims to suppress noise or other small
fluctuations in the image.
• smoothing also blurs all sharp edges that bear important
information about the image.
• Gradient operators are based on local derivatives of the
image function.
• Derivatives are bigger at locations of the image where the
image function undergoes rapid changes, and the aim of
gradient operators is to indicate such locations in the image
• Another classification of local pre-processing
methods is according to the transformation properties;
• linear and non-linear transformations can be
distinguished.
Linear operations calculate the resulting value in the
output image pixel f(i, j) as a linear combination of
brightnesses in a local neighborhood O of the pixel
g(i, j) in the input image.
• The contribution of the pixels in the neighborhood O is
weighted by coefficients h:
• Image smoothing
• • Image smoothing is the set of local pre-processing methods whose
predominant use is the suppression
• image noise — it uses redundancy in the image data.
• • Calculation of the new value is based on averaging of brightness
values in some neighborhood O.
• • Smoothing poses the problem of blurring sharp edges in the image,
and so we shall study smoothing methods which are edge preserving.
• • They are based on the general idea that the average is computed only
from those points in the neighborhood which have similar properties to
the processed point.
• • Local image smoothing can effectively eliminate impulsive noise or
degradations appearing as thin stripes, but does not work if
degradations are large blobs or thick stripes.
• Smoothing using a rotating mask
• 1. Consider each image pixel (i, j). Calculate dispersion in the mask for all possible mask rotations
• about pixel (i, j).
• 2. Choose the mask with minimum dispersion.
• 3. Assign to the pixel (i, j) in the output image the average brightness in the chosen mask.
• • Other mask shapes can also be used.
• • The following figure shows another set of eight masks covering a 5×5 neighborhood of the current
• pixel Again the ninth mask is the 3 × 3 neighborhood of the current pixel itself.
• • Another possibility is to rotate a small 2 × 1 mask to cover the 3 × 3 neighborhood of the current
• pixel.
• • This algorithm can be used iteratively. (What about other algorithms?)
• • The iterative process converges quite quickly to stable state (that is, the image does not change
• any more).
• Median filtering
• • In a set of ordered values, the median is the central value.
• • Median filtering assigns the output pixel brightness value to be the median value of the
brightness values in a neighborhood of the pixel.
• • Median filtering reduces blurring of edges.
• • The idea is to replace the current point in the image by the median of the brightness in its
neighborhood.
• • The median of the brightness in the neighborhood is not affected by individual noise spikes
and so
• median smoothing eliminates impulsive noise quite well.
• • As median filtering does not blur edges much, it can be applied iteratively
• Edge detectors
• Edge: what is it?
• • Edge detectors are a collection of very important local image pre-processing methods used
to locate
• (sharp) changes in the intensity function.
• • Edges are pixels where the brightness function changes abruptly.
• • Neurological and psychophysical research suggests that locations in the image in which the
function
• value changes abruptly are important for image perception.
• • Edges are to a certain degree invariant to changes of illumination and viewpoint.
• • If only edge elements with strong magnitude (edgels) are considered, such information often
suffices for image understanding.
• • The positive effect of such a process is that it leads to significant reduction of image data.
• • Nevertheless such a data reduction does not undermine understanding the content of the
image(interpretation) in many cases.
• • Edge detection provides appropriate generalization of the image data.
Zero-crossings of the second
derivative
• An edge detection technique based on the zero-
crossings of the second derivative
• explores the fact that a step edge corresponds to
an abrupt change in the image function.
• The first derivative of the image function should
have an extremum at the position corresponding
to the edge in the image, and so the second
derivative should be zero at the same position;
however, it is much easier and more precise to
find a zero-crossing position than an extremum.
Scale in image processing
• Many image processing techniques work locally, theoretically at the level
of individual
• pixels—edge detection methods are an example. The essential problem in
such computation is scale. Edges correspond to the gradient of the
image function, which is computed as a difference between pixels in
some neighborhood. There is seldom a sound reason for choosing a
particular size of neighborhood, since the ‘right’ size depends on the size of
the objects under investigation. To know what the objects are assumes that
it is clear
• how to interpret an image, and this is not in general known at the pre-
processing stage. The solution to the problem formulated above is a special
case of a general paradigm called the system approach. This
methodology is common in cybernetics or general system theory to study
complex phenomena
Canny edge detection
UNIT - 4
• divide an image into parts that have a strong correlation with objects or
areas of the real world contained in the image.
• We may aim for complete segmentation, which results in a set of disjoint
regions corresponding uniquely with objects in the input image,
• partial segmentation, in which regions do not correspond directly with
image objects.
• A complete segmentation of an image R is a finite set of regions R1, . . . ,
RS,
• Segmentation methods can be divided into three groups
• First is global knowledge about an image or its part; this is usually
represented by a histogram of image features.
• Edge-based segmentations form the second group,
• region-based segmentations the third—many different characteristics
may be used in edge detection or region growing,
• Approaches in Image Segmentation
1.Similarity approach: This approach is based on detecting similarity
between image pixels to form a segment, based on a threshold. ML
algorithms like clustering are based on this type of approach to segment an
image.
2.Discontinuity approach: This approach relies on the discontinuity of
pixel intensity values of the image. Line, Point, and Edge Detection
techniques use this type of approach for obtaining intermediate
segmentation results which can be later processed to obtain the final
segmented image.
Image Segmentation Techniques
3.Region-Based Segmentation
UNIT-5
Edge detection is used for image segmentation and data extraction in
areas such as image processing, computer vision, and machine
vision.
Edge image thresholding
• Almost no zero-value pixels are present in an edge image—small edge values
correspond to non-significant gray-level changes resulting from quantization
noise, small lighting irregularities, etc.
• Simple thresholding of an edge image can be applied to remove these small
values.
• Non-maximal suppression of directional edge data
1. Quantize edge directions eight ways according to 8-connectivity.
2. For each pixel with non-zero edge magnitude, inspect the two adjacent
pixels indicated by the direction of its edge.
3. If the edge magnitude of either of these two exceeds that of the pixel under
inspection, mark it for deletion.
4. When all pixels have been inspected, re-scan the image and erase to zero
all edge data marked for deletion.
Edge relaxation
• Relaxation is a well-known approach to improving estimates of some
property by paying regard to estimated values of that property in an
immediate neighborhood—thus, some understanding of local, probably with
an associated metric, is necessary
Border tracing
• If a region border is not known but regions have been defined in the image,
borders can be detected uniquely.
• The first goal is to determine inner region borders. As defined earlier, an
inner region border is a subset of the region—conversely, the outer border is
not a subset of the region.
Outer boundary tracing
1. Trace the inner region boundary in 4-connectivity until done.
2. The outer boundary consists of all non-region pixels that were tested during
the search process; if some pixels were tested more than once, they are listed
more than once in the outer boundary list.
a. Inner
b. Outer
c. combined
• Morphology: a branch of biology that deals with the form and structure
of animals and plants
4/29/2023 2
Preliminaries (1)
• Reflection
• Translation
The translation of a set B by point z ( z1 , z2 ), denoted ( B ) Z ,
is defined as
( B) Z {c | c b z , for b B}
4/29/2023 3
Example: Reflection and Translation
4/29/2023 4
Preliminaries (2)
4/29/2023 5
Examples: Structuring Elements (1)
origin
4/29/2023 6
Examples: Structuring Elements (2)
Accommodate the
entire structuring
elements when its Origin of B visits
origin is on the every element of A
border of the
original set A
At each location of
the origin of B, if B
is completely
contained in A,
then the location is
a member of the
new set, otherwise
it is not a member
of the new set.
4/29/2023 7
Erosion
A B z | ( B) Z A
c
4/29/2023 8
Example
of Erosion
(1)
4/29/2023 9
Example
of Erosion
(2)
4/29/2023 10
Dilation
2
With A and B as sets in Z , the dilation of A by B,
denoted A B, is defined as
A B= z | B A
z
The set of all displacements z, the translated B and A
overlap by at least one element.
A B z | B A A
z
4/29/2023 11
Examples of Dilation (1)
4/29/2023 12
Examples of Dilation (2)
4/29/2023 13
Duality
• Erosion and dilation are duals of each other with respect to set complementation
and reflection
A B A B
c c
and
A B Ac B
c
4/29/2023 14
Duality
• Erosion and dilation are duals of each other with respect to set complementation
and reflection
A B z | B Z A
c c
z | B Z A
c c
z | B Z Ac
Ac B
4/29/2023 15
Duality
• Erosion and dilation are duals of each other with respect to set complementation
and reflection
A
c
A B z| B
c
z | B A
c
Z
Ac B
4/29/2023 16
Opening and Closing
• Opening generally smoothes the contour of an object, breaks narrow isthmuses, and
eliminates thin protrusions
• Closing tends to smooth sections of contours but it generates fuses narrow breaks and
long thin gulfs, eliminates small holes, and fills gaps in the contour
4/29/2023 17
Opening and Closing
4/29/2023 18
Opening
4/29/2023 19
Example: Opening
4/29/2023 20
Example: Closing
4/29/2023 21
4/29/2023 22
Duality of Opening and Closing
• Opening and closing are duals of each other with respect to set complementation
and reflection
A B (A
c c
B)
A B ( A B)
c c
4/29/2023 23
The Properties of Opening and Closing
► Properties of Opening
(a) A B is a subset (subimage) of A
(b) if C is a subset of D, then C B is a subset of D B
(c) ( A B ) B A B
► Properties of Closing
(a) A is subset (subimage) of A B
(b) If C is a subset of D, then C B is a subset of D B
(c) ( A B ) B A B
4/29/2023 24
4/29/2023 25
The Hit-or-Miss
Transformation
B B1 , B2
B1 : object
B2 : background
A B A B1 ( Ac B2 )
4/29/2023 26
Some Basic Morphological Algorithms (1)
• Boundary Extraction
The boundary of a set A, can be obtained by first eroding A by B and then
performing the set difference between A and its erosion.
( A) A A B
4/29/2023 27
Example 1
4/29/2023 28
Example 2
4/29/2023 29
Some Basic Morphological Algorithms (2)
• Hole Filling
A hole may be defined as a background region surrounded by a connected
border of foreground pixels.
Let A denote a set whose elements are 8-connected boundaries, each boundary
enclosing a background region (i.e., a hole). Given a point in each hole, the
objective is to fill all the holes with 1s.
4/29/2023 30
Some Basic Morphological Algorithms (2)
• Hole Filling
1. Forming an array X0 of 0s (the same size as the array containing A), except the
locations in X0 corresponding to the given point in each hole, which we set to 1.
2. Xk = (Xk-1 + B) Ac k=1,2,3,…
4/29/2023 31
Example
4/29/2023 32
4/29/2023 33
Some Basic Morphological Algorithms (3)
Let A be a set containing one or more connected components, and form an array
X0 (of the same size as the array containing A) whose elements are 0s, except at
each location known to correspond to a point in each connected component in A,
which is set to 1.
4/29/2023 34
Some Basic Morphological Algorithms (3)
X k ( X k 1 B ) A
B : structuring element
until X k X k -1
4/29/2023 35
4/29/2023 36
4/29/2023 37
Some Basic Morphological Algorithms (4)
• Convex Hull
A set A is said to be convex if the straight line segment joining any two points in A
lies entirely within A.
The convex hull H or of an arbitrary set S is the smallest convex set containing S.
4/29/2023 38
Some Basic Morphological Algorithms (4)
• Convex Hull i
Let B , i 1, 2, 3, 4, represent the four structuring elements.
The procedure consists of implementing the equation:
X ki ( X k 1 * B i ) A
i 1, 2,3, 4 and k 1, 2,3,...
with X 0i A.
When the procedure converges, or X ki X ki 1 , let D i X ki ,
the convex hull of A is
4
C ( A) D i
i 1
4/29/2023 39
4/29/2023 40
4/29/2023 41
Some Basic Morphological Algorithms (5)
• Thinning
The thinning of a set A by a structuring element B, defined
A B A ( A * B)
A ( A * B) c
4/29/2023 42
Some Basic Morphological Algorithms (5)
B B1
, B 2
, B 3
,..., B n
where B i is a rotated version of B i -1
4/29/2023 43
4/29/2023 44
Some Basic Morphological Algorithms (6)
• Thickening:
4/29/2023 45
Some Basic Morphological Algorithms (6)
4/29/2023 46
Some Basic Morphological Algorithms (7)
• Skeletons
A skeleton, S ( A) of a set A has the following properties
a. if z is a point of S ( A) and ( D) z is the largest disk
centered at z and contained in A, one cannot find a
larger disk containing ( D) z and included in A.
The disk ( D) z is called a maximum disk.
b. The disk ( D) z touches the boundary of A at two or
more different places.
4/29/2023 47
Some Basic Morphological Algorithms (7)
4/29/2023 48
Some Basic Morphological Algorithms (7)
The skeleton of A can be expressed in terms of
erosion and openings.
K
S ( A) S k ( A)
k 0
4/29/2023 49
4/29/2023 50
4/29/2023 51
Some Basic Morphological Algorithms (7)
4/29/2023 52
4/29/2023 53
Some Basic Morphological Algorithms (8)
• Pruning
a. Thinning and skeletonizing tend to leave parasitic components
b. Pruning methods are essential complement to thinning and
skeletonizing procedures
4/29/2023 54
Pruning:
Example
X 1 A {B}
4/29/2023 55
Pruning:
Example
X 2 X1 * Bk
8
k 1
4/29/2023 56
Pruning:
Example
X3 X2 H A
H : 3 3 structuring element
4/29/2023 57
Pruning:
Example
X 4 X1 X 3
4/29/2023 58
Pruning:
Example
4/29/2023 59
Watershed algorithm
• Watershed algorithm is based on extracting sure background and foreground
and then using markers will make watershed run and detect the exact
boundaries. This algorithm generally helps in detecting touching and
overlapping objects in image.
• To separate objects in images, we will fill out each valley with water of
different colors.
• Slowly, the water will rise up and to a point water from different valleys start
to merge. This is when we build barriers on top of the peak to avoid having
the peak underwater. Once the barriers are built out, the barriers constitutes
the boundary of the object.