0% found this document useful (0 votes)
28 views100 pages

Understanding Image Processing Basics

The document provides an overview of computer vision and image processing, distinguishing between applications for human consumption and those that do not involve human input. It covers key topics such as image restoration, enhancement, compression, and the characteristics of digital images, including resolution and color representation. Additionally, it discusses the human visual system and various types of images, including binary, grayscale, color, and multispectral images.

Uploaded by

a.bohy4casa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views100 pages

Understanding Image Processing Basics

The document provides an overview of computer vision and image processing, distinguishing between applications for human consumption and those that do not involve human input. It covers key topics such as image restoration, enhancement, compression, and the characteristics of digital images, including resolution and color representation. Additionally, it discusses the human visual system and various types of images, including binary, grayscale, color, and multispectral images.

Uploaded by

a.bohy4casa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Image Processing

1
Introduction to Computer Vision
and Image Processing
Computer imaging can be separated into two
:primary categories
.Computer Vision .1
Image Processing .2
In computer vision application the processed
images output for use by a computer, whereas in
image processing applications the output images
.)are for human consumption
2
These two categories are not totally
separate and distinct. The boundaries that
separate the two are fuzzy, but this definition
allows us to explore the
differences between the two and to explore
the difference between the two and to
understand how they fit together

Computer Vision Image Processing

3
Computer Vision
Computer vision computer imaging where the application doses
not involve a human being in visual loop. One of the major
.topics within this field of computer vision is image analysis
Image Analysis: involves the examination of the image data to
.facilitate solving vision problem

Computer vision systems are used in many and various types of


environments, such as: Manufacturing Systems , Medical
Community, DNA analysis, Satellites Orbiting, Infrared Imaging

4
Image Processing
Computer Image processing is computer imaging where
application involves a human being in the visual loop. In other
words the image are to be examined and a acted upon by
.people

:The major topics within the field of image processing include


.Image restoration
.Image enhancement
Image compression

5
Image Restoration
Is the process of taking an image with some known, or estimated
degradation, and restoring it to its original appearance. Image
restoration is often used in the field of photography or publishing
where an image was somehow degraded but needs to be
improved before it can be printed

6
Image Enhancemnet
Involves taking an image and improving it visually, typically
by taking advantages of human Visual Systems responses.
One of the simplest enhancement techniques is to simply
.stretch the contrast of an image
Enhancement methods tend to be problem specific. For
example, a method that is used to enhance satellite images
.may not suitable for enhancing medical images
Although enhancement and restoration are similar in aim, to
make an image look better. They differ in how they approach
the problem. Restoration method attempt to model the
distortion to the image and reverse the degradation, where
enhancement methods use knowledge of the human visual
.7 systems responses to improve an image visually
.Image enhancement by b
a. image with poor contrast
contrast stretching

Image Enhancement

8
Image Compression
Involves reducing the typically massive
amount of data needed to represent an
image. This done by eliminating data that
are visually unnecessary and by taking
advantage of the redundancy that is
inherent in most images. Image data can be
reduced 10 to 50 times, and motion image
data (video) can be reduced by factors of 100
.or even 200
9
a. Image before compression b. Image after compression
(92) KB (6.59)KB

.Image Compression

10
Computer Imaging Systems
Computer imaging systems are comprised of
two primary components types, hardware
and software. The hardware components
can be divided into image acquiring sub
system (computer, scanner, and camera) and
display devices (monitor, printer).The
software allows us to manipulate the image
and perform any desired processing on the
.image data
11
Digitization
The process of transforming a standard
analog signal (continuous) into digital
.signal (discrete) is called digitization
Analog signals use a continuous variety of
amplitude values whereas digital
signal takes a limited set of distinct values
at consistently spaced spots in the time.
Analog signals are continuous in nature,
.whereas digital signals are discrete
12
Analog vs digital signal

13
What is a digital image?
 We usually operate on digital (discrete) images:
 Sample the 2D space on a regular grid
 Quantize each sample (round to nearest integer)
 If our samples are D apart, we can write this as:
f[i ,j] = Quantize{ f(i D, j D) }
 The image can now be represented as a matrix of integer values
