The report of the lab1

The report of the lab1
The report of the lab1

DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING

Image Processing

EEE330

The Report of Image Enhancement

Instructor:Dr.Jimin.Xiao

Student Name:Lei.Shi

ID:1201652

Email:Lei.shi12@https://www.360docs.net/doc/ac10062223.html,

Abstract

This experiment concerning the images enhancement and recovery has been conducted in the computer laboratory at March23,2016.In the experiment, several Matlab functions have been utilized for the objectives of the lab.The lenna photograph known well in the image processing?led has been introduced in the software Matlab and some other pictures obtained from the original lenna picture are utilized for investigating the characteristics of these Matlab func-tions.

Key Words:Matlab,Image processing.

Contents

Contents1

1Introduction2

1.1Background (2)

1.2PSNR&SSIM (2)

1.3Assignment&Objectives (3)

2Methodology&Results6

2.1Task1 (6)

2.2Task2 (6)

2.3Task3 (11)

2.4Task4 (13)

2.5Task5 (15)

2.6Task6 (18)

2.7Task7 (21)

2.8Task8 (23)

3Conclusion26 Bibliography27 Appendices28

1

Chapter1

Introduction

1.1Background

Image is the visual base of the humanity to perceive the world and is also the signi?cant method to receive,express and transform messages.The require-ment that utilize images to present messages and understand the world has been more and more remarkable in the21th century.This experiment is aiming at studying the features of some Matlab functions in the process of enhancing and recovering some lenna images which are blurred or added with noise.

1.2PSNR&SSIM

In the?eld of image processing,the term PSNR is the abbreviation of Peak signal-to-noise ratio which is applied to measure the quality of reconstruction of lossy image.[1]According to the citation,in general,the higher value of the PSNR will indicate the quality of reconstruction of the lossy image is higher. Nevertheless,there are some constraints for this metric.When the reconstruc-tions of the lossy image are obtained by different codec,the PSNR will not be

2

valid for a metric to measure the quality of the reconstruction.The calculation

formulas of PSNR are given in the portion of task1.Besides this metric,there

still another method SSIM is adopted to measure the quality of reconstruction

of the lossy image.According to the citation[2],the maximum value of SSIM

is1and the value is closer to1and the quality of reconstruction of the lossy

image will be higher.Since there has been the ssim function in the Matlab,the

command ssim can be utilized directly in the experiment in order to?nd the

SSIM value.The comparison of the two method also has been conducted in the experiment so that the better metric of them will be adopted in the future study.

1.3Assignment&Objectives

The experiment is divided into eight portions and the task of each section has

been speci?ed in the lab script.Utilizing the Matlab functions imhist,histeq, blockproc,im?lter,fspecial,med?lt2and deconvwnr to?nish the experimental tasks

step by step.Before the experiment,the image materials are provided in the compressed?le lab1.zip which includes six images:lenna512AWGN.bmp,lenna512SandP.bmp, lenna512dark.bmp,lenna512DBG.bmp,lenna512BBG.bmp and lenna512blurred.bmp.

In the process of the experiment,the changes of the image before and after pro-

cessing are required to be observed and the relative images are needed to be

attached at the corresponding sections and then to provide some explanations

for the corresponding changes.The tasks of the experiment are listed below.

1Task1:To write a function in the Matlab to measure the Peak Signal to Noise

Ratio(PSNR)between two images in the unit dB with the given formulas of

PSNR.

2Task2:Firstly,to download the other six lenna images which are blurred

or have some noise.These images are compressed in the?le lab.zip given

Page3of34

together with the lab script.Then utilizing the function written in the?rst task to calculate the values of the PSNR between the original lenna image and the each image in the?le https://www.360docs.net/doc/ac10062223.html,st,depicting the histograms of all images and comparing them with each other to?nd the changes and explain them.

3Task3:To design a piece-wise linear function(mapping function)to enhance the contrast of the image lenna512dark.bmp and con?rm the effectiveness of the designed function from the aspects of histogram and the value PSNR of the images.

4Task4:To utilize the histeq function to enhance the contrast of the image lenna512dark.bmp and compare the output image with the result gained from the task3.

