CPT105程序辅导、讲解Programming程序、Java编程辅导 辅导留学生 Statistics统计、回归、迭代|辅导Python编程

- 首页 >> Matlab编程
CPT105 - Introduction to Programming in Java
CPT105
Erick Purwanto and Andrew Abel– October 2020
CPT105 CW3 2020
The Wonderful, Colourful World of Andrews
Due date: Part A 7
th ; Part B, C 14th December at 18:00 - 30% of final mark
This assignment has three parts, Parts A, B, C. You will use the existing Color and
Picture classes that you have used in your lab classes and create methods to
modify images. Part A will be due on Monday 7th December 2020 (2020/12/7)
at 18:00pm, and Parts B and C will be due on Monday 14th December 2020
(2020/12/14) at 18:00 pm.
We will be using two classes a lot in this project: Color and Picture. The Color
class provides us an encapsulation for the RGB color component values and is
located in the java.awt package – you need to import it. The Picture class allows
you to write Java programs that manipulate pictures and is provided in the
cw3.zip file on Learning Mall.
To support you, we have provided a cw3.zip folder on Learning Mall. This
contains some sample code, empty methods for you to work with, and a sample
image.
All submission will be via Learning Mall as used throughout this semester, see
end of each part for further instructions.
Part A – Image Modifications (45% of assignment), DUE Monday 7th
December 2020 (2020/12/7) at 18:00
In Part A, you have to write a method to manipulate an input Picture object as
described in the following section. You have to follow the description to produce
the correct output. There are 4 tasks to complete, Task A1, A2, A3 are worth
10%, A4 is worth 15% . You should submit your individual methods on in the
appropriate code runner section of Learning Mall. There are sample correct
output images in the zip file that you can use to test your method, using the
Picture’s equals method.
In all these tasks, you will be marked based on the output images, and you have a
sample project provided on Learning Mall to use.
Part A.1 Tilt (10%)
Write a method Picture tilt(Picture picture) to tilt a picture by rotating the
picture 30 degrees clockwise. To rotate a picture by θ radians counterclockwise,
copy the color of each pixel (cols, rows) in the source picture to a target pixel
(colt, rowt) whose coordinates (in int) are given by the following formulas:
colt = (int) ( (cols - colc) × cos θ - (rows - rowc) × sin θ + colc )
rowt = (int) ( (cols - colc) × sin θ + (rows - rowc) × cos θ + rowc )
CPT105 - Introduction to Programming in Java
CPT105
Erick Purwanto and Andrew Abel– October 2020
where colc and rowc are the coordinates (in double) of the center of the width-byheight
picture, computed by:
colc = 0.5 × (width - 1)
rowc = 0.5 × (height - 1)
Note that you should only copy the pixel if the target pixel is in bounds, so as not
to change the dimension of the image. Use black for target pixels with no copied
color.
For example, an original Andrew and the tilted Andrew is shown below. A fully
working and perfect image will get full marks, with mark deductions for
repeated attempts.
Part A.2 Emboss (10%)
Write a method Picture emboss(Picture picture) to add an emboss style effect to a
picture by applying the following kernel (see Appendix 1 for information on a
Kernel Filter’:
An original Andrew and the embossed Andrew are shown below. A fully
working and perfect image will get full marks, with deductions for repeated
submissions. For more information about applying a Kernel Filter, please see the
appendix at the end of this sheet.
CPT105 - Introduction to Programming in Java
CPT105
Erick Purwanto and Andrew Abel– October 2020
Part A.3 Blur (10%)
Write a method Picture blur(Picture picture) to blur a picture by applying the
following kernel (one-ninth in a 9-by-9 diagonal matrix). This means applying
the diagonal matrix, and then dividing the result by 9:
An original Andrew and the blurred Andrew are shown below. A fully working
and perfect image will get full marks, with deductions for repeated submissions.
CPT105 - Introduction to Programming in Java
CPT105
Erick Purwanto and Andrew Abel– October 2020
Part A.4 Edge Detection (15%)
Write a method Picture edge(Picture picture) to perform edge detection of a
picture as follows. First convert the picture into a grayscale picture. You can
achieve that by simply calling the static grayScale(picture) method, which is
provided as part of the example code, and is similar to the method created in
your lab classes.
Picture grayPic = CW3_Example.grayScale(picture);
Next, apply these two kernels to each grayscale component (you only need to do
one computation since all three color components of a grayscale picture are the
same) of a pixel, the following:
to obtain the value Gx, and the following
to obtain the value Gy.
Finally, clamp the value G = Gx
2 + Gy
2
, and the set the color of that pixel to 255 – G.
An original Andrew and the edge detected Andrew are shown below. A fully
working and image will get full marks, with deductions for repeated
submissions.

CPT105 - Introduction to Programming in Java
CPT105
Erick Purwanto and Andrew Abel– October 2020
Submission
Submit your code for part A to Learning Mall in a similar manner to the weekly
programming quizzes (CW1s). Further guidance is provided in your lab classes. Again,
the priority is to ensure that your code produces an image, as credit will be given
accordingly.
Part B – Creative Image Transforms (30% of assignment), DUE Monday 14th
December 2020 (2020/12/14) at 18:00
In Part B, you have more creativity to create methods to transform images.
There are 2 tasks to complete, both are worth 15% of your grade. In both
methods, you must draw the original image with a transformed image side by
side, and the method must be general and applied to any picture. You should
submit your individual methods on in the appropriate code runner section of
Learning Mall.
In all these tasks, you will be marked based on the output images. You should
therefore prioritise being able to display an image over a complex transform that
does not work.
Part B.1 Positional Transform (15%)
In Part A1, you applied a positional transform. Now, write a method
positionalTransform, that will transform the pixel positions of the original picture and
display the original and transformed images side by side in the same picture. You have
a free choice of how you wish to do this. The original and transform must be drawn
on the same image. More creativity will get extra marks! You should experiment and
carry out independent research, and submit it to Learning Mall.
CPT105 - Introduction to Programming in Java
CPT105
Erick Purwanto and Andrew Abel– October 2020
For example, for 50 marks, you can create a method that produce a mirror image, such
as:
You will get more marks for more creative transformations. For 60+ marks, you can
create a wave effect, for example:
Part B.2 Color Transform (15%)
Write a method colorTransform that will transform the Color of the pixel of the
original picture. You have a free choice of how you wish to do this. The original
and transform must be drawn on the same image. More creativity will get extra
marks.
For example, for 50 marks, you can create a method that produces a negative
picture effect, such as:
CPT105 - Introduction to Programming in Java
CPT105
Erick Purwanto and Andrew Abel– October 2020
For 60+ marks, you can create a see-through-a-glass effect, for example:
Submission
Submit your code to Learning Mall in the section allocated to Part B. Further guidance
is provided in your lab classes. The priority is to ensure that your code produces an
image, as credit will be given accordingly.
You should also submit documentation for these questions, as will be discussed in Part
C.
Part C – Documentation (25% of assignment), DUE Monday 14th December
2020 (2020/12/14) at 18:00
In Part C, you need to complete the design and documentation of the programs
you wrote in the previous parts. This is worth 25% of your overall grade, and
will be submitted on Learning Mall.
CPT105 - Introduction to Programming in Java
CPT105
Erick Purwanto and Andrew Abel– October 2020
Class Diagram
You used the Picture class to create your objects. Draw a class diagram. You
must use a drawing tool of your own, such as Powerpoint, Visio, or an equivalent.
You must not use any autogeneration software.
Report
You must submit a written report. You must provide a description (100-150
words) for each of the methods you have created in Part B. In each description,
you should describe the technical steps in your method, the effect you are trying
to achieve, and how it is creative and meaningful (i.e. a useful effect). Your
report should also contain 3 sample pictures (these must be new pictures, not
the sample image given) to demonstrate your transforms.
Submission
Submit your solution for part C online in the CW3 Part C dropbox on Learning Mall.
You should submit several files:
 One design document with your class diagram, the description of each
method in Section B, and the code copy and pasted for each method, and
your sample pictures.
 One .txt file for each .java class file. These documents must NOT be in a
ZIP archive. The file name must be the class name. Each file must have
your name/student number in a comment at the top.
Notes
 All of the coding can and should be achieved using the Java resources
covered in the lectures so far this semester.
 You will need to do independent research to investigate possible
transforms in section B
 Your code must compile in learning mall. If it does not compile, it will get
0 marks.
 A starter set of classes is available on Learning Mall for you to use, as well
as some images.
 The design should be your own. Shared designs with friends will be
considered plagiarism.
CPT105 - Introduction to Programming in Java
CPT105
Erick Purwanto and Andrew Abel– October 2020
This assignment is individual work. Plagiarism (e.g. copying materials from
other sources without proper acknowledgement) is a serious academic
offence. Plagiarism and collusion will not be tolerated and will be dealt with in
accordance with the University Code of Practice on Academic Integrity. Individual
students may be invited to explain parts of their code in person, and if they fail to
demonstrate an understanding of the code, no credit will be given for that part of
the code.
Appendix 1: Kernel Filter
A kernel filter modifies the pixels in a picture by replacing each pixel with a linear
combination of its neighboring pixels and itself. The matrix that characterizes the
linear combination is known as the kernel.
Specifically, to apply a kernel filter to a picture, perform the following operation for
each RGB components of each pixel p separately:
 Align the center of the kernel on pixel p.
 The new component value of pixel p is obtained by multiplying each kernel
element with the corresponding component value, and adding the results.
After that, combine the results to get the new color.
For example, to apply an emboss kernel filter (see Part A.2 above) to the middle Red
component value of 50 of a pixel on some part of a picture:
we compute the new value to be
= (-2)10 + (-1)20 + (0)30 + (-1)40 + (1)50 + (1)40 + (0)10 + (1)20 + (2)30 = 90.
We then combine that with the similar computation on the Green and Blue
components to obtain the new color of the corresponding pixel.
Note the following important information about the computation:
 Periodic boundary conditions. When applying a kernel filter to a pixel near the
boundary, some of its neighboring pixels may not exist. In such cases, assume the
CPT105 - Introduction to Programming in Java
CPT105
Erick Purwanto and Andrew Abel– October 2020
leftmost column wraps around to the rightmost column, and vice versa; and the
top row wraps around to the bottom row, and vice versa. For example:
 Rounding. When applying a kernel filter, the resulting RGB components may
become fractional if the kernel weights are fractional. Round each RGB component
to the nearest integer, with ties rounding up.
 Clamping. When applying a kernel filter, the resulting RGB components may not
remain between 0 and 255. If an RGB component of a pixel is less than 0, set it to
0; if is greater than 255, set it to 255.

站长地图