You are on page 1of 50

Computer Vision and Image

processing (CoSc4151)
2. Digital Image Fundamentals

Jimma University
Jimma Institute of Technology
For Computer Science students
Abel W.
Concept of image
What is an image?

 Signal = function (variable with physical meaning)

I. one-dimensional (e.g. dependent on time)

plane)

 In general an image is a signal and as with all signals they

are functions of physical things.
CV & IP 02 18-Nov-16 2
Concept of image
Image function value = brightness at image
points
Brightness is dependent on several factors
1. object surface reflectance properties
 surface material, microstructure and marking
2. Illumination properties
 provide their own light as in glow in the dark stickers
3. object surface orientation with respect to a viewer and
light source
 temperature, distance from the observer
CV & IP 02 18-Nov-16 3
Concept of image
• Image capturing

CV & IP 02 18-Nov-16 4
Concept of image
 Image intensity, f(x, y), is proportional to EM
 Required f(x, y) is nonzero and finite
f ( x , y )  i ( x, y ) r ( x, y )
where 0  i( x, y )  , incident illumination
0  r(x, y)  1, reflected illumination
Typical values: 90,000 lm/m 2 , clear sunny day

10,000 lm/m 2 , cloudy day
i(x,y)   2
 0.01 lm/m , full moon, clear night
 2
 1,000 lm/m , commercial office
 0.01, black material

r(x, y)   0.8, flat white wall paint
CV & IP 02

0.93, snow
18-Nov-16 5
Concept of image
 Thus, the intensity image lies in the
range

i r  f ( x, y )  i r
min min max max

0  f ( x, y )  L  1

CV & IP 02 18-Nov-16 6
Digital image representation
 A digital image can be  Where
represented as a two- f(x, y) =monochrome
dimensional (2D) matrix images of size M×N
of real numbers. X = row number (from 0
to M−1)
Y = column number
(between 0 and N−1)

CV & IP 02 18-Nov-16 7
Digital image representation
 The value of the two-dimensional function f(x, y) at
any given pixel of coordinates (x0,y0), denoted by
f(x0,y0), is called the intensity or gray level of the
image at that pixel.
 Maximum and Minimum values that a pixel intensity
can vary based on
 data type

CV & IP 02 18-Nov-16 8
Digital image representation
1. Data Type
 Logical: 1.0 for white and 0.0 for Black
 uint8( unsigned integer, 8 bits): 0(Black) and 255(White)
2. Convection

 f( p, q)to refer to the MATLAB representation of f(x, y) ( where p

denotes row and q denotes column )
CV & IP 02 18-Nov-16 9
Concept of pixel
 A digital image, I, is a mapping from a 2D grid of
uniformly spaced discrete points, {p = (r , c)}, into
a set of positive integer values, {I( p)}, or a set of
vector values, e.g., {[R G B]T( p)}.
 At each column location in each row of I there is a
value.
 The pair ( p, I( p) ) is called a “pixel” (for picture
element).

CV & IP 02 18-Nov-16 10
Concept of pixel
 p = ( r, c) is the pixel location indexed by row, r,
and column, c.
 I( p) = I( r, c) is the value of the pixel at location p.
 If I( p) is a single number then I is monochrome.
 If I( p) is a vector (ordered list of numbers) then I
has multiple bands (e.g., a color image).

CV & IP 02 18-Nov-16 11
Concept of pixel
Pixel : [ p, I(p)] Pixel Location: p = (r , c)
Pixel Value: I(p) = I(r , c)

