For this assignment, you may work with a partner (and we recommend that you do).
Because this is a larger assignment than usual, this will count as two homework assignments.
The image array is stored as an unsigned char array because only a single byte worth of space is necessary for representing all values between 0 and 255. However, in your code you should think of the array as storing int values between 0 and 255, and write code that manipulates these int values (don't assign an image array bucket a char constant like 'a'). For example, to set a pixel to the second most white value I'd do:
image[i][j] = 255-1; // I would really use the constant (WHITE -1) here image[i][j] = 'q'; // don't do this even though it is legal C
I will provide you with a base C program which will read in, write out, and display a 480x480 greyscale TIFF image.
In addition, the starting point code includes a function that prints out the initial menu of options, and the prototypes and partial implementations of all the functions you need to write (you may add additional functions).
Use the function comments as guides on how to implement a feature.
This program requires that you write a large number of functions. However, after you figure out the first couple, they should get a lot easier. I suggest that you start with feature 1 (make negative), and that you implement and test incrementally (i.e. first implement and test feature 1 before starting on feature 2, and so on).
% cd ~/cs21/hw08 % cp ~newhall/public/cs21/hw08/* . % ls Makefile README imageproc.c libcs21graphics.a pic.tif tiff.h display.tclStart by reading through the README file for an explaination of how to compile and run the imageproc program.
There is one image file, pic.tif, for you to use, and another, quad.tif, that is useful in testing the quad-split feature. In addition, there are other pictures that you can use in ~newhall/public/cs21/hw08_figs/. Just copy over the ones you want into your working directory:
% cp ~newhall/public/cs21/hw08_figs/filename.tif .The starting point code includes a library, libcs21graphics.a, of routines to view covert to/from a tiff image file from/to a 2 dimensional array of pixel values. You do not have to add code to call these functions, as this is already done for your in the imageproc.c file.
The starting point code also uses a Makefile for compiling the program. To build the imageproc executable file, just type make:
% make # compiles imageproc executable fileFor more information about using and writing makefiles see: Makefile basics
To run the program:
% ./imageproc Enter the name of a 480x480 greyscale TIFF image: pic.tif What do you want to do to your image? 1. Make a negative 2. Flip it vertically 3. Flip it horizontally 4. Switch the top left and bottom right corners 5. Darken 6. Lighten 7. Polarize 8. Scroll the image vertically 9. Scroll the image horizontally 10. Zoom in 11. Blur the image 12. Rotate 90 degrees 13. Revert to the original 14. Sort Rows 15. Quad Split the image Extra Credit Special Effects # feel free to add more of these ---------------------------- # but leave QUIT as the last 16. # menu option if you do add more 17. 18. 19. 20. Quit Your choice:
Each time you enter a choice, the chosen effect should be cumulative. For example, if I choose Lighten 4 times in a row, the image should become more and more light. Option 13 allows a user to revert to the original image. Use the function comments as a guide in how to implement an effect (some examples are shown below too). For some effects, you may need to make a temporary local copy of the image so that you don't lose initial pixel values that your effect is changing.
% xv newpic.gifClicking the right mouse button in the window will bring up a menu window. From here you can crop the image and resize the image to exactly 480x480 pixels by selecting the ImageSize->Set Size menu options. Once it is the correct dimension, save it as a greyscale tif file by selecting Save and choosing TIF for Format and GreyScale for Colors.
Original Image (and option 13): | Blur: |
Flip Horizontally: | Scroll Horizontally by -200 pixels: |
Flip Vertically: | Scroll Vertically by 200 pixels: |
Zoom (zoom center selected): | Switch top left and bottom right corners: |
Polarize: | Negative: |
Rotate 90 Degrees: | Sort Each Row (use Bubble Sort): |
Quad Split Image:
(using the input file pic.tif) | Quad Split Image:
(using the input file quad.tif) |
EXTRA CREDIT IDEAS: | EXTRA CREDIT IDEAS: |
8 squares puzzle (extra credit)
(randomly reassigns 9 squares to 8 slots): | A Tiling Effect (extra credit): |
EdgeDetect (extra credit): | Histogram of pixel values (extra credit): |
Corner Split Image (extra credit): | Rotate by an arbitrary number of degrees: |
this would read in a degree amount entered
by the user (any real value, positive, negative, or zero) and rotate the image around the center by that many degrees. the resulting image can be drawn inside
|