0% found this document useful (0 votes)
12 views107 pages

Dip Oj

The document discusses morphological image processing, focusing on operations such as erosion, dilation, opening, and closing, which manipulate images based on their shapes. It explains the use of structuring elements to process images and includes examples and problems to illustrate these concepts. Additionally, it covers the hit-or-miss transformation for shape detection and boundary extraction techniques in digital image processing.

Uploaded by

Ruhina Tabasshum
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)
12 views107 pages

Dip Oj

The document discusses morphological image processing, focusing on operations such as erosion, dilation, opening, and closing, which manipulate images based on their shapes. It explains the use of structuring elements to process images and includes examples and problems to illustrate these concepts. Additionally, it covers the hit-or-miss transformation for shape detection and boundary extraction techniques in digital image processing.

Uploaded by

Ruhina Tabasshum
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/ 107

E C E

Digital Image Processing


ECE-4223

Oishi Jyoti
Lecturer
Dept. of ECE, RUET
Reference Book

 Digital Image Processing (4th Edition) – Rafael C Gonzalez, Richard E Woods


(Chapter – 9 )
Outline

 Erosion and dilation


 Opening and closing
 The hit-or-miss transform
Morphological Image processing

Morphological operations are a set of operations that process images based on shapes. In a morphological
operation, each pixel in the image is adjusted based on the value of other pixels in its neighborhood.
They apply a structuring element to an input image and generate an output image.

Structuring element: A structuring element is a matrix that identifies the pixel in the image being
processed and defines the neighborhood used in the processing of each pixel. You typically choose a
structuring element the same size and shape as the objects you want to process in the input image.

• The matrix dimensions specify the size of the structuring element.


• The pattern of ones and zeros specifies the shape of the structuring element.
• An origin of the structuring element is usually one of its pixels, although generally the origin can be
outside the structuring element.
Dilation and Erosion

The most basic morphological operations are two:


1. Dilation: Dilation adds pixels to the boundaries of objects in an image
2. Erosion: Erosion removes pixels on object boundaries.

Remember two things:

Dilation: Erosion:
a) Full match- 1 a) Full match- 1
b) Partial match -1 b) Partial match -0
c) No match- 0 c) No match- 0
Example or Dilation and Erosion
Have a look at the following example

0 0 0 0 0 0 1
0 0 1 1 0 0 1
0 1 1 1 1 0 1
0 0 1 1 0 0
0 0 1 0 0 0
0 0 0 0 0 0
Problem: A⊕B Problem: A⊖B
0 0 1 1 0 0 0 0 0 0 0 0
0 1 1 1 1 0 0 0 0 0 0 0
0 1 1 1 1 0 0 0 1 1 0 0
0 1 1 1 1 0 0 0 1 0 0 0
0 0 1 1 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0 0 0
Problem 1

 Given the image A and structuring element of B-

0 0 0 0 0 0 1
0 0 1 1 0 0 1
0 1 1 1 1 0 1
0 0 1 1 0 0
0 0 0 0 0 0
0 0 0 0 0 0

a) A dilated by B
b) Ac eroded by B
Opening and Closing
 Opening is generally used to restore or recover the original image to the maximum
possible extent.
 Closing is generally used to smoother the contour of the distorted image and fuse back
the narrow breaks and long thin gulfs.
 The combination of Opening and Closing is generally used to clean up artifacts in the
segmented image before using the image for digital analysis.
( After
opening)

( After (Opening
closing) followed
by closing)
Opening and Closing
 Opening :
 Properties of Opening are:
1. XoY is a subset (subimage of X)
2. If X is a subset of Z then XoY is a subset of ZoY
3. (XoY)oY = XoY

 Closing:
 Properties of Closing are:
1. X is a subset subimage of X.Y
2. (X.Y).Y = X.Y
Problem 2

 Given the image A and structuring element of B.

1 1 1 0 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 0 1 1 1 1 1 1

