spatial-domain image enhancement toolbox … image enhancement toolbox using matlab ... image...

29
EECE-7311 2D Signal & Image Processing FALL2012 Spatial-Domain Image Enhancement Toolbox Using MATLAB Haofu Liao, BSEE December 7, 2012 Department of Electrical and Computer Engineering Northeastern Universit y

Upload: hoanganh

Post on 30-May-2018

255 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

EECE-7311 2D Signal & Image Processing FALL2012              

Spatial-Domain Image Enhancement Toolbox Using MATLAB

                                     

Haofu Liao, BSEE  

December 7, 2012                                            

Department of Electrical and Computer Engineering  

Northeastern University

Page 2: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

2  

ABSTRACT

This report designed a toolbox for some useful spatial-domain image enhancement

techniques with MATLAB. In this report, we first studied and introduced some useful techniques

of spatial-domain image enhancement. Then, based on these study, this report designed a useful

toolbox with MATLAB. Finally, this report implemented this toolbox on some specific images

and verified the functions of these image enhancement techniques.

                                                                                             

Page 3: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

3  

Contents I. Introduction .............................................................................................................................. 4

II. The Definition of Spatial-Domain Pixel Point Transformations .................. 5

Logarithmic and Exponential Transformation ..................................................................... 5 A.

Linear Transformation ......................................................................................................... 7 B.

Gamma Transformation ....................................................................................................... 9 C.

Gray-Level Slicing ............................................................................................................. 10 D.

Bit-Plane Slicing ................................................................................................................ 11 E.

Histogram Equalization ...................................................................................................... 12 F.

III. Toolbox Design ........................................................................................................... 12

Interface ............................................................................................................................. 13 A.

Functions ............................................................................................................................ 17 B.

IV. Implementation and Analysis .................................................................................. 19

Logarithmic and Exponential Adjustment ......................................................................... 19 A.

Linear Transformation ....................................................................................................... 21 B.

Gamma Transformation ..................................................................................................... 25 C.

Gray-Level Slicing ............................................................................................................. 27 D.

Bit-Plane Slicing ................................................................................................................ 27 E.

Histogram Equalization ...................................................................................................... 28 F.

V. Conclusions ........................................................................................................................... 29

VI. References ....................................................................................................................... 29

VII. Vita ................................................................................................................................. 29

 

   

Page 4: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

4  

I. Introduction

Image enhancement is the process of manipulating an image so that the result is more

suitable than the original for a specific application. Image enhancement approaches fall into two

broad categories: spatial domain methods and frequency domain methods. In this report, we will

focus on the spatial-domain image enhancement.

The term spatial domain refers to the aggregate of pixels composing an image. Spatial

domain methods are procedures that operate directly on these pixels. Spatial domain processes

will be denoted by the expression

𝑔 𝑛!,𝑛! = 𝑇 𝑓(𝑛!,𝑛!)

where 𝑓 𝑛!,𝑛! is the input image, 𝑔(𝑛!,𝑛!) is the processed image, and T is an operator on 𝑓.

The simplest form of 𝑇 is when the neighborhood is a single pixel. In this case, 𝑔 depends only

on the value of 𝑓 at 𝑛!,𝑛! , and 𝑇 becomes a gray-level transformation function of the form

𝑦 = 𝑇(𝑥)

where, for simplicity in notation, 𝑦 and 𝑥 are variables denoting, respectively the gray-level of

𝑓 𝑛!,𝑛! and 𝑔(𝑛!,𝑛!) at any point 𝑛!,𝑛! . This report will study and introduce several useful

transformations 𝑇 here

• Logarithmic and Exponential Transformation

• Linear Transformation (including piecewise linear transformation and complement

transformation)

• Gamma Transformation

• Gray-Level Slicing

• Bit-Plane Slicing

• Histogram Equalization

MATLAB provides us a convenient way to create graphic user interface (GUI). With the

help of MATLAB, this report will design a toolbox, which can be useful to study and understand

the meaning of these transformations.

This report is organized as follow: section II studied some useful techniques of spatial-

domain image enhancement, including linear adjustment, gamma adjustment, logarithmic and

