31
Image Processing Ch2: Digital image Fundamentals Prepared by: Hanan Hardan Hanan Hardan 1

Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

  • Upload
    others

  • View
    2

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

Image Processing

Ch2: Digital image Fundamentals

Prepared by: Hanan Hardan

Hanan Hardan 1

Page 2: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

Image Acquisition:

The image is captured by a sensor (eg. Camera), and digitized if the output of the camera or sensor is not already in digital form, using analogue-to-digital convertor

Hanan Hardan 2

Page 3: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

Image sampling and quantization

In order to process the image, it must be saved on computer.

The image output of most sensors (eg: Camera) is continuous voltage waveform.

But computer deals with digital images not with continuous images, thus: continuous images should be converted into digital form.

Hanan Hardan 3

Page 4: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

Image sampling and quantization To convert continuous image (in real life) to digital image (in computer) we use Two processes: 1.sampling 2.quantization. Remember that: the image is a function f(x,y), x and y: are coordinates F: intensity value (Amplitude) Sampling: digitizing the coordinate values Quantization: digitizing the amplitude values Thus, when x, y and f are all finite, discrete quantities, we call the image a digital image.

Hanan Hardan 4

Page 5: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

How does the computer digitize the continuous image?

Ex:

scan a line such as AB from the continuous image, and represent

the gray intensities.

How does the computer digitize the continuous image?

Ex:

scan a line such as AB from the continuous image, and represent

the gray intensities.

Hanan Hardan 5

Page 6: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

How does the computer digitize the continuous image?

Sampling: digitizing coordinates

Quantization: digitizing intensities

sample is a small white square, located by a vertical tick mark as a point x,y

Quantization: converting each sample gray-level value into discrete digital quantity.

Gray-level scale that divides gray-level into 8 discrete levels

Hanan Hardan 6

Page 7: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

How does the computer digitize the continuous image? Now:

the digital scanned line AB representation on computer:

The continuous image VS the result of digital image after sampling and quantization

Hanan Hardan 7

Page 8: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

Digital Image Representation

The result of sampling and quantization is a matrix of real numbers

Assume that an image f(x,y) is sampled so that the resulting image has M rows and N columns. We say that the image is of size M x N. The values of the coordinates (x,y) are discrete quantities. For clarity, we use integer values for these discrete coordinates.

Hanan Hardan 8

Page 9: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

Digital Image Representation

Images as Matrices

Each element of this array is called an image element, picture element, pixel or pel.

A digital image can be represented naturally as a MATLAB matrix:

Hanan Hardan 9

Page 10: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

Pixels!

Every pixel has # of bits (k) so, the gray intensities ( L ) that the pixel can hold, is calculated

according to a number of pixels it has (k).

L= 2k Q: Suppose a pixel has 1 bit, how many gray levels can it represent? Answer: 2 intensity levels only, black and white. Bit (0,1) 0:black , 1: white Q:Suppose a pixel has 2 bit, how many gray levels can it represent? Answer: 4 gray intensity levels 2Bit (00, 01, 10 ,11). Now .. if we want to represent 256 intensities of grayscale, how many bits

do we need? Answer: 8 bits which represents: 28=256

Hanan Hardan 10

Page 11: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

Number of storage of bits:

N * M: the no. of pixels in all the image.

K: no. of bits in each pixel

L: grayscale levels the pixel can represent

L= 2K

all bits in image= N*N*k

Hanan Hardan 11

Page 12: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

Number of storage of bits:

EX: Here: N=32, K=3, L = 23 =8

# of pixels=N*N = 1024 . (because in this example: M=N)

# of bits = N*N*K = 1024*3= 3072

N=M in this table, which means no. of horizontal pixels= no. of vertical pixels. And thus:

# of pixels in the image= N*N Hanan Hardan 12

Page 13: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

Spatial and gray-level resolution

Hanan Hardan 13

Page 14: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

Spatial and gray-level resolution

Resolution: How Much Is Enough?

This all depends on what is in the image and what you would like to do with it

