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 a constant here (WHITE -1) 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 ~/cs1/hw6 % cp ~instructor/public/cs1/hw6/* . % ls Makefile README imageproc.c libcs1graphics.a pic.tif tiff.hThere is one image file, pic.tif, for you to use. In addition, the pictures of you I took in class on Tuesday and a few extra pictures are in my ~instructor/public/cs1/hw6figs/ subdirectory. You can copy any of these over into your working directory:
% cp ~instructor/public/cs1/hw6figs/me.tif .This starting point code using a makefile for compiling the program. The README file contains information on how to compile this code using 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 Extra Credit Special Effects ---------------------------- 15. 16. 17. 18. 19. 20. Quit Your choice:
The initial menu will present you with options for 14 manipulations. You must implement all of options 1-14, and option 20. Figures showing some of the options are shown below.
% 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|
|Zoom (zoom center selected)||Switch top left and bottom right corners|
|Rotate 90 Degrees||Sort Each Row (use Bubble Sort)|
|8 squares puzzle (extra credit)
(randomly reassigns 9 squares to 8 slots)
|Venetian blinds? (extra credit)|
|EdgeDetect (extra credit)||Histogram of pixel values (extra credit)|
|Right Split Image (extra credit)||Corner Split Image (extra credit)|
|A Tiling Effect|