ECE4076 Computer Vision Lab 3




Rate this product

ECE4076 Computer Vision
Lab 3 (Weeks 7,8): Image stitching by homography
Each task in this lab exercise is worth 2% of your final unit grade (total 10%). A task is only considered
complete if you can demonstrate a working program and show understanding of the underlying concepts. Note
that later tasks should reuse code from earlier tasks.
In this laboratory exercise, you will create a program that stitches two images with known homography into a
single wide-angle image using bilinear interpolation.
Lecture 7 slides (Homography section)
Input images: left.jpg, right.jpg
Task 1: Draw test points on left image
Draw the following points onto the left image as red crosses. Display the resulting image.
{338,197,1}, {468,290,1}, {253,170,1}, {263,256,1}, {242,136,1}
Recall from lectures that these 3-element homogeneous coordinates can be transformed to 2D image pixel
coordinates by dividing the first and second elements by the third (needed for later tasks).
Task 2: Use Homography to find right image points
The following homography transforms pixel coordinates between the left and right images as xr = H*xl
H =
1.6010 -0.0300 -317.9341
0.1279 1.5325 -22.5847
0.0007 0 1.2865
Apply the homography to transform the left image points in Task 1 to the corresponding locations in the right
image. Draw the transformed points as red crosses. Check your result before moving on.
Task 3: Bilinear interpolation of the right image
The transformed coordinates via homography can be in between pixel locations. Write a bilinear interpolation
function to compute the intensity of the transformed pixel coordinate in right.jpg using intensity values from
neighbouring pixel locations. Print the interpolated intensity value for each transformed point in Task 2. The first
point should be around 67 whereas the last point should be around 58.
HINT: The bilinear interpolation function should take the transformed pixel coordinate and the intensity values of
its four neighbours as input arguments, and should output the interpolated intensity value.
Background info:
ECE4076 Computer Vision
Task 4: Image stitching
Create a 1024×384 (width x height) image and fill the LHS with the left image. This stitched image will use the left
image coordinate system (xl) throughout the stitching process.
Next, fill in the remaining 512×384 pixels on the RHS by transforming their pixel coordinates (left image
coordinates) to the right image coordinates via the homography from Task 2. Sample the right image to fill in the
missing parts of the stitched image pixel-by-pixel as follows:
1) If the right pixel coordinate is valid, generate the pixel value using bilinear interpolation
2) If the right pixel coordinate is invalid, use a pixel value of zero
Display the stitching results. It should look like a wide-angle image with a visible seam where the two images join.
Task 5: Better blending
Improve the visual quality of the stitched image by trying the following image processing techniques:
1) Adjust the width of the output image automatically so that less black pixels are visible
2) Adjust the brightness (by a scaling factor) of each image so that the seam is less visible
3) Apply a small amount of Gaussian blur or alpha blending near the seam to make it less visible
4) Adjust the horizontal location of the seam (it can be moved further to the left as the right image overlaps into
the left by quite a few pixels).
Note that you do not have to try all of the above. However, you will only receive a mark here depending on
● the quality of the stitched image
● whether a serious programming attempt is made to improve the stitched image.