Problem Solving Assignment #6
Turnin for Extra Credit due Monday, February 18th, 11:59 pm
Turnin due Tuesday, February 19th, 11:59 pm
Interview due Friday, February 22th, 11:59 am
Required Reading: Chapter 2, Chapter 3, Chapter 4, Chapter 5, Chapter 6
Please read this whole page and be able to answer the understanding questions before starting on this assignment. Ask a tutor, TA or instructor if you have any questions before you begin.
You will work with a partner on this PSA. Before you begin you MUST have a partner. Please review the guidelines for pair programming. There is an individual interview required for this PSA which is 20% of your PSA grade. This PSA has a total of 16 points. However, all PSA assignments are weighted equally. The interview is always 20% of the total PSA grade (i.e. if you managed to obtain all 16 points but failed to complete an interview your total PSA grade would be 80%).
Files to turn in: Picture.java, PSA6.java, and some picture files (max of 10) (pic0.jpg, pic1.jpg,...pic9.jpg). Any other file modified will not be collected and grade will be according to only the three files mentioned.
Note the green screen is in B250 in the basement of the CSE building
Please read this whole page and be able to answer the understanding questions before starting on this assignment. Ask a tutor, TA or instructor if you have any questions before you begin.
You will work with a partner on this PSA. Before you begin you MUST have a partner. Please review the guidelines for pair programming. There is an individual interview required for this PSA which is 20% of your PSA grade. This PSA has a total of 16 points. However, all PSA assignments are weighted equally. The interview is always 20% of the total PSA grade (i.e. if you managed to obtain all 16 points but failed to complete an interview your total PSA grade would be 80%).
Files to turn in: Picture.java, PSA6.java, and some picture files (max of 10) (pic0.jpg, pic1.jpg,...pic9.jpg). Any other file modified will not be collected and grade will be according to only the three files mentioned.
Note the green screen is in B250 in the basement of the CSE building
Setup
1) Right-click in an open space on the Desktop and select 'Open in Terminal' from the drop down menu.
(it will bring up the following window)
(it will bring up the following window)
2) Highlight the following 10 lines with the mouse, right-click to copy:
cd ../public/PSA6
make directories
make install
cd
cd PSA6
mv PSA6.java.empty PSA6.java
mv Picture.java.empty Picture.java
ls
3) Select the terminal window with the mouse and right-click to paste.
4) Verify that the 'PSA6.java' and the 'Picture.java' files are shown as the result of the last command.
Following these procedures, your files will be named correctly and be located in the correct places. For every assignment you need to follow correct
naming of assignments in the correct locations to get credit for your work.
5) Proceed to start your programming assignment. You must write your code in the files in your PSA6 folder.
cd ../public/PSA6
make directories
make install
cd
cd PSA6
mv PSA6.java.empty PSA6.java
mv Picture.java.empty Picture.java
ls
3) Select the terminal window with the mouse and right-click to paste.
4) Verify that the 'PSA6.java' and the 'Picture.java' files are shown as the result of the last command.
Following these procedures, your files will be named correctly and be located in the correct places. For every assignment you need to follow correct
naming of assignments in the correct locations to get credit for your work.
5) Proceed to start your programming assignment. You must write your code in the files in your PSA6 folder.
Problem
Chromakey -- Write a program that uses at least 3 images to create a new image.
Method: chromaKey
CREATIVITY
Commenting your code:
For 2 points you must comment your code. As always you must comment your code and include your and your partner's Name, login, Date, and Partner History at the top of PSA6.java (1 point). However, you are also required to write comments at the top of your chromakey methods in Picture.java explaining what the method does (1 point). You should also add in-line comments if you feel they are necessary (if you can't remember what a line does, your should probably include an in-line comment, or if you do something really creative you might want to provide a comment)
- You will take a picture with at least one person wearing a colored T-shirt in front of the green screen, located in B250
- You will then find two pictures. One will be the background (to replace the green screen) and one will replace the T-shirt. You could put the person in the picture in Hawaii by using the Hawaii background and give them a fractal colored T-shirt.
- There is room for creativity. You can have multiple people in the image, or you could use a blue and a green sheet to provide two different backgrounds. The minimum required is replacing one background and one T-shirt.
- Note: it is okay if you modify the picture of you took in front of the green screen slightly (to make the green more green or brighter). However, you can't just do the whole PSA using Photoshop.
Method: chromaKey
- For this project, you have a fairly large range of freedom to make your picture interesting. At the core, you are using the colors of pixels in the image to allow you to substitute pixels from other images. You will be able to take a picture of a person wearing a red (or other colored) shirt in front of a green canvas and make the background (canvas) look like another locale (Hawaii, Big Bear, whatever you want) and their T-shirt have a new design (Tie-Dye, Star Wars, etc.).
- To perform this project these are the minimal requirements.
- Add at least one method (to Picture.java) called chromaKeyXXXX where "XXXX" is the color you are replacing. This method will alter the calling object and take at least one parameter and use at least one final value (if you are still unsure about final values see THIS Piazza post). The parameter is a Picture which will be the picture you use when replacing pixels. If you choose to use a second parameter it is the source or original picture before chromakey was applied.
- Example 1: void chromakeyGreen(Picture input). Any pixel in the calling object that is "green enough" will be replaced with the background. You will use final values for this. (i.e. you might want to use "final Color greenReplaced", where you might use the distance() method to check the colors or you could set a threshold value for green "final int greenThreshold" where if the green value of a pixel is below or above then it is replaced by the background). There are many ways to do this, but you must have and use at least one final variable
- Example 2: void chromakeyBlack(Picture input, Picture original). This method takes in a second picture, which is the original picture before chromakey was applied. Let's say you replace your blue background with a scene from Star Wars. Then you want to replace the red in your shirt, but the lasers are also getting replaced. For this, the best thing to do is to pass the original "source" Picture (before any changes) as an additional parameter to the method. You would then check the "source" picture for red values and if they are red, replace the pixels in the calling object with the pixels from your T-shirt background.
- Create a new file called PSA6.java where you will write an application to test your methods. Start by copying the sample code provided below.
- REQUIREMENT You must use the picture that you and your partner took using the sheets in the lab as the source picture. The pictures that will replace the background and shirt can be used from pictures in media sources or from the internet.
- IMPORTANT In order for the grader to grade your submission your code must work with different paths. To obtain each media file, do NOT use the file path or MediaPath functions. Copy the images you want to use for your final submission into the same folder as your code. Then ensure that the file path is simply "picX.jpg". For example, if you want to use pic0.jpg, use
- String fileName = "pic0.jpg";
- Picture p = new Picture(fileName);
- Using the above method for creating pictures, you will open your three images.
- Show your original image (the picture of you and/or your partner in front of the blue or green screen).
- You will then call your chromakey method to change the background.
- For example: If your background is a green sheet, you would call chromakeyGreen on your picture and pass it the threshold and the background picture. This will cause the green pixels in your image be replaced with the background.
- Substituting the background using an above method is worth 5 points.
- You will then call your chromakey method to change the T-shirt color.
- For example: If your T-shirt is blue you would call chromakeyBlue on your picture and pass it the picture for the T-shirt and threshold. This will cause the blue pixels in your image be replaced with the new T-shirt picture.
- Substituting the T-shirt using an above method is worth 5 points.
- The PSA6.java file is worth 4 points
- Finally, show your new picture!
- Lastly, If you would like please post your resulting image on the wiki. We really enjoyed viewing your submissions for the previous projects.
CREATIVITY
- You are absolutely encouraged to be creative in this assignment, we expect some AWESOME looking pictures to be posted on Piazza!
- Make sure it looks good, the basic assignment shouldn't take too long, so we expect the final picture to look really good.
- NOTE: It works well if your source picture is smaller then the other two, why is this?
Commenting your code:
For 2 points you must comment your code. As always you must comment your code and include your and your partner's Name, login, Date, and Partner History at the top of PSA6.java (1 point). However, you are also required to write comments at the top of your chromakey methods in Picture.java explaining what the method does (1 point). You should also add in-line comments if you feel they are necessary (if you can't remember what a line does, your should probably include an in-line comment, or if you do something really creative you might want to provide a comment)
Sample Code
/* Filename: PSA6.java
* Created by: Partner Name 1 Login 1 PID1 Email1
* and Partner Name 2 Login 2 PID2 Email2
* Date:
* Partner History:
* Partner 1:
PSA1 Partner:
PSA2 Partner:
PSA3 Partner:
PSA4 Partner:
PSA5 Partner:
PSA6 Partner:
PSA7 Partner:
PSA8 Partner:
PSA9 Partner:
* Partner 2:
PSA1 Partner:
PSA2 Partner:
PSA3 Partner:
PSA4 Partner:
PSA5 Partner:
PSA6 Partner:
PSA7 Partner:
PSA8 Partner:
PSA9 Partner:
* Date:
* Description: This class is designed to...
* Posted to Piazza:
*/
public class PSA6
{
public static void main (String[] args)
{
...
}
}
* Created by: Partner Name 1 Login 1 PID1 Email1
* and Partner Name 2 Login 2 PID2 Email2
* Date:
* Partner History:
* Partner 1:
PSA1 Partner:
PSA2 Partner:
PSA3 Partner:
PSA4 Partner:
PSA5 Partner:
PSA6 Partner:
PSA7 Partner:
PSA8 Partner:
PSA9 Partner:
* Partner 2:
PSA1 Partner:
PSA2 Partner:
PSA3 Partner:
PSA4 Partner:
PSA5 Partner:
PSA6 Partner:
PSA7 Partner:
PSA8 Partner:
PSA9 Partner:
* Date:
* Description: This class is designed to...
* Posted to Piazza:
*/
public class PSA6
{
public static void main (String[] args)
{
...
}
}
How to turnin your homework
1) Open the terminal
2) cd PSA6
3) autograder login -e yourucsdemailhere -p (wait for password prompt)
4) type in your password
5) turnin PSA6
2) cd PSA6
3) autograder login -e yourucsdemailhere -p (wait for password prompt)
4) type in your password
5) turnin PSA6
PSA6 Understanding Quiz
Answers can be found here
1) At minimum you are required to
2) To avoid having pixelation effect (some pixels are from one image, others nearby are from another), which of the following is a good strategy for avoiding them?
1) At minimum you are required to
- A Substitute the background with another image
- B Substitute your T-shirt with another color
- C Substitute the background color with another image AND substitute your T-shirt with another image
2) To avoid having pixelation effect (some pixels are from one image, others nearby are from another), which of the following is a good strategy for avoiding them?
- A. Wear a T-shirt of very distinct color different than skin tone, background, other clothing.
- B. Use explore() to look at the colors of the troublesome pixels and adjust you thresholds (parameters) to cope with those values.
- C. Take multiple pictures trying to vary the amount of light angle of the light source to create more solid colors.
- D. All of the above can be helpful