The image can now be accessed as a two-dimension
array of data
:The digital image is 2D- array as
I(0,0) I(0,1) ………………………..I(0,N-1)
I(1,0) I(1,1) ………………………..I(1,N-1)
……………………………………………………
……………………………………………
I(N-1,0) I(N-1,1) …….……………..I(N-1,N-1)

:In image matrix, the image size is (NXN) [matrix dimension] then
Ng= 2 m ………..(1)
Where Ng denotes the number of gray levels m is the no. of bits contains in digital
.image matrix
Example :If we have (6 bit) in 128 X 128 image .Find the no. of gray levels to
?represent it ,then find the no. of bit in this image
:Solution
Ng= 26=64 Gray Level
Nb=15128 * 128* 6= 9.8304 * 104 bit
The Human Visual System
The Human Visual System (HVS) has two primary
:components
.Eye
.Brian
The structure that we know the most about is the image *
.receiving sensors (the human eye)
The brain can be thought as being an information processing *
unit analogous to the computer in our computer imaging
.system
These two are connected by the optic nerve, which is really a
bundle of nerves that contains the path ways for visual
.information to travel from the receiving
16
Image Resolution
The resolution has to do with ability to separate two
adjacent pixels as being separate, and then we can say
that we can resolve the two. The concept of resolution is
.closely tied to the concepts of spatial frequency
Spatial frequency concept, frequency refers to how
rapidly the signal is changing in space, and the signal has
two values for brightness-0 and maximum. If we use this
signal for one line (row) of an image and then repeat the
line down the entire image, we get an image of vertical
stripes. If we increase this frequency the strips get closer
and closer together, until they finally blend together
17
Image resolution

18
Image brightness Adaption
In image we observe many brightness levels and
the vision system can adapt to a wide range. If the
mean value of the pixels inside the image is
around Zero gray level then the brightness is low
and the images dark but for mean value near the
255 then the image is light. If fewer gray levels are
used, we observe false contours bogus lines
resulting from gradually changing light intensity
.not being accurately represented