exponential adjustment, bit-plane slicing, gray-level slicing, and histogram equalization. Section

Page 5: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

5  

III designed a toolbox for these techniques in MATLAB. Section IV implemented the toolbox on

some specific images and verified the functions of these image enhancement techniques.

Conclusions are shown in Section V.

II. The Definition of Spatial-Domain Pixel Point Transformations

Logarithmic and Exponential Transformation

1. Logarithmic Transformation

The general form of the logarithmic transformation is

 𝑦 =ln 1+ 𝑒! − 1 𝑥  

𝐾 ,𝐾 ≥ 0

Where 𝐾 is a constant. The shape of the log curve shows that this transformation maps a narrow

 

range of low gray-level values in the input image into a wider range of output levels, which

means it compress the bright range and expand the dark range.

Figure  1  Logarithmic  Transformation  

K=0  

K>0  

Page 6: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

6  

2. Exponential Transformation

The form of the exponential transformation is

𝑦 =1+ 𝐾 ! − 1

𝐾 ,𝐾 ≥ 0

where 𝐾 is a constant. The shape of the log curve shows that this transformation maps a narrow

range of high gray-level values in the input image into a wider range of output levels, which

means it compress the dark range and expand the light range.

3. Combination of these Two Transformation

𝑦 =

ln 1+ 𝑒!! − 1 𝑥  –𝐾 ,𝐾 < 0𝑥,𝐾 = 0

1+ 𝐾 ! − 1𝐾 ,𝐾 > 0

In this report, for simplicity, we combined this two transformation together. Hence, K can

vary from minus infinity to plus infinity.

Figure  2  Exponential  Transformation

K=0  

K>0  

Page 7: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

7  

Linear Transformation

In this report, we defined three types of linear transformation here: no-point linear

transformation, one-point linear transformation, and two-point linear transformation.

1. No-Point Linear Transformation

The basic form of no-point linear transformation is

𝑦 = 𝐺𝑥+ 𝐵, 0 ≤ 𝑥 ≤ 1,0 ≤ 𝑦 ≤ 1  

where 𝐺 and 𝐵 are both constants. This form of linear transformation is used for correcting a

common defect called poor contrast. There, 𝐺 and 𝐵 vary from minus infinity to plus infinity. It

is not good for us to control. In this report, in order to control the coefficient easily when we

design the toolbox, we defined this linear transformation like this

𝑦 = 𝑡𝑎𝑛𝜃 𝑥 − 𝑥! + 𝑦!,−𝜋 ≤ 𝜃 ≤ 𝜋, 0 ≤ 𝑥! ≤ 1,0 ≤ 𝑦! ≤ 1

where 𝜃, 𝑥! and 𝑦! are constant. For 𝜃, 𝑥! and 𝑦! are all vary in a limit range, it is easy for us to

control the form of the no-point linear transformation.

Figure  3  No-­‐Point  Linear  Transformation

Page 8: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

8  

2. One-point Linear Transformation

The form of one-point linear transformation is

𝑦 =

𝑦!𝑥!𝑥, 0 ≤ 𝑥 ≤ 𝑥!

1 − 𝑦!1 − 𝑥!

𝑥 +𝑦! − 𝑥!1 − 𝑥!

, 𝑥! ≤ 𝑥 ≤ 1  

where 𝑥! and 𝑦! are both constant. This type of linear transformation is defined to stretch the

dark range or the light range of the image. When the point (𝑥!,𝑦!) is in the upper left of the

transformation area, it stretch the dark range. And when the point (𝑥!,𝑦!) is in the lower right of

the transformation area, it stretch the light range.

3. Two-point Linear Transformation

The form of two-point linear transformation is

Figure  4  One-­‐Point  Linear  Transformation

Page 9: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

9  

𝑦 =

𝑦!𝑥!𝑥, 0 ≤ 𝑥 ≤ 𝑥!

𝑦! − 𝑦!𝑥! − 𝑥!

𝑥 +𝑦!𝑥! − 𝑦!𝑥!𝑥! − 𝑥!

, 𝑥! ≤ 𝑥 ≤ 𝑥!1− 𝑦!1− 𝑥!

𝑥 +𝑦! − 𝑥!1− 𝑥!

