### Recent Question/Assignment

School of Engineering
EEET2169 – Image Processing/EEET1255 – Image Systems Engineering
Laboratory 1
Point operations and histogram processing
1 Aims
(i) To introduce Matlab and components of the Mathworks Image Processing Toolbox.
(ii) To review the principles of digital image representation in Matlab.
(iii) To develop an appreciation for the factors affecting the presentation of images on modern digital computer displays.
(iv) To implement common point and histogram image processing operations in Matlab.
2 Introduction
You are expected to work individually. Each student must submit a technical laboratory report summarising their work and their results. The report should be submitted as a PDF document, accompanied by a single .zip archive containing your Matlab code and the images produced. This laboratory project will run for one week, with submission due at the end of week 3 (electronic submission via the subject Canvas website; 1 week after the laboratory session).
In this laboratory, you will derive a subjective estimate of the non-linear response of your computer monitor and implement algorithms to perform several common, low-level image processing operations.
All operations will be performed in Matlab [1]. Matlab and the Image Processing Toolbox [2] may be downloaded for installation on your home computer under the RMIT Total Academic Headcount (TAH) license (see [3]).
The supplied EEET2169-Lab1.zip file contains a number of template .m files and several test images for use in this laboratory.
Note: The Image Processing Toolbox includes a substantial library of common low-level image processing functions. However, in this laboratory you will be implementing your own version of several of these common operations.
3 Gamma correction
The response of many devices used for display of digital images, including consumer LCD computer monitors, obey a power law:
??(??) = ??& (1) where ??(·) denotes the display intensity, ?? ? [0,1] denotes the requested normalized intensity or gray level, and the exponent, ? ? 1, captures the nonlinear response. As a result, an image with pixel values representing linearly-scaled light intensity will appear dark and lacking detail, for small and mid-range pixel values, when displayed.
3.1 Estimating gamma for your display device
Measuring the nonlinear response of a display calibration is typically performed using a photometer. However, here you will obtain a subjective estimate of the gamma of your monitor by exploiting the inherent low-pass characteristics of the human visual system. Specifically, we will present, on the screen, test images as shown schematically in Figure 1. These images consist of horizontal bands containing a high-frequency checkerboard pattern interleaved with horizontal bands containing a uniform gray level.
Figure 1. Schematic illustration of the test image for estimating display gamma. Note, the image on the left is shown at reduced resolution and reduced contrast for clarity. Typical gray levels are indicated on the 4x4 pixel region shown enlarged on the right.
When viewed from a distance, the low-pass frequency response of the human visual system causes the checkerboard pattern to be perceived with an intensity given by:
??. = 5 , (2)
where ??566 and ??7 represent the intensities produced by gray levels of 255 and 0, respectively. For our purposes, we will assume that ??7 ˜ 0 . Under the same viewing conditions, the uniform bands, with gray level ?? ? [0,255], are perceived with an intensity ??7 = ?? = ??566, where ?? is given by
&
?? . (3)
By matching the intensity ?? of the uniform bands to the perceived intensity ??. of the checkerboard pattern, it is possible to obtain an estimate of ? for your monitor.
Using Matlab:
a) Open mkTestImage.m. This file defines a function (to be written by you) that accepts a single input argument, the gray level, gLvl, of the uniform gray bands, and returns a single output argument, imgOut, the test image. Write the function to generate a 256×256 pixel test image as shown schematically in Figure 1. The checkerboard should contain alternating pixels of minimum (0; black) and maximum (255; white) intensity, and should be 16 pixels high. The uniform gray bands should also be 16 pixels high.
b) Open runTest.m. In this file write a script or a function to generate a test image with a specified gray level (by calling mkTestImage()) and display it on the screen.
c) Ensure your monitor is adjusted correctly (see Appendix A). Start with an initial gray level for the uniform bands (gLvL) of 128. Viewing the test image from a distance of 0.5–1m, adjust the gray level until the uniform gray bands appear to match the intensity of the checkerboard bands. Make a note of the gray level that achieves the best match. You may like to perform this measurement several times and average the results.
d) Save the best matching test image as an 8-bit grayscale PNG image (no alpha channel) to a file named test.png to include in your report.
e) Calculate the value of ?? for your monitor. Hint: write an expression relating the gray level (gLvL) of the best matching test image to the intensity of the checkerboard.
f) Plot the estimated gamma function, i.e., intensity vs normalized gray level, for your monitor and include it in your report.
g) Plot the inverse gamma function for your monitor and include it in your report.
3.2 Gamma correction of images for display
As noted above, images with pixel values representing linearly-scaled light intensity will appear dark and lacking detail when displayed on most computer monitors. To display such images, it is necessary to compensate or correct for the nonlinear response of the display device – a process referred to as gamma correction.
The supplied EEET2169_Lab1.zip file contains a number of calibrated photographs from the University of Texas calibrated natural image database [4]. These images contain linear sRGB pixel values.
In Matlab:
a) Open the file sRGBToGray.m. This file defines a function (to be written by you) that accepts a linear sRGB image (no gamma correction) as it’s input and returns a linear grayscale image as it’s output. Pixel values in the grayscale image should contain the luminance (but not chromaticity) information from the sRGB input image. Hint: convert from sRGB to the CIE XYZ colour space.
b) Load the test image 7292.png (from the images/ subdirectory of the supplied .zip file) and display it on the screen.
c) Convert this image from linear sRGB to grayscale using sRGBToGray(). Display this grayscale image on the screen.
d) Save this linear grayscale image as an 8-bit grayscale PNG image (no alpha channel) to a file named 7292_linear.png to include in your report.
e) Plot the histogram of pixel intensity values for this linear grayscale image, and include it in your report. Make sure all axes are labelled.
f) Gamma correct this linear grayscale image for your monitor.
g) Save this gamma corrected grayscale image as an 8-bit grayscale PNG image (no alpha channel) to a file named 7292_corrected.png to include in your report.
h) Plot the histogram of pixel intensity values for this gamma corrected grayscale image, and include it in your report.
4 Colour space conversions In Matlab:
a) Load the linear sRGB image 7292.png from Section 3.2 above.
b) Convert this image to a grayscale image using the function rgb2gray() provided by the Image Processing Toolbox, and gamma correct this image for your monitor.
c) Compare this new grayscale image with the grayscale image you derived in Section 3.2(f). Note and discuss any differences in your report.
5 Histogram processing In Matlab:
a) Open the file eqHist.m. This file defines a function (to be written by you) that accepts two input arguments: a grayscale image, imgIn, and a positive integer, nLvls, specifying the desired number of gray levels. This function should perform global histogram equalization, i.e., it should transform the input image, imgIn, into an image, imgOut, with nLvls gray levels, mapping an approximately equal number of pixels to each gray level in imgOut. Do not use the function histeq() provided by the image processing toolbox.
b) Use eqHist() to equalize the histogram of the linear grayscale image from 3.2(c) above. Save the resulting image as an 8-bit grayscale PNG image to a file named 7292_eq.png to include in your report.
c) In your report, show both images (i.e., before and after histogram equalization) together with their corresponding histograms. Comment on the likely source of any artefacts present.
d) How do your results differ if you apply histogram equalization after gamma correction? 6 Report and assessment
As you complete the exercises described above record all results and observations in your lab report. All calculations, derivations, images, histograms etc. (annotated as appropriate) as well as the associated discussion should be documented in your lab report.
Include your name, student number and the course code on the first page of your report, and number every page.
Make sure all figures are numbered and have a descriptive caption.
Make sure all axes are labelled.
The images/ subdirectory of the supplied.zip file contains a several other example images from the University of Texas calibrated natural image database. These may be useful for testing and demonstrating your code and exploring the operations implemented here. You are encouraged to use additional examples of your own to illustrate interesting use cases.
You should upload two files via the subject’s Canvas website:
1. Your lab report as a single .pdf file, and
2. A single .zip file containing your Matlab source (.m) files, the PNG images described above and any other example images you have used.
7 References
[1] Mathworks Inc., https://au.mathworks.com/products/matlab.html [online] (Accessed 2021-02-01).
[2] Mathworks Inc., The Image Processing Toolbox. https://au.mathworks.com/help/images/index.html [online] (Accessed 2021-03-07).
[3] https://rmititsm.service-now.com/kb_view.do?sysparm_article=KB0011275 [online] (Accessed 2021-03-08).
[4] University of Texas at Austin, Center for Perceptual Systems, http://natural-scenes.cps.utexas.edu/db.shtml
[online] (Accessed 2021-03-07).
8 Appendix A
8.1 Monitor adjustment for estimating gamma
For best results when attempting to estimate gamma for your display it is important to adjust your display appropriately. The goal is to have black appear as dark as possible while maximizing the dynamic range of the display. To do so, you will adjust two parameters:
Brightness or “black point”, and
Contrast.
Before adjusting your display settings, make a note of both these settings so you can restore them later if desired.