0% found this document useful (0 votes)
4 views

Dip unit 5 ppt

The document outlines the course outcomes and topics covered in a Digital Image Processing course, including image segmentation, edge detection, and various coding algorithms for image compression. It details methods for evaluating image compression performance and discusses the principles of detecting discontinuities in images using gradient operators. Additionally, it introduces techniques like thresholding and the Hough transform for feature detection in images.

Uploaded by

vinaygupta.cse26
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)
4 views

Dip unit 5 ppt

The document outlines the course outcomes and topics covered in a Digital Image Processing course, including image segmentation, edge detection, and various coding algorithms for image compression. It details methods for evaluating image compression performance and discusses the principles of detecting discontinuities in images using gradient operators. Additionally, it introduces techniques like thresholding and the Hough transform for feature detection in images.

Uploaded by

vinaygupta.cse26
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/ 57

JAIPUR ENGINEERING COLLEGE AND RESEARCH CENTRE

Department of Computer Science & Engineering


Digital Image Processing(6CS3-01)
COURSE OUTCOMES
CO4: Evaluate various coding algorithms used in image processing and compression
Topics Covered:
Introduction of image segmentation
Detection of discontinuities
Point detection
Line detection
Edge Detection
Thresholding
Adaptive Thresholding
Thresholding based on boundary characteristics
Anju Rajput
VISION & MISSION OF DEPARTMENT
VISION: To become renowned Centre of excellence in computer science
and engineering and make competent engineers & professionals with high
ethical values prepared for lifelong learning.

MISSION:
• M1: To impart outcome based education for emerging technologies in the
field of computer science and engineering.
• M2: To provide opportunities for interaction between academia and
industry.
• M3: To provide platform for lifelong learning by accepting the change in
technologies
• M4: To develop aptitude of fulfilling social responsibilities
Course Outcomes
• Understand the fundamental aspects of image processing
• Apply the mathematical foundations of coloring and image
enhancement in spatial and frequency domains
• Compare and Implement filters for various types of noise.
• Evaluate various coding algorithms used in image processing and
compression
What are the performance metrics for evaluating
image compression
Compression Ratio (CR)
•Formula: CR = Original Size / Compressed Size
•Indicates how much the image has been compressed. Higher is better for
storage/bandwidth.
Bitrate (Bits Per Pixel - bpp)
•Number of bits used per pixel after compression.
•Lower bitrate with high quality is desirable
Entropy
•Measures the average amount of information per pixel.
•Lower entropy after compression suggests effective redundancy removal.

Redundancy
Image Segmentation
Image Segmentation
Image segmentation divides an image into regions that are connected and
have some similarity within the region and some difference between
adjacent regions.
Thegoal is usually to find individual objects inan image.
For the most part there are fundamentally two kinds of approaches to
segmentation: discontinuity andsimilarity.
 Discontinuity: Approach is to partition image basedon abrupt changesin intensities(edges).
 Similarity: Approach is to partition the image based on similar regions according to
predefined criteria. Suchasthresholding, region growing, region splitting & merging.
How to achieve segmentation?

Image is divided into separate regions that are homogeneous


with respect to a choosen property such as color, brightness,
texture, etc.
Segmentation algorithms generally are based on 2 basic
properties of gray level values: Discontinuity and Similarity

Segmentation methods:
1. Global approaches such as thresholding
2. Edge-based segmentation
3. Region-based segmentation
Detection of Discontinuities
 There are 3 basic types of discontinuities: points, lines and edges.
 The detection is based on convoluting the image with a spatial mask.
 A general 3x3 mask
w1,1 w1,0 w1,1 
w
 0,1 w0,0 w0,1 
w1,1 w1,0 w1,1 
 The response of the mask at any point (x,y) in the
1 1
image is R x, y    p(x  i, y  j) w(i, j)
i 1 j1

In digital images, discontinuities occur where there's an abrupt change in pixel intensity.
These can be:

1.Point Discontinuities – a single pixel differs significantly from neighbours.