, 𝑥! ≤ 𝑥 ≤ 1

where 𝑥!,𝑦!, 𝑥!,𝑦! are all constant. This type of linear transformation is defined to stretch the

middle range of the image. There are two points, (𝑥!,𝑦!) and (𝑥!,𝑦!), in the transformation.

Their position defines the mid rang that should be stretched. Thus, by control values of

𝑥!,𝑦!, 𝑥!,𝑦!, we can stretch the specific mid rang of the image.

Gamma Transformation

The form of gamma transformation is

𝑦 =

𝑥 − 𝑙𝑖ℎ𝑖 − 𝑙𝑖

!

ℎ𝑜 − 𝑙𝑜 + 𝑙𝑜, 𝑙𝑖 ≤ 𝑥 ≤ ℎ𝑖

𝑙𝑜, 𝑥 ≤ 𝑙𝑖𝑙ℎ, 𝑥 ≥ 𝑙ℎ

, 𝛾 ≥ 0, 𝑙𝑖 < ℎ𝑖

where 𝑙𝑖, ℎ𝑖, 𝑙𝑜, ℎ𝑜 and 𝛾 are constant. Here, 𝑙𝑖, ℎ𝑖, 𝑙𝑜  and  ℎ𝑜 stand for low input, high input, low

Figure  5  Two-­‐Point  Linear  Transformation

Page 10: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

10  

output and high output. The gamma transformation has two functions. First, by varying the

coefficient 𝛾 we can stretch the dark or the light range. If 𝛾 < 1 it stretch the dark range, and if

𝛾 > 1 it stretch the light range. Second, by varying the coefficients 𝑙𝑖, ℎ𝑖, 𝑙𝑜  and  ℎ𝑜 we can

define the range of input and output and change the contrast of the image.

Gray-Level Slicing

The form of gray-level slicing is

𝑦 =𝑦!, 𝑥! ≤ 𝑥 ≤ 𝑥!

𝑦!, 𝑒𝑙𝑠𝑒  

where 𝑥!, 𝑥!,𝑦!  𝑎𝑛𝑑  𝑦! are constant. It is used to brighten desired range of gray level but

reduces all others to a constant level.

Figure  6  Gamma  Transformation

Page 11: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

11  

Bit-Plane Slicing

Here, we assume that each pixel is represented by 8 bits. Thus, the image is composed of 8

1-bit planes. That is, in the 𝑘th bit plane, each pixel has the value of 𝑘th bit of the corresponding

pixel. For a bit can only have the value of 0 or 1, each plane can only be a pure black and white

image.

We can get each bit-plane by the way below

Step1: 𝑦 = 𝑚𝑜𝑑(𝑥, 2), and output 𝑦.

Step 2: 𝑥!"# =!!!!

Step 3:  𝑥 = 𝑥!"#, if 𝑥 ≠ 0, goes to step1.

Here 𝑥 is a 256 level image. Hence, The output 𝑦 of each iteration is a bit-plane.

By bit-plane slicing we can know the contribution of each bit plane that made to the image

appearance.

Figure  7  Gray-­‐Level  Slicing

Page 12: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

12  

Histogram Equalization

1. Histogram

The histogram of a digital image with gray levels from 0 to 𝐿 − 1 is a discrete function

𝐻 𝑥! = 𝑁!, where 𝑥! is the 𝑘!! gray level, 𝑘 = 1,2… 𝐿 − 1, 𝑁! is the number of pixels in the

image with that gray level, 𝑁 is the total number of pixels in the image.

2. Histogram Equalization

The histogram equalization is to obtain an image whose histogram is constant or flat over

the entire dynamic range.

The form of histogram equalization is

𝑦 = 𝑝!(𝑢)𝑑𝑢!

!  

where 𝑝!(𝑢) is the probability density function of 𝑥.

III. Toolbox Design

This toolbox is based on the spatial-domain image enhancement techniques that we have

talked above. It is consist of 55 components, and there are 10 MATLAB files including more

than 1400 command lines to support its running. In this toolbox, we provide 6 types of

transformation modes, and it can realize about 8 transformation functions. The main idea of this