a) A opened by B
b) A closed by B
Hit-or-Miss Transformation
⮚ Conceptually hit-or-miss transformation is mainly tool for shape
detection/presence.
⮚ The concept forwards with starting with small shape or sub-set of the
main input image.
⮚ In figure ‘A’ is an input image, C,D,E are some objects on the
image (sub-set of A).
⮚ We want to find any shape is present in the image or not
⮚ Suppose we want to find the existence of D into the image A
⮚ Several steps are shown as in the figure
Hit-or-Miss Transformation

⮚ After erosion of A by D the obtained set is only possible locations


of D
⮚ All point after erosion is geometrically the center of D, i.e D is
completely inside A
⮚ All the points matched as the center of D within A is the ‘hit’
other wise the points are ‘miss’ points.
Hit-or-Miss Transformation
Equations for the explanations:

As the local background of the sub image D is obtained as [W-D]. This can be written as B=(B1 and B2). Where
B1=D is formed for the elements of the foreground and B2=W-D which is for background elements.

Here D is mainly a structuring element. This hit-or-miss concept can be written in of erosion and dilation as the
following
Hit-or-Miss Transformation
Structuring element in this operation:
⮚ The structuring element used in the hit-and-miss is a slight extension to the type that has been introduced for
erosion and dilation
⮚ It can contain both foreground and background pixels i.e. both ones and zeros
Hit-or-Miss Transformation

An application of heat-or-miss: Finding the convex corner of an image


Hit-or-Miss Transformation
An application of heat-or-miss: Finding the convex corner of an image
⮚ Figure 3 Effect of the hit-and-miss based right angle convex corner detector on a simple binary image

⮚ The output is the result of implementing the four kernel/structuring element separately and merging the four of
the intermediate outputs.
Hit-or-Miss Transformation

An application of heat-or-miss: Different kernels for different applications


⮚ Figure illustrates some structuring elements that can be used for locating various binary feature
Hit-or-Miss Transformation
An Example of heat-or-miss: Calculating the values of a binary image

0 0 0 0 0 0 0 0 0 0 0 1 0
0 1 1 1 1 1 0 0 1 0 0 0 0
0 1 1 1 1 1 0 0 1 0 0 0 0
0 1 1 1 1 1 0
B1 B2
0 1 1 1 1 1 0
0 1 1 1 1 1 0
0 0 0 0 0 0 0
A 0 0 0 0 0 0 0
0 1 1 1 1 1 0
0 1 1 1 1 1 0
0 1 1 1 1 1 0
0 1 1 1 1 1 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
Hit-or-Miss Transformation
 An Example of heat-or-miss: Calculating the values of a binary image

1 1 1 1 1 1 1 0 0 0 0 0 0 0
1 0 0 0 0 0 1 1 1 1 1 1 1 1
1 0 0 0 0 0 1 1 0 0 0 0 0 1
1 0 0 0 0 0 1 1 0 0 0 0 0 1
1 0 0 0 0 0 1 1 1 0 1 0 1 1
1 0 0 0 0 0 1 1 0 0 0 0 0 1
1 1 1 1 1 1 1 1 0 0 0 0 0 1
Hit-or-Miss Transformation
 An Example of heat-or-miss: Calculating the values of a binary image

0 0 0 0 0 0 0
0 1 1 1 1 1 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
Hit-or-Miss Transformation
Checking your understanding: Solve the following

1 0 0 1 1 1 0
B1 = Last 3by3 part of A
1 0 0 0 1 0 0 B2 = Compliment of B1
1 0 0 0 1 1 1
Now find,
1 1 0 0 1 0 0
0 1 0 1 0 1 0 Verify your answer with,
0 1 0 1 1 1 1
0 1 0 1 1 1 1
A
Hit-or-Miss Transformation
Checking your understanding: Solve the following

A
Hit-or-Miss Transformation
Checking your understanding: Solve the following

