Sunteți pe pagina 1din 44

Fundamental Image Processing Steps

1. Image Acquisition: Image acquired from


sensors/cameras/CCD Cameras etc.. In digital
form.

Dinesh K. Vishwakarma, Ph.D.


2. Image Enhancement
This refers to processing an image so that the
result is more suitable for a particular
application. Example include:
a) Sharpening or de-blurring an out of focus
image
b) Highlighting the edges
c) Improving Image contrast or Brightening
and Image
d) Removing Noise.
Dinesh K. Vishwakarma, Ph.D.
3. Image restoration
This may be considered as reversing the
damage done to an image by a known cause,
for example:
a) Removing of blur caused by linear motion
b) Removal of optical distortions
c) Removing periodic interference.

Dinesh K. Vishwakarma, Ph.D.


4. Image segmentation
This involves subdividing an image into
constituent parts, or isolating certain aspects
of an image:
a) Finding lines, circles, or particular shapes in
an image,
b) In an aerial photograph, identifying cars,
trees, buildings, or roads.

Dinesh K. Vishwakarma, Ph.D.


5. Wavelets
• Wavelets are used to represent the images at
various degrees.
• It also used for compression.

Dinesh K. Vishwakarma, Ph.D.


6. Morphology
• Extraction of image feature that may be useful
to identify shapes or structures or boundaries
or skeletons.

Dinesh K. Vishwakarma, Ph.D.


Gray Scale or Intensity
• Pixels with Neighborhoods

Dinesh K. Vishwakarma, Ph.D.


Image Interpolation
• It is tool used for image zooming, shrinking, rotating
and geometric corrections.

Example: An image 500x500 pixels has to be enlarged 2


times to 1000x1000 pixels. Simplest way is to create an
imaginary 1000x1000 grid with the same pixels spacing
in the original image, and then shrink it so that it fits
exactly over the original image. Obviously the pixel
spacing in the shrunken 1000x1000 grid will be less
than the pixel spacing in the original image.

Dinesh K. Vishwakarma, Ph.D.


Interpolation types
• NEAREST NEIGHBOR INTERPOLATION: assigning
intensity to its nearest neighbor in the original image.
This approach is simple but it creates undesirable
artifacts such as distortion of straight edges.
• BILINEAR INTERPOLATION: In this interpolation we use
4 nearest neighbors to estimate intensity at a given
location. Let (x,y) denote the coordinates of the
location to which we want to assign intensity value
and let v(x,y) be a intensity value. Then it can be
determine;
v( x, y)  ax  by  cxy  d
Dinesh K. Vishwakarma, Ph.D.
Interpolation types
• BICUBIC INTERPOLATION: This involves sixteen nearest
neighbors of a point. The intensity value that assign to
a point (x,y) is given by the eq.
3 3
v ( x, y )   a x y ij
i j

i 0 j 0

• BICUBIC interpolation does better of preserving the


fine details than BILINEAR.
• BICUBIC INTERPOLATION is used in commercial editing
programs likes Adobe Photoshop and Corel Photopoint.

Dinesh K. Vishwakarma, Ph.D.


Different Image Standard
• JPEG Joint Photographic Experts Group
• GIF Graphics Interchange Format
• BMP Bit Mapped
• TGA Truevision Graphics Adaptor
• PNG Portable Network Graphics
• TIFF Tagged Interchange/Image File Format
• EXIF Exchangeable Image File Format
• PCX Personal Computer eXchange

Dinesh K. Vishwakarma, Ph.D.


Types of Digital Images
• BINARY IMAGES : Each pixel is BLACK or
WHITE since there is only 2 possible values for
each pixel.
a) Only required only 1 bit to sore 1 pixel.
b) These images are suitable for finger print,
or architectural plan.

Dinesh K. Vishwakarma, Ph.D.


1. A BINARY IMAGE
• A binary image is shown in figure below. In
this image, we have only the two colours:
White for the edges, and black for the
background.

Dinesh K. Vishwakarma, Ph.D.


2. A GRAY SCALE IMAGE
• Each pixel is a shade of gray, normally from 0 (BLACK)
to 255 (WHITE).This range means that each pixel can
be represented by eight bits, or exactly one byte.
This is a very natural range for image file handling.
Other grayscale ranges are used, but generally they
are a power of 2. Such images arise in medicine (X-
rays), images of printed works, and indeed 256
different gray levels is sufficient for the recognition
of most natural objects.

Dinesh K. Vishwakarma, Ph.D.


FIGURE OF GRAY SCALE IMAGE

Dinesh K. Vishwakarma, Ph.D.


3. TRUE COLOUR OR RGB IMAGE
• Each pixel has particular colour, that colour is
described by the amount of RED, GREEN and
BLUE in it.
• If each these have a components 0-255, this
gives a total of 2563 =16777216 different
possible colours in the image. This is enough
for any image.
• Total number of bits required for each pixel is
24 bits colour image.

