COMP9517: Computer Vision Lab 1

$30.00

Download Details:

  • Name: lab01-0bsum7.zip
  • Type: zip
  • Size: 13.63 MB

Category:

Description

Rate this product

Question 1: Write a function that performs contrast stretching. Read the given gray-scale
image and apply your function to test whether it indeed improves the image quality.
The lab files should be submitted online.
Instructions for submission will be posted closer to the deadline.

Intensity Histogram
The histogram of an image shows the frequency of pixel intensity values. It gives statistical
information and removes the location information of the pixels. For a digital image with gray
levels from 0 to 𝐿 βˆ’ 1, the histogram is a discrete function β„Ž(π‘Ÿπ‘˜
) = π‘›π‘˜ where π‘Ÿπ‘˜ ∈ [0, 𝐿 βˆ’ 1]
is the kth gray level and π‘›π‘˜ is the number of pixels with gray level π‘Ÿπ‘˜.
Question 2: Write a function that computes and plots the histogram of the given image.
Image Edges
Edges are an important source of semantic information in images and they occur in human
visual perception at divisions between different areas of intensity, colour, and texture. A grayscale image can be thought of as a 2D landscape with areas of different intensity living at
different heights. A transition between areas of different intensity in an image 𝐼 means there
must be a steep slope which we formalise as the gradient:
βˆ‡πΌ = (
πœ•πΌ
πœ•π‘₯ ,
πœ•πΌ
πœ•π‘¦)
Since the image 𝐼 is discrete, we need to approximate the continuous derivatives πœ•πΌ/πœ•π‘₯ and
πœ•πΌ/πœ•π‘¦ by finite differences. Simple examples of convolution kernels that perform finite
differencing are the Sobel filters defined as follows:
𝑆π‘₯ = [
βˆ’1 0 1
βˆ’2 0 2
βˆ’1 0 1
] and 𝑆𝑦 = [
βˆ’1 βˆ’2 βˆ’1
0 0 0
1 2 1
]
Question 3: Write a function that computes the two gradient images πœ•πΌ/πœ•π‘₯ β‰ˆ 𝐼 βˆ— 𝑆π‘₯ and
πœ•πΌ/πœ•π‘¦ β‰ˆ 𝐼 βˆ— 𝑆𝑦 from the given image.
Notice that the OpenCV built-in Sobel functions can also be applied to achieve this result. But
the challenge is to implement your own functions. You can verify the result of your own
functions by comparing with the result of the built-in functions.
Image Sharpening
Sometimes images are not as sharp as they could be, and fine details look a bit blurred. An
image can be sharpened by using specific filters that enhance the high-frequency content in
the image. One possible technique to accomplish this is called unsharp masking.
The figure below gives a schematic overview of this technique. In words, it takes the input
image 𝐼 and convolves it with a Gaussian kernel 𝐺 with standard deviation or scale 𝜎,
resulting in a slightly blurred image 𝐿. Next, the blurred image 𝐿 is subtracted from the input
image 𝐼, resulting in image 𝐻, in which the high frequencies are enhanced. Then, each pixel
in 𝐻 is multiplied by a constant factor π‘Ž, and the resulting image is added pixel-wise to the
input image 𝐼, resulting in output image 𝑂.
Question 4 (2.5 marks): Write a function that implements the above technique. Apply it to
the given image using, for example, 𝜎 = 1.0 pixels and π‘Ž = 1.25. The differences between 𝐼
and 𝑂 are subtle but the latter should be visibly sharper.
Notice that this technique may produce output pixel values outside the range [0,255]. Thus,
make sure you use the right data types for the computations. Also, you can apply contrast
stretching (which you implemented in answer to Question 1) to force the contrast in 𝐼 and 𝑂
to be in the same range [0,255], so you can properly compare the two images visually.