toolbox is to give the user a clear view of the relations between the transformation results,

transformation functions and the histogram.

Page 13: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

13  

Interface

The interface of the toolbox consist of 6 parts: Select Image Button, Pop-up Menu, Image

Window, Transformation Function Window, Histogram Window, and Control Option panel.

Figure  9  Toolbox  Interface

Select Image Button Pop-up Menu

Image Window

Control Options panel

Transformation Function Window

Histogram Window

Figure  8  Toolbox  on  the  GUIDE

Page 14: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

14  

1. Image Select Button

It is used for selecting an image. When a user clicks this button, a GUI dialog will show up,

and then the user can browse his image and input it to the toolbox. When an image has

input to the toolbox, the toolbox will be initialized automatically, i.e. image window,

transformation window, and histogram window will process and display the corresponding

figures.

2. Pop-up Menu

It is used for selecting the transformation mode. When a user clicks this button, the pop-up

menu will show the available transformation modes, and when the user chooses a transformation

mode from the menu, the toolbox will be set to that mode. Then the user control options panel

will show up the corresponding control components.

Figure  10  GUI  Dialog  for  Selecting  the  Image

Figure  11  Pop-­‐up  Menu

Page 15: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

15  

3. Image Window

It is used for displaying the transformation results of the image.

4. Transformation Function Window

This window is used for displaying the transformation function. From this window, the user

can have a better understanding of the transformation function. This window not only displays

the curve of the transformation function, but also displays some useful makers, labels, and

legends to illustrate the function.

5. Histogram Window

This window displays the histogram of the transformation result.

Figure  12  Image  Window

Figure  12  Transformation  Function  Window  with  Point  and  Line  Makers,  Text  Box.

Figure  13  Transformation  Function  Window  with  Line  Markers,  Text  Box,  Legend

Page 16: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

16  

6. Control Options Panel

This control options panel provides an area that the user can do some adjustments and

operations to the input image.

From Figure 15 we can know that there are four buttons on the top of the control options

panel. The first one is the histogram equalization button. It can do the histogram equalization to

the input image. The second one is the complement button. By clicking this button, the user can

get the negative effect of the image. The third one is the save current image button. When the

user clicks this button, then all the following operations will aim to the saved image. The fourth

one is the original image button. It can recover the current image to the original image.

Below these buttons there will be some control components that can change the value of

coefficients of the transformation function. These control components vary with the

transformation mode. Each time when the user manipulates these control components, the image

Figure  14  Histogram  Window

Figure  15  Control  Option  Panel

Page 17: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

17  

window, the transformation function window and the histogram window will have corresponding

changes instantly. Hence, the user can have a better understanding of those transformations.

7. Bit-Plane Slicing Window

The bit-plane slicing window is an extra window that outside the main window of the

toolbox. This window displays the results of the bit-plane slicing and the reconstructed image

with selected bit planes.

Functions

In this subsection, we will talk about the design of the MATLAB functions. The toolbox is

supported by 10 MATLAB functions: Image_Enhancement_SD, display_bitplane,

display_gamma, display_graylevel, display_linear_no_point, display_linear_one_point,

display_linear_two_points, display_logandexp, bit_plane_slicing, and tick_judgement.

Figure  16  Bit-­‐Plane  Slicing  Window

Page 18: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

18  

1. Main function

The main function of the toolbox is the function: Image_Enhancement_SD. There are two

main parts in this function.

• Initialization

Initializing some user data that will be used by other functions. Creating the handles table.

The handles table contains a number of component handles. When a user chooses a

transformation mode, the background program will do two things. First, hide the control

components of the former mode. Second, show the control components of the current mode. To

finish this kind of hide/show operation, the background need to look up the handles table to

determine which control components should be hide, and which should be show.

• Callback Functions

There are more than 40 callback functions in the main function. These callback functions are

used to finish some background operations of the components. When a component is activated,

the toolbox will call its corresponding callback function automatically.

2. Display functions

This toolbox has 7 display functions: display_bitplane, display_gamma, display_graylevel,

display_linear_no_point, display_linear_one_point, display_linear_two_points, and

display_logandexp.

Each display function corresponds to a type of transformation mode. It means when a