19
Image Representation
We have seen that the human visual system (HVS) receives an
input image as a collection of spatially distributed light energy; this
is form is called an optical image. Optical images are the type we
deal with every day –cameras captures them, monitors display
them, and we see them [we know that these optical images are
represented as video information in the form of analog electrical
signals and have seen how these are sampled to generate the
.digital image I(r , c)
The digital image I (r, c) is represented as a two- dimensional array
of data, where each pixel value corresponds to the brightness of
the image at the point (r, c). in linear algebra terms , a two-
dimensional array like our image model I( r, c ) is referred to as a
matrix , and one row ( or column) is called a vector

20
Binary Image
Binary images are the simplest type of images and can
take on two values, typically black and white, or ‘0’ and
‘1’. A binary image is referred to as a 1 bit/pixel image
because it takes only 1 binary digit to represent each
.pixel
These types of images are most frequently in computer
vision application where the only information required
for the task is general shapes, or outlines information. For
example, to position a robotics gripper to grasp () an
.object or in optical character recognition (OCR)
Binary images are often created from gray-scale images
via a threshold value is turned white (‘1’), and those
.below
21
it are turned black (‘0’)
Gray Scale Image
Gray _scale images are referred to as
monochrome, or one-color image. They contain
brightness information only brightness
information only, no color information. The
number of different brightness level available. The
typical image contains 8 bit/ pixel (data, which
allows us to have (0-255) different brightness
(gray) levels. The 8 bit representation is typically
due to the fact that the byte, which corresponds
to 8-bit of data, is the standard small unit in the
.world of digital computer
22
Color Image
Color image can be modeled as three band monochrome image
.data, where each band of the data corresponds to a different color

The actual information stored in the digital image data is brightness


information in each spectral band. When the image is displayed,
the corresponding brightness information is displayed on the
screen by picture elements that emit light energy corresponding to
.that particular color
23
Multispectral Images
Multispectral images typically contain
information outside the normal human
perceptual range. This may include infrared
ultraviolet ,X-ray, acoustic or radar data.
Source of these types of image include
satellite systems underwater sonar systems
.and medical diagnostics imaging systems

24
Multispectral Images
A multispectral image is one that captures image
data within specific wavelength ranges across the
electromagnetic spectrum. The wavelengths may be
separated by filters or detected via the use of
instruments that are sensitive to particular
wavelengths, including light from frequencies
beyond the visible light range, i.e. infrared and ultra-
violet. Spectral imaging can allow extraction of
additional information the human eye fails to capture
with its visible receptors for red, green and blue. It
was originally developed for military target
identification

25
electromagnetic spectrum

26
Overview of Image Properties
• An image is composed of an array of dots,
more commonly referred to as pixels (short
for picture elements). One generally refers to
a computer image's dimensions in terms of
pixels; this is also often (though slightly
imprecisely) known as its resolution. Some
common image sizes are 640 × 480, 800 × 600,
and 1024 × 768 pixels, which also happen to
be common dimensions for computer
displays.

27
• In addition to horizontal and vertical
dimensions, an image is characterized by
depth. The deeper the image, the more colors
(or shades of gray) it can have. Pixel depths
are measured in bits, the tiniest units of
computer storage;
- a 1-bit image can represent two colors
(often, though not necessarily, black and
white).
- a 2-bit image four colors.
- an 8-bit image 256 colors, and so on.

28
• To calculate the raw size of the image data
before any compression takes place, one
needs only to know that 8 bits make a byte.
• Thus a 320 × 240, 24-bit image has 76,800
pixels, each of which is 3 bytes deep, so its
total uncompressed size is 230,400 bytes.

29
1-bit Images

Each pixel is stored as a single bit (0 or 1), so


also referred to as binary image.
Such an image is also called a 1-bit
monochrome image since it contains no color.
Next Figure shows a 1-bit monochrome image
(called “Lena“ by multimedia scientists - this is
a standard image used to illustrate many
algorithms).

30
31
8-bit Gray-level Images

Each pixel has a gray-value between 0 and 255. Each


pixel is represented by a single byte; e.g., a dark pixel
might have a value of 10, and a bright one might be
230.
Bitmap: The two-dimensional array of pixel values that
represents the graphics/image data.
Image resolution: refers to the number of pixels in a
digital image (higher resolution always yields better
quality).
- Fairly high resolution for such an image might be
1600 * 1200, whereas lower resolution might be
640 * 480.
32
Bitmap (raster) versus vector images

Vector graphics are computer graphics


images that are defined in terms of points
on a Cartesian plane, which are connected
by lines and curves to form polygons and
other shapes. Vector graphics have the
unique advantage over raster graphics in
that the points, lines, and curves may be
scaled up or down to any resolution with
no aliasing. The points determine the
direction of the vector path; each path may
have various properties including values for
stroke color, shape, curve, thickness, and
.fill

33
Frame Buffer

34
Multimedia Presentation
Each pixel is usually stored as a byte (a value
between 0 to 255), so a 640 × 480 grayscale
image requires 300 kB of storage (640 × 480 =
307, 200).
Next Fig shows the Lena image again, but this
time in grayscale.

35
36
Dithering
• which is a means of mixing pixels of the
available colors together to give the
appearance of other colors (though generally
at the cost of some sharpness) .
• When an image is printed, the basic strategy
of dithering is used, which trades intensity
resolution for spatial resolution to provide
ability to print multi-level images on 2-level (1-
bit) printers.

37
An ordered dither consists of turning on the
printer output bit for a pixel if the intensity
level is greater than the particular matrix
element just at that pixel position.

Next Fig. (a) shows a grayscale image of "Lena".


The ordered-dither version is shown as (b),
with a detail of Lena's right eye in (c).
38
39
Dithering examples

40
• The image on the left is the original.

• The middle one is like taking those pristine files and


dramatically reducing their bit depth. It’s pretty hard to
recognize the image.

• The one on the right has been reduced the same amount,
but this time with dither applied.

41
Color Image Data Types
• The most common data types for graphics and image
file formats ; 24-bit color and 8-bit color.
• Some formats are restricted to particular
hardware/operating system platforms, while others
are “cross-platform” formats.
• Even if some formats are not cross-platform, there are
conversion applications that will recognize and
translate formats from one system to another.
• Most image formats incorporate some variation of
compression technique due to the large storage size of
image files. Compression techniques can be classified
into either lossless or lossy.
42
8-bit Color Images
Many systems can make use of 8 bits of color
information (the so-called “256 colors”) in producing
a screen image.
Such image files use the concept of a lookup table to
store color information.
- Basically, the image stores not color, but instead
just a set of bytes, each of which is actually an
index into a table with 3-byte values that specify
the color for a pixel with that lookup table index.

43
Color Look-up Tables (LUTs)
The idea used in 8-bit color images is to store only
the index, or code value, for each pixel. Then, e.g., if
a pixel stores the value 25, the meaning is to go to
row 25 in a color look-up table (LUT).

44
45
24-bit Color Images

• In a color 24-bit image, each pixel is represented by


three bytes, usually representing RGB.
- This format supports 256* 256* 256 possible
combined colors, or a total of 16,777,216 possible
colors.
- However such flexibility does result in a storage
penalty: A 640*480 24-bit color image would
require 921.6 kB of storage without any
compression.
• Full-color photographs may contain an almost infinite
range of color values. Dithering is the most common
means of reducing the color range of images down to
the 256 (or fewer) colors seen in 8-bit GIF images.

46
Chapter Two

Image Analysis

47
Image Analysis
Image analysis involves manipulating the image data to
determine exactly the information necessary to help solve a
computer imaging problem. This analysis is typically part of a
larger process, is iterative in nature and allows us to answer
application specific equations: Do we need color information? Do
we need to transform the image data into the frequency domain?
?Do we need to segment the image to find object information
What are the important features of the image? Image analysis is
primarily data reduction process. As we have seen, images
contain enormous amount of data, typically on the order
hundreds of kilobytes or even megabytes. Often much of this
information is not necessary to solve a specific computer imaging
problem, so primary part of the image analysis task is to
determine exactly what information is necessary. Image analysis
is 48used both computer vision and image processing. But it is
System Model
The image analysis process can be broken down into three
:primary stages
.Preprocessing -1
.Data Reduction -2
.Features Analysis -3
:Preprocessing
Is used to remove noise and eliminate irrelevant, visually
unnecessary information. Noise is unwanted information that can
result from the image acquisition process, other preprocessing
:steps might include
Gray –level or spatial quantization (reducing the number of bits-
.per pixel or the image size)
.Finding regions of interest for further processing-
49
Data Reduction
Involves either reducing the data in the spatial
domain or transforming it into another domain
called the frequency domain, and then extraction
.features for the analysis process

50
Features Analysis
The features extracted by the data reduction
process are examine and evaluated for their use in
.the application
After preprocessing we can perform segmentation
on the image in the spatial domain or convert it into
the frequency domain via a mathematical
transform. After these processes we may choose to
filter the image. This filtering process further
reduces the data and allows us to extract the
.feature that we may require for analysis

51
Preprocessing
preprocessing algorithm, techniques and operators are used to perform
initial processing that makes the primary data reduction and analysis
:task easier. They include operations related to
.Extracting regions of interest-
.Performing basic algebraic operation on image-
.Enhancing specific image features-
.Reducing data in resolution and brightness-
Preprocessing is a stage where the requirements are typically obvious
and simple, such as removal of artifacts from images or eliminating of
image information that is not required for the application. For example,
in one application we needed to eliminate borders from the images that
have been digitized from film. Another example of preprocessing step
involves a robotics gripper that needs to pick and place an object ; for
this we reduce a gray-level image to binary (two-valued) image that
.contains all the information necessary to discern the object ‘s outlines
52
Region –of-Interest Image Geometry
Often, for image analysis we want to investigate more closely a specific
area within the image, called region of interest (ROI). To do this we
need
operation that modifies the spatial coordinates of the image, and these
are categorized as image geometry operations. The image geometry
:operations discussed here include
.Crop , Zoom, enlarge , shrink, translate and rotate
The image crop process is the process of selecting a small portion of
the image, a sub image and cutting it away from the rest of the image.
After we have cropped a sub image from the original image we can
zoom in on it by enlarge it. The zoom process can be done in numerous
:ways
.Zero-Order Hold -1
.First _Order Hold -2
.53Convolution -3
Zero-Order hold
is performed by repeating previous pixel values, thus
:creating a blocky effect as in the following figure

54
First _Order Hold

is performed by finding linear interpolation between a


adjacent pixels, i.e., finding the average value between two
pixels and use that as the pixel value between those two, we
can do this for the rows first as follows

55
56
First _Order Hold Method

57
Convolution

this process requires a mathematical process to


:enlarge an image. This method required two steps
Extend the image by adding rows and columns -1
of zeros between the existing rows and columns
Perform the convolution -2

58
59
+
The convolution process requires us to overlay the mask on the image, multiply
the coincident values and sum all these results. This is equivalent to finding the
vector inner product of the mask with underlying sub image. The vector inner
product is found by overlaying mask on sub image. Multiplying coincident terms,
and summing the resulting products For example, if we put the mask over the
upper-left corner of the image, we obtain (from right to left, and top to bottom):
)0(1/4 + )0(1/2+ )3(1+ )0(1/2+ )0(1/4+ )0(1/2+ )0(1/4
3= )0(1/4+ )0(1/2+
Note that the existing image values do not change. The next step is to slide the
:mask over by one pixel and repeat the process, as follows
)0(1/4 + )5(1/2+ )0(1+ )3(1/2+ )0(1/4+ )0(1/2+ )0(1/4
4= )0(1/4+ )0(1/2+
Note this is the average of the two existing neighbors. This process continues until
we get to the end of the row, each time placing the result of the operation in
.location corresponding to center of mask
When the end of the row is reached, the mask is moved down one row, and the
process is repeated row by row. This procedure has been performed on the entire
.image, the process of sliding, multiplying and summing is called convolution
. 60
61
what if we want to enlarge an image by
?something other than a factor of (2N-1)

To do this we need to apply a more general method. We


take two adjacent values and linearly interpolate more
than one value between them. This is done by define an
:enlargement number k and then following this process
.Subtract the result by k -1
.Divide the result by k -2
Add the result to the smaller value, and keep adding -3
the result from the second step in a running total until
.all (k-1) intermediate pixel locations are filled

62
Example: we want to enlarge an image to three times its original size,
.and we have two adjacent pixel values 125 and 140
.Find the difference between the two values, 140-125 =15
.The desired enlargement is k=3, so we get 15/3=5
: next determine how many intermediate pixel values .we need
K-1=3-1=2. The two pixel values between the 125 and 140 are
.and 125+2*5 = 135 130=125+5
We do this for every pair of adjacent pixels .first along the rows and
then along the columns. This will allows us to enlarge the image by any
.factor of K (N-1) +1 where K is an integer and N×N is the image size
To process opposite to enlarging an image is shrinking. This process is
.done by reducing the amount of data that need to be processed
Two other operations of interest image geometry are: Translation and
Rotation. These processes may be performed for many application
specific reasons, for example to align an image with a known template
.in pattern
63 matching process or make certain image details easer to see
Example of Enlarge image 5 times
:Example
Given an image has two adjacent pixel values of
.210 and 240. Enlarge the image five times

differences of color value ( 30 = 240-210 .1


)between the two adjacent pixels
K = 5 ---- 30/5 = 6 .2
K-1 = 5-1 = 4 .3
K = 1 - 210 + 6*1 = 216 .4
K = 2 - 210 + 6*2 = 222 .5
K=3 - 210 + 6*3 = 228 .6
K= 4 - 210 + 6* 4 = 234 .7

64
Ch2, lesson2: Zooming and shrinking

Nearest neighbor interpolation


Example:
Suppose A 2x2 pixels image will be enlarged 2 times by the nearest neighbor method:

1. Lay an imaginary 4*4 grid over the original image..


2. For any point in the overlay, look for the closest pixel in the original image, and assign its gray level to the
new pixel in the grid. (copy)
3. When all the new pixels are assigned values, expand the overlay grid to the original specified size to obtain
the zoomed image.

• Pixel replication (re sampling) is a special case that is applicable when the size of the image needs to be
increased an integer number of times (like 2 times not 1.5 for example).

ve : Nearest neighbor is fast +


ve: it produces a checkerboard effect like-
!this

65
Image Algebra
There are two primary categories of algebraic
:operations applied to image
.Arithmetic operations -1
Logic operations -2

Addition, subtraction, division and multiplications


comprise the arithmetic operations, while AND, OR
and NOT makeup the logic operations. These
operations which require only one image, and are
.done on a pixel –by-pixel basis
66
67
Subtraction of two images is often used to detect
motion consider the case where nothing has changed in
a sense; the image resulting from subtraction of two
sequential image is filled with zero-a black image. If
something has moved in the scene, subtraction
produces a nonzero result at the location of movement.
Applications include Object tracking , Medical imaging,
Law enforcement and Military applications
Multiplication and Division are used to adjust the
brightness of an image. One image typically consists of a
constant number greater than one. Multiplication of the
pixel values by a number greater than one will darken
the image (Brightness adjustment is often used as a
.processing
68
step in image enhancement)
69
a. Original image b. Image divided by value<1 c. Image divided by value >1

.Image Division

70
Logic operations
logic operations AND, OR and NOT form a complete set, meaning that
any other logic operation (XOR, NOR, NAND) can be created by a
combination of these basic elements. They operate in a bit-wise
.fashion on pixel data

71
Example: A logic AND is performed on two images, suppose
the two corresponding pixel values are (111)10 is one image
and (88)10 in the second image. The corresponding bit
:strings are
011011112 10)111(
AND 010110002 (88)10
---------------------------
01001000
The logic operation AND and OR are used to combine the
information in two images. They may be done for special
effects, but a more useful application for image analysis is to
perform a masking operation. Use AND and OR as a simple
method to extract a Region of Interest from an image, if
.more sophisticated graphical methods are not available

72
Example: A white square ANDed with an image
will allow only the portion of the image
coincident with the square to appear in the
output image with the background turned black;
and a black square ORd with an image will allow
only the part of the image corresponding to the
black square to in the output image but will turn
.the rest of the image white
This process is called image masking. The NOT
operation creates a negative of the original
image, by inverting each bit within each pixel
.value

73
A. Original image b. Image mask c. ANDing a and
))(AND) d. Image mask e. ORing a and d
b (OR)