p = (r , c)
= (row # , col # )
=CV(&272,
IP 02
277) 18-Nov-16 12
Digital image acquisition process

CV & IP 02 18-Nov-16 13
Image sampling and quantization
 An image may be continuous with respect to the x- and
y-coordinates, and also in amplitude.
 When x, y, and the amplitude values are all finite,
discrete quantities, we call the image a digital image.
 To convert it to digital form, we have to sample the
function in both coordinates and in amplitude.
1. Digitizing the coordinate values is called sampling.
2. Digitizing the amplitude values is called quantization.

CV & IP 02 18-Nov-16 14
Image sampling

Continuous image

A scan line from A to B in

the continuous image
To sample this take
equally spaced samples
along
CV & IP 02line AB. 18-Nov-16 15
Image sampling
 The samples are shown as
small white squares
superimposed on the
function.

 The set of these discrete

locations gives the
sampled function
CV & IP 02 18-Nov-16 16
Image quantization
 In order to form a
digital function, the
gray-level values
also must be
converted
(quantized) into
discrete quantities.

CV & IP 02 18-Nov-16 17
Concepts of sampling and quantization

CV & IP 02 18-Nov-16 18
Types of Digital Image
 Binary (1-Bit) Images
 Gray-Level (8-Bit) Images
 Color Images

CV & IP 02 18-Nov-16 19
Types of Digital Image
1. Binary (1-Bit) Images: encoded as a 2D array, typically
using 1 bit per pixel, where a 0 usually means “black” and a 1
means “white”

CV & IP 02 18-Nov-16 20
Types of Digital Image
2. Gray-Level (8-Bit) Images: (also referred to as
monochrome) encoded as a 2D array of pixels, usually with 8
bits per pixel, where a pixel value of 0 corresponds to “
black,” a pixel value of 255 means “white,” and intermediate
values indicate varying shades of gray

CV & IP 02 18-Nov-16 21
Gray-level images
 Continuous image function f(x,y)
arguments - two co-ordinates (x,y) can have any value
 Digital image functions - represented by matrices
co-ordinates = integer numbers
Cartesian (horizontal x axis, vertical y axis)
 Monochromatic image function range
lowest value - black
highest value - white
 Limited brightness values = grey levels
CV & IP 02 18-Nov-16 22
Gray level images

CV & IP 02 18-Nov-16 23
Representation of gray level images
a digital 8-bit, 8x8 images is shown as an array of numbers on the
left and brightness levels on the right.

CV & IP 02 18-Nov-16 24
Gray level images
• The number of distinct gray levels is usually a power
of 2 that is, 𝑳 = 𝟐𝑩

where B is the number of bits in the binary representation of

the brightness levels.

• When B>1 we speak of a gray-level image; when B=1

we speak of a binary image.

• In a binary image there are just two gray levels which

can be referred as “black” and “white” or “0” and “1”.
CV & IP 02 18-Nov-16 25
Types of Digital Image
3. Color Images: Representation of color images is more
complex and varied.
 The two most common ways of storing color image
contents are
 RGB representation in which each pixel is usually represented by a
24-bit number containing the amount of its red (R), green (G),
and blue (B) components
 indexed representation—where a 2D array contains indices to a
color palette (or lookup table-(LUT)).

CV & IP 02 18-Nov-16 26
Cont.. Color Image
 24-Bit (RGB) Color images, represented using three
2D arrays of same size, one for each color channel:
red (R), green (G), and blue (B)
 Each array element contains an 8-bit value, indicating
the amount of red, green, or blue at that point in a
[0, 255] scale. The combination of the three 8-bit
values into a 24-bit number allows 2 raised to
24 (16,777,216, usually referred to as 16 million or 16
M) color combinations.

CV & IP 02 18-Nov-16 27
Cont’d… color images
Represented by vector not scalar
• Red, Green, Blue (RGB)
• Hue, Saturation, Value (HSV)
• Cyan, Magenta, Yellow (CMY)

Solid color cube

((28)3 = 16,777,216 colors)
CV & IP 02 18-Nov-16 28
Cont.. Color Image
• 24-Bit (RGB) Color

Original Image
b. Red Plane
c. Green Plane
d. Blue Plane
CV & IP 02 18-Nov-16 29
Properties that define image format

• Pixel (or spatial) resolution (e.g. 640x480 pixels)

• Pixel bit-depth (8-bit)
• Number of planes (1 for gray scale images, 3 for color)
• Colorspace (RGB, CMYK etc.)

CV & IP 02 18-Nov-16 30
Binary and Gray scale images

CV & IP 02 18-Nov-16 31
Intensity Resolution
 Smallest discernible change in intensity level

7-bit

6-bit CV & IP 02 5-bit 2-bit 18-Nov-16

1-bit
32
Image of size

CV & IP 02 18-Nov-16 33
Image of size
fewer Pixels Mean Lower Spatial Resolution

CV & IP 02 18-Nov-16 34
Image interpolation
Introduction
• An image f(x,y) tells us the intensity values at the
integral lattice locations, i.e., when x and y are both
integers
• Image interpolation refers to the “guess” of intensity values
at missing locations, i.e., x and y can be arbitrary
• Note that it is just a guess (Note that all sensors have finite
sampling distance)
• image interpolation is about D-A conversion

CV & IP 02 18-Nov-16 35
Image interpolation:
 Image re-sampling or re-sizing operations:-
 zooming, shrinking, rotating, and geometric corrections

 Uses known image data to estimate at the new locations.

 Different methods:
1. Nearest neighbor interpolation:-
2. Linear interpolation
3. Bilinear interpolation
4. Cubic interpolation and others
CV & IP 02 18-Nov-16 36
Image Interpolation
Example:
f(1) = 1, f(2) = 10, f(3) = 5 , f(4) = 16, f(5) = 20

CV & IP 02 18-Nov-16 37
Image Interpolation
How can we find f(1.5)?
 One approach: take the average of f(1) and f(2)

f (1.5) = 5.5

CV & IP 02 18-Nov-16 38
Linear interpolation
Fit a line between each pair of data points

CV & IP 02 18-Nov-16 39
Linear interpolation
• What is f(1.8)?
Answer: 0.2 f(1) + 0.8 f(2)

f (1.8) = 0.2 (1) + 0.8 (10) = 8.2

CV & IP 02 18-Nov-16 40
Linear interpolation
 To compute f(x), find the two points xleft and xright that x lies
between
f (x) = (xright - x) / (xleft – xright) f (xleft) +
(x - xleft) / (xleft – xright) f (xright)
f (xleft)

f (xright)

xleft x xright

CV & IP 02 18-Nov-16 41
Bilinear interpolation
Interpolate in x, then in y
Example
 We know the red values
 Linear interpolation in x between red
values gives us the blue values
 Linear interpolation in y between the
blue values gives us the answer

http://en.wikipedia.org/wiki/
Bilinear_interpolation

CV & IP 02 42
18-Nov-16
Bilinear interpolation
Bilinear interpolation: - uses the
four nearest neighbors to estimate the
intensity at a the new location

http://en.wikipedia.org/wiki/
Bilinear_interpolation

CV & IP 02 43
18-Nov-16
Cont’d…
Nearest neighbor interpolation

Direct zooming

Bilinear interpolation

CV & IP 02 18-Nov-16 44
Extrapolation
 Suppose you only know the values f(1), f(2), f(3), f(4)
of a function
 What is f(5)?
 This problem is called extrapolation
 Much harder than interpolation: what is outside the image?
 For the particular case of temporal data, extrapolation is
called prediction (what will the value of MSFT stock be
tomorrow?)
 If you have a good model, this can work well

CV & IP 02 18-Nov-16 45
Image extrapolation

http://graphics.cs.cmu.edu/projects/scene-completion/
Computed using a database of millions of photos
CV & IP 02 18-Nov-16 46
Mathematical Tools used in Digital Image
Processing
1. Array versus Matrix Operations:
 Digital image viewed as an array
 Array operation is pixel-by-pixel
 Consider image arrays A and B, where
 a11 a12  b11 b12 
A  , B 
 21 22 
a a  21 22 
b b
then  a11 a12 
 a 2
a 2
 A  b11 b12 
A  2
2 11 12
2 
, C  
a21 a22  B  a21 a22 
 b21 b22 
CV & IP 02 18-Nov-16 47
Mathematical Tools used in Digital Image
Processing cont’d…
2. Linear versus Nonlinear Operations:
 most image processing operations are linear.
 Consider an input image f(x, y), an operator H
and output g(x, y), i.e.,
H[f(x, y)] = g(x, y)
H is a linear operator if the following is true.

H [ai f i ( x, y )  a j f j ( x, y )]  ai g i ( x, y )  a j f j ( x, )
Mathematical Tools used in Digital Image
Processing cont’d…
3. Arithmetic Operations:

 Same size images, M x N, and the basic arithmetic

operations are

s ( x , y )  f ( x , y )  g ( x, y )
d ( x , y )  f ( x, y )  g ( x , y )
p ( x, y )  f ( x, y )  g ( x, y )
v ( x, y )  f ( x, y )  g ( x, y )
Thank you!!!

CV & IP 02 18-Nov-16 50