Uploaded by jotir71803

Unit1 VKB DIVP

advertisement
Shri Sant Gajanan Maharaj College of Engineering Shegaon,
Maharashtra, India
Digital Image and Video Processing
By
Prof. V. K. Bhangdiya
Department of Electronics and Telecommunication
Institute Vision
To impart world-class Engineering and Management education in an
environment of spiritual foundation to serve the global society .
Institute Mission
M1
M2
M3
M4
To develop excellent learning center through continuous design and
up gradation of courses in closed interaction with R&D centers,
Industries and Academia.
To produce competent, entrepreneurial and committed technical and
managerial human, with Spiritual foundation to serve the society
To develop state-of-the -art infrastructure, centers of excellence and
to pursue research of global and local relevance.
To inculcate ethical, spiritual and human values to serve the global
society.
Department Vision
To impart quality education and excel in Electronics and Telecommunication
Engineering research to serve the global society.
Department Mission
M1
To develop excellent learning center through continuous interaction
with Industries, R&D centers and Academia.
M2
To produce competent, entrepreneurial and committed Electronics
and Telecommunication Engineers.
M3
M4
To develop state-of-the -art infrastructure, centers of excellence and
to pursue research of global and local relevance.
To inculcate ethical, spiritual and human values to serve the global
society.
Program Outcomes (POs)
Engineering Graduates will be able to






PO1 - Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals, and an
engineering specialization to the solution of complex engineering problems.
PO2 - Problem analysis: Identify, formulate, review research literature, and analyze complex engineering problems
reaching substantiated conclusions using first principles of mathematics, natural sciences, and engineering sciences.
PO3 - Design/development of solutions: Design solutions for complex engineering problems and design system
components or processes that meet the specified needs with appropriate consideration for the public health and safety,
and the cultural, societal, and environmental considerations.
PO4 - Conduct investigations of complex problems: Use research-based knowledge and research methods
including design of experiments, analysis and interpretation of data, and synthesis of the information to provide valid
conclusions.
PO5 - Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern engineering and
IT tools including prediction and modeling to complex engineering activities with an understanding of the limitations.
PO6 - The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal, health,
safety, legal and cultural issues and the consequent responsibilities relevant to the professional engineering practice.






PO7 - Environment and sustainability: Understand the impact of the professional engineering solutions in societal
and environmental contexts, and demonstrate the knowledge of, and need for sustainable development.
PO8 - Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of the
engineering practice.
PO9 - Individual and team work: Function effectively as an individual, and as a member or leader in diverse teams,
and in multidisciplinary settings.
PO10 -Communication: Communicate effectively on complex engineering activities with the engineering
community and with society at large, such as, being able to comprehend and write effective reports and design
documentation, make effective presentations, and give and receive clear instructions.
PO11 -Project management and finance: Demonstrate knowledge and understanding of the engineering and
management principles and apply these to one’s own work, as a member and leader in a team, to manage projects and
in multidisciplinary environments.
PO12 -Life-long learning: Recognize the need for, and have the preparation and ability to engage in independent and
life-long learning in the broadest context of technological change.
Program Specific Outcomes (PSOs)


PSO1 Students will be able to apply the fundamental and design knowledge in the areas of analog and digital circuits
and systems for solving the real world engineering problems
PSO2 Students will be able to apply the fundamental knowledge for the analysis and development of communication
based circuits and systems
Welcome to Wonderful World of
Image Processing
7
Lecture 1




Teaching objectives
Scope of the subject
Introduction to syllabus
references
Teaching Objectives
By the end of this semester, you will
– Grasp the basics of digital image processing and its
connections to other scientific and technological fields such as
psychology, morphology, photography, astronomy and so on.
– Understand various basic image processing concepts and
algorithms.
– Be able to use MATLAB as a tool of simulation and solving
problems.
– Understand the basics of digital video processing
9
Overview: Computer Imaging

Definition of computer imaging:


Acquisition and processing of visual information by computer.
Why is it important?



Human primary sense is visual sense.
Information can be conveyed well through images (one picture
worth a thousand words).
Computer is required because the amount of data to be
processed is huge.
Overview: Computer Imaging

Computer imaging can be divided into two main
categories:



Computer Vision: applications of the output are for use by a
computer.?
Image Processing: applications of the output are for use by
human. ?
These two categories are not totally separate and distinct.
Overview: Computer Imaging

