CS-256 Visual Computing Assignment (only 1 assignment, worth 20% of module)
Aims
Understand how an image is stored internally, and how to manipulate the image
Translate useful graphics algorithms into working code
Improve your programming skills through self-study and a challenging assignment
Combine interaction with visual feedback
Practice presenting your work in a viva situation
Individuals or pairs
You may complete and submit the assignment as an individual or as a pair (two students working together). If done as a pair, you must both attend the viva at the same time and indicate that your submission is joint (so you both get the marks). Do not do it in a team of more than two people. Do not split as a team once you have decided to work together as your solutions may be duplicates.
Files:
The supporting framework is written in Java. You may use and build on this framework. If you wish to
carry out the coursework in a different language you may do so, but there will be no provided
framework. You will be required to demonstrate your working program on 7/3/2024 or 14/3/2024.
You will require a copy of the Java template downloaded from Canvas. It demonstrates how to display
and manipulate images, with functions that will help you with the exercise.
[Note: You should not redistribute the template code anywhere – you will not have permission to do that]
Assignment Summary:
Implement Gamma correction
Implement image resizing
Implement cross correlation
Implement Gamma correction
This should be done using the gamma correction equation, and for full marks, using the look
up table approach. This can be accomplished by watching the "coding Gamma correction"
video. Every student should be able to get 30% by watching and following the coding in the
video and using the provided base code. It is OK if your code is like mine in the video.
3. Cross correlation with Laplacian
Implement the cross correlation (weighted sum) of a filter with a pixel (and its neighbourhood)
as a function and use that for all pixels in the image to create the intermediate image.
Implement normalisation on an intermediate image to create a new cross-correlated and
normalised image for display. Use the following filter as input. This will achieve the full marks
for this part. You can further experiment with passing different filters (e.g., you could have a
radio button that switches between different filters). This would not attract further marks,
but you may like to do it as a challenge and to understand this part of the course more deeply.
Or this may be more useful for copy and paste:
{
};
Mark distribution vs. time
Submission Requirements:
You will demonstrate your working program to me, or a post-graduate at times you will book using an
Eventbrite link I will send. These will be in the assignment advisory slots of 7th March and 14th March).
Submit your assignment through Canvas by the deadline at the top of this document. If you have
several files, place them in a ZIP). The coursework is worth 20% of this module. There is only 1
coursework. It is marked at the viva. You will get zero marks if you do not do the viva (even if you
submitted something on time). You will get zero marks if you do not make a submission (even if you
try to do the viva). You only get marks if you do both the on-time submission and the viva. If you
worked as a pair, you will only get marks if you both attend the viva.
Image resizing
Implement image resizing using nearest neighbour interpolation and bilinear interpolation.
There are also details about how to do this in the “coding Gamma correction” video. I go as far
as demonstrating code for nearest neighbour interpolation. This (with Gamma correction) is
enough to get 45% on the assignment.
2.
5x5 Laplacian Matrix:
-4-1 0-1-4
-1 2 3 2 -1
03430
-1 2 3 2 -1
{-4,-1, 0,-1,-4}, |
{-1, 2, 3, 2,-1}, |
{0,3,4,3,0}, |
{-1, 2, 3, 2,-1}, |
{-4,-1, 0,-1,-4} |
Video
-4-1 0-1-4
There is a video of an example solution available on Canvas.
The time taken to do each part is variable, and depends on your skills. The marks may or may not represent the time you spend on each item. Gamma correction is easier than image resizing, but has equal marks. This acknowledges start up time and encouragement to progress to something that works to hand in.
Academic misconduct:
This is important. Each year a student will try to present code they don’t understand – don’t be that
student. A simple question like “Why did you do that” or “What does that do” should not stump you.
An assignment is not something to get through with minimal work. We aim to stretch you and give you
practise for your future academic work (e.g. third year project) and preparation for your future career.
Marking scheme
Note, if you cannot answer questions about your code (or have limited understanding of it), the marks will be reduced (sometimes down to zero).
Understanding can be tested using questions like: How is this implemented, how are the other parts implemented, what does this bit of code do? Appropriate marks will be deducted from each part if the you cannot describe your own code. Just reading comments out is insufficient and marks should be deducted. All in code comments must be in English.
-
Implement gamma correction [30 marks] For each pixel the colour of the pixel is fetched, the gamma correction equation is applied to each colour channel, and the colour is copied back to the pixel. The value for gamma correction is obtained using a floating point slider. Values between 0.1 and 3.0 seem reasonable where 1.0 has no effect and could be the starting point. Values greater than 1.0 will make the image brighter, and values less than 1.0 make it darker if implemented correctly. This can be seen from the equation. It is OK if the code is the same as my example code for Gamma Correction. The full 30 marks is for using the look up table approach.
-
Image resizing [30 marks] Nearest neighbour interpolation is also presented in the coding video. You will probably have a listener on the resizing slider that will call the resizing code with the desired image scaling factor. In the resizing function, you will create an image of the correct new size. For each pixel in the new image, work out where the pixel should be sampled from on the old image. This value should be the floating point position. At this stage it would be good practice to call a function that takes that sample position (as floats). The nearest neighbour sampling function will then round down to the nearest integer and sample the image at that position (i.e., just get the colour at that position). [15 marks]. Here is some advice for bilinear interpolation. You can choose to follow it or do something else. A good approach would be to write the “lerp” function first that takes two floating point values and the ratio between them, and returns the interpolated value. Then write the bilinear function that carries out 3 lerps to find the correct sample value at a 2D position. Both of these functions should be tested with known values to make sure they are working. Then write a function that calls the bilinear function for each of the colour components for the sample you wish to find. This can be called from the sampling function. [15 marks] (giving a total of 30 marks for part 2).
-
Cross correlation using Laplacian filter [40 marks] A good approach will create the weighted sum function from the cross correlation definition and pass in the filter to it. This can be called from a cross correlation function that will find the weighted sum for each pixel and store it in the intermediate buffer. There will be a normalisation function that will create an image that can be displayed from the intermediate buffer.
Submission Procedure:
Submit the assignment through Canvas before the deadline. Demonstrate/viva your assignment
after the deadline at times to be notified.
The college policy for late submission will be used. The timestamp from Canvas will be used. I will email students at their University account, so you must read this frequently during the term. You might not be able to demonstrate/viva if you submit late.
If you have extenuating circumstances, follow the extenuating circumstances process. We will not have a problem with making alternative arrangements for your viva if your EC period covers the viva. But, if, as a result of extenuating circumstances, you get a one week extension, you must attend the viva slots. The extension does not apply to the marking viva, only the submission date. You may choose the later viva slot (14th March). If your EC applies to the whole period of submission and vivas (e.g. 1st March to 15th March) we can make a special arrangement for the viva.
Individuals or pairs
If you do the assignment as a pair of students, please both submit the same code and indicate at the
head of the code that you worked as a pair and indicate the student number and name of both
students. Important: Make this clear at the viva.
To be clear, the same quality of solution submitted by a single student will get the same marks as the
same quality of solution submitted by a pair of students. There is no mark disadvantage for being in a
pair.
Both students in a pair will get the same marks unless you both agree that the marks should be distributed differently. I don’t have a procedure yet for informing me of this because I presume this would not happen, but if it does, then perhaps an email to me is best indicating the split. E.g., tell me that one student gets 1.0 times the mark, and the other gets n times the mark where n<1. Then I will multiply the full mark by n for the lower student, and the primary student gets the full mark.