Key questions include

Can you see what you need to see within the image?

Hanan Hardan 14

Page 15: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

Resolution: How Much Is Enough? (cont…)

The picture on the right is fine for counting the number of cars, but not for reading the number plate

Hanan Hardan 15

Page 16: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

Spatial resolution:

Sampling is the principal factor determining the spatial resolution of an image

Basically, spatial resolution is the smallest discernible detail in an image.

Spatial Resolution

( .هي وحدة قياس لاصغر جزء في الصورة يمكن تمييزة بالعين )

, فهو فقط يحد ابعاد الصورة , عدد البكسلات في الصورة لا يحدد وضوحها

فكلما , هو المسؤول عن تحديد الوضوح Spatial resolutionاما

اكثر كان لها قدرة كانت البكسلات متقاربة وتحمل قيم لونيه صحيحة

.اعلى على توضيح معالم الصورة بشكل اوضحHanan Hardan 16

Page 17: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

How to choose the spatial resolution

= Sampling locations

Ori

gin

al i

mag

e

Sam

ple

d i

mag

e

Under sampling, we lost some image details!

Spatial resolution

Hanan Hardan 17

Page 18: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

How to choose the spatial resolution : O

rigin

al i

mag

e

Spatial resolution

(sampling rate)

Sampled image

No detail is lost!

1m

m

Hanan Hardan 18

Page 19: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

Effect of Spatial Resolution Example:

256x256 pixels

64x64 pixels

128x128 pixels

32x32 pixels

insufficient spatial resolution appearance of checkerboard pattern in the image

Hanan Hardan 19

Page 20: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

Example: Spatial resolution

الصورة في اليسار تحمل عدد بكسلات اكبر من الصورة في الجهه اليمين

لماذا؟ ومع ذالك الصورة في اليسار تبدوا غير واضحة,

Hanan Hardan 20

Page 21: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

gray-level resolution

Quantization is the principal factor determining the gray level resolution of an image

Gray-level resolution refers to the smallest discernible change in gray level.

يمكن تمييزها ( كثافة اللون الرمادي)وهي تعني اصغر تغيير في الكثافة

ورؤيتها

Color depth/ levels is given by

kL 2Hanan Hardan 21

Page 22: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

Effect of Quantization Levels Example:

256 levels 128 levels

32 levels 64 levels Hanan Hardan 22

Page 23: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

Effect of Quantization Levels (cont.)

16 levels 8 levels

2 levels 4 levels

In this image,

it is easy to see

false contour.

Hanan Hardan 23

Page 25: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

Common image formats include:

1 sample per point (B&W or Grayscale)

3 samples per point (Red, Green, and Blue)

For most of this course we will focus on grey-scale images

Hanan Hardan 25

Page 27: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

Image Types : Binary Image

Binary image or black and white image

Each pixel contains one bit :

1 represent white

0 represents black

1111

1111

0000

0000

Binary data

Hanan Hardan 27

Page 28: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

Grayscale Images

A grayscale (or graylevel) image is simply one in which the only colors are shades of gray (0 – 255)

Hanan Hardan 28

Page 29: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

Digital Image Types : Intensity Image

Intensity (monochrome or gray scale) image

each pixel corresponds to light intensity

normally represented in gray scale (gray

level).

39871532

22132515

372669

28161010

Gray scale values

Hanan Hardan 29

Page 30: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

Color Images

Color image: A color image contains pixels each of which holds three intensity values corresponding to the red, green, and blue or( RGB)

Hanan Hardan 30

Page 31: Ch2: Digital image Fundamentals - Philadelphia University · 2021. 3. 1. · Hanan Hardan 16. How to choose the spatial resolution = Sampling locations age age Under sampling, we

39871532

22132515

372669

28161010

39656554

42475421

67965432

43567065

99876532

92438585

67969060

78567099

Digital Image Types : RGB Image

Color image or RGB image:

each pixel contains a vector

representing red, green and

blue components.

RGB components

Hanan Hardan 31