They overlap each other in certain areas.
COMPUTER IMAGING
Computer
Vision
Image
Processing
Computer Vision

Does not involve human in the visual loop.

One of the major topic within this field is image analysis

Image analysis involves the examination of image data to
facilitate in solving a vision problem.
Computer Vision

Image analysis process involves two other topics:

Feature extraction: acquiring higher level image info (shape and
color)

Pattern classification: using higher level image information to
identify objects within image.
Computer Vision

Examples of applications of computer vision:






Quality control (inspect circuit board).
Hand-written character recognition.
Biometrics verification (fingerprint, retina, DNA, signature, etc).
Satellite image processing.
Skin tumor diagnosis.
And many, many others.
Image Processing

Processed images are to be used by human.

Therefore, it requires some understanding on how the human
visual system operates.

Among the major topics are:

Image enhancement (unit 2).

Image Segmentation (unit 3).

Image compression (unit 4).
Image Processing

Image enhancement:

Improve an image visually by taking an advantage of human
visual system’s response.

Example: improve contrast, image sharpening, and image
smoothing.
Image Processing

Image compression:


Remove the amount of data required to represent an image by:

Removing unnecessary data that are visually unnecessary.

Taking advantage of the redundancy that is inherent in most images.
Example: JPEG, MPEG, etc.
Image Enhancement
Image Resoration
An Example of Image Restoration
IMAGE COMPRESSION
 Video compression
IMAGE SEGMENTATION
Microsoft multiclass segmentation data set
Image Inpainting
Interactively select objects. Remove them and automatically
fill with similar background (from the same image)
I. Drori, D. Cohen-Or, H. Yeshurun, SIGGRPAH’03
More Examples
Object Detection / Recognition
Content-Based Image Retrieval
Visual Mosaicing

Stitch photos together without thread or scotch tape
Visible Digital Watermarks
from IBM Watson web page
“Vatican Digital Library”
Invisible Watermark


Original, marked, and their amplified luminance difference
human visual model for imperceptibility: protect smooth areas and sharp edges
Why Image processing?
Principle application areas
*Human interpretation
*Machine perception
Human vision is limited to visual band only
Machine covers almost entire EM spectrum from radio to gamma rays
Why Do We Process Images?

Enhancement and restoration

Remove artifacts and scratches from an old photo/movie

Improve contrast and correct blurred images

Composition (for magazines and movies), Display, Printing …

Transmission and storage


images from oversea via Internet, or from a remote planet
Information analysis and automated recognition

Providing “human vision” to machines

Medical imaging for diagnosis and exploration

Security, forensics and rights protection
Why Digital?



“Exactness”

Perfect reproduction without degradation

Perfect duplication of processing result
Convenient & powerful computer-aided processing

Can perform sophisticated processing through computer hardware or software

Even kindergartners can do some!
Easy storage and transmission

one pen drive can store hundreds of family photos!

Paperless transmission of high quality photos through network within seconds
So What’s a Digital Image After All?
A Physical Perspective of Image Acquisition

Extend the capabilities of human vision systems


34
From visible spectrum to non-visible electromagnetic power
spectrum
From close-distance sensing to remote sensing
Medical Images
The absorption characteristics of human
body tissues
Multispectral Satellite Images
Radar cross section
Image Processing in Manufacturing
Some examples of manufactured goods checked using digital image processing. (a) Circuit board controller. (b)
Packaged pills. (c) Bottles. (d) Air bubbles in a clear plastic product. (e) Cereal. (f) Image of intraocular implant.
Radar Image
Spaceborne radar image of mountainous region in southeast Tibet.
Visible (I): Photography
Which camera is the most expensive,
Leica M8, Canon 40D or Nikon D700?
Visible (II): Motion Pictures
40
Visible (III): Biometrics and Forensics
You=ID
41
Visible (IV): Light Microscopy
42
Taxol (250)
Anti Cancer Agent
Cholesterol (40) Microprocessor (60)
Visible (V): Remote Sensing
Earth at night (Only Asia/Europe shown)
43
Beyond Visible (I): Thermal Images
Operate in infrared frequency
Human body disperses
heat (red pixels)
44
Autoliv’s night vision system
on the BMW 7 series
Beyond Visible (II): Radar Images
Operate in microwave frequency
45
Beyond Visible (III): MRI and Astronomy
knee
46
spine
head
Beyond Visible (IV): Fluorescence Microscopy
Operate in ultraviolet frequency
47
normal corn
smut corn
Beyond Visible (V): Medical Diagnostics
Operate in X-ray frequency
chest
48
head
Other Non-Electro-Magnetic Imaging Modalities