2.Line Discontinuities – a line of pixels with intensity different from surroundings.
3.Edge Discontinuities – a sudden jump in intensity across a boundary (most common).
Detection of Discontinuities in Image Processing
We use derivative operators (discussed earlier) to detect them:
1. First-Order Derivatives (Gradients)
•Measure the rate of change in intensity.
•Large gradient = high intensity change = possible edge.
•Common operators:
•Sobel
•Prewitt
•Roberts

2. Second-Order Derivatives (Laplacian)


•Detect points where the rate of intensity change itself changes (zero-crossings).
•Sensitive to fine details.
•Often used in combination with smoothing (e.g., LoG – Laplacian of Gaussian).
Types of Discontinuities & Their Appearance:

Type Example Appearance


Point Noise spike Single isolated pixel
Line Scratch or thin edge Thin, straight contrast
Sharp transition between
Edge (step/jump) Object boundary
regions
What is the Sobel Operator
• The Sobel operator detects edges in an image by approximating the gradient
(rate of change) of intensity. It emphasizes regions where intensity changes
rapidly — which usually correspond to edges or boundaries of objects.
• The Sobel operator uses two 3×3 convolution masks to compute gradients in:
• Horizontal direction (Gx)
• Vertical direction (Gy)
• Then, it combines the two to get the gradient magnitude.
What is the Prewitt Operator?

The Prewitt operator is used to detect horizontal and vertical edges in an


image by approximating the gradient. It works similarly to the Sobel
operator, but the weight values in the kernel are constant (no emphasis on the
center row/column).
What is the Roberts Operator?
• The Roberts Cross operator is a first-order derivative operator that
computes the gradient of an image using 2×2 kernels. It is designed to detect
edges diagonally, rather than purely horizontal or vertical like Sobel or
Prewitt.
What is the Laplacian Operator?
• The Laplacian operator is a second-order derivative operator that
detects edges by calculating the rate of change of the gradient (i.e., how
quickly intensity changes are themselves changing).
• Unlike Sobel or Prewitt (which detect edges in specific directions),
Laplacian is direction-independent (isotropic) and highlights areas of
rapid intensity change in all directions.
Point Detection
 A point has been detected at the location p(i,j) on which the mask is centered if
|R |>T, where T is a nonnegative threshold, and R is obtained with the
following mask.

 1  1 1
 
  1 8 1
1  1 1

 The idea is that the gray level of an isolated point will be quite different from the
gray level of its neighbors.

Original Noise Added Filtered O/P Threshold Output

 If, at a certain point in the image, |Ri|>|Rj| for all j i , that point is said to be more likely
associated with a line in the direction of mask i.
Line Detection masks:

-1 -1 -1 2 -1 -1

2 2 2 -1 2 -1

-1 -1 -1 -1 -1 2
Horizontal + 45°

-1 2 -1 -1 -1 2

-1 2 -1 -1 2 -1

-1 2 -1 2 -1 -1
Vertical - 45°
Line Detection masks:
Edge detection
 It locates sharp changes in the intensity function.
 Edges are pixels where brightness changes abruptly.
 A change of the image function can be described by a gradient that points in the
direction of the largest growth of the image function.
 An edge is a property attached to an individual pixel and is calculated from the
image function behavior in a neighborhood of the pixel.
 Magnitude of the first derivative detects the presence of the edge.
 Sign of the second derivative determines whether the edge pixel lies on the dark
sign or light side.
Edge detection
Edge detection
Edge detection
Detection of Discontinuities
• Gradient Operators

First-order derivatives:

– The gradient of an image f(x,y) at location (x,y)is defined as the
vector:

G x   f
x

f      f 
G y  y 
– The magnitude of this vector: f  mag(f) G 2  G 2
x y 
1
2

 Gx 
– The direction of this vector:  (x, y)  tan  
1
G 
 y