Dinesh K. Vishwakarma, Ph.D.


A TRUE COLOUR IMAGE

Dinesh K. Vishwakarma, Ph.D.


4. INDEXED IMAGE
• Most colour image has only a small subset of
colour image of more than sixteen million
possible colours.
• For convenience to store and file handling the
image has associated a colour map or colour
palette which is simply a all colours used in the
image.
• Each pixel has a value which does not gives its
colour but index to a colour map.
• It is convenient if a colour image has 256 colours
or less then only 1 byte is required to store each
pixel.
Dinesh K. Vishwakarma, Ph.D.
FIGURE OF AN INDEX COLOUR IMAGE

Dinesh K. Vishwakarma, Ph.D.


IMAGE FILE SIZE
• A BINARY IMAGE: Let us consider a 512 x 512
binary image. The number of bits used in this
image is:
512 x 512 x1=262,144 bits
=32768 bytes
• A GRAY SCALE IMAGE: A gray scale image of
same size requires:
512 x 512 x 8= 2097152 bits
=262144 bytes
Dinesh K. Vishwakarma, Ph.D.
IMAGE FILE SIZE
• A COLOUR OR RGB IMAGE: Let us consider a
512 x 512 colour image. The number of bits
used in this image is:
512 x 512 x 3 x 8= 6291456 bits
= 786432 bytes

Dinesh K. Vishwakarma, Ph.D.


MATLAB under standing
• IMREAD: reading a image file
a=imread(‘lena.jpg’);
• IMSHOW: showing a image file in MATLAB
imshow(a);
• SIZE: determine the size of image
size(a);
• a(100,200,1:3); all values of colours at pixel
(100X200).
• impixel(a,100,200); it will also gives all values of
colours at pixel (100x200).
Dinesh K. Vishwakarma, Ph.D.
MATLAB under standing
• Imfinfo(‘lena.jpg’); will get the information
about the image file ‘lena.jpg’.

Dinesh K. Vishwakarma, Ph.D.


DATA TYPES & CONVERSION

>>a=24
>>b=uint8(a);
>>b
24
Dinesh K. Vishwakarma, Ph.D.
IMAGE CONVERSION
• Image can be converted from one type to
another. We can understand with the below
tables.

Dinesh K. Vishwakarma, Ph.D.


Image data type conversion Eg.
>>c=imread('cameraman.tif');
>> cd=double(c);
>> imshow(c),figure,imshow(cd)

Type double, the imshow function expects the values to be between 0 and 1,
where 0 is displayed as black, and 1 is displayed as white.
Dinesh K. Vishwakarma, Ph.D.
>>imshow(cd/255)
>>imshow(cd/512)
>>imshow(cd/128)

Dinesh K. Vishwakarma, Ph.D.


BINARY IMAGE
• A binary image will have only two values: 0 and 1.
MATLAB does not have a binary data type.
• Gray Scale images can be transformed into a sequence
of binary images by breaking them up into their bit-
planes.
• If we consider the Gray value of each pixel of an 8-bit
image as an 8-bit binary word, then the 0th bit plane
consists of the last bit of each gray value. Since this bit
has least effect in terms of value, it is called LSB.
• Similarly the 7th bit plane consists of the first bit in
each value. This bit has the greatest effect in terms of
the magnitude of the value, so it is called the most
significant bit, and the plane consisting of those bits
the most significant bit plane.
Dinesh K. Vishwakarma, Ph.D.
A Gray Scale to Binary Image
• If we take a Grayscale image, we start by making
it a matrix of type double; this means we can
perform arithmetic on the values.
>> c=imread('cameraman.tif');
>> cd=double(c);
• We now isolate the bit planes by simply dividing
the matrix cd by successive powers of 2,
throwing away the remainder, and seeing if the
final bit is 0 or 1. We can do this with the mod
function.
Dinesh K. Vishwakarma, Ph.D.
>> c0=mod(cd,2);
>> c1=mod(floor(cd/2),2);
>> c2=mod(floor(cd/4),2);
>> c3=mod(floor(cd/8),2);
>> c4=mod(floor(cd/16),2);
>> c5=mod(floor(cd/32),2);
>> c6=mod(floor(cd/64),2);
>> c7=mod(floor(cd/128),2);
The most significant bit plane, c7, is actually a threshold of the
image at level 127.
>> ct=c>127;
>> all(c7(:)==ct(:))
We can recover and display the original image with:
>> cc=2*(2*(2*(2*(2*(2*(2*c7+c6)+c5)+c4)+c3)+c2)+c1)+c0;
>>Dinesh
imshow(uint8(cc))
K. Vishwakarma, Ph.D.
Spatial Resolution
• Spatial resolution is the density of pixels over the
image.
• The greater the spatial resolution, the more pixels
are used to display the image.
• We can experiment with spatial resolution with
MATLAB
• imresize function. Suppose we have an 256 X 256
8-bit Grayscale image saved to matrix X Then
command
>>imresize(x,1/2); will halve the size of image
>>x2=imresize(imresize(x,1/2),2); can recover
orginal.
Dinesh K. Vishwakarma, Ph.D.
Dinesh K. Vishwakarma, Ph.D.
Dinesh K. Vishwakarma, Ph.D.
Relationship between pixels
(0,0)