Acoustic imaging


Electron microscopy


Shine a beam of electrons through a speciman
Synthetic images in Computer Graphics

49
Translate “sound waves” into image signals
Computer generated (non-existent in the real world)
Acoustic Imaging
visible
seismic
potential locations of oil/gas
50
Electron Microscope
51
2500 Scanning Electron Microscopy (SEM) image of
damaged integrated circuit
(white fibers are oxides resulting from thermal destruction)
Cartoon Pictures (Non-photorealistic)
52
Hayao Miyazaki’2008
Synthetic Images in Gaming
53
Warcraft III by Blizzard
Virtual Reality (Photorealistic)
54
Graphics in Art
55
Mixture of Graphics and Photos
56
Morgantown, WV in Google Map
Summary: Importance of Visual Information

Various imaging modalities help us to see invisible
objects due to





57
Opaqueness (e.g., see through human body)
Far distance (e.g., remote sensing)
Small size (e.g., light microscopy)
Other signals (e.g., seismic) can also be translated into
images to facilitate the analysis
Images are important to convey information and support
reasoning
A picture is worth a thousand words!
Toward the Future: Nano-scale Imaging
New imaging technology that
can reveal fine structures at the
nano scale is going to be useful
In biology (e.g. protein sequencing
and folding)
58
Tour Guide
Image
Acquisition
D.I.P.
Theme
Park
Image
Compression
Image
Manipulation
Image
Display
59
Image
Generation
Image
Analysis
Image
Perception
Introduction to Syllabus
UNIT I
 Digital Image Fundamentals
Elements of visual perception, image as a 2-D signal, image sensing and acquisition, image
sampling and quantization, image formats, image types, basic relationships between pixels
neighborhood, adjacency, connectivity, distance measures.
UNIT II
 Image Enhancements and Filtering in Spatial and Frequency domain:
Gray level transformations, histogram equalization and specifications, spatial-domain smoothing
filters – linear and order-statistics, spatial-domain sharpening filters: first and second derivative,
two-dimensional DFT and its inverse, frequency domain filters low-pass and high-pass.
UNIT III
 Image Segmentation and Image morphological techniques
Detection of discontinuities, Thresholding : local and global, region-based segmentation, edge and
boundary detection techniques using Laplace, Gaussian and high pass filtering, Basic
morphological image processing concepts, Basic concepts of erosion and dilation, The Hit-or-Miss
Transformation.
Syllabus Cont…
UNIT IV
 Image restoration and Compression techniques.
Image degradation and restoration technique (Wiener filtering), Image Compression Redundancy–
inter-pixel, psycho-visual and coding, entropy, Loss less compression (Huffman and Lempel-Ziv),
Lossy compression- predictive and transform coding; Still image compression standards – JPEG
and JPEG-2000
UNIT V
 Fundamentals of Video Processing.
Time-Varying Image Formation model, fundamentals of Three-Dimensional Motion Model, Geometric
Image Formation, Photometric Image Formation, Sampling of Video signals in spatial domain,
formats of video signals.
UNIT VI
 Applications of digital video processing.
Motion estimation using pixel based, block matching and mesh based, Application of motion
estimation in video coding, Fundamentals of Temporal segmentation, Video object detection and
tracking.
BOOKS
Text Books :
1. “Gonzaleze and Woods ,”Digital Image Processing “, 3rd edition , Pearson
2. S. Jayaraman, S. Esakkirajan, T. Veerakumar,”Digital Image Processing “, 2nd edition, McGraw Hill publication
3. M. Tekalp ,”Digital video Processing”, Prentice Hall International
4. Yao wang, Joem Ostarmann and Ya – quin Zhang, ”Video processing and communication “, 1st edition , PHI
Reference Books :
1)“ Fundamental Digital Image Processing “by A.K.Jain –Prentics Hall Inc.
2)“Digital Image Processing” By W.K Pratt IIIrd ed John Wiley
3) “Digital Image Processing and Analysis” by B Chanda and D. Mujumdar-PHI new Delhi
lecture2




