Computer Vision Course Lecture 2
Computer Vision Course Lecture 2
Lecture (2)
Image Processing
What is an image?
• An image is a single picture which represents something.
• It may be a picture of a person, of people or animals, or of an
outdoor scene.
Digital Camera
What is Image Processing?
• Removing noise
from an image.
• Noise is random
errors in the
image.
Examples of (1)
• Removing motion blur from an image.
Examples of (2)
1. Binary images.
2. Grayscale images.
3. Color images.
Binary images
• Each pixel is just black or white.
• Since there are only two possible values for each pixel, we only
need one bit per pixel (0 for black and 1 for white).
Grayscale images
• Each pixel can be represented by exactly one byte (8 bits).
• Each pixel is a shade of grey, normally from 0 (black) to 255
(white).
Color images (RGB)
• Each pixel has a particular color; that color being described by the
amount of red, green and blue in it.
• If each of these components has a range from 0 to 255, this gives a
total of 2563 = 16,777,216 different possible colors in the image.
• Since the total number of bits required for each pixel is 3 × 8 = 24,
such images are also called 24-bit color images.
• Such an image may be considered as consisting of a stack of three
matrices; representing the red, green and blue values for each pixel.
• This means that for every pixel there correspond three values.
Color images (RGB)
Digital Image
• A grid (matrix) of intensity values. 255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 20 0 255 255 255 255 255 255 255
=
255 255 96 127 145 175 255 255 255 255 255 255
255 255 127 145 175 175 175 255 255 255 255 255
255 255 127 145 200 200 175 175 95 255 255 255
255 255 127 145 200 200 175 175 95 47 255 255
255 255 127 145 145 175 127 127 95 47 255 255
255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255 255 255 255 255
r ( x, y )
f ( x, y ) = g ( x, y )
b( x, y )
Image transformation
• Thus, when adding 128, all gray values of 127 or greater will be
mapped to 255.
• And when subtracting 128, all gray values of 128 or less will be
mapped to 0.
• In general, adding a constant will lighten an image, and
subtracting a constant will darken it.
Arithmetic operations of grayscale images
Arithmetic operations of grayscale images
Arithmetic operations of grayscale images
• From the result shown in the previous figure, and since the gray
values are all clustered together in the center of the histogram, we
would expect the image to be poorly contrasted, as indeed it is.
• We can stretch the gray levels in the center of the range out by applying
the linear function shown at the right in the same figure. This function has
the effect of stretching the gray levels 5 − 9 to gray levels 2 − 14 according
to the equation:
14 − 2
𝑗= 𝑖−5 +2
9−5
Histogram stretching
Histogram stretching
• Where 𝑖 is the original grey level and 𝑗 is its result after the
transformation.
• Gray levels outside this range are either left alone (as in this case) or
transformed according to the linear functions at the ends of the graph
above. This yields:
Histogram stretching
• And the corresponding histogram indicates an image with greater
contrast than the original:
Histogram stretching
Histogram equalization