transformation mode has been chosen, the current components will only call the display function

of this mode.

The display functions will work in this sequence: First, get the value of the current

components. Second, use transformation function to process the input image. Third, display the

transformation result, transformation function and the histogram of current image (the

transformation result).

3. Other functions

• The bit_plane_slicing Function

Page 19: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

19  

This function is the core function of the bit-plane slicing window. It manages the display of

the bit-plane images and operations of the radio buttons. It contains two parts: The first part is

the initialization part. In this part, the function will first get and display the original image, then

process bit-plane slicing, and display each bit plane. The second part contains several callbacks

of the radio buttons.

• The tick_ judgment Function

Tis function is used for display ticks in the transformation function window.

IV. Implementation and Analysis

Logarithmic and Exponential Adjustment

• Implementation

Figure  17  Log  and  Exp  Transformation,  K=-­‐4

Figure  18  Log  and  Exp  Transformation,  K=-­‐2

Page 20: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

20  

We choose the image lena.jpg as our input image. The values of the coefficient 𝐾 are

−4,−2, 0,4,𝑎𝑛𝑑  16. From the figures above, we can find that the image becomes darker and

darker as 𝐾 increases. As a result, the corresponding histogram moves from the right to the left,

which means that there are more pixels have the value that close to 0 (black) as K increases.

• Analysis

When 𝐾 is less than zero, the transformation is a logarithmic transformation. It will stretch

Figure  19  Log  and  Exp  Transformation,  K=0

Figure  20  Log  and  Exp  Transformation,  K=4

Figure  21  Log  and  Exp  Transformation,  K=16

Page 21: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

21  

the dark range of the image and compress the light range of the image (This can also be seen on

the histogram). Hence, the image becomes bright. When 𝐾 is larger than zero, the transformation

is an exponential transformation. It will compress the dark range of the image and stretch the

light range of the image (This can also be seen on the histogram). Hence, the image becomes

dark.

Linear Transformation

1. No-Point Linear Transformation

• Implement

Figure  22  No-­‐Point  Linear  Transformation,  𝑥! = 0.5,  𝑦! = 0.5, 𝜃 = !!

Figure  23  No-­‐Point  Linear  Transformation,  𝑥! = 0.5,  𝑦! = 0.5,  𝜃 = − !!

Page 22: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

22  

We choose the image lena.jpg as our input image. The coefficients of each figure are shown

on their caption.  From the figures above, we can find that Figure 23 is the complement of Figure

22. And their histograms are symmetric. The Figure 24 is brighter than the Figure 22 (original

image). And the point (𝑥!,𝑦!) is on the upper left of the transformation area. The Figure 25 is

darker than the Figure 22. And the point (𝑥!,𝑦!) is on the bottom right of the transformation area.

• Analysis

For Figure 23, we can know that its transformation function is

𝑦 = 1− 𝑥

It means that the transformation function will transform each pixel of the image to its

complement value. That is, when a pixel is white, it will become black after the transformation.

For Figure 24, from the transformation function, we can know that all the out put pixel value is

larger than 0.5, and when the input pixel value is larger than 0.5, the output pixel value will be

fixed to 1. This can be seen clearly from the histogram. Hence the output image will become

lighter than the original image. Similarly, we can explain why the output image of Figure 25 is

Figure  24  No-­‐Point  Linear  Transformation,  𝑥! = 0.25,  𝑦! = 0.75,  𝜃 = !!

Figure  25  No-­‐Point  Linear  Transformation,  𝑥! = 0.75,  𝑦! = 0.25,  𝜃 = !!

Page 23: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

23  

dark.

2. One-Point Linear Transformation

• Implementation

We choose the image lena.jpg as our input image. The coefficients of each figure are shown

on their caption. From the figures above, we can find that Figure 26 is brighter than the original

image, and its histogram moves to the right. Figure 27 is darker than the original image, and its

histogram moves to the left.

• Analysis

From the transformation function of Figure 26, we can know that the dark range of the

image is stretched and the light range is compressed. It can also be seen on its histogram. It

means that there are more pixels fall in the light range. Thus, we can see that the output image is

brighter than the original one. Similarly, we can explain why the Figure 27 is darker than the