0 0 0 0 0 0 0
Now find, the corner of the image.
0 1 1 1 1 1 0
0 1 1 1 1 1 0
0 1 1 1 1 0 0
⨯ 1 ⨯ ⨯ 1 ⨯ ⨯ 0 0 0 0 ⨯
0 1 1 1 0 0 0
0 1 1 1 1 0 1 1 0 0 1 1
0 1 1 0 0 0 0
0 0 ⨯ ⨯ 0 0 ⨯ 1 ⨯ ⨯ 1 ⨯
0 0 0 0 0 0 0
B1 B2 B3 B4
A
Hit-or-Miss Transformation
Checking your understanding: Solve the following

0 0 0 0 0 0 0 0
Now find, HMT.
0 0 1 1 1 0 0 0
0 0 1 1 1 0 0 0
0 0 0 1 1 1 0 0
⨯ 1 ⨯
0 0 0 1 1 1 0 0
1 1 1
0 0 1 1 1 1 0 0
⨯ 1 ⨯
0 0 1 1 1 1 0 0
B1
0 0 0 0 0 0 0 0
A
Hit-or-Miss Transformation
Checking your understanding: Solve the following

Now find, if there is any 3by3 shape in the image.

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 1 1 0 1 1 1 0 1 1 1 0 0 0
0 0 1 1 0 1 1 1 0 1 1 1 1 0 0
0 0 1 1 0 1 1 1 0 1 1 1 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
A
Boundary Extraction
Boundary Extraction: Boundary Extraction is a Digital Image Process to extract edges from a binary image. It has
also been used as the basis for extracting edges on grayscale and color images.
⮚ The process includes two major steps
⮚ Erode the input image using any kernel of any size
⮚ Then performing the set different of the eroded image and the original input image results in the image with
boundary extracted
⮚ A 3X3 kernel extracts the most sophisticated boundary of one pixel thickness
⮚ Increase in kernel size will increase the boundary thickness.
⮚ Mathematical definition of boundary extraction can be written as
β(A) = A - (A Ɵ B)
⮚ Here B is the structuring element
Boundary Extraction
Approach of boundary extraction

Some practical example


Boundary Extraction
Boundary Extraction: An example, Consider the following image and kernel. Then AƟB would be same as A
except one pixel.

Kernel (B)

Image (A) AƟB

Now Boundary β(A) = A - (A Ɵ B)


Region Filling
Region Filling: Region-Filling is a method to fill a bounded region with a certain color or image. It means filling
the color in a pixel which is connected with other 4 or 8 pixels, and then algorithm fills the color in all pixels in
the Region. Region can correspond to:-
1. Interior
2. Boundary
⮚ Interior region filling, FLOOD-FILL algorithm is used, where you have to change the values of all pixels in the
interior regions to new values.
⮚ In boundary regions to new value are BOUNDARY-FILL algorithms.
⮚ Here we go through boundary filling algorithm.
⮚ This operation starts with any fixed point ‘p’ within the region, This point sometimes called a seed.
⮚ This initial point is assigned to foreground color. That is p=1 in binary image
⮚ This method can fill region in RGB image also.
Region Filling
Region Filling: Boundary Filling
The mathematical form of the process is: X[k] = (X[k-1] ⊕ B) ∩ Ac where k=1,2,3,4…….
• Here X0 =p and p=1 in binary image.
• Terminates at X[k] = = = X[k-1]
• Union of X[k] and the A image is the final filled image B=A U X[k]
• This is called conditional dilation
Region Filling
Region Filling: Example
⮚ Initial image and the structuring element, mainly 4-
neighbor pixels
⮚ Complement of the image A
⮚ Next steps until meet the condition X[k]=X[k-1]
⮚ Finally union of the original image and the X[k]
image
Region Filling
Region Filling: This example will make clear
Region Filling
Region Filling: This example will make clear
Region Filling
Region Filling: This example will make clear
Region Filling
Region Filling: This example will make clear
The final of A U X[k]

⮚ This technique helps to eliminate error from image like spots and damaged regions
⮚ To extract shellute from captured images
Connected Component Extraction
Connected Component: To find out all pixel which are connected with a initial known value.
⮚ Similar way like boundary filling algorithm
Mathematically be written as X[k] = (X[k-1] ⊕ B) ∩ A where k=1,2,3,4…….
• Here X0 =p , Terminates at X[k] = = = X[k-1]

