Assignment 1:
1) Write a MATLAB function to perform a piecewise linear brightness and contrast adjustment on monochrome images using the generic method described in equation (s = c · r + b). It should take as arguments a monochrome image, the c coef?cient (slope), and the b coef?cient (offset).
2) Write a MATLAB function to perform a simple version of image solarization technique (also known as Sabatier effect), a point transformation that processes an image by leaving all pixels brighter than a certain value (T ) untouched, while extracting the negative of all pixels darker than T .
3) Write a MATLAB function to perform a point transformation by which each pixel value in an input image of class uint8 is replaced by the square of its original value and answer the following questions:
a) Do you have to explicitly make provisions for clamping the results (so that they stay within range)? Why (not)?
b) Is the resulting image brighter or darker than the original image? Explain.
4) Repeat the problem above, this time for an input image of class double. Does the answer to any of the questions change? Why?
5) The sigmoid function used to generate a point transformation similar to Figure can be described by the equation
s = 1/[1 + (m/r)S
where r is the original pixel value, s is the resulting pixel value, m is a user-speci?ed threshold, and S is a parameter that controls the slope of the curve.
Write aMATLAB script that generates and plots the point transformation function described in equation.
6) Apply the transformation function developed for Problem above to different images and experiment with different values of m and S. Report a summary of your ?ndings.
Assignment 2:
1) The 7 × 7 image with eight gray levels is given below, where each gray level value is represented in normalized form from 0 (black pixel) to 1 (white pixel).
0 3/7 2/7 2/7 1/7 1/7 4/7
3/7 2/7 1/7 1/7 1/7 1/7 4/7
2/7 0 1 1/7 3/7 0 0
0 5/7 1/7 0 6/7 0 1/7
1/7 1/7 1/7 3/7 6/7 6/7 5/7
1/7 1/7 1/7 1/7 5/7 6/7 4/7
0 1 0 0 0 0 4/7
(a) Calculate the probabilities of each gray level and plot the image's histogram.
(b) Which pixels are predominant in the original image, dark or bright?
(c) Using the cumulative distribution function, equalize the histogram calculated in part (a) and plot the resulting (equalized) histogram.
(d) Show the resulting 7 × 7 image after histogram equalization.
2) Write aMATLABscript to showthat a second (or third, fourth, etc.) consecutive application of the histogram equalization algorithm to an image will not produce any signi?cant change in the histogram (and, consequently, in the image).
3) Given a 256 × 256 pixels image with eight gray levels, whose gray-level distribution is given in the following table.
Gray Level (rk) nk p(rk)
0 2621 0.04
1/7 0 0.00
2/7 0 0.00
3/7 5243 0.08
4/7 7209 0.11
5/7 12,452 0.19
6/7 24,904 0.38
1 13,107 0.20
It is desired that the original histogram is changed to approach the histogram corresponding to the table below.
zk pˆ(zk)
0 0.27
1/7 0.16
2/7 0.19
3/7 0.16
4/7 0.11
5/7 0.06
6/7 0.03
1 0.02
(a) Which pixels predominate in the original image, dark or bright? Explain.
(b) Assuming the histogram modi?cation will be successful, what will be the probable effect of this modi?cation on the original image?
(c) Equalize the original histogram using the function s = T (r).
(d) Obtain the function v = G(z) and its inverse.
(e) Plot the most relevant histograms: original, desired, equalized, and resulting.
(f) Fill out the table below with the ?nal values for nk and pˆ(zk) for the eight values of zk, comparing with the desired values and explaining possible differences.
zk nk pˆ(zk)
0
1/7
2/7
3/7
4/7
5/7
6/7
1
4) Write aMATLAB script that implements region-based histogram equalization. Your script should allow the user to interactively select (with the mouse) a region of interest (ROI) within an image to which the histogram equalization operation will be applied.
5)
(a) Write a MATLAB function that creates an 8-bit random image with a uniform distribution of pixel values and takes two parameters: height and width. Hint: use MATLAB function rand.
(b) Write a MATLAB script that uses the function you have just written to create a 128 × 128 random image.
(c) Inspect the image's histogram. Does it show a uniform (i.e., ?at-shaped) distribution as expected? Explain.
6)
(a) Write a MATLAB function that creates an 8-bit randomimagewith a Gaussian (normal) distribution of pixel values and takes four parameters: height, width, mean value (μ), and standard deviation (σ).
(b) Write a MATLAB script that uses the function you have just written to create a 128 × 128 random image with a Gaussian (normal) distribution of pixel values, with mean value μ = 128 and standard deviation σ = 60.
(c) Inspect the image's histogram. Does it show a Gaussian (i.e., bell-shaped) distribution as expected? Explain.
(d) Repeat the previous two steps for different values of μ and σ.
7) An 8-bit image has a minimum gray level of 140 and a maximum gray level of 195. Describe the effect on the histogram of this image after each of these operations is performed (separately):
(a) Subtraction of 130 from all pixel gray levels (histogram sliding).
(b) Histogram stretching.
(c) Histogram equalization.
8) Provide empirical evidence of the nonuniqueness of a histogram by writing a MATLABscript that reads amonochrome image, displays its histogram, and generates another gray-level image very different from the original, but whose histogram is identical to the original image's histogram. Hint: "Given an image f with a particular histogram Hf , every image that is a spatial shuf?ing of the gray levels of f has the same histogram Hf " [Bov00a].