– It points in the direction of the greatest rate of change of f at
location (x,y)
Detection of Discontinuities
• Gradient Operators
Detection of Discontinuities
• Gradient Operators

Roberts cross-gradient operators

Prewitt operators

Sobel operators
Detection of Discontinuities
• Gradient Operators
Detection of Discontinuities Gradient
Operators: Example
Detection of Discontinuities Gradient
Operators: Example
Detection of Discontinuities
Gradient Operators
Second Order Derivative
 The Laplacian of a 2D function f(x,y) is a 2nd-order derivative defined as

 2f  2f
 f (x', y' ) 
2

x 2
y 2
 The Laplacianhas the same properties in all directions and is therefore invariant to
rotation in the image.
 It can also be implemented in digital form in various ways.
 For a 3x3 region, the mask is given as

 It is seldom used in practice for edge detection for the


following reasons:
1. As a 2nd-order derivative, it is unacceptably sensitive to noise.
2. It produces double edges and is unable to detect edge direction.
 The Laplacian usually plays the secondary role of detector for establishing
whether a pixel is on the dark or light side of an edge.
Thresholding
 Suppose that an image, f(x,y), is composed of light objects on a dark
background, and the following figure is the histogram of the image.

image with dark background


and a light object

 Then, the objects can be extracted by comparing pixel values with a


threshold T.
Thresholding
 One way to extract the objects from the background is to select a
threshold T that separates object from background.
 Any point (x,y) for which f(x,y) > T is called an object point;
otherwise the point is called a background point.

1 if f (x,y)  T
g(x, y)  
0 f f (x, y)  T
 When T is a constant applicable over an entire image, then the
above process is called as Global thresholding.
Thresholding
 When the value of T changes over an image
 Then that process is referred as Variable thresholding.
 Sometimes it is also termed as local or regional thresholding.
 Where, the value of T at any point (x,y) in an image depends on
properties of a neighborhood of (x,y).
 If T depends on the spatial coordinates (x,y) themselves, then
variable thresholding is often referred to as dynamic or adaptive
thresholding.
Thresholding
Multilevel Thresholding
 It is also possible to extract objects that have a specific intensity
range using multiple thresholds.
image with dark background
and two light objects

Extension to color images is straightforward: There are three color channels, in


each one specify the intensity range of the object… Even if objects are not
separated in a single channel, they might be with all the channels… Application
example: Detecting/Tracking faces based on skin color…
Multilevel Thresholding
• A point (x,y) belongs

– to an object class if T1 < f(x,y) T2

– to another object class if f(x,y) > T2

– to background if f(x,y)  T1

a if f (x, y)  T2

g(x, y)  b if T1  f (x, y)  T2
c if f (x, y)  T1

Thresholding
Thresholding
Role of Noise in Image Thresholding
Basic Global thresholding
Based on visual inspection of histogram
1. Select an initial estimate for T.
2. Segment the image using T. This will produce two groups of pixels:
G1 consisting of all pixels with gray level values > T and G2
consisting of pixels with gray level values  T
3. Compute the average gray level values 1 and 2 for the pixels in
regions G1 and G2
4. Compute a new threshold value
5. T = 0.5 (1 + 2)
6. Repeat steps 2 through 4 until the difference between the values of T in
successive iterations is smaller than a predefined parameter ΔT.
Basic Global thresholding

Initially T= average intensity of


image T0 = 0
3 iterations
with result T = 125
Basic Global thresholding
1. Works well in situations where there is a reasonably clear valley
between the modes of the histogram related to objects and
background.

2. ΔT is used to control the number of iterations.


3. Initial threshold must be chosen greater than the minimum and
less than the maximum intensity level in the image

4. The average intensity of the image is a good initial choice for T.


Basic Adaptive Thresholding
• subdivide original image into small areas.
• utilize a different threshold to segment each subimages.
• since the threshold used for each pixel depends on the
location of the pixel in terms of the subimages, this type of
thresholding is adaptive.
Example of Adaptive Thresholding
Edge & Boundary Linking
• Set of pixels from edge detecting algorithms, seldom define a
boundary completely because of noise, breaks in the boundary etc.
• Therefore, Edge detecting algorithms are typically followed by
linking and other detection procedures, designed to assemble edge
pixels into meaningful boundaries.
• 2 types – local and global