Image masking

Complement Image
.b. Image after NOT operation
a. Original image

74
Image Restoration: Image restoration methods are
used to improve the appearance of an image by
application of a restoration process that use
.mathematical model for image degradation

:Example of the type of degradation


Blurring caused by motion or atmospheric -1
.disturbance
.Geometrics distortion caused by imperfect lenses -2
Superimposed interference patterns caused by -3
.mechanical systems
Noise from electronic source -4

75
?What is noise
Noise is any undesired information that contaminates an
image. Noise appears in image from a variety of source.
The digital image a acquisition process, which converts an
optical image into a continuous electrical signal that is then
sampled is the primary process by which noise appears in
.digital images
At every step in the process there are fluctuations caused
by natural phenomena that add a random value to exact
brightness value for a given pixel. In typical image the noise
:can be modeled with one of the following distribution
.Gaussian (“normal”) distribution -1
.Uniform distribution -2
76
.Salt _and _pepper distribution -3
.Image Noise

77
Noise Removal using Spatial Filters
:Spatial filtering is typically done for
.Remove various types of noise in digital images
.Perform some type of image enhancement
These filters are called spatial filter to distinguish them[
.]from frequency domain filter
:The three types of filters are
Mean filters
Median filters (order filter)
Enhancement filters

78
Mean and median filters are used primarily to
conceal or remove noise, although they may also
be used for special applications. For instance, a
mean filter adds “softer” look to an image. The
enhancement filter high lights edges and details
.within the image
Spatial filters are implemented with convolution
masks. Because convolution mask operation
provides a result that is weighted sum of the
values of a pixel and its neighbors, it is called a
.linear filter 79
Image Enhancement & Restoration