Figure  26  One-­‐Point  Linear  Transformation,  𝑥! = 0.3,  𝑦! = 0.7

Figure  27  One-­‐Point  Linear  Transformation,  𝑥! = 0.7,  𝑦! = 0.3

Page 24: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

24  

original image.

3. Two-Point Linear Transformation

• Implementation

We choose the image lena.jpg as our input image. The coefficients of each figure are shown

on their caption. From the figures above, we can find that Figure 28 has a high contrast, and its

histogram moves to left and right side. Figure 29 has a poor contrast, and its histogram moves to

the center.

• Analysis

From the transformation function of the Figure 28, we can find that the middle range of the

image has been stretched. It means there are more pixels fall in both dark and light range. Hence,

the pixel that is dark will be darker, and the pixel that is light will be lighter. As a result, the

image will have a high contrast. From the transformation function of the Figure 29, we can find

that the dark and light range of the image has been stretched. It means there are more pixels fall

Figure  28  Two-­‐Point  Linear  Transformation,  𝑥! = 0.4,𝑦! = 0.2, 𝑥! = 0.6, 𝑦! = 0.8

Figure  29  Two-­‐Point  Linear  Transformation,  𝑥! = 0.2,𝑦! = 0.4, 𝑥! = 0.8, 𝑦! = 0.6

Page 25: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

25  

in the middle range. Hence, the image will be neither dark nor light. As a result, the image will

have a poor contrast.

Gamma Transformation

• Implementation

Figure  30  Gamma  Transformation,  𝛾=1,  𝐿𝑜𝑤  𝐼𝑛𝑝𝑢𝑡 = 0.3,𝐻𝑖𝑔ℎ  𝐼𝑛𝑝𝑢𝑡 = 0.7, 𝐿𝑜𝑤  𝑂𝑢𝑡𝑝𝑢𝑡 = 0,𝐻𝑖𝑔ℎ  𝑂𝑢𝑡𝑝𝑢𝑡 = 1

                 Figure  31  Gamma  Transformation,  𝛾=1,  𝐿𝑜𝑤  𝐼𝑛𝑝𝑢𝑡 = 0,𝐻𝑖𝑔ℎ  𝐼𝑛𝑝𝑢𝑡 = 1, 𝐿𝑜𝑤  𝑂𝑢𝑡𝑝𝑢𝑡 = 0, .35  𝐻𝑖𝑔ℎ  𝑂𝑢𝑡𝑝𝑢𝑡 = 0.65

Figure  32  Gamma  Transformation,  𝛾=1,  𝐿𝑜𝑤  𝐼𝑛𝑝𝑢𝑡 = 0,𝐻𝑖𝑔ℎ  𝐼𝑛𝑝𝑢𝑡 = 1, 𝐿𝑜𝑤  𝑂𝑢𝑡𝑝𝑢𝑡 = 0,𝐻𝑖𝑔ℎ  𝑂𝑢𝑡𝑝𝑢𝑡 = 1

Page 26: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

26  

We choose the image lena.jpg as our input image. The coefficients of each figure are shown

on their caption. From the figures above, we know that Figure 30 has a very high contrast and its

histogram is highly concentrated on 1 and 0. Figure 31 has a very poor contrast. Its histogram is

concentrated on the middle. Figure 32 is the original image with 𝛾 = 1. Figure 33 is darker than

the original image and its histogram is concentrated on low gray-levels. Figure 34 is brighter

than the original image and its histogram is concentrated on high gray-levels.

• Analysis

From the transformation function of Figure 30, we can know that all the gray-levels that less

than 0.3 are fixed to 0 and those who larger than 0.7 are fixed to 1. The gray-levels that between

0.3 and 0.7 are stretched from 0 to 1 uniformly. It means there are more pixels have a color close

to black or white. Hence Figure 30 has a high contrast. From the histogram and transformation

function of Figure 31, we can know that the output image have only the pixel values that

between 0.35 and 0.65. It means the pixel values in the image won’t vary a lot. Hence, it has a

poor contrast. From the transformation function of Figure 33, we can know that its dark range

has been compressed and its light range has been expanded. It can also been seen from its

