Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function...

30
Chapter 5 The Gray-Leve l Histogram ( 灰灰灰灰灰 ) The gray-level histogram is a funct ion showing, for each gray level, t he number of pixels in the image th at have that gray level. The abscissa of a gray-level histog ram is gray level and the ordinate is frequency of occurrence (number of pixels)

description

Another way to define the Gray-level histogram Contour lines in an image A(D) A(D+  D)

Transcript of Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function...

Page 1: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that have that gray level. The abscissa of a gray-level histogram is gray level and the ordinate is frequency of occurrence (number of pixels)

Page 2: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

Image Lenna The Histogram of Lenna

0 50 100 150 200 250

0

100

200

300

400

500

600

700

Page 3: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

Another way to define the Gray-level histogram Contour lines in an image

A(D)

A(D+D)

Page 4: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

For continuous image, the histogram H(D) is defined as: (1)Where A(D) is the threshold area function of a continuous image.For the case of digital functions, fix D=1, (2)

)( )()(lim)(0

DAdDd

DDDADADH

D

)1()()( DADADH

Page 5: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

The Two-Dimensional Histogram The two-dimensional histogram shows

how the pixels are distributed among combinations of two gray levels

For two images, obtained through colored filters, in red and blue light, the value of the two-dimensional histogram at the coordinate is the number of corresponding pixel pairs having gray level in the red image and gray level in the blue image.

),( BR DD

RD BD

Page 6: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

Properties of the Histogram (3) (4)For a discrete image, (5)

)()()( DAPAdPPH DD

image of area )(0

dPPH

columns) of(number

rows) ofnumber ()(255

0

D

DH

Page 7: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

If an image contains a single uniformly gray object on a contrasting background, and the boundary of that object has the contour line defined by gray level D1, then (6)

image of area )(0

dPPH

Page 8: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

• 500 象素 *546 象素 =• 273000 ,最左侧直方图峰值的灰度级为 33

Page 9: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

• 从灰度 54 到 255 级

• 约占图象总面积的 60%255

54H(D)dD=163001

Page 10: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

Probability density function(PDF): Normalize the gray-level histogram by dividing by the area of the image, i.e., Cumulative distribution function (CDF):0/)( ADH

0/)( ADA

Page 11: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

USES OF THE HISTOGRAM Digitizing Parameters Checking the histogram can bring

problems into the open before much time has been wasted

Page 12: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

Boundary Threshold Selection Suppose an image contains a dark

object on a light background, its histogram is a bimodal one

A threshold gray level chosen in the area of the dip will produce a reasonable boundary for the object

0 50 100 150 200 250 3000

2

4

6

8

10

12

Page 13: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.
Page 14: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

显然如果阈值对应于直方图的谷,阈值从 T 增加到 T+ ΔT ,只会导致面积略微变化。因此可以把阈值的选择误差对面积测量的影响降到最低。

上例中当灰度级从 115 变化到 144 时,象素为 1850 ,占图象总面积的 1% 。因此把阈值选取为 130 ,此时树叶的面积约占总面积 28.87% 。

Page 15: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

Integrated Optical Density (IOD)

For a digital image

It can be written as

where Nk is the number of pixels with gray level k

NL

i

NS

j

jiDIOD1 1

),(

255

0

255

0

)(kk

k kkHkNIOD

a b

dxdyyxDIOD0 0

),(

Page 16: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

For continuous image

and

If an object within the image if enclosed by a threshold boundary at gray level T,

0

)( dDDDHIOD

00 0

)(),( dDDDHdxdyyxDa b

T

dDDDHTIOD )()(

Page 17: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

The mean interior gray level is the ratio of IOD to area:

T

T

dDDH

dDDDH

TATIODMGL

)(

)(

)()(

Page 18: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

RELATIONSHIP BETWEEN HISTOGRAM AND IMAGE

One dimensionConsider the one-dimensional Gaussian pulse given by

-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 20

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

2

)( xexD

Page 19: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

The area is merely the inverse of the image function

The histogram is given by 0 )ln()( xDDx

0 )ln(

1)ln(2)(

xDD

DdDdDH

Page 20: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

The histogram of the Gaussian pulse

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

5

10

15

20

25

30

Page 21: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

Two DimensionsThe image function in polar coordinates is given byA Contour of constant gray level P is a circle of radiusSuch a contour encloses an area

20,0 ),(2

rerD r

)ln()( PPr

)ln()]([)( 2 PPrPA

Page 22: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

00. 20. 40. 60. 8

- 4- 2

24

y

- 4- 2

24

x

Page 23: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

5

10

15

20

25

30

0. 2 0. 4 0. 6 0. 8 1p

H( P)

P 灰 度

Page 24: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

The histogram is given by P

PAdPdPH

)()(

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

5

10

15

20

25

30

Page 25: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

SUMMARY OF IMPORTANT POINTS

1. The gray-level histogram is the negative of the derivative of the threshold area function.2. The histogram shows how many pixels occur at each gray level.3. Inspection of the histogram points out improper digitization.4. The area and IOD of a simple object can be computed from the histogram of its image.5. The histogram of an image of specified functional form can be derived with the aid of the area function.

Page 26: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

习题 P68 第 3 题解:

2 260 18050 800100 20x x

H D e e

0

20

40

60

80

100

20 40 60 80 100 120 140 160 180 200 220 240x

H1

Page 27: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

习题

0

2468

101214161820

20 40 60 80 100 120 140 160 180 200 220 240x

H2

Page 28: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

习题

• 从图中观察阈值灰度约可定在 100• 物体的 IOD=• 物体的面积 =

0

20

40

60

80

100

20 40 60 80 100 120 140 160 180 200 220 240x

H

2180

255 255800

100 100

D

H D dD e dD

2180

255 255800

100 100

D

DH D dD De dD

Page 29: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

习题 P68 第 4 题解:黑色象素数 =520+920+490+30+40+5910=7910 白色象素数 =6050+80+20+80+440+960+420=7970 足球的总象素 =7910+7970=15880 足球的面积 =41457.6 平方毫米 象素的间距 =41457.6/15880=2.6 毫米

Page 30: Chapter 5 The Gray-Level Histogram ( 灰度直方图 ) The gray-level histogram is a function showing, for each gray level, the number of pixels in the image that.

上机实习 1 、在 matlab 软件中编制读取图象并输出其直方图

的程序。 ( 不使用 imhist 函数 )