(x-1,y-1) (x,y-1) (x+1,y-1)

(x-1,y) (x,y) (x+1,y)

(x-1,y+1) (x,y+1) (x+1,y+1)

Conventional indexing method


Dinesh K. Vishwakarma, Ph.D.
Neighbors of pixels

(x-1,y-1) (x,y-1) (x+1,y-1) 8-neighbors of p:

(x-1,y-1)
(x-1,y) p (x+1,y)
(x,y-1)
(x+1,y-1)
(x-1,y)
(x-1,y+1) (x,y+1) (x+1,y+1) (x+1,y)
N8(p) = (x-1,y+1)
(x,y+1)
(x+1,y+1)

8-neighborhood relation considers all neighbor pixels.


Dinesh K. Vishwakarma, Ph.D.
Neighbors of pixels

(x-1,y-1) (x+1,y-1) Diagonal neighbors of p:

(x-1,y-1)
p
(x+1,y-1)
ND(p) = (x-1,y1)
(x+1,y+1)
(x-1,y+1) (x+1,y+1)

Diagonal-neighborhood relation considers only diagonal


neighbor pixels.
Dinesh K. Vishwakarma, Ph.D.
Connectivity
• Connectivity is adapted from neighborhood relation.
• Two pixels are connected if they are in the same class
(i.e. the same color or the same range of intensity) and
they are neighbors of one another.

• For p and q from the same class


w 4-connectivity: p and q are 4-connected if q  N4(p)
w 8-connectivity: p and q are 8-connected if q  N8(p)
w mixed-connectivity (m-connectivity):
p and q are m-connected if q  N4(p) or
q  ND(p) and N4(p)  N4(q) = 

Dinesh K. Vishwakarma, Ph.D.


adjacency
• A pixel p is adjacent to pixel q if they are
connected. Two image subsets S1 and S2 are
adjacent if some pixel in S1 is adjacent to some
pixel in S2.

S1
S2

Dinesh K. Vishwakarma, Ph.D.


Adjacency
• We can define type of adjacency:
a) 4-adjacency: 2 pixel p & q with value from
V are 4-adjacent if q is in the set of N4 (p).
b) 8-adjacency: 2 pixel p & q with value from
V are 8-adjacent if q is in the set of N8 (p).
c) m-adjacency:(Mixed): 2 pixel p & q with
value from V are m-adjacent if:
1) q is in N4 (p) or
2) q is in ND (p) and the set N4 (p)  N4 (q )
has no pixel whose values are from V.
Dinesh K. Vishwakarma, Ph.D.
Path
A path from pixel p at (x,y) to pixel q at (s,t) is a sequence
of distinct pixels:
(x0,y0), (x1,y1), (x2,y2),…, (xn,yn)
such that
(x0,y0) = (x,y) and (xn,yn) = (s,t)
and
(xi,yi) is adjacent to (xi-1,yi-1), i = 1,…,n

q
p

We can define type of path: 4-path, 8-path or m-path


depending
Dinesh K. Vishwakarma,on
Ph.D. type of adjacency.
Paths (Examples)
8-path m-path

p p p

q q q

8-path from p to q m-path from p to q


solves this ambiguity
results in some ambiguity

Dinesh K. Vishwakarma, Ph.D.


Distance
For pixel p, q, and z with coordinates (x,y), (s,t) and (u,v),
D is a distance function or metric if

w D(p,q) 0 (D(p,q) = 0 if and only if p = q)

w D(p,q) = D(q,p)

w D(p,z) D(p,q) + D(q,z)

Example: Euclidean distance

De ( p, q)  ( x - s)2  ( y - t )2
Dinesh K. Vishwakarma, Ph.D.
Distance [Contd..]
D4-distance (city-block distance) is defined as

D4 ( p, q)  x - s  y - t

2
2 1 2
2 1 0 1 2

2 1 2

Pixels with D4(p) = 1 is 4-neighbors of p.


Dinesh K. Vishwakarma, Ph.D.
Distance [contd..]
D8-distance (chessboard distance) is defined as

D8 ( p, q)  max( x - s , y - t )

2 2 2 2 2
2 1 1 1 2
2 1 0 1 2

2 1 1 1 2
2 2 2 2 2

Pixels with D8(p) = 1 is 8-neighbors of p.


Dinesh K. Vishwakarma, Ph.D.