5Task5:To apply the function fspecial to generate some?lters with the different parameter len and the same parameter theta=0.Then using the im?lter func-tion to gain different the blurred images of the original lenna https://www.360docs.net/doc/ac10062223.html,stly, to display the blurred output images and to compare the histograms of them and to?nd the differences between them.Of course,the explanations of the changes are required to be given.

6Task6:To design a linear spatial domain low pass?lter to reduce the noise and to improve the PSNR value between the original lenna image and image lenna512AWGN.bmp in the?le lab1.zip.There are two choices for the spatial ?lter.One of which is to use3×3kernels and another is to use5×5kernels. Then to display the?ltered images and to calculate the PSNR values.At last, to compare the results of the two kinds?lters with discussing the effective-ness of them.

7Task7:To apply the nonlinear spatial?lter-median?lter to process the image

Page4of34

lenna512SandP.bmp.Similarly,the median?lter also has two types3×3win-dow and5×5window.The output images are needed to be depicted and the PSNR values are necessary to be calculated to conduct a comparison.In addi-tion,the linear spatial?lter-average?lter with the size3kernels is adopted to process the image lenna512SandP.bmp.Then to compare the results and the performances gained by the nonlinear?lter and the linear?lter.

8Task8:The image lenna512blurred.bmp is gained by someone point spread function with the linear parameter len and the zero theta.To utilize the func-tion deconvmnr to recover the blurred image when the additive noise is lo-cated in the interval of0to0.0004and to try the different parameter len to ?nd the best len.

Page5of34

Chapter2 Methodology&Results

2.1Task1

The formula for measuring the PSNR is listed below.

PSNR(dB)=10log10(2552

mse

)(2.1)

Where the mse is decided by

mse=1

N

?ri

?ci

(im(ri,ci)?im2(ri,ci))2(2.2)

The function called calculate psnr is written in the matlab script which is attached in the task1portion in the appendix.

2.2Task2

The six images in the?le lab1.zip are loaded in the Matlab as im wn,im SP,im d, im DBG,im BBG and im blr respectively.The original image and these images

6

and the histograms of them are displayed as below.

Figure2.1:The original image and histogram of lenna512.bmp

Figure2.2:The image and histogram of lenna512AWGN.bmp

Page7of34

Figure2.3:The image and histogram of lenna512SandP.bmp

Figure2.4:The image and histogram of lenna512dark.bmp

Page8of34

Figure2.5:The image and histogram of lenna512DBG.bmp

Figure2.6:The image and histogram of lenna512BBG.bmp

Page9of34

Figure2.7:The image and histogram of lenna512blurred.bmp

Then using the function written in the task1to calculate the PSNR between the original image and the other?ve images and the corresponding PSNR values are displayed in the table2.1.

image lenna512

AWGN

lenna512

SandP

lenna512

dark

lenna512

DBG

lenna512

BBG

lenna512

blurred

PSNR(dB)28.106919.478115.201113.828011.431821.3622

Table2.1:The PSNR value of these images

A histogram of an image represents the number of the different pixels which have different gray scale value ranging from0to255shown in anyone his-togram above.The original image has an uniform pixels distribution on the gray scale shown in the?gure2.1.Nevertheless,the other images have differ-ent pixels distribution on the gray scale.Some of which compress the range of gray scale like the image lenna512dark and some stretch the gray scale.In addition,the number of the pixels on speci?cal gray values are changed.The different histograms determine the differences of the images.In the task1,the

Page10of34

PSNR value measuring function has been given.After comparing the PSNR values of these images,the fact that the large PSNR value indicates the higher quality image compared to the original image can be found.

2.3Task3

The piece-wise linear function is designed and the whole Matlab script is at-tached in the corresponding section of the appendix.The code of the function is attached as below.

function imageo=enhance_contrast(imagei)

imagei=double(imagei);

imageo=(imagei*0.8+imagei*2.9+imagei*0.8)/3;

imageo=uint8(imageo);

In order to enhance the contrast of an image,?rstly,the gray values of the image can be utilized to multiply with0.8,2.9and0.8respectively to be the three new images.Then to get the average value of them and to regard the?nal result to be the enhanced image.This function will be applied in this task to gain the en-hanced image of the image lenna512dark.After running the Matlab script,the image and the histograms of the original image,the enhanced image and the output image are displayed as below.

Page11of34

Figure2.8:The image and histogram of the corresponding images

