Docsity

Problems on Introduction Digital Images - Assignment 2 | ECE 178, Assignments of Electrical and Electronics Engineering

Toggle sidebar
bg1
ECE 178 HW #2
Due: Wednesday, Oct 15, 2008
Cha pter 2
Problems 2.15 , 2 .1 6, 2.17 ,
Cha pter 3
Problems 3.4, 3. 5
Progra mmi ng a s sig n m e nt
In this MA TLAB assignme nt , we shall study the effect of histog ram equalization and how it
can be implemented with a piecewise linear transfor ma tio n of the pixel values. The original
image is lena.gif. Pl ot its histogram using the i mhis t command in MA TLAB. Then, consider
the darkened versi on of the image, called daklena.gif. Again, plo t its histogram using the
imhis t functi on and comm en t on the his togram differen ce between the 2 images. For the 2
gif images, see class website www.ece.ucsb.edu/~manj/ece1 78 .
Th en , use the histogram equalization command in MATLAB, called hist eq, on the
darklena.gif image. Comment on the image qualit y obtained after the histogram equalization
and comm en t on its hist ogram , with respect t o the histograms obtained fro m lena.gif and
darklena.gif.
Now, we shall study th e effec t of using an ap pr opriate piecewise linear transforma tion t o
the pixel values. T he logic is as follows: say, we provide 2 vectors a = [a1; a2; a3; a4] and
b = [b1; b2; b 3; b 4] as inpu t. Then , as showed in Fig. 1, t he regio n [a1 , a2] is map ped to
[b1 , b2], the region [a2 , a3] is mapped to [b2 , b 3] and t he region [ a3 , a4] gets mapped to
[b3 , b4]. You ha ve to c ho ose a p ro per set o f v alues fo r a = [ a1; a 2; a 3; a 4] and b = [b1; b2; b3;
b4] and then use t he m to perfor m piecewise linear transforma tion of the pixel values.
pf2

Partial preview of the text

Download Problems on Introduction Digital Images - Assignment 2 | ECE 178 and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

ECE 178 HW

Due: Wednesday, Oct 15, 2008

Chapter 2 Problems 2.15, 2.16, 2.17, Chapter 3 Problems 3.4, 3. Programming assignment In this MATLAB assignment, we shall study the effect of histogram equalization and how it can be implemented with a piecewise linear transformation of the pixel values. The original image is lena.gif. Plot its histogram using the imhist command in MATLAB. Then, consider the darkened version of the image, called daklena.gif. Again, plot its histogram using the imhist function and comment on the histogram difference between the 2 images. For the 2 gif images, see class website www.ece.ucsb.edu/ ~ manj/ece178. Then, use the histogram equalization command in MATLAB, called histeq, on the darklena.gif image. Comment on the image quality obtained after the histogram equalization and comment on its histogram, with respect to the histograms obtained from lena.gif and darklena.gif. Now, we shall study the effect of using an appropriate piecewise linear transformation to the pixel values. The logic is as follows: say, we provide 2 vectors a = [ a 1 ; a 2 ; a 3 ; a 4 ] and b = [ b 1 ; b 2 ; b 3 ; b 4 ] as input. Then, as showed in Fig. 1, the region [ a 1 , a 2 ] is mapped to [ b 1 , b 2 ], the region [ a 2 , a 3 ] is mapped to [ b 2 , b 3 ] and the region [ a 3 , a 4 ] gets mapped to [ b 3 , b 4 ]. You have to choose a proper set of values for a = [ a 1 ; a 2 ; a 3 ; a 4 ] and b = [ b 1 ; b 2 ; b 3 ; b 4 ] and then use them to perform piecewise linear transformation of the pixel values.

Your MATLAB routine should take the darklena.gif image and a and b as inputs, and the output should be the image, with piecewise linear transformation performed. Using Fig. 1 as the reference, you should use vectors a and b, each of length 4, and set a 1 = 0, a 4 =1, b 1 = 0 and b 4 = 1. Then, you should intelligently choose a 2 ; a 3 ; b 2 and b 3 , so that the perceptual quality of the image obtained after piecewise linear transformation is good. The pseudocode is as follows:

  • im = input image matrix
  • use “find” function in MATLAB to find the pixel values in the image between ai and ai +1, for all i.
  • The line between the coordinates ( ai; bi ) and ( ai +1 ; bi +1) has the equation: To implement the above mentioned logic in MATLAB, use where im is the input image and out is the output image.
  • Repeat the above process for all i and thus, im will be converted to out. Things to turn in: (a) M-file (b) Images obtained after using histeq and after using piecewise linear transformation (c) Also plot their histograms along with the histograms of lena.gif and darklena.gif. (d) Comments on the differences between the histograms and also justify how you chose a and b for the piecewise linear transformation problem.