## Image Modification

### Due Date: Tuesday, April 11, 2006, at 11:59 pm

For this machine problem, you are to write a function in JES that will first separate an image into 4 parts or quadrants. In each quadrant of the picture we wish to modify the pixels in a different way. The quadrants would be created by "cutting" the picture in half vertically and horizontally.

• The first quardant of the image will be left unchanged.
• The second quardant of the image will modify the amount of red in all the pixels in that part of the image.
• The third quardant of the image will modify the amount of green in all the pixels in that part of the image.
• The fourth quardant of the image will modify the amount of blue in all the pixels in that part of the image.

Look at the table below to understand what should be done. We will number the quadrants in the same manner as is done with a coordinate plane in mathematics.

Modify
Red

Leave
Unchanged

Modify
Green

Modify
Blue

When you modify the saturation of a color in each quardant of the image, you may either remove all of that color (set the value of that color to 0) or you may set that amount of that color to the maximum (set the value of that color to 255). Below are three pictures. The first picture is the original picture. The second picture has all of desired color removed from each quadrant of the picture. The third picture has the desired color in each quadrant of the picture set to a maximum value.

Note the second picture. Since the picture is already dark, the amount of each color is already low. Thus setting the color value to zero doesn't make that big of a change in the picture. Now consider the third picture. Setting the color value to the maximum causes a much larger change in the picture.

Below is another set of three pictures. The first picture is the original picture. The second picture has all of desired color removed from each quadrant of the picture. The third picture has the desired color in each quadrant of the picture set to a maximum value.

Note the third picture. Since the picture is mostly white, the amount of each color is already high. Thus setting the color value to its maximum doesn't make that big of a change in the picture. Now consider the second picture. Setting the color value to zero causes a much larger change in the picture.

Your program can either set the appropraite color value in each quadrant to either zero or to 255. Once you find a picture you might like to modify, determine which way will give you the better effect. This choice is completely up to you; however, don't set one quardant's color value to zero and another quadrant's color value to 255. If you set one quadrant's color value to zero, set the other two quadrant's color values to zero.

A few items to note for this project:

• Your program should be written to work with any picture, thus your program must be able to determine the height and width of the picture in order to divide the picture into the four quadrants. We will use our own picture for the grading of the assignment.

• Your program is to prompt the user for a picture to modify and is also to prompt the user to save the modified picture. Using the pickAFile() function in JES is a good way to prompt the user for the filename of the picture.

• The function that is called from the command area of JES is to have the name of hw3(). This function may call other functions. These other functions can have any name you wish. Note that "your program" would consist of the the function hw3() and any other functions that are called by hw3(). This will help make grading of the assignment faster.

• The filename that your program is in should be hw3.py. This will also help make grading of the assignment faster.

• Your program can be written using 3 if statements inside of a for loop. The for loops will loop for all of the pixels in the picture. One if statement will determine if the pixel is in Quadrant 2 and modify the amount of red in that pixel. Another if statement will determine if the pixel is in Quadrant 3 and modify the amount of green in that pixel. The last if statement will determine if the pixel is in Quadrant 4 and modify the amount of blue in that pixel.

You only need to electronically submit your hw3.py file via email. Email your file to the CS 100 instructor account:

```      i100@cs.uic.edu
```
We will use our own picture for the grading of the assignment, so you don't have to send in a picture.

You are encouraged to set up a JES display web page on which you can display any images you created for this assignment.