From the histogram,the pixels distribution on the gray scale of the output im-age is closer to the original image compared with the lenna512dark.In the vision aspect,after enhancing,the output image is also apparent higher quality than the image lenna512dark.The PSNR and SSIM are collected from the command window shown as below.

Figure2.9:The PSNR and SSIM of the lenna512dark and the enhanced image

Page12of34

The data are collected into the Table2.2shown as below.

image lenna512dark

Enhanced lenna512dark

PSNR(dB)15.201152.8568

SSIM(dB)0.88980.9980

Table2.2:The PSNR and SSIM of the lenna512dark and the enhanced image

Aftering applying the PSNR function of the task1,the PSNR of the original image and the image lenna512dark is calculated as15.2011and the PSNR of the original image and the output image is52.8568.Which indicates there is an apparent improved effect on the enhanced image due to the larger PSNR value. In addition,the experiment also provides the SSIM value to measure the dif-ference between two images.The SSIM values of the image lenna512dark and output image compared with the reference image is0.8898and0.9980re-spectively.It is clear that the image after enhancing has a larger SSIM value and this image is also closer to the original image and has a higher quality in the side of vision.

2.4Task4

Using the Matlab function histeq to enhance the contrast of the lenna512dark and the result has been compared with the results gained from the task3.The Matlab script is attached in the appendix.The enhanced images from the task3 and from this task are exhibited as below.

Page13of34

Figure2.10:The image and histogram of the enhanced images

According to the?gure2.11,the result gained by the Matlab command histeq is abrupt,which causes some places of the image is too bright and some places are too dark.In the histogram,the pixels distribution of this image is more discrete than the result of the task3.Consequently,the enhancement effect of the command histeq is inferior to the function designed in the task3.Also the PSNR and SSIM are calculated in the command window shown as below and the data of this part and the relative data from task3are collected into the Table 2.3.

Page14of34

Figure2.11:The image and histogram of the enhanced images

image lenna512dark

Enhanced

lenna512dark

Enhanced lenna512dark

by histeq

PSNR(dB)15.201152.856819.0761

SSIM(dB)0.88980.99800.8501

Table2.3:The PSNR and SSIM of the lenna512dark and the enhanced image

The PSNR value of the?nal result is19.0761shown in the Table2.3.This value is signi?cant smaller than the PSNR value52.8568in the tsak3.This evidence proofs the enhanced image obtained by histeq is weak compared with the results of the task3.In addition,the SSIM also can con?rm the conclusion.In this portion,the SSIM value of the reference image and the output image is0.8501, which is smaller than the SSIM value0.9980gained in the task3and then to re?ect that the command histeq is inferior to the function written in the task3.

2.5Task5

In this section,the command fspecial is used to form some?lters with different parameters and then apply the command im?lter to gain the blurred images. The Matlab script is attached in the corresponding part of the appendix.As for the command fspecial,there are two parameters,theta and len.The former is al-

ways kept as zero and the latter can be chosen as10,60and120.The generated blurred images and the reference images are exhibited as below.

Figure2.12:The image and histogram of the reference images and the blurred images

Observing from the histograms of the blurred images,the quality of the blurred image is lower,the gray scale on the histogram is narrower and the number of the pixels of the gray value locating at the center of the whole gray range appar-

Page16of34

ently increases,which indicates the distribution of the pixels is more compact on the gray scale.Since the camera and the objects exist relative movement, when the camera tries to capture the image of the moving objects in the tran-sient time of pressing the shutter of the camera,the?nal image can be regarded as the sum of a set of images.Actually,the sum of the images is the total addi-tion of the gray values of all images at corresponding point.Due to the move-ment of the objects,the distribution of the gray values will tend to gather into the center gray value.Here provides a?ow chart to show a system to utilize the histogram of image to auto-focus.

Page17of34

Start

Get a series motion blurred images with the di?erent len and moving shots

To generate all histograms of all blurred images

To?nd the most extensive distribution of gray values of all histograms

To?nd the best len and achieve auto-adjust the shot of camera then?nish the auto-focus

End

2.6Task6

The linear gaussian spatial domain low pass?lters are designed and the Matlab script is attached in the appendix.Since there are many types of linear spatial low pass?lters,there only choose two types,average and gaussian to improve the PSNR value of the image lenna512AWGN.According to the instruction of

Page18of34

相关主题
相关文档
最新文档