Enhancement techniques are employed


essentially to get better quality picture and not
necessarily the original object from the
.degraded scene like Restoration techniques

80
Image Enhancement & Restoration

• Spatial image enhancement techniques


(noise reduction)
– Spatial low-pass, high-pass & band-pass
filtering
– Unsharp masking & crisping
– Directional smoothing
– Median filtering

81
Arithmetic mean filter smoothing or
low-pass filter.

1⁄9 1⁄9 1⁄9

1⁄9 1⁄9 1⁄9


1⁄9 1⁄9 1⁄9

82
83
Unsharp masking

84
The median filter

The median filter is a non linear filter (order filter). These


filters are based on as specific type of image statistics
called order statistics. Typically, these filters operate on
small sub image, “Window”, and replace the centre pixel
value (similar to the convolution process).
Order statistics is a technique that arranges the entire
pixel in sequential order, given an NXN window (W) the
pixel values can be ordered from smallest to the largest.
I1 ≤ I2 ≤ I3...…………………< IN
Where I1, I2, I3...……, IN are the intensity values of the
subset of pixels in the image

85
a. Salt and pepper noise b. Median filtered image (3x3)

86
Example of Median Filter
Example:
Given the following 3X3 neighborhood
5 5 6
3 4 5
3 4 7
We first sort the value in order of size (3,3,4,4,5,5,5,6,7) ; then we select
the middle value ,in this case it is 5. This 5 is then placed in centre
location.
A median filter can use a neighbourhood of any size, but 3X3, 5X5 and
7X7 are typical. Note that the output image must be written to a
separate image (a buffer); so that the results are not corrupted as this
process is performed.
(The median filtering operation is performed on an image by applying
the sliding window concepts, similar to what is done with convolution).
The window is overlaid on the upper left corner of the image, and the
median is determined. This value is put into the output image (buffer)
corresponding to the centre location of the window. The window is then
slide one pixel over, and the process is repeated.

