Recent Question/Assignment

School of Electrical Engineering and Computing
Inft1004 Introduction to Programming – Assignment 2 (Callaghan)
Due by 11.59pm on Sunday, 13 May, 2018 (end of week 9)
Weighting 30%
Paired work Students are encouraged to work in pairs on this assignment.
Your assessment task
For this assignment you are to write a Python program in JES that superimposes a watermark on an image. A watermark is a somewhat transparent image, generally greyscale, imposed on another image. Two typical uses of watermarks are shown in Figure 1.
* A copy of all the images in this assignment can be found in the examples directory for the assignment.
Figure 1: Two typical examples of a watermark. On the left, the forbidden_city.jpg image has been used to watermark the beach.jpg picture. On the right, some text has been used to watermark the beach.jpg picture
The watermarking process in this assignment can be broken into six main tasks:
1. Make a greyscale version of the watermark image based on luminance. (Easy)
2. Using a specified scale factor, scale the watermark image up or down to use as a watermark on the original image. (Medium)
3. Blend (overlay) the scaled grey watermark image with the original image. (Medium)
4. Improve the blend step so that it depends on the luminance of the watermark image. (Hard)
5. Take a list of strings and use it to make a text-based watermark image showing these strings. By following the tasks 1-4, use this text image to watermark the original image. (Hard)
6. Change the scaling process so that rather than using a specified scale factor is automatically calculates the scale factor so the water mark image is as small as possible but is either two thirds the height of the original or two thirds of the width. (Tricky)
Each of these tasks is described in more detail below. Some are harder than others and will have subtasks. The later tasks tend to be more difficult. You may not be able to complete all of these tasks.
Journal
As programming is a complex task, you are required to maintain and submit a journal, a separate wordprocessed document in which you
• record when and for how long you work on which aspects of the assignment, and which bits are done by which member of the pair;
• briefly list questions that arise, difficulties that you encounter, and how you overcome them;
• summarise lessons that you learn.
By the time you’ve finished the program your journal will probably be many pages long. The journal is intended to record your design thoughts, your programming thoughts, and the time you spend on the task, so you must keep it up to date at all times. A ‘journal’ that is thrown together the day before the assignment is due is not a journal at all. When you hand in your files, your journal must be a pdf file.
Cover sheet
With each part of the assignment you are required to hand in a cover sheet, indicating that what you are handing in is your own work, and that you have not given or shown it to anyone else in the class (excluding your partner if you worked as a pair). This sheet is intended to be signed. However, if you do not wish to print it, sign it, and scan it, you may type your name where the signature is expected. The fact of submitting it from your user account will serve as a signature. When you hand in your files, your cover sheet must be a pdf file.
Files and folders
For each part of the assignment you will be handing in three files: your Python program, your pdf journal, and your pdf cover sheet. There is a particular structure that you are required to follow.
All three files will be in a folder whose name is your names, without spaces, followed by the abbreviation Assign2 depending on which part of the assignment you are doing. If Abby Archer and Zeke Zammit are working together, their folder will be called AbbyArcherZekeZammitAssign2.
Within that folder, your Python program will follow the same name convention. It will be your names followed by Assign2.py (eg AbbyArcherZekeZammitAssign2.py); your journal will have your names followed by Journal.pdf, (eg AbbyArcherZekeZammitJournal.pdf); and your cover sheet will have your names followed by CoverSheet.pdf, eg AbbyArcherZekeZammitCoverSheet.pdf. Remember that both the journal and the cover sheet are to be pdf files.
Handing in your work
You are to hand in each part of the assignment electronically using Blackboard’s Assignment facility.
Because you need to hand in a whole folder and its contents, you are required to zip the files together. Remember, for each part you are to hand in a folder containing exactly three files: your Python program, your pdf journal, and your pdf cover sheet.
When you zip your folder and its contents, in way that preserves their directory structure, be sure that you produce a .zip file, NOT some other format such as a .rar file. There are many zipping software packages, some commercially available, some free, and some provided with operating systems. Well before you submit your assignment, be sure that you have access to appropriate software and know how to use it. Once you have zipped your files together, be sure to unzip them to a new location to check that they unzip correctly. Make sure that the zip file has the same name as the folder. For example, AbbyArcherZekeZammitAssign2.zip.
When you are ready to submit your zipped file, log in to Blackboard, go to the site for this course, and follow these steps . . .
• Select the Assessment folder.
• Click the Assignment 2 link, which will take you to the upload page.
• In panel 2, Assignment materials, click Browse my computer (next to Attach file), and navigate to your zip file. There’s no need to enter a link title. In the comments field put your name if you worked alone, or both of your names if you worked as a pair.
• In panel 3, Submit, click the Submit button.
• If you don’t see a message saying the assignment is complete, go back and check that you’ve done all these steps. If there’s still a problem, try Blackboard’s help under Course tools, search for assignment, and select the help page on submitting assignments.
• If you want to submit an updated version of the final assignment, go back to the Assignment link and click Start new submission on the assignment’s Review submission history page. Make sure you’re aware of the deadline: the final marking will be applied only to the most recent submission, and if it’s submitted late it will be marked as late.
You might be required to demonstrate your program, and to explain aspects of your code, in a subsequent tutorial class.
Development
The dates on the calendar are closer than they appear! One of the common problems reported by students is that they fail to start programming assignments early enough and simply run out of time. Novice programmers frequently underestimate the amount of time needed to design, write and test code. Even though some aspects of the assignment will require work from week 6 and week 7 you are advised to start now. Keep in mind that tutorials and lectures over the next few weeks will support your understanding of the problem and will help you to complete your assignment.
Be careful to follow the requirements as specified here. Do not try to improve the requirements. The customer has carefully stipulated these requirements. Make sure you test your code carefully and be sure to adopt our coding standards as discussed in lectures. Be careful not to introduce side-effects in your functions. No argument passed to a function should be changed inside the function. (When passing an image you will have to duplicate the image and change the copy before returning it).
Problem-solving
Several aspects of this assignment involve problem-solving. This is not unusual: it is difficult to specify programming tasks that do not require problem-solving. While you might be tempted to just write some code and hope that it will eventually do what you want it to do, in the end it will be far more effective to first work out exactly what you want the code to do, and only then start writing the code.
Based on past experience, students who believe that they are having trouble with their program code are generally having trouble with their program design, their algorithm. If your program isn’t doing what you want it to do, this is probably because you haven’t solved the problem and clearly worked out how the program should do what you want it to do. You are unlikely to get the program working correctly if you haven’t solved the problems and designed the solution correctly.
When you need to problem-solve, the key is not to search the web for inspiration, it is not to randomly try things in the hope that one of them will work: it is to write down what you have, to write down what you want, and to think about how to get from the first to the second. It often helps to draw diagrams. It definitely helps to discuss the problem, and possible solutions, with your partner. If you actually solve the problem for yourself, rather than finding something somewhere that you might be able to bend into a solution, it will be a huge step in your development as a programmer.
Some general suggestions
It’s really important to tackle one task, one function, at a time. At first the whole assignment will seem overwhelming. But by doing one function at a time you will find it much easier to accomplish. Although of course some functions are tougher than others. So long as you start early enough, you should complete most of the functions. Hand in what you have finished but do not submit code that does not run.
Assignment 2 – 120 marks - 30% course mark
For the assignment you are required to do tasks 1, 2, 3, 4, 5 and 6, as specified below. You may find tasks 4, 5, and 6 are harder than the early tasks. If you run out of time and you may not be able to complete these later tasks. Note that the later tasks will rely on you having finished the earlier tasks
If you complete all tasks you will have three functions that we will mark. (Make sure they are defined exactly like this, otherwise, when we test them, they will not work and they will nor be marked.)
def watermarkWithPicture(originalImage, watermarkImage, strength, scaleFactor):
# This function watermarks the original image with the watermark image.
# The strength of the watermark (0-100) is supplied and determines
# how transparent the watermark image will be. The watermark is
# scaled by using the specified scale factor (it could be smaller or larger)
#
# Requires tasks 1-3 to be completed. (Greyscale, Scaling, Simple blending)
# Will be improved by task 4. (Blending based on luminance)
# def watermarkWithText(originalImage, listStrings, strength, fontSize): # This function watermarks the original image with the text provided
# in a list of strings. To do this a watermark image is first created
# from the strings and then this is text-based image is used as the watermark.
# The font size of text to be used can be specified (12—40)
# The strength of the watermark (0-100) is also supplied and the watermark is
# scaled to be the width of the original image.
# Requires task 5 to be completed. (Creating a text image for the watermark)
# Reuses the watermarkWithPicture function (tasks 1-4)
# def watermarkWithScaledPicture(originalImage, watermarkImage, strength): # This function watermarks the original image with the watermark image.
# The strength of the watermark (0-100) is supplied and determines # how transparent the watermark image will be. The watermark is # automatically scaled based on the size of the two images.
#
# Requires task 6 to be completed. (Automatic scaling of watermark)
# Reuses the watermarkWithPicture function (tasks 1-4)
#
More detail about these three main functions are explained below. It is expected that these three main functions will call a number of other functions that you write to help complete the tasks (1, 2, 3, 4, 5, 6). Note in some cases in will be even simpler to break each of these tasks into smaller parts and write a few functions that can be used to complete a single task. (Divide and conquer!)
watermarkWithPicture(originalImage, watermarkImage, strength, scaleFactor)
When we mark your assignment, the first thing we will do is run a function called
watermarkWithPicture(...) with appropriate arguments. This function will call functions for the other tasks in turn. Be sure that you name this function exactly the way it is named here; if the name is even slightly different, JES will not find the function when we try to run it. Also be sure that you define it as having four parameters in the correct order.
The first parameter, originalImage, is a picture or the main original image. The second parameter, watermarkImage, is also a picture, an image to be used as the watermark.
The function will return a copy of the original image with the watermark. There should be no side effects. The last thing the function does before returning is to repaint this new watermarked image. So don’t forget before the function returns, to repaint() the final watermarked image it has created.
The third parameter, strength, is the strength of the watermark, an indication of how visible the watermark should be. This will be an integer in the range from 0 to 100. With a strength of 100, the watermark image will completely replace the corresponding pixels of the original image. With a strength of 0, the watermark image will be completely transparent or invisible. With a strength of 40, 40% of the watermark will be blended with 60% of the original image. Some examples are shown in Figure 2.
The fourth parameter, scaleFactor, is a scale factor that is used to change the size of the watermark. It is a floating point (decimal) number. If it is less than 1.0 (e.g. 0.75) it will reduce the size of the watermark. If it is larger than 1.0 (e.g. 1.5) it will increase the size of the watermark. If the scale factor is 1.0 the watermark will just remain at the same size. Some examples are shown in Figure 3.
For example, if we want to place a watermark on the beach picture, the first argument will be the beach picture. In the command area you might have entered
beachFile = pickAFile() # select the file beach.jpg
beachPicture = makePicture(beachFile)
This beachPicture could then be used as the first argument.
If the water mark image is the picture of barbara, you might have entered
barbaraFile = pickAFile() # select the file barbara.jpg
barbaraPicture = makePicture(barbaraFile)
You could use barbaraPicture as the second argument.
You might try a strength such as 0, 25, 50, 75 or 100. All of these will impact on the strength (visibility) of the watermark. See some examples in Figure 2.
A scale factor like 0.75 will reduce the size of the watermark image by about three quarters. A scale factor like 1.5 will increase the size of the watermark image so it is one and a half times larger. See some examples in Figure 3.
You might then test the watermarkWithPicture function like this:
watermarkWithPicture(beachPicture, barbaraPicture, 25, 0.75)
watermarkWithPicture(beachPicture, barbaraPicture, 50, 1.0)
watermarkWithPicture(beachPicture, barbaraPicture, 75, 1.5)
You should test your function with lots of different values. We will certainly test your function with lots of different pictures, strengths and scale factors. Although we will be careful to choose arguments that do not create problems. For example, we will make sure the watermark image, when scaled is smaller than the original image being watermarked. We will also make sure the strength is between 0-100. This means you do not have to include checks in your code for these types of errors.
Figure 2: Examples of different strengths used when overlaying the turtle.jpg image as a watermark on top of the barbara.jpg image. In this example the scale factor is 1.0 so the turtle image remains at normal size. Note that in this
example the watermark is created using the simplest version of our watermarking blending (tasks 1,2,3). Compare this with Figure 8 where the more advanced version of blending is used (tasks 1,2,3 4).
Figure 3: Examples of different scales used when overlaying the turtle.jpg image as a watermark on top of the barbara.jpg image. In this example the strength is 50 in each image. In this example the watermark is created using the simplest version of our watermarking blending (tasks 1,2, 3).
To write this function you will need to complete a number of the 6 specified tasks. It requires that at least tasks 1-3 to be completed. (Greyscale, Scaling, Simple blending). The way this function works will then be improved by completing task 4. (Blending based on luminance).
This function will also be used by the watermarkWithText function you create in task 5. (Creating a textbased image and using it for the watermark).
One problem with the watermarkWithPicture function is that you need to be careful to provide a scaling factor so that the watermark image fits into the original image. This will be improved by completing task 6. (Automatic scaling of watermark). The watermarkWithScaledPicture function will reuse tasks 1-4 and could also be used to improve task 5.
Task 1: Greyscale. Make a greyscale version of watermark based on luminance
In this task you will create a new greyscale picture from the watermarkImage. There are different approaches to forming a greyscale image. We looked at one of these in a tutorial. This tutorial question simply averages the three colour channels of each pixel. A more sophisticated approach is to generate the greyscale image based on luminance.
This luminance approach uses a weighted average of the colour channels to calculate the new grey value. Luminance models accommodate the different impacts of red, green, and blue colour on our perception. There have been a number of different algorithms developed that use various amounts of the three colour channels to calculate the luminance value. In this task make sure you use the CIE 1931 linear luminance model that calculates the weighted average using 0.2121 of the red channel, 0.7152 of the green channel and 0.0722 of the blue channel.
For each pixel in the colour image you first need to calculate the weighted average (luminance) from the red, blue and green channels. To make the greyscale image use this calculated luminance value to set the red, blue and green channels of the greyscale pixel. (Remember all greyscale images have the same red, green and blue value).
Original image Simple average grey Weighted average grey scale scale image image based on luminance
Figure 4: Examples of two different greyscale algorithms. The picture on the left is the original turtle.jpg image. The middle picture shows the result of averaging the three colour channels to create a greyscale image. The picture on the right is created using the more sophisticated weighted average (luminance) of colour channels.
Task 2: Scaling. Scale the watermark image up or down based on scale factor
If the watermark image is too small, it won’t be an effective watermark. If it’s too big, it won’t fit in the original image. It could even crash the program when you try to place it on a smaller image. To create the watermark this function relies on the user to provide a sensible scaleFactor. Based on this scale factor you will need to create a new scaled watermark image of the required size. To do this you will need to work out the size of the scaled watermark image and create this image. The height will just be the height of the starting image multiplied by the scaling factor. The width can be calculated in the same way. But you will need to copy the appropriate parts of the starting mark image to the scaled image.
Problem-solving. How do you scale an image up or down by a specified factor? In chapter 6, the textbook has a program to scale a picture down by 0.5 (ie to make its width and height half of what they were) and a program to scale a picture up by 2 (ie to make its width and height twice what they were). But these programs give you very little idea of how to scale a picture up or down by, say, 0.372 or 3.84. That is what you now need to do, and you will need to think it out very carefully. See Figure 5 for some examples.
scaleFactor = 1.5
barbara_scaled_1.5
Figure 5: Examples of applying the first two tasks (greyscale and scaling) to the barbara.jpg picture.
To complete this task it might be a good idea to start by writing a function that takes a starting image and returns a new scaled image that is a copy of the starting image but half the size (scaleFactor=0.5). To do this scaling you will need to find a colour for each pixel in the scaled down image. This colour will come from one of the pixels in the starting image. While you need to set the colour of every pixel in the scaled down image, you can skip every second pixel in the starting image.
Once you get that function working, try replacing the scaling factor with a parameter, and try it with different values such as 0.5, 1.5, 4, etc. So long as you’ve made the scaled picture the right size, you should have written a general picture-scaling function. Make sure the function creates and returns a new scaled image. You can test this function works before including it as the next step in the watermarkWithPicture function. This second step will take the grey water image from step one and scale it to create a larger it smaller version. This scaled grey watermark will be blended into the original image in the next task.
Task 3: Blend the scaled grey watermark image with the original image.
This is a relatively easy task, based on the blending programs in the book and the lectures.
At what location in the first image should you place the watermark? Place it so that the centre of the watermark is at the centre of the first image.
How transparent should the watermark be? The transparency should be as specified by the strength parameter. See Figure 2 and Figure 6 for some examples.
Note that at this stage we just have a normal transparent overlay, which includes a clear pale box showing the boundaries of the watermark image. That’s fine for task 3 you’ll be fixing it in the next task
Figure 6: Examples of using the barbara.jpg image as a watermark on the beach.jpg image. The picture on the left was created with a strength of 30 and a scale factor of 0.8, The picture on the right was created with a strength of 75 and a scale factor of 1.5.
Task 4: Improve the blend step using the luminance of the watermark image.
At the end of task 3 you should have a transparent overlay of the watermark image on the original image. You should be able to adjust the strength and scale of the watermark image.
The next task is to change the blending process to make the ‘brighter’ pixels (those with higher luminance) more transparent. In task 3 the blending process is the same for each pixel. In task 4 this will change so that the amount of blending is calculated differently for each pixel. The blending for each pixel will depend on both the strength parameter but also the luminance of the pixel. (Remember the luminance is the weighted average of the red, green and blue colour channels. This is the same luminance calculation you used in calculate the greyscale image in task 1.)
Some examples of the effect of this task are shown in Figure 7 and Figure 8. Note that the darker pixels in the watermark image, are overlaid quite strongly (at the specified strength, which is 50 in Figure7 and 70 in Figure 8). The white pixels are completely transparent. This is what you are required to achieve in task 4.
Figure 7: Examples of the different effects of blending. The image on the left shows the forbidden_city.jpg image used as a watermark on the beach.jpg image. This was produced by the simple blending approach using tasks 1,2 and 3. The picture on the right used the same images but was created with the more complex blending approach using tasks 1,2 and 4. In both cases the same strength of 50 and the same scale factor of 1.0 was used.
strength = 70 strength = 70
scaleFactor = 2.1 scaleFactor = 2.1
Figure 8: Examples of the different effects of blending. The image on the left shows the turtle.jpg image used as a watermark on the barbara.jpg image. This was produced by the simple blending approach using tasks 1,2 and 3. The picture on the right used the same images but was created with the more complex blending approach using tasks 1,2 and 4. In both cases the same strength of 70 and the same scale factor of 2.1 was used.
Problem-solving. In the week 6 lecture we varied the transparency levels from 0 at the top of a superimposed image to 100% at the bottom. To do that we worked out a formula that related the level of transparency to the y-coordinate of the superimposed image. Once again we need varying transparency, but this time the level will depend on the luminance of the superimposed pixel. So transparency will be different for each pixel. As with the greyscale in task 1, you should use a weighted average of the channels, not a plain average, when calculating the luminance.
def watermarkWithText(originalImage, listStrings, strength, fontSize)
Task 5: Watermark an image with a list of strings
In this task you will need to implement the watermarkWithText. To test this function we will call this function called with appropriate arguments. This function will call functions for the other tasks in turn. It will need to reuse the watermarkWithPicture function from tasks 1-4.
Once again, be sure that you name the function exactly the way it is named here. Also be sure that you define it as having the four parameters as shown. If the name or parameters are different, JES will not find the function when we try to run it. If you do not attempt this task finished, that is OK just leave the function out of your program and make a note in your journal and your code.
The first, and third parameters are exactly the same as the corresponding parameters of watermarkWithPicture function. The first parameter, originalImage, is a picture on which the watermark will be placed.
The function will return a copy of the original image with the watermark. There should be no side effects. The last thing the function does before returning is to repaint this new watermarked image. So don’t forget before the function returns, to repaint() the final watermarked image it has created.
The second parameter, listStrings is a list of strings that will be displayed as the watermark. For example, here are a couple of examples of lists that you might set up for testing.
list3Strings = [---Draft---, -Copyright-, -2018-]
list4Strings = [-This is a-, -copyright image.-, -All rights-, -are reserved.-]
Each of these strings will be displayed on a separate line with a space between. The text should be placed so that it is approximately in the centre of the original image.
The transparency of the text will depend on the strength parameter. This parameter is the strength of the watermark, an indication of how visible the watermark should be. This will be an integer in the range from 0 to 100. With a strength of 100, the watermark image will completely replace the corresponding pixels of the original image. With a strength of 0, the watermark image will be completely transparent or invisible. Some examples are shown in Figure 9 and Figure 10.
The fourth parameter, fontSize, is the size of the font to be used to create the text on the image. In my code I used the bold sansSerif style of text. You can use another style if you wish. (JES doesn’t give you much choice). I will only test your program with fonts between size 12 and 40. This might make it easier to create an algorithm for laying out the text in the centre of the image.
For example, I might test the code with calls like...
watermarkWithText(churchPicture, list4Strings, 30, 30)
watermarkWithText(churchPicture, list4Strings, 50, 30)
watermarkWithText(churchPicture, list4Strings, 80, 30)
watermarkWithText(barbaraPicture, list3Strings, 70, 12)
watermarkWithText(barbaraPicture, list3Strings, 70, 20)
watermarkWithText(barbaraPicture, list3Strings, 70, 30)
watermarkWithText(barbaraPicture, list3Strings, 70, 40)
Figure 9: Examples of the different effects of strength when a text watermark is added to the church.jpg picture. The images use the list of strings [-This is a-, -copyright image.-, -All rights-, -are reserved.-]. The font is the same in each image (bold, sansSerif, size=30). A range of different strengths are used (30, 50, 80). Note that this uses tasks 1-4 to create the final blended images.
Figure 10: Examples of the different effects of strength when a text watermark is added to the barbara.jpg picture. The images use the list of strings [---Draft---, -Copyright-, -2018-]. The same strength (70) is used. The font (bold, sansSerif) is the same in each image but four font different sizes are used (12, 20, 30, 40)
You should test your function with lots of different values. We will certainly test your function with a range of different pictures, strings, strengths and font sizes. Although we will be careful to choose arguments that do not create problems. For example, we will make sure to use a sensible list of strings. We will also make sure the strength is between 0-100 and the font size is an integer between 12-40. This means you do not have to include checks in your code for these types of errors.
Problem-solving: you already know how to add text to an image, and perhaps even how to add text with a specified style. If you add black text to a white image, you will have something that you could use as a watermark. Of course, there is more to it than that. You will need to create a white image that is the same size as the original file and then add the text to this white image. Once you have this picture you can use it as the watermark image and just reuse the tasks from 1-4 to add the water mark to the original picture. If you use a scale factor of 1.0 the watermark text-based image will not change size when it is blended.
Why a list of strings? Because when adding text to an image, you can’t include line breaks. So, if you want spaces between strings (as in Figure 10), you need to add the separate strings to the image at different rows of the image.
If you write text using the standard font, it will probably be very small when you use it as a watermark. To reduce this pixellation, we need the option of specifying a (much) bigger font.
Problem-solving: how do you add a style to the text and then centre the text into an image. This algorithm will depend on the font size. You may need to do some trial and error calculations to work this out. An approximate solution is Ok as it can be tricky to get it perfectly centred when you change font sizes.
Once you have solved these problems, you should have a function that produces an image from the list of strings. That function then simply calls the watermarkwithPicture function with appropriate arguments, with the new text-based image as the second argument.
def watermarkWithScaledPicture(originalImage, watermarkImage, strength)
Task 6: Watermark a picture by automatically scaling a watermark image
You may wish to stop now. Especially if you are running out of time. At least make sure you make a backup of your work in case you cannot get this final function to work. It is tricky and not worth a lot of marks so you may wish to leave it out of your assignment.
Apart from the name, watermarkWithScaledPicture this function is similar to the first function.
However, watermarkWithScaledPicture has one less argument. Notice the scaleFactor from the first function is not included in this final function.
This is because the scale factor is automatically calculated so the water mark image is as small as possible, while also being either two thirds the height of the original or two thirds of the width. Once you have worked out the scale factor you should just reuse the first function watermarkWithPicture to place the watermark in the centre of the original image.
Remember this function works in a similar way to the first. We have decided an ideal size for the watermark: either its height will be two-thirds of the height of the original image it is being placed on, or its width will be two-thirds of the width of the original image, whichever gives the smaller watermark. The smallest watermark has the fewest number of pixels.
You can see some examples in Figure 11.
Notice that there are a few possible combinations that you need to consider and in each case the watermark is either two thirds the height or width of the original image.
Figure 11: Examples of the automatic scaling function (task 6).
Assessment criteria
Your work will be assessed as follows. (Sufficient evidence needs to be provided. 120 marks, worth 30 % of the overall course mark
Criteria Mark
Your journal, as specified above, clearly showing evidence of the design and development process 15
Programming style (eg functional decomposition, well-named variables) and documentation (appropriate and useful comments in the code). Meeting standard coding requirements (single return statement, no side effects etc.) 15
function watermarkWithPicture 5
Task 1 - Greyscale 10
Task 2 - scaling 20
Task 3 - simple blending 10
Task 4 - luminance blending 15
Task 5 - the function watermarkWithText, create text-base image, 20
Task 6 - the function watermarkWithScaledPicture, automatic scaling 10
120
Penalties
Once these marks have been allocated, marks will be deducted for the following:
• failure to follow instructions/requirements, eg with file names
• syntax errors or runtime errors in your program
• failure to fully and clearly reference any material from external sources, such as code written by other people or code with which other people have assisted you
• late submission – the assignment is due by 11.59pm on Sunday, 13 May, 2018 (end of week 9). Work will be penalised 10% for every day or part day by which it is late.
If you get code from other people or sources, or if other people help you with your own code, you must add comments making this clear, and explain it in your journal. If the marker uncovers evidence that you have cheated in any way, for example, by sharing your code with others in the class, or by getting help from anyone other than your partner and not referencing it, the matter will be reported to the Student Academic Conduct Officer as a potential case of academic misconduct. (See Academic integrity below.)
Paired work
When two students work as a pair, all folders and files (as described above) should clearly indicate the names of both students in the pair. Only one copy of the work needs to be handed in, only one journal needs to be handed in (a combined journal for the pair), and both students in the pair will normally get the same mark for the assignment, regardless of who did how much of the work, unless it is clear that this would be a serious injustice.
Academic integrity – getting assistance or code
This assignment is your chance to gain an understanding of fundamental concepts of program structure and coding syntax on which later learning will be based. It is important that you master these concepts yourself.
Since you are mastering fundamental skills, you are permitted to work from the textbook and course examples, but you must acknowledge assistance from other textbooks or classmates. In particular, you should try not to use code or algorithms from external sources, and not to obtain help from people other than your instructors, as this can prevent you from mastering these concepts. However, if you do get code or assistance from these external sources, you must ‘attribute’ it: both in your journal, and in comments in your code, you must clearly explain where or who the code or assistance came from, and how much help or code was provided.
Here is a detailed guide to who you can get help from, and where you can get code from. Please pay careful attention to it.
Assistance: who might you want help from? Status
Yourself, your partner Highly encouraged
Your lecturer, your tutor Encouraged
Classmates, PASS tutor, other tutors Attribution required
Online forums, relatives, friends, other students not in this course Not acceptable
Resources: where might you want to get code from? Status
Course textbook, course notes and examples, your partner Encouraged
Other textbooks Attribution required
Online programs, hired coders, relatives, friends, other students Not acceptable
Obtaining code or assistance for which attribution is required without attributing it, or obtaining any code or assistance from sources marked ‘Not acceptable’, is a breach of academic integrity, and can be referred to the School Academic Conduct Officer for investigation. Furthermore, providing such code or assistance is also a breach of academic integrity, and can be treated as such.
If you do receive code or assistance for any of the assignment, there is a specific way in which you must provide the attribution in your program. We call this a reference comment.
The reference should say whether it is for externally sourced code, an externally sourced algorithm, or personal assistance. It should be given a unique identifier so that its end can be clearly marked.
The beginning and end of each reference should be marked in a particular way that stands out from the code. In the examples below we use lines of hash symbols to do this.
Each reference should include:
• its purpose: why was external code or assistance sought?
• the date the code or assistance was used;
• the source of the code or assistance;
• the author of the code, if known, or the person providing assistance;
• the url, if applicable;
• any adaptation that was required to incorporate external code;
• a brief description of assistance that was provided, if applicable.
Here are some examples.
#############################################
# Reference A3: externally sourced algorithm
# Purpose: sort a list of sublists by the second element in each sublist, descending
# Date: 2 May 2017
# Source: Python documentation
# Author: Andrew Dalke and Raymond Hettinger
# url: https://docs.python.org/3/howto/sorting.html
# Adaptation required: changed variable names; saw need to assign result to original list name
#############################################
freqList = sorted(freqList, key = lambda wordFreq: wordFreq[1], reverse = True)
#############################################
# End reference A3
#############################################
#############################################
# Reference C5: externally sourced code
# Purpose: make a collage with various colour transformations because I didn’t understand the one in the book # Date: 12 Sep 2017
# Source: stackoverflow
# Author: Gauthier Boaglio
# url: https:#stackoverflow.com/questions/15693938/how-do-i-change-image-colors-with-jes-programing
# Adaptation required: changed variable names
#############################################
# This is where the copied code goes
#############################################
# End reference C5
#############################################
#############################################
# Reference P7: personal assistance
# Purpose: deal with index out of range error
# Date: 25 Aug 2017
# Source: fellow student Susan Piper
# Assistance: explained that these errors arise if we try to access pixels beyond the edge of the picture
#############################################
# This is where the newly modified code goes
#############################################
# End reference P7
#############################################