Analyse the characteristics of pixels in a small neighbourhood ( 3x3, or


5x5 ) about every point that has undergone edge detection. All points
that are similar are linked, forming a boundary of pixels that share
some common properties.
Local Processing
• 2 main properties for establishing similarity of edge pixels:-
• strength of the response of the gradient operator used to produce the
edge pixel

• direction of the gradient.

• A point in the predefined neighbourhood of (x,y) is linked to the pixel at (x,y) if


both magnitude and direction criteria are satisfied. This process is repeated for
every location in the image.
Edge & Boundary Linking by Hough
Transforms
The Hough transform is a technique which can be used to isolate
features of a particular shape within an image.
Hough transform is most commonly used for the detection of
regular curves such as lines, circles, ellipses, etc.
The main advantage of the Hough transform technique is that it is
tolerant of gaps in feature boundary descriptions and is relatively
unaffected by image noise.

The line equation is y = mx + c


However, the problem is that there are infinite line passing through one points
Therefore, an edge point in an x-y plane is transformed to a c-m plane Now equation
of line is c = (-x)m + y
• Hough Transform steps:
1) Load the image
2) Find the edges of the image using any edge detector
3)Quantize the parameter space P
4) Repeat the following for all the pixels of the image: if
the pixel is an edge pixel, then
(a) c = (-x)m + y or calculate ρ
(b) P(c,m) = P(c,m) + 1 or increment position in P
5) Show the Hough Space
6) Find the local maxima in the parameter space
7)Draw the line using the local maxima

• The major problem with this algorithm is that it does not work for vertical
lines, as they have a slope of infinity
• Convert line into polar coordinates ρ = x cosӨ + ysinӨ, where Ө is the angle
between the line and x-axis, and ρ is the diameter
Example of Hough Transform
Q. Using hough transform, show that the points (1,1), (2,2), (3,3) are collinear . Find
the equation of line.
Sol: Note: Three or more points that lie on the same line are collinear points
The equation of line is y=mx+c , where m=slope and c=intercept
To perform hough transform, we need to convert line from (x,y) plane to (m,c) plane.
The equation of line in (m,c) plane is
c=-mx+y…….(eq.1)
Now
1. For (x,y)= (1,1) ; c=-m+1…..(eq.2)
Now we will consider two conditions i.e if c=0, in eq.1 means 0=-m+1 i.e m=1
if m=0 in eq.2 then c=1

Therefore we can write (m,c)= (1,1)


2. Now for (x,y) = (2,2)
c= -2m+2 …..(eq.3) from eq.1
Again we will consider two condition
If c=0 in eq.3 then 0=-2m+2 i.e m=1

If m=0 in eq.3 then c=2 therefore (m,c)=(1,2)

3. Now for (x,y) =(3,3)


C= -3m+3…….(eq.4)
Again we will consider two condition
If c=0 in eq.4 then 0=-3m+3 i.e m=1

If m=0 in eq.4 then c=3 therefore (m,c)=(1,3)

Now we have (m,c)= (1,1) , (1,2) , (1,3)


Now plot these values
(m,c)=(1,1) (m,c)=(1,2)

(m,c)=(1,3)
So , by seeing this diagram we have to see the point at
which all these 3 lines meet at same point.
So this point is m=1 and c=0
i.e (m,c)= (1,0)

Now original equation of line is y=mx+c


Put the value (m,c)= (1,0) in this equation we will get
y=x
Therefore final equation of line is y=x
• Now we have to show that points are collinear or not
The final line of equation is y=x
So for (1,1) (2,2) (3,3)
x=1, y=1 x=2, y=2 x=3, y=3
Plot these values

So it shows that points are collinear

You might also like