⮚ Mainly used to detect artifacts in images


⮚ Discontinuity of bones in X-ray images
Connected Component Extraction
Connected Component: Example
Connected Component Extraction
Connected Component Extraction
Connected Component Extraction
Connected Component Extraction
Connected Component Extraction
Connected Component: Example to check understanding

Consider the following image and structuring element. Then find out the connected component in the image.

1 1 1 0 0 0 0 1 1 1
1 0 1 0 0 0 0 1 1 1
1 1 1 0 0 1 1 1 1 1
1 1 0 0 0 1 1
1 1 0 0 1 1 1
1 0 1 1 0 0 1
0 0 1 1 1 1 1
Other algorithms

➢ Thinning
➢ Thickening
➢ Skeleton
➢ Pruning
Thinning
➢ To remove selected foreground pixels from binary images
➢ Reduces the area of shape from every side of the image
➢ It also an application of hit-or-miss transform
➢ It an iterative method
➢ Mathematically can derived as

• Thinning of a set A of foreground pixels by a structuring element B, can be defined in terms of the hit-or-miss
transform:

➢ Obtained by a sequence of operation


Thinning
➢ Thinning operation is calculated by
translating the origin of the structuring
element to each possible pixel position in
the image
➢ If the foreground and background pixels in
the structuring element exactly match
foreground and background pixels in the
image, then the image pixel underneath the
origin of the structuring element is set to
background (zero).
➢ Otherwise unchanged
Thickening
➢ Thickening is a morphological operation that is used to
grow selected regions of foreground pixels in binary
images

➢ The thickening operation is related to the hit-and-miss


transform and can be expressed quite simply in terms of
it. The thickening of an image I by a structuring element
J is:

➢ It is also Obtained by a sequence of operation like


thinning
Skeleton

 An important approach to representing the structural shape of a plane region is to


reduce it to a graph.
 This reduction may be accomplished by obtaining the skeleton of the region via a
thinning algorithm.
Skeleton
Skeleton
Skeleton
Skeleton
Pruning
Pruning
Pruning
➢ Eliminates the parasites form the images
➢ The unwanted branches are removed
➢ It also detects the skeleton of image and then thins the image
Work example

1 1 0 0 0 0 0 1 1 1 × ×
1 1 1 1 1 1 1 1 0 0 × 1 × 1 1 1 1
1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 × × 1 1
1 1 1 1 1 1 1 1 0 0
B1 B2 …………… B8
1 1 1 0 0 1 1 1 0 0

Thin: If kernel completely match – 0


If kernel not match – Unchanged

Thick: Completely match – 1


Not match - Unchanged
Image Segmentation
⁂ It is a stage of transition from image processing methods whose inputs and
outputs are images, in which the inputs are images but outputs are attributes
extracted from those images.
⁂ Segmentation refers to the process of partitioning an image into multiple
regions.
⁂ Used to locate –
1. Object
2. Boundaries
Image Segmentation
❖ Discontinuity
1. Isolated point
2. Line detection
3. Edge detection

❖ Similarity
1. Thresholding
2. Region growing
3. Region split
Image Segmentation
⁂ Point Detection
- Done using sharpening filters. (Laplacian kernel)
Image Segmentation
⁂ Point Detection
Image Segmentation
⁂ Line Detection
- We use 2nd order derivatives which result in a thinner line than first
derivative.
Image Segmentation
⁂ Line Detection
Image Segmentation
⁂ Edge Detection
- Used frequently for segmenting image based on abrupt changes in intensity
- Thicker lines : Robert-cross, Prewitt, Sobel Operators (First derivative)
- Thinner line : Laplacian(2nd Order)
- Maximum Edge strength in a predetermine directions : Kirsch Compass
- Canny Edge Detection
Image Segmentation
0 1 1 -1 -1 0
⁂ Edge Detection
-1 0 1 -1 0 1

-1 -1 0 0 1 1

Prewitt mask for diagonal edges

0 1 2 -2 -1 0

-1 0 1 -1 0 1

-2 -1 0 0 1 2

