|
||||||||
Image Arrays Exercisedue Jan 29PEER GRADED In this exercise, you will gain experience with multi-dimensional arrays and use in functions. The application will be to create a simple image processing program that will brighten each pixel value in an image (each element in the array representing the image) by adding to it a constant value making sure the resulting value does not exceed 255. The function you will write that will brighten the image is called brighten(int x) x is the ammount you are increasing all of the image pixel values by. YOU MUST make sure that your images stay in the range of 0 to 255 for each pixel. Important: THERE may be errors in the code below that you are responsible for finding and fixing ---this is part of the work and will make you learn the SW you are given. GO to either Gimp - photo editing tool or http://www.fine-view.com/
to download a tool to open up and display PGM files which
|
Introduction
- Image Manipulation - Brightening
Today we will be writing an image manipulation routine to gain some valuable experience in programming with multidimensional arrays. You will be using some open-source code from USF to do image reading from a file into a multi-dimensional array and image writting from such an array to a file. Download the following 2 files: imageio.h and imageio.cpp . You will use the following main function and insert a loop asking the user whether they wish to brighten the image and by how much or they wish to write to a file. Use the following image x.pgm to test this program. (AS DISCUSSED in class there may be some problems in the following Main code -- to fix this you will need to read the imageio.h and imagio.cpp carefully) #include <iostream> #include "imageio.h" #include <stdlib.h> using namespace std; int main() { unsigned char **image; int rows, cols; unsigned char value = 10; //creates a 2D array image and fills in the values associated with //the pixels in the image. Also, reads in the number of rows and //columns in the image and stores in the variables rows, cols. read_pgm_image("image.pgm", image, rows, cols ); switch ( getMenuInput() ) { case 1: brighten(image, rows, cols, value); break; //NEED to prompt for value!!! case 2: write_pgm_image("outputImage.pgm", image, rows, cols, "brightened image", 255); break; default: exit(0); } cout << "\nDone!\n\n"; return 0; }
Brightening function You need to implement the following algorithm: for (each element in the 2D array image, i) { i = i + value; if (i > 255) i = 255; //saftey check as pixel value cant be above 255 }
|
Deliverables
Evaluation
main function is correct and complete 15 points brighten funciton is correct and complete 30 points all files included in project as should and runs 5 points