Image processing
Lab 4
By: Eng Noha Abd-Elkareem
Histogram Processing
• Histogram Equalization
• Histogram Matching(Specification)
• Local Enhancement
Histogram Equalization
Histogram equalization is a technique for adjusting image intensities to enhance
contrast.
• Pr(rk): The probability of occurrence of gray level 𝑟𝑘, where:
• This equation is histogram equalization or linearization. Thus, a processed (output)
image is obtained by mapping each pixel with level 𝑟𝑘 in the input image into a
corresponding pixel with level 𝑠𝑘 in the output image.
K=0,1,………………….,L-1
Histogram (Specification)Matching
Histogram matching is the method used to generate a processed image that
has a specified histogram.
r s z
q=0,1,……,L-1
T( r) G(z)
Histogram Equalization
Q) Assume that an image of 32x32 with 32 gray levels distributed as follow
• For the image represented in the previous table
• (i) Draw the image histogram
• (ii) Find the average(mean) intensity and the standard deviation
• (iii)Find the equalized histogram
Histogram Equalization
• (iv) Find the specified histogram according the following values?
Example
Sol. MN=32*32=1024
𝑟𝑘 𝑛𝑘 𝑃𝑟(𝑟𝑘)=𝑛𝑘/MN
12 74 74/1024=0.07
14 50 0.05
15 100 0.1
16 250 0.24
18 150 0.15
19 280 0.27
20 30 0.03
21 50 0.05
22 40 0.04
(i) Draw the image histogram
(ii) Find the average(mean) intensity and the standard
deviation
The mean (Average intensity) of r: 𝜇 =
𝑖=0
𝐿−1
𝑟𝑖𝑃(𝑟𝑖) =(12*0.07)+(14*0.05)+(15*0.1)+…………=17.24
Variance 𝜎2 = 𝑖=0
𝐿−1
(𝑟𝑖−𝜇)2𝑃(𝑟𝑖)
=(12 − 17.24)2∗ 0.07 + 14 − 17.24 2 ∗ 0.05 + … … … … . . = 6.09
standard deviation 𝜎 = 𝑣𝑎𝑟𝑖𝑎𝑛𝑐𝑒= 6.09=2.47
(iii)Find the equalized histogram
𝑠12 =31*(0.07)=2.17 ≅ 2 P(𝑠2)=0.07
𝑠14 = 31 ∗ 0.05 + 0.07 = 3.72 ≅ 4 P(𝑠4)=0.05
𝑠15 = 31 ∗ 0.1 + 0.05 + 0.07 = 6.82 ≅ 7 P(𝑠7)=0.1
𝑠16 = 14.26 ≅ 14 P(𝑠14)=0.24
𝑠18 =18.91≅ 19 P(𝑠19)=0.15
𝑠19 =27.28≅ 27 P(𝑠27)=0.27
𝑠20=28.21≅ 28 P(𝑠28)=0.03
𝑠21 =29.76≅ 30 P(𝑠30)=0.05
𝑠22 =31 P(𝑠31)=0.04
L-1=31
(iii)Find the equalized histogram
Assignment
• Assume that an image of 32x32 with 8 bit gray levels distributed as follow
• A)Draw the histogram, which type of images does we have?
• B)Draw the transformation function T(r),and then draw the equalized histogram
• C) Write a computer program for computing the histogram of an image using matlab
• D) Rescaling the image such that the intensity values will be in the range(0-60)
Gray level 3 5 6 8 10 12 13 15
No. of pixels 124 50 100 245 150 275 30 50
Assignment
• Q)Apply histogram equalization to the image. Show your work and sketch
the resulting image.
6 13 12 13
12 6 7 12
13 7 7 12
14 11 11 14
Thank You

Image processing lab4.pdf image processing

  • 1.
    Image processing Lab 4 By:Eng Noha Abd-Elkareem
  • 3.
    Histogram Processing • HistogramEqualization • Histogram Matching(Specification) • Local Enhancement
  • 4.
    Histogram Equalization Histogram equalizationis a technique for adjusting image intensities to enhance contrast. • Pr(rk): The probability of occurrence of gray level 𝑟𝑘, where: • This equation is histogram equalization or linearization. Thus, a processed (output) image is obtained by mapping each pixel with level 𝑟𝑘 in the input image into a corresponding pixel with level 𝑠𝑘 in the output image. K=0,1,………………….,L-1
  • 5.
    Histogram (Specification)Matching Histogram matchingis the method used to generate a processed image that has a specified histogram. r s z q=0,1,……,L-1 T( r) G(z)
  • 6.
    Histogram Equalization Q) Assumethat an image of 32x32 with 32 gray levels distributed as follow • For the image represented in the previous table • (i) Draw the image histogram • (ii) Find the average(mean) intensity and the standard deviation • (iii)Find the equalized histogram
  • 7.
    Histogram Equalization • (iv)Find the specified histogram according the following values?
  • 8.
    Example Sol. MN=32*32=1024 𝑟𝑘 𝑛𝑘𝑃𝑟(𝑟𝑘)=𝑛𝑘/MN 12 74 74/1024=0.07 14 50 0.05 15 100 0.1 16 250 0.24 18 150 0.15 19 280 0.27 20 30 0.03 21 50 0.05 22 40 0.04
  • 9.
    (i) Draw theimage histogram
  • 10.
    (ii) Find theaverage(mean) intensity and the standard deviation The mean (Average intensity) of r: 𝜇 = 𝑖=0 𝐿−1 𝑟𝑖𝑃(𝑟𝑖) =(12*0.07)+(14*0.05)+(15*0.1)+…………=17.24 Variance 𝜎2 = 𝑖=0 𝐿−1 (𝑟𝑖−𝜇)2𝑃(𝑟𝑖) =(12 − 17.24)2∗ 0.07 + 14 − 17.24 2 ∗ 0.05 + … … … … . . = 6.09 standard deviation 𝜎 = 𝑣𝑎𝑟𝑖𝑎𝑛𝑐𝑒= 6.09=2.47
  • 11.
    (iii)Find the equalizedhistogram 𝑠12 =31*(0.07)=2.17 ≅ 2 P(𝑠2)=0.07 𝑠14 = 31 ∗ 0.05 + 0.07 = 3.72 ≅ 4 P(𝑠4)=0.05 𝑠15 = 31 ∗ 0.1 + 0.05 + 0.07 = 6.82 ≅ 7 P(𝑠7)=0.1 𝑠16 = 14.26 ≅ 14 P(𝑠14)=0.24 𝑠18 =18.91≅ 19 P(𝑠19)=0.15 𝑠19 =27.28≅ 27 P(𝑠27)=0.27 𝑠20=28.21≅ 28 P(𝑠28)=0.03 𝑠21 =29.76≅ 30 P(𝑠30)=0.05 𝑠22 =31 P(𝑠31)=0.04 L-1=31
  • 12.
  • 13.
    Assignment • Assume thatan image of 32x32 with 8 bit gray levels distributed as follow • A)Draw the histogram, which type of images does we have? • B)Draw the transformation function T(r),and then draw the equalized histogram • C) Write a computer program for computing the histogram of an image using matlab • D) Rescaling the image such that the intensity values will be in the range(0-60) Gray level 3 5 6 8 10 12 13 15 No. of pixels 124 50 100 245 150 275 30 50
  • 14.
    Assignment • Q)Apply histogramequalization to the image. Show your work and sketch the resulting image. 6 13 12 13 12 6 7 12 13 7 7 12 14 11 11 14
  • 15.