87
Note that the outer rows and columns are not replaced. In
practice this is usually not a problem due to the fact that the
images are much larger than the masks. And these “wasted”
rows and columns are often filled with zeros (or cropped off
the image). For example, with 3X3 mask, we lose one outer
row and column, a 5X5 mask we lose two rows and columns.
This is not visually significant for a typical 256 X 256 or
512X512 images.
The maximum and minimum filters are two order filters that
can be used for elimination of salt- and-pepper noise. The
maximum filter selects the largest value within an ordered
window of pixels values; where as the minimum filter selects
the smallest value.
88
In a manner similar to the median, minimum and
maximum filter, order filter can be defined to select a
specific pixel rank within the ordered set. For
example we may find for certain type of pepper
noise that selecting the second highest values
works better than selecting the maximum value. This
type of ordered selection is very sensitive to their
type of images and their use it is application
specific. It should note that, in general a minimum or
low rank filter will tend to darken an image and a
maximum or high rank filter will tend to brighten an
image.
89
The Enhancement filter
.Laplacian type -1 •
.Difference filter -2 •
.These filters will tend to bring out, or enhance details in the image •
:Example of convolution masks for the Laplacian-type filters are •
2- 1 2- 1- 1- 1- 0 1- 0
1 5 1 1- 9 1- 1- 5 1-
2- 1 2- 1- 1- 1- 0 1- 0
.The Laplacian type filters will enhance details in all directions equally •