Sobel mask for diagonal edges

Better noise
suppression
Image Segmentation
Image Segmentation

0 -1 0 -1 -1 -1

-1 4 -1 -1 8 -1
Second order kernels (The Laplacian)
0 -1 0 -1 -1 -1
Canny Edge Detection

 Noise Reduction
 Gradient Calculation
 Non-Maximum Suppression
 Double Thresholding
 Hysteresis
Canny Edge Detection

 Noise Reduction
 Since edge detection is susceptible to noise in the image, first step is to remove the
noise.
Canny Edge Detection

 Gradient Calculation
 Smoothens image is filtered with a sobel kernel in both X and Y direction to get
derivatives.
Canny Edge Detection
 Non-Maximum Suppression
 The final image should have thin edges. Thus, we must perform non-maximum
suppression to thin out the edges.
 The algorithm goes through all the points on the gradient intensity matrix and finds the
pixels with the maximum value in the edge directions.
Canny Edge Detection
 Double Thresholding
 More than maxVal = edges,
less than minVal = not edges
Canny Edge Detection

 Hysteresis
 Connected with ‘sure-edges’ pixel is considered to be part of edges.
Image Segmentation of Gray Image
⁂ In bi-level thresholding, image is segmented into two different regions.
⁂ The pixels with gray values greater than a certain value T are classified as object pixels, and
the others with gray values lesser than T are classified as background pixels.
⁂ Gray scale image contains pixel value within 0 to 255.
Image Segmentation of Gray Image
WaterShed Algorithm
⁂ The watershed is a classical algorithm used for segmentation, for separating
different objects in an image.
WaterShed Algorithm
⁂ Watershed : A watershed is the area of the land that drains to a particular
points along a stream
WaterShed Algorithm

⁂ Three types of points


1. Regional Minima
2. Catchment basin or watershed
3. Divide lines or watershed line
WaterShed Algorithm
⁂ Objective is to find watershed lines.
⁂ The idea –
1. A hole in regional minima
2. From where water will rise at uniform rate
3. While rising , at some point the water from two region will meet which is
the watershed line.
Watershed Algorithm

⁂ Algorithm –
1. Start with pixels with lowest possible
values.
2. For each pixel intensity –
>> If there is adjacent pixel within one
region, add the pixel to that region.
>> Else if there is adjacent pixel which is
adjacent to more region, mark as boundary.
>> Else start new region
Watershed Algorithm

General Segmentation :
Watershed Algorithm

Watershed Segmentation :
Computer Graphics : Line Algorithm
 DDA : Digital Differential Analyzer DDA algorithm is the simple line generation algorithm
which is explained step by step here.
❑ Step 1: Input the two endpoints of the line segment, (x1,y1) and (x2,y2).
❑ Step 2: Calculate the difference between the x-coordinates and y-coordinates of the endpoints
as dx and dy respectively.
❑ Step 3: Calculate the slope of the line as m = dy/dx.
❑ Step 4: Set the initial point of the line as (x1,y1).
❑ Step 5: If 0<m ≤ 1, x=x1+1, y=y1+m
If -1 ≤ m < 0, x=x1-1, y=y1-m
If m>1, x=x1+(1/m), y=y1+1
If m<-1, x=x1-(1/m), y=y1-1
❑ Step 6: Plot the pixel at the calculated (x,y) coordinate.
❑ Step 7: Repeat steps 5 and 6 until the endpoint (x2,y2) is reached.
Computer Graphics : Line Algorithm
 Bresenham : The Bresenham algorithm is another incremental
scan conversion algorithm. The big advantage of this algorithm
is that, it uses only integer calculations.

 General line equation : y = mx + b


