Complete the provided program that performs two image processing tasks: (1) Detecting areas of color closed to one specified by user for the given image and its central location (computed the same way as "mass" or "gravity" center in physics, and (2) pixelize the image. The program is partially developed. Your task is to provide the code for the two image processing functions. You must use the provided incomplete program to get any credit.
All image processing functions used in this homework are based on a one pass "window processing" algorithm that is somewhat similar to the algorithm used in other types of problems such as plate/printed circuit board temperature distribution problem that was targeted by the previous assignment.
A few examples of image processing functions that perform certain operations on similar data structures are provided in case you feel lost after reading the text above. Those examples may not cover all possible cases but should give some idea what you are asked to do.
The image format that is utilized in this homework - PPM portable pixel map - is not commonly used in commercial software. It was chosen because of its simlicity that allow writing simple functiosn that read and write images that can be inspected by students. You may need to instal a trial version of Corel PaintShop Pro in order to generate the source images and view the results. You may print them directly or copy them to the clipboar so that they could be pasted into MSWord or your favorite text editor. Use color printer if possible and reasonable.
To generate a PPM file load an image of your choice into PaintShop and then save it as ASCII PPM
Please verify that your program produces the correct results. Run your
program using a pair of test images -
run1.ppm
. Then compare your results with sample resulting images (one for gravity center
calculation and one for pixelization) that are provided below.
Also run your program using another image -
run2.ppm,
and on one more image of your choice. You must print the source images and the
images generated by your program. Do not print the contents of the image files
in the text format. You may but do not have to use a color printer.
The common probles may result in the following errorous results. The incorrect results shown here could be caused by not checking for correct color saturation ranges before storing them back in arrays (not storing the temporary data in the large enough integer variables, not adjusting negative and to high positive color saturations), or by incorrect initialization of the result structure size (If you forget to set the size then you may receive an image of size 0 by 0). Other common errors include swapping width and height of the images (not shown here).
If your image looks like static noise on TV then verify if your computations did not result in the RGB values outside of the range 0 to max_c. Such values must be stored in a temporary signed integer variable tested against the range before storing them into the bitmap. Storing those directly into the bitmap results in the odometer roll over effect. This applies only to certain operations that involve number crunching rather than simple copying or averaging of values.