chapter 4: point processing 4.1 introduction

26
1 Chapter 4: Point Processing 4.1 Introduction • Any image-processing operation transforms the gray values of the pixels. • Image-processing operations may be divided into three classes based on the information required to perform the transformation. •From the most complex to the simplest, they are as follows: Transforms Neighborhood processing Point operations

Upload: dayo

Post on 05-Jan-2016

105 views

Category:

Documents


1 download

DESCRIPTION

Chapter 4: Point Processing 4.1 Introduction. From the most complex to the simplest, they are as follows: Transforms Neighborhood processing Point operations. Any image-processing operation transforms the gray values of the pixels. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Chapter 4: Point Processing 4.1  Introduction

1

Chapter 4: Point Processing4.1 Introduction

• Any image-processing operation transforms the gray values of the pixels.

• Image-processing operations may be divided into three classes based on the information required to perform the transformation.

•From the most complex to the simplest, they are as follows: Transforms Neighborhood processingPoint operations

Page 2: Chapter 4: Point Processing 4.1  Introduction

2

(Point operations)

FIGURE 4.1

Page 3: Chapter 4: Point Processing 4.1  Introduction

3

4.2 Arithmetic Operations

• These operations act by applying a simple function

ex: y=x±C, y=Cx

• In each case we may have to adjust the output slightly in order to ensure that the results are integers in the

0 . . . 255 range (type uint8)

Page 4: Chapter 4: Point Processing 4.1  Introduction

4

FIGURE 4.3

Page 5: Chapter 4: Point Processing 4.1  Introduction

5

FIGURE 4.4 & TABLE 4.1

Page 6: Chapter 4: Point Processing 4.1  Introduction

6

FIGURE 4.5

Page 7: Chapter 4: Point Processing 4.1  Introduction

7

COMPLEMENTS • The complement of a grayscale image is its

photographic negative• type double (0.0~1.0):1-m• type uint8 (0~255): 255-m

4.2 Arithmetic Operations

Page 8: Chapter 4: Point Processing 4.1  Introduction

8

4.3 Histograms

• A graph indicating the number of times each gray level occurs in the image

>>imhist functiona = [10 10 10 10 10;

20 20 20 20 10; 50 50 50 50 50; 90 90 90 50 50]

0

1

2

3

4

5

6

7

0 10 20 50 90

Page 9: Chapter 4: Point Processing 4.1  Introduction

9

FIGURE 4.8

Page 10: Chapter 4: Point Processing 4.1  Introduction

10

4.3.1 Histogram Stretching• A table of the numbers ni of gray values

(with n = 360, as before)• We can stretch out the gray levels in the center

of the range by applying the piecewise linear function

Page 11: Chapter 4: Point Processing 4.1  Introduction

11

• where i is the original gray level and j is its result after the transformation

4.3.1 Histogram Stretching

• This function has the effect of stretching the gray levels 5–9 to gray levels 2–14

• The corresponding histogram

Page 12: Chapter 4: Point Processing 4.1  Introduction

12

• Use of imadjust

• imadjust is designed to work equally well on images of type double, uint8, or uint16

FIGURE 4.10

• the values of a, b, c, and d must be between 0 and 1

• the function automatically converts the image im (if needed) to be of type double

Page 13: Chapter 4: Point Processing 4.1  Introduction

13

• Note that imadjust does not work quite in the same way as shown in Figure 4.9

• The imadjust function has one other optional parameter: the gamma value

4.3.1 Histogram Stretching

Page 14: Chapter 4: Point Processing 4.1  Introduction

14

FIGURES 4.12 & 4.13

Page 15: Chapter 4: Point Processing 4.1  Introduction

15

• A PIECE WISE LINEAR-STRETCHING FUNCTION

• The heart of this function will be the lines

where im is the input image and out is the output image

4.3.1 Histogram Stretching

Page 16: Chapter 4: Point Processing 4.1  Introduction

16

Refer to figure 4.15Refer to figure 4.15

FIGURE 4.16

The tire image after piecewise linear-stretching and piecewise linear-stretching function.

Page 17: Chapter 4: Point Processing 4.1  Introduction

17

Function histpwlfunction out = histpwl(im,a,b)%% HISTPWL(IM,A,B) applies a piecewise linear transformation to the pixel values% of image IM, where A and B are vectors containing the x and y coordinates% of the ends of the line segments. IM can be of type UINT8 or DOUBLE,% and the values in A and B must be between 0 and 1.%% For example:%% histpwl(x,[0,1],[1,0]) %% simply inverts the pixel values.%classChanged = 0;if ~isa(im, 'double'), classChanged = 1; im = im2double(im);end if length(a) ~= length (b) error('Vectors A and B must be of equal size');end

N=length(a);out=zeros(size(im));

for i=1:N-1

pix=find(im>=a(i) & im<a(i+1));

out(pix)=(im(pix)-a(i))*(b(i+1)-b(i))/(a(i+1)-a(i))+b(i);

end

pix=find(im==a(N));

out(pix)=b(N);

if classChanged==1

out = uint8(255*out);

end

Page 18: Chapter 4: Point Processing 4.1  Introduction

18

4.3.2 Histogram Equalization• An entirely automatic procedure• Suppose our image has L different gray levels, 0,

1, 2, . . . , L − 1, and gray level i occurs ni times in the image

Where n=n0 +n1 +n2 +· · ·+nL−1

• EXAMPLE Suppose a 4-bit grayscale image has the histogram shown in Figure 4.17, associated with a table of the numbers ni of gray values

Page 19: Chapter 4: Point Processing 4.1  Introduction

19

((LL-1)/-1)/nn

4.3.2 Histogram Equalization

Page 20: Chapter 4: Point Processing 4.1  Introduction

20

FIGURE 4.19

• histeq

Page 21: Chapter 4: Point Processing 4.1  Introduction

21

FIGURE 4.20

Page 22: Chapter 4: Point Processing 4.1  Introduction

22

FIGURE 4.21

Page 23: Chapter 4: Point Processing 4.1  Introduction

23

• WHY IT WORKS If we were to treat the image as a continuous function f (x, y) and the histogram as the area between different contours, then we can treat the histogram

as a probability density function.

4.3.2 Histogram Equalization

Page 24: Chapter 4: Point Processing 4.1  Introduction

24

4.4 Lookup Tables• Point operations can be performed very

effectively by using a lookup table, known more simply as an LUT

• e.g., the LUT corresponding to division by 2 looks like

• If T is a lookup table in MATLAB and im is our image, the lookup table can be applied by the simple command

Page 25: Chapter 4: Point Processing 4.1  Introduction

25

• e.g., >> b = b+1;

4.4 Lookup Tables

>> b2 = T(b+1);

• As another example, suppose we wish to apply an LUT to implement the contrast-stretching function

Page 26: Chapter 4: Point Processing 4.1  Introduction

26

FIGURE 4.23