Basic image processing steps
Image as function
Image as matrix
Introduction to MATLAB image processing
Basic image processing steps
Image Formation




For natural images we need a light source (with wavelength
λ)
E(x; y; z; λ ¸): incident light on a point
Each point in the scene has a reflectivity function.r(x; y; z; λ ¸)
Light reflects from a point and the reflected light is captured
by an imaging device.
c(x; y; z; λ ¸) = E(x; y; z; λ ¸) X r(x; y; z; λ ¸): reflected light.
Electromagnetic spectrum
Usually we will assume that source of radiation is within
visible light frequency
Image in non-visible spectrum

Gamma rays (medicine, astronomy etc).

X-rays (medicine, electronic industry, astronomy)

Ultraviolet spectrum (lithography, industrial inspection,
microscopy, lasers, biological imaging, astronomy)

Infrared spectrum (the same application area as in visible spectrum
plus food industry, satellite observations, industrial)

Radio waves (medicine, astronomy)
Definition of Image
y

An Image may be defined as a two dimensional
function f(x,y)

Where x and y are spatial (Plane)Coordinates

Amplitude of f(x,y) at any pair of coordinate
(x,y)is called Intensity or gray level of the image
at that point
x

* find one mistake on this page
Y
X
Digital Image

When x,y and amp(f(x,y) are all finite ,discrete quantities
Image is a Digital Image

Thus a digital image is composed of finite number of
elements(pixels) having particular location and value.
INTRODUCTION TO MATLAB FOR DIP
Introduction to reading and displaying image
imread
imshow
imview
imtool
understanding properties of image
Size
dimension
lecture3

Human visual system
Structure of eye
Cornea --- Outer tough transparent
membrane, covers anterior surface.
Sclera --- Outer tough opaque
membrane, covers rest of the optic
globe.
Choroid --- Contains blood vessels,
provides nutrition.
Iris --- Anterior portion of choroid, it
control the amount of light entering the
eye by contraction and expansion.
Varies in diameter between 2-8 mm
Structure of eye
Pupil --- Central opening of the Iris,
controls the amount of light entering the
eye (diameter varies 2-8 mm).
Lens --- Made of concentric layers of
fibrous cells, contains 60-70% water.
Retina --- Innermost layer, “screen” on
which image is formed by the lens
when properly focused, contains
photoreceptors (cells sensitive to light).
Two types of photoreceptors: rods and
cones (light sensors).
Synaptic endings
Cell nucleus
Inner segments
Rods and Cones
Outer segments
Rod






75-150 million, distributed over the
entire retina,
Highly sensitive to low light level or
scotopic conditions.
Black and white.
Dispersed in the periphery of the
retina.
Rods have multiple sensors tied to
each nerve.




Cone
6-7 million, located in central portion of
retina (fovea)
Sensitive to high light level or photopic
conditions.
Three types of cones responsible for color
vision.
Concentrated in the fovea.
It have higher resolution than rods
because they have individual nerves tied
to each sensor.
Structure of eye
Fovea --- Circular indentation in the
retina of about 1.5mm diameter, dense
with cones.
• Photoreceptors around fovea
responsible for spatial vision
(still images).
• Photoreceptors around the periphery
responsible for detecting motion.
Blind Spot --- The absence of receptors
in this area
Distribution of rods and cones in the retina.
Image formation

Lens of eye is flexible

Shape of the lens is controlled by tension in the fibers of the
ciliary body

To focus on distant object lens is flattened
Steps

Light come to iris.

Photosensitive muscles adjust size of iris and regulates
amount of light allowed in eye.

Light falls on the lens, Other group of muscles adjust
lens in order to give appropriate focusing of image.

Light passes through the posterior compartment

Light falls on retina

Light should come to the exact position on the
• Light is transformed in visual cells to electric impulses.
•On relatively small distance from the yellow spot is so called blind
spot. It is position where optical nerve exits.
•This nerve is connected with the brain. Optical nerve is connected
with visual cells with ganglions.
•This nerve “integrate” outputs of visual cells.
Focal length: distance between the center of the lens and retina
When eye focuses on nearby objects- lens is strongly refractive
For the situation shown
If h is the height of object in retinal image
15/100 = h/17
h= 2.55 mm
Brightness adaptation
Range of light intensity for HVS is
very large about 10 10
Visual system cannot operate over
the complete range simultaneously
Brightness adaptation is variation
in sensitivity to adapt the intensity
level
Actual/perceived brightness
Illustration of the Mach band
effect.
Perceived intensity is not a
simple function of actual
intensity.
Simultaneous contrast
Perceived brightness does not simply depend on its intensity.
Optical illusions
The visible spectrum can be
divided into three bands:
Blue (400 to 500 nm).
Green (500 to 600 nm).
Red (600 to 700 nm).
Visible spectrum extends between 0.4µm- 0.7 µm
λ = c/f ;
c = 3x108
Luminance: measure of amount of energy an observer perceives.
Brightness: subjective descriptor of light perception that is practically impossible
to measure
Image Sensing and Acquisition




Single sensor
Line scan
Array sensor
Other (MRI, Ultrasound)

Sensors:
(a) Single sensing element.
(b) Line sensor.
(c) Array sensor.
Single sensor
Combining a single
sensing element with
mechanical motion to
generate a 2-D image.
Sensor strip
(a) Image acquisition
using a linear sensor
strip.
(b) Image acquisition
using a circular
sensor strip.
Digital image acquisition
(a) Illumination (energy) source.
(b) A scene.
(c) Imaging system.
(d) Projection of the scene onto the
image plane.
(e) Digitized image.
A (2D) Image
An image = a 2D function f(x,y) where
• x and y are spatial coordinates
• f(x,y) is the intensity or gray level
o
y
An digital image:
• x, y, and f(x,y) are all finite
• For example x 1,2,…, M  ,
x
y 1,2,…, N
f (x, y) 0,1,2,…,255
Digital image processing  processing digital images by means of a digital computer
Each element (x,y) in a digital image is called a pixel (picture element)
A Simple Image Formation Model
f ( x, y)  i( x, y)  r ( x, y)
0  f (x,y)   : Image (positive and finite)
Source: 0  i(x,y)   :
Illumination component
Object: 0  r(x,y)  1:
Reflectance/transmission component
Lmin  f (x,y)  Lmax
in practice
where Lmin  iminrmin and Lmax  imax rmax
i(x,y):
Sunlight: 10,000 lm/m2 (cloudy), 90,000lm/m2 clear day
Office: 1000 lm/m2
r(x,y):
Black velvet 0.01; white pall 0.8; 0.93 snow
Sampling and Quantization
• Spatial Resolution (Sampling)
– Determines the smallest perceivable image detail.
– What is the best sampling rate?
• Gray-level resolution (Quantization)
– Smallest discernible change in the gray level value.
– Is there an optimal quantizer?
Image sampling and quantization
Sampling
1-D Sampling
Signal Reconstruction from Samples
2-D Sampling
2-D Sampling
y
x
Image Quantization
Comb(x, y; x, y) 
Image Sampling and Quantization
(a) Continuous image.
(b) A scan line showing intensity
variations along line AB in the
continuous image.
(c) Sampling and quantization.
(d) Digital scan line.

Digital image has a
finite number of
pixels and levels
Image Sampling and Quantization in a
Sensor Array
(a)Continuous image
projected onto a sensor
array.
(b) Result of image
sampling and
quantization.
Representing Digital
Images
(a): f(x,y), x=0, 1, …, M-1, y=0,1, …, N-1
x, y: spatial coordinates  spatial domain
(b): suitable for visualization
(c): processing and algorithm development
x: extend downward (rows)
y: extend to the right (columns)
Dynamic Range
Lmin  f (x,y)  Lmax
in practice
where Lmin  iminrmin and Lmax  imax rmax
0  f (x,y)  L1
and
L  2k
Dynamic range in photography
describes the ratio between the
maximum and minimum measurable
light intensities (white and black,
respectively)
Spatial Resolution
Spatial resolution: smallest discernible details
• # of line pairs per unit distance
• # of dots (pixels) per unit distance
• Printing and publishing
• In US, dots per inch (dpi)
Newspaper
magazines
book
Large image size itself does not mean high
spatial resolution!
Scene/object size in the image
1280*960
http://www.shimanodealer.com/fishing_reports.htm
Effects of reducing spatial resolution.
(a) 930 dpi, (b) 300 dpi,
(c) 150 dpi, and (d) 72 dpi.
IMAGE TYPES
The Image Processing defines four basic types of images1.
2.
3.
4.
Binary Image (Also known as a two-level image)
Indexed Image (Also known as a pseudo-color image)
Grayscale Image (Also known as an intensity, gray scale, or gray
level image)
True-color (Also known as an RGB image )
These image types determine the way MATLAB interprets data matrix
elements as pixel intensity values.
109
Vector (Shapes)
vs.
Raster (Pixels)
Objectives:
1. Identify the difference between vector
and raster file formats
2. Explain the applications of the two
image formats
Raster Image Files
-constructed by a series of pixels, or
individual blocks, to form an image.
-JPEG, GIF, BMP, PNG ,etc.
-when the pixels are stretched to fill space
they were not originally intended to fit, they
become distorted, resulting in blurry or
unclear images.
Pixels

Pixels: individual squares on a grid
that makes up an image. Each
square is made up of a color.
Raster Editing Tools


Resolution: identifies the number of
pixels. Often described using dots
per inch (dpi) or pixels per inch (ppi)


Web Resolution: 72 dpi
Print Resolution: 200-300 dpi



Microsoft Paint (licensed)
Adobe Photoshop (licensed)
Gimp (open source)
Paint.Net (open source)
Vector Image Files
They are constructed using proportional
formulas rather than pixels.
-
EPS, AI ,PDF , etc…
- is made up of lines and filled areas
only, which are mathematically drawn
and calculated (hence the term vector)
by the software you use.
Editing Tools
•Illustrator (.AI)*
•Encapuslated PostScript (.EPS)*
•PostScript (.PS)*
•Scalable
Vector
Graphic
Vector/Raster When and Why?


If you are working with mainly solid color objects,
manipulated text or many small objects, the clear
answer is that a VECTOR program will save you
time.
If you are working with complicated drop shadows, or
other 3D effects, texture or photographs, RASTER is
the correct choice.
Examples
Binary Image
(Also known as a two-level image)
Logical array containing only 0s
and 1s, interpreted as black and
white, respectively.
117
Indexed Image
(Also known as a pseudo-color image)
Array of class logical, uint8, uint16, single, or
double whose pixel values are direct indices into
a color-map.
The color-map is an m-by-3 array of class
double.
For single or double arrays, integer values range
from [1, p].
For logical, uint8, or uint16 arrays, values range
from [0, p-1].
118
Grayscale Image
(Also known as an intensity, gray scale, or gray level image)
Array of class uint8, uint16, int16, single,
or double whose pixel values specify
intensity values.
- For uint8, values range from [0,255].
- For uint16, values range from [0,65535].
- For int16, values range fro
[-32768, 32767].
119
True-color – Primary color Images
(Also known as an RGB image )
m-by-n-by-3 array of class uint8,
uint16, single, or double whose pixel
values specify intensity values.
- For uint8, values range from [0, 255].
- For uint16, values range from [0, 65535].
IMAGE Formats
MATLAB supports the following graphics file formats,
along with some others:








BMP (Microsoft Windows Bitmap pixel, .bmp)
GIF (Graphics Interchange Files,
.gif)
HDF (Hierarchical Data Format,
.hdf)
JPEG (Joint Photographic Experts Group, .jpg)
PCX (Paintbrush,
.pcx)
PNG (Portable Network Graphics,
.png)
TIFF (Tagged Image File Format,
.tif)
XWD (X Window Dump,
.xwd)
Basic Relationships

Neighbors and Neighborhoods

Adjacency & connectivity

Region and Boundary

Distance measures

Basic Logical Operation
Neighbors of a Pixel

A pixel p at coordinates (x,y) has four horizontal and vertical neighbors
whose coordinates are given by:
(x+1,y), (x-1, y), (x, y+1), (x,y-1)
(x-1, y)
(x, y-1)
P (x,y)
(x, y+1)
(x+1, y)
This set of pixels, called the 4-neighbors of p, is denoted by N4(p).
Each pixel is one unit distance from (x,y) and some of the neighbors of p lie
outside the digital image if (x,y) is on the border of the image.
Neighbors of a Pixel

The four diagonal neighbors of p have coordinates:
(x+1, y+1), (x+1, y-1), (x-1, y+1), (x-1, y-1)
and are denoted by ND (p).
(x-1, y-1)
(x-1, y+1)
P (x,y)
(x+1, y-1)
(x+1, y+1)
together with the 4-neighbors N4(p), and diagonal neighbors ND (p) are called 8-neighbors of p,
denoted by N8 (p).
(x-1, y-1)
(x-1, y)
(x-1, y+1)
(x, y-1)
P (x,y)
(x, y+1)
(x+1, y-1)
(x+1, y)
(x+1, y+1)
As before, some of the points in ND (p) and N8 (p) fall outside the image if (x,y) is on the border of the
image.
Adjacency and Connectivity

Let V: a set of intensity values used to define adjacency and
connectivity.

In a binary image, V = {1}, if we are referring to adjacency of
pixels with value 1.

In a gray-scale image, the idea is the same, but V typically
contains more elements, for example, V = {180,181, …, 200}

If the possible intensity values 0 – 255, V set can be any
subset of these 256 values.
Adjacency and Connectivity
Two pixels are connected if they are neighbors and their gray
levels satisfy some specified criterion of similarity.
Example: in a binary image two pixels are connected if they are
4-neighbors and have same value (0/1).
Types of Adjacency
1.
4-adjacency: Two pixels p and q with values from V are
4-adjacent if q is in the set N4(p).
2.
8-adjacency: Two pixels p and q with values from V are
8-adjacent if q is in the set N8(p).
3.
m-adjacency =(mixed)
4-adjacency
8-adjacency
0
1
1
0
1
1
0
1
1
0
1
0
0
1
0
0
1
0
0
0
1
0
0
1
0
0
1
Set of Pixels 4-Adjacency
8-Adjacency
m-adjacency:
Two pixels p and q with values from V are m-adjacent if :


q is in N4(p) or
q is in ND(p) and the set N4(p) ∩ N4(q) has no pixel whose values are
from V (no intersection)
0
1
1
0
1
1
0
1
1
0
1
1
0
1
0
0
1
0
0
1
0
0
1
0
0
0
1
0
0
1
0
0
1
0
0
1
Set of Pixels 4-Adjacency
8-Adjacency
m-Adjacency
Mixed adjacency is a modification of 8-adjacency. It is introduced to eliminate
the ambiguities that often arise when 8-adjacency is used.
A Digital Path




A digital path (or curve) from pixel p with coordinate (x,y)
to pixel q with coordinate (s,t) is a sequence of distinct
pixels with coordinates (x0,y0), (x1,y1), …, (xn, yn)
where (x0,y0) = (x,y) and
(xn, yn) = (s,t) and
pixels (xi, yi) and (xi-1, yi-1) are adjacent for 1 ≤ i ≤ n
n is the length of the path
If (x0,y0) = (xn, yn), the path is closed.
We can specify 4-, 8- or m-paths depending on the type of
adjacency specified.
Connectivity
• Path from p to q: a sequence of distinct and adjacent pixels with coordinates
Starting point p
•
•
•
•
ending point q
adjacent
Closed path: if the starting point is the same as the ending
point
p and q are connected: if there is a path from p to q in S
Connected component: all the pixels in S connected to p
Connected set: S has only one connected component
Connectivity
S represent a subset of pixels in an image, Two pixels p
and q are said to be
 connected in S if there exists a path between them.
 Two image subsets S1 and S2 are adjacent if some pixel in
S1 is adjacent to some pixel in S2.
 Let
Region
Let R be a subset of pixels in an image, we call R a region of the
image if R is a connected set.
 Region that are not adjacent are said to be disjoint.
 Example: the two regions in figure, are adjacent only if 8adjacany is used.
Boundary (border)
The boundary of a region R is the set of pixels in the
region that have one or more neighbors that are not in R.
Boundary (border) image contains K disjoint regions, Rk,
k=1, 2, ...., k, none of which touches the image border.
Region and Boundary
If R happens to be an entire image, then its boundary is defined as the set
of pixels in the first and last rows and columns in the image.
This extra definition is required because an image has no neighbors
beyond its borders
Normally, when we refer to a region, we are referring to subset of an
image, and any pixels in the boundary of the region that happen to
coincide with the border of the image are included implicitly as part of the
region boundary.
EXAMPLE 1
(a) S1 and S2 are not 4-connected
because q is NOT in the set N4(p)
q
p
(b) S1 and S2 are 8-connected
because q is in the set N8(p).
(c) S1 and S2 are m-connected
because (i) q is in ND (p), and (ii) the
set N4(p) ∩ N4(q) is empty.
EXAMPLE 2
Consider the image segment shown.
(a) Let v={0,1} and compute the lengths of the shortest 4-, 8-, and m-path
between p and q. If a particular path does not exist between these two
points, explain why. (b) Repeat for V = {1, 2}.
8-path
distance 4
m-path
distance 5
Cont..

V={1,2}
4-path length is 6
8-path length is 4
m- path length is 6
Distance Measures

For pixels p, q and z, with coordinates (x,y), (s,t) and (v,w),
respectively, D is a distance function if:
(a) D (p,q) ≥ 0 (D (p,q) = 0 iff p = q),
(b) D (p,q) = D (q, p), and
(c) D (p,z) ≤ D (p,q) + D (q,z).
Distance Measures

The Euclidean Distance between p and q
is defined as:
De (p,q) = [(x – s)2 + (y - t)2]1/2
q (s,t)
Pixels having a distance less than or equal
to some value r from (x,y) are the points
contained in a disk of radius r centered at (x,y)
p (x,y)
Distance Measures
The D4 distance (city-block distance) between p and
q is defined as:
D4 (p,q) = | x – s | + | y – t |
q (s,t)
Pixels having a D4 distance from
(x,y), less than or equal to some
value r form a Diamond centered
at (x,y)
D4
p (x,y)
Distance Measures
Example:
The pixels with distance D4 ≤ 2 from (x,y) form
the following contours of constant distance.
The pixels with D4 = 1 are
the 4-neighbors of (x,y)
Distance Measures

The D8 distance ( chessboard distance)
between p and q is defined as:
D8 (p,q) = max(| x – s |,| y – t |)
q (s,t)
Pixels having a D8 distance from
(x,y), less than or equal to some
value r form a square Centered
at (x,y)
D8(b)
p (x,y)
D8(a)
D8 = max(D8(a) , D8(b))
Distance Measures
Example:
D8 distance ≤ 2 from (x,y) form the following
contours of constant distance.
D8 = 1 are the 8-neighbors of (x,y)
Distance measures
Example:
Compute the distance between the two pixels using the three distances :
q:(1,1) , p: (2,2)
Euclidian distance : ((1-2)2+(1-2)2)1/2 = sqrt(2).
D4(City Block distance): |1-2| +|1-2| =2
D8(chessboard distance ) : max(|1-2|,|1-2|)= 1
(because it is one of the 8-neighbors )
1
1
2
3
2
q
p
3
Distance Measures

Dm distance:
is defined as the shortest m-path between the points.
In this case, the distance between two pixels will
depend on the values of the pixels along the path, as
well as the values of their neighbors.
Distance Measures

Example:
Consider the following arrangement of pixels and
assume that p, p2, and p4 have value 1 and that
p1 and p3 can have can have a value of 0 or 1
Suppose that we consider
the adjacency of pixels
values 1 (i.e. V = {1})
Distance Measures

Cont. Example:
Now, to compute the Dm between points p and p4
Here we have 4 cases:
Case1: If p1 =0 and p3 = 0
The length of the shortest m-path
(the Dm distance) is 2 (p, p2, p4)
Distance Measures

Cont. Example:
Case2: If p1 =1 and p3 = 0
now, p1 and p will no longer be adjacent (see madjacency definition)
then, the length of the shortest
path will be 3 (p, p1, p2, p4)
Distance Measures

Cont. Example:
Case3: If p1 =0 and p3 = 1
The same applies here, and the shortest –
m-path will be 3 (p, p2, p3, p4)
Distance Measures

Cont. Example:
Case4: If p1 =1 and p3 = 1
The length of the shortest m-path will be 4 (p, p1 , p2, p3, p4)
Matlab Code
Basic Set and Logical Operations
Set Operations Based on Coordinates
A region in an image is represented by a set of coordinates within the region
Logic Operations for Binary Image
Illustration of logical operations involving
foreground (white) pixels. Black represents binary
0’s and white binary 1’s. The dashed lines are
shown for reference only. They are not part of the
result.
Download