Y = m(Xk+1) + b
So, d_upper and d_lower are given as follows −
d_lower=y−yk =m(Xk+1)+b−Yk
And d_upper=(yk+1)−y = Yk+1−m(Xk+1)−b
Now, d_lower−d_upper <0, select d_lower
d_lower−d_upper >0, select d_upper
Line Algorithm
Now, d_lower − d_upper=2m(xk+1)−2yk+2b−1
Let us substitute m with dy/dx where dx and dy are the differences between the end-points.
dx(d_lower−d_upper)=dx(2.(dy/dx)(xk+1)−2yk+2b−1)
=2dy.xk−2dx.yk+2dy+2dx(2b−1)
=2dy.xk−2dx.yk+C
So, a decision parameter pk for the kth step along a line is given by −
pk=dx(dlower−dupper) = 2dy.xk−2dx.yk+C

The sign of the decision parameter Pk is the same as that of d_lower−d_upper.


If pk is negative, then choose the lower pixel, otherwise choose the upper pixel.
Line Algorithm
Now, At step k+1, the decision parameter is given as −
pk+1 = 2dy.xk+1−2dx.yk+1 + C
Subtracting pk from this we get − pk+1−pk=2dy(xk+1−xk)−2dx(yk+1−yk)
But, xk+1 is the same as (xk)+1. So −
pk+1=pk+2dy−2dx(yk+1−yk)
Where, Yk+1–Yk is either 0 or 1 depending on the sign of Pk.

The first decision parameter p0 is evaluated at (x0,y0) is given as −


p0=2dy−dx
Line Algorithm
Step 1 − Input the two end-points of line, storing the left end-point in (x0,y0).
Step 2 − Plot the point (x0,y0).
Step 3 − Calculate the constants dx, dy, 2dy, and 2dy–dx and get the first value for the decision parameter
as −
p0=2dy−dx
Step 4 − At each Xk along the line, starting at k = 0, perform the following test −
If pk < 0, the next point to plot is (xk+1,yk) and pk+1=pk+2dy
Otherwise, (xk+1,yk+1) and pk+1=pk+2dy−2dx
Step 5 − Repeat step 4 dx–1 times.
Circle Algorithm
Step 1 − Get the coordinates of the center of the circle and radius, and store them in x, y, and R
respectively. Set x=0 and y=R.
Step 2 − Set decision parameter P = 3 – 2R.
Step 3 − Repeat through step-4 while yi+1 ≤ xi+1 .
Step 4 − Case1 : if P < 0
xi+1 = xi +1
yi+1 = yi
Pi+1 = Pi + 4xi+1 + 6
Case2 : if P ≥ 0
xi+1 = xi +1
yi+1 = yi -1
Pi+1 = Pii+ 4(xi+1 – yi+1 ) +10
Circle Algorithm
Octant 1 – (x1,y1)
Octant 2 – (x2,y2) where x2=y1 and y2=x1
Net Octant 1,2 – (X,Y)
Octant 3,4 – (X,-Y)
Octant 5,6 – (-X,-Y)
Octant 7,8 – (-X,Y)
Window to Viewport Transformation
 World coordinate – It is the Cartesian coordinate w.r.t which we define the diagram, like
Xwmin, Xwmax, Ywmin, Ywmax
 Device Coordinate –It is the screen coordinate where the objects are to be displayed,
like Xvmin, Xvmax, Yvmin, Yvmax
 Window –It is the area on world coordinate selected for display.
 ViewPort –It is the area on the device coordinate where graphics is to be displayed.
Window to Viewport Transformation
 (Xw, Yw): A point on Window
 (Xv, Yv): Corresponding point on Viewport
Window to Viewport Transformation
Cohen Sutherland Algorithm
Cohen Sutherland Algorithm
Steps
1) Assign the region codes to both endpoints.
2) Perform OR operation on both of these endpoints.
3) if OR = 0000,
then it is completely visible (inside the window).
else
Perform AND operation on both these endpoints.
i) if AND ≠ 0000,
then the line is invisible and not inside the window.
Also, it can’t be considered for clipping.
ii) else
AND = 0000, the line is partially inside the window
and considered for clipping.
Cohen Sutherland Algorithm

4) After confirming that the line is partially inside the window, then we find the intersection with the
boundary of the window. By using the following formula:-

Slope:- m= (y2-y1)/(x2-x1)

a) If the line passes through top or the line intersects with the top boundary of the window.
x = x + (y_wmax – y)/m
y = y_wmax