90
Laplacian filter

91
Example :Describe the effects of High pass filter on the
? image
30 3 30
3 30 3
30 3 3

Sol
+ )1-(3 + )5(30 + )1-(3 + )0(30 + )1-(3 + )0(30
)0(30 + )1-(3 + )0(3

150 + 12- = 0 + 3 - 0 + 3 – 150 + 3 - 0 + 3 - 0 =


138 =

92
Image quantization
Image quantization is the process of reducing the image data •
by removing some of the detail information by mapping
:group of data points to a single point. This can be done by
.Gray_Level reduction (reduce pixel values themselves I(r, c) •
.Spatial reduction (reduce the spatial coordinate (r, c) •
The simplest method of gray-level reduction is Thresholding. •
We select a threshold gray _level and set everything above
that value equal to “1” and everything below the threshold
equal to “0”. This effectively turns a gray_level image into a
binary (two level) image and is often used as a preprocessing
step in the extraction of object features, such as shape, area,
or parameter

93
Cont. Image quantization
A more versatile method of gray _level reduction is the process
of taking the data and reducing the number of bits per pixel.
This can be done very efficiency by masking the lower bits via
an AND operation. Within this method, the numbers of bits
.that are masked determine the number of gray levels available
:Example
We want to reduce 8_bit information containing 256 possible
.gray_level values down to 32 possible values
This can be done by ANDing each 8-bit value with the bit string
1111000. this is equivalent to dividing by eight(32),
corresponding to the lower three bits that we are masking and
then shifting the result left three times. [Gray _level in the
image 0-7 are mapped to 0, gray_level in the range 8-15 are
.mapped to 8 and so on]
94
Edge Detection
Detecting edges is a basic operation in image processing. The
edges of items in an image hold much of the information in
.the image
:The edges tell you where
.Items are
.Their size
shape
.and something about their texture
Edge detection methods are used as a first step in the line
detection processes, and they are used to find object
boundaries by marking potential edge points corresponding to
place in an image where rapid changes in brightness occur.
After these edge points have been marked, they can be
merged to form lines and objects outlines
95
.Edge Detection Cont
Sobel Operator: The Sobel edge detection masks look for edges in -1
both the horizontal and vertical directions and then combine this
:information into a single metric. The masks are as follows

Column Mask Row Mask


1 0 1- 1- 2- 1-
2 0 2- 0 0 0
1 0 1- 1 2 1

These masks are each convolved with the image. At each pixel location we
now have two numbers: S1, corresponding to the result form the row
mask and S2, from the column mask. We use this numbers to compute
two matrices, the edge magnitude and the edge direction, which are
:defined as follows
=Edge Magnitude S1ˆ2 + S2 ˆ2

Edge Direction = Tan -1 S1


96 S2
EXAMPLE Sobel Filter
?Ex. decribe the effects of Laplace and Sobel filters on the image
200 20 10
200 20 10
200 20 10

Solution : 1- Laplace 0 -1 0
1- 4 1-
0 1- 0
+ )0(10 + + )1-(200 + )4(20 + )1-(10 + )0(200+ )1-(20 + )0(10 =
170- = )0(200 + )1-(20
Sobel Mask(row) -1 -2 -1 Mask (column) -1 0 1 -2
2- 0 0 0
2 0
1 1 2 1
1 2
S1 = 10(-1) + 20(-2) +200(-1) + 10(0) + 20(0) + 200(0) +10(1)+20(2) +200(1)
0=
97
S2 = 10(-1) +20(0) +200(1)+10(-2)+20(0)+200(2) +10(-1)+20(0)+200(1)
.Edge Detection Cont
:
=Edge Magnitude
S1ˆ2 + S2 ˆ2

= 2ˆ 760 + 2ˆ 0
760 =

Edge Direction = Tan -1 S1


S2
Tan -1 = 0

7600
tan-1(0) =

98
Laplacian Operators

The Laplacian operator described here are similar to


the ones used for pre-processing (as described in
enhancement filter). The three Laplacian masks that
follow represent different approximation of the
Laplacian masks are rationally symmetric, which
means edges at all orientation contribute to the
result. They are applied by selecting one mask and
convolving it with the image selecting one mask and
.convolving it with the image

99
.Laplacian Operators Cont
1 2- 1 0 1- 0
1- 1- 1-
2- 4 2- 1- 4 1-
1- 8 1-
1 2- 1 0 1- 0
1- 1- 1-
These masks differ from the Laplacian type previously described
in that the centre coefficients have been decreased by one. So, if
we are only interested in edge information, the sum of the
coefficients should be zero. If we want to retain most of the
information the coefficient should sum to a number greater than
zero. Consider an extreme example in which the center
coefficient value will depend most heavily up on the current
value,
100
with only minimal contribution from surrounding pixel

You might also like