Labwork 4¶
Problem 1: Harris corner detection¶
The structure tensor is a well-known construct that encodes directional information within a neighbourhood and provides a tool for characterizing local shapes in an image
In this equation,
where
in which
Your task is to implement the Harris corner detector to estimate the cornerness (% TODO 1
. Briefly, you should follow the following steps:
- First, compute the directional derivatives
and . You can use thedipimage
built-in functionsdx
anddy
for this purpose. Don’t forget to use the correctsigma
( ) for computing the derivatives. - Compute the structure tensor
. For smoothing the structure tensor elements with you can use thedipimage
functiongaussf
per element. - Finally, calculate the Harris cornerness (
).
Hint
It is easiest if you only compute the 3 independent elements of .*
, the MATLAB matrix element-wise multiplication operator. Look at MATLAB documentations in order to fully understand the difference between *
and .*
.
First, apply your implementation on artificially created images with a triangle. You can generate such an image using the supplied routine triangle.m
. Study the effect on % TODO 2
). Try different values for
Figure 1. Harris corner detection
Problem 2: Principal component analysis (PCA)¶
In this assignment, you are going to reproduce the results of applying PCA to the multispectral satellite images shown in the lecture notes and book (Chapter 11 of Gonzalez and Woods 2018). You are provided the six spectral bands (Figure 2) and your task is as follows (% TODO 3-8
):
- Compute the six principal component images and the six eigenvalues
of covariance matrix (this should give these values, see Table 1). - Reconstruct the multispectral images using only the two principal components corresponding to the largest eigenvalues
. - Calculate and visualize the error between the reconstructions and the original images.
- Increase the number of principal components for reconstruction to see how the error changes.
Table 1: Eigenvalues of the covariance matrix obtained from the images in Figure 2
10344 | 2966 | 1401 | 203 | 94 | 31 |
In order to accomplish this task you can either use the MATLAB built-in function pca()
or implement your own routine using eig()
(or eigs()
). Try to make yourself familiar with the input and output arguments of pca()
function. You can see the documentations of this function by typing:
>> help pca
in the MATLAB Command Window. You will also need to properly handle negative pixel gray values.
Hint
Most of the operations in this Labwork can be done in vectorial implementation without for
loop. Remember that MATLAB functions are by default column-wise operator, i.e. if you apply mean()
function to an
Figure 2. Multispectral satellite images in six spectral bands. (Images are adapted from Gonzalez & Woods, 2018)
Files¶
You need to download the following scripts and images for this labwork.