b) If the line passes through the bottom or the line intersects with the bottom boundary of the window.
x = x + (y_wmin – y)/m
y = y_wmin
c) If the line passes through the left region or the line intersects with the left boundary of the window.
y = y+ (x_wmin – x)*m
x = x_wmin
Cohen Sutherland Algorithm
d) If the line passes through the right region or the line intersects with the right boundary of the
window.
y = y + (x_wmax -x)*m
x = x_wmax

5) Now, overwrite the endpoints with a new one and update it.
6) Repeat the 4th step till your line doesn’t get completely clipped
Image Compression

 Image compression is a process applied to a graphics file to minimize its size in bytes
without degrading image quality below an acceptable threshold.
 By reducing the file size, more images can be stored in a given amount of disk or
memory space
 Types:
1. Lossy
2. Lossless
Lossy Compression

 Reduces an image file size by permanently


removing less critical information
 Also reduce image quality
 It is irreversible
 Example of lossy compression: JPEG (Joint
Photographic Experts Group)
Lossy Compression

 Following are the steps of JPEG Image Compression-


 Step 1: The input image is divided into a small block which is having 8x8 dimensions.
This dimension is sum up to 64 units. Each unit of the image is called pixel.
 Step 2: JPEG uses [Y,Cb,Cr] model instead of using the [R,G,B] model. So in the 2nd
step, RGB is converted into YCbCr.
 Step 3: After the conversion of colors, it is forwarded to DCT.
 Step 4: Quantization is used to reduce the number of bits per sample.
 Step 5: The zigzag scan is used to map the 8x8 matrix to a 1x64 vector.
 Step 6: In this step, Run Length Encoding (RLE) is applied to components.
 Step 7: In this step, components are coded into Huffman.
RLE

 Run–length encoding (RLE) is a simple form of lossless data compression that runs on
sequences with the same value occurring many consecutive times. It encodes the
sequence to store only a single value and its count.

 WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWW
WWWWWWWWWWWWWWBWWWWWWWWWWWWWW
 With a run-length encoding (RLE) data compression algorithm applied to the above
hypothetical scan line, it can be rendered as 12W1B12W3B24W1B14W.

V.V.I
Huffman Coding

 Huffman coding is a lossless data compression algorithm.


 In this algorithm, a variable-length code is assigned to input different characters.
 The code length is related to how frequently characters are used.
 Most frequent characters have the smallest codes and longer codes for the least frequent
characters.

 Initial Message:

V.V.I
Huffman Coding

 Initial Message:

 Each character occupies 8 bits. There are a total of 15 characters in the above string.
Thus, a total of 8 * 15 = 120 bits.
 Calculate the frequency of letter

V.V.I
Huffman Coding

 Sort the characters in increasing order of the frequency. These are stored in a priority
queue Q.

 Make each unique character a leaf node.

V.V.I
Huffman Coding

Character Frequency Code Size

A 5 11 5*2 = 10

B 1 100 1*3 = 3

C 6 0 6*1 = 6

D 3 101 3*3 = 9

4 * 8 = 32 bits 15 bits 28 bits

V.V.I
Lossless Compression

 Lossless compression means that you reduce the size of an image without any quality
loss.
 Removes unnecessary metadata from JPEG and PNG files
 Lossless image formats:
GIF
PNG
BMP
Wavelet Compression

 Wavelet compression offers an approach that allows one to reduce the size of the data
while at the same time improving its quality through the removal of high-frequency
noise components.
 Steps:
1. Digitize the source image to a signal
2. Decompose the signal into a sequence
3. Use thresholding to modify the wavelet
4. Use quantization to new sequence
5. Apply entropy encoding (RLE, Huffman) to compress
Fractal Compression

 Fractal compression uses the properties of fractal objects for compression. It is a lossy
compression.

 Fractal objects resemble the main object. So, by removing the similar objects the
image can be compressed.
Topics

 Blur
 Smooth
 Sharp
 Intensity Transformation
 Zooming
 Concave and Convex hull
THANK YOU

You might also like