Figure  33  Gamma  Transformation,  𝛾=2.5,  𝐿𝑜𝑤  𝐼𝑛𝑝𝑢𝑡 = 0,𝐻𝑖𝑔ℎ  𝐼𝑛𝑝𝑢𝑡 = 1, 𝐿𝑜𝑤  𝑂𝑢𝑡𝑝𝑢𝑡 = 0,𝐻𝑖𝑔ℎ  𝑂𝑢𝑡𝑝𝑢𝑡 = 1

Figure  34  Gamma  Transformation,  𝛾=0.3,  𝐿𝑜𝑤  𝐼𝑛𝑝𝑢𝑡 = 0,𝐻𝑖𝑔ℎ  𝐼𝑛𝑝𝑢𝑡 = 1, 𝐿𝑜𝑤  𝑂𝑢𝑡𝑝𝑢𝑡 = 0,𝐻𝑖𝑔ℎ  𝑂𝑢𝑡𝑝𝑢𝑡 = 1

Page 27: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

27  

histogram. Its means there are more pixel values that fall in to the dark range. Hence the image is

darker than the original image. Similarly, we can explain why the Figure 34 is brighter than the

original image.

Gray-Level Slicing

The left image of Figure 35 is an original bubble image. Now, we want to highlight the

bubbles in the image and ignore other objects. Hence, we do a gray-level slicing to the bubble

image, and by vary the parameter 𝑥! and 𝑥!, we can know that the pixel values of the bubbles is

between about 0.65 to 1. Hence, after the gray-level slicing we get the transformed image on the

right of Figure 35. Here, 𝑥! represents the minimum value of the slicing range. 𝑥! represents the

maximum value of the slicing range.

Bit-Plane Slicing

From the bit planes of Figure 36, we know that the 1st bit plane contains the least significant

bit, and it contributes very little to the appearance. It looks like just a noise image. The 8th bit

plane contains the most significant bit, and it looks very close to the original image.

Only the higher order bits (5th to 8th bit plane) contain visually significant data. The other bit

planes contribute the more subtle details.

The right upper image of Figure 36 is the reconstructed image of 3rd, 5th, 6th and 7th bit-

plane. We can see that it looks like the original image, but has lost some details.

Figure  35  Gray-­‐Level  Slicing,  𝑥! = 0.65, 𝑥! = 1, 𝑦! = 0, 𝑦! = 1

Page 28: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

28  

Histogram Equalization

Figure  37  Histogram  Equalization

Figure  36  Bit-­‐Plane  Slicing  of    “Cameraman”  Image

Page 29: Spatial-Domain Image Enhancement Toolbox … Image Enhancement Toolbox Using MATLAB ... Image enhancement is the process of manipulating an image so that ... ! is the input image,

29  

The upper left image of Figure 37 has a very poor contrast. And its histogram is

concentrated on the middle. After histogram equalization, from the bottom left image of Figure

37, we can find that the contrast has been greatly improved. And the histogram is almost

uniformly distributed on the entire gray-levels.

V. Conclusions

In this report, we first studied the basic theory of some spatial-domain enhancement

techniques. For some techniques, this report also provides some revised transformations, which

can simplify the design of the toolbox. Then, this report introduced the design of the interface of

the toolbox, and explains the work sequences of the MATLAB functions of the toolbox. Finally,

this report, realized all the spatial-domain enhancement techniques that mentioned in the first

part with help of the toolbox. For each implementation, this report also gave an analysis of the

corresponding spatial-domain technique.

VI. References

[1] R.C. Gonzalez and R.E. Woods, Digital Image Processing, Prentice Hall, Upper

Saddle River, NJ, 2001 (Third Edition).

[2] John W. Woods, Multidimensional Signal, Image, and Video Processing and

Coding, Academic Press, Waltham, MA, 2012 (Second Edition)

[3] R.C. Gonzalez, R.E. Woods, and S.L. Eddins, Digital Image Processing Using

MATLAB, Prentice Hall, Upper Saddle River, NJ, 2004.

VII. Vita

LIAO HAOFU

Education

B.S. Communication Engineering 2012 Beijing University of Posts and Telecommunication