Anne
Dawson: CSCI101A_FA_FA04.htm
Friday 29th October 2004, 11:28 PT, AHD
This document is subject to change without notice.
Please
report any errors or omissions in this document to:
adawson@coquitlamcollege.com
Special instructions: For
this assignment you may work in teams of 2, or alone.
This assignment is due at the start of the last class of the
semester (Week 13 Class 2).
Final
Assignment Specification
------------------------------
Introduction
------------
A digital image can be represented as a collection of small
square regions known as pixels -the word pixel is short for "picture
elements". In the case of a colour image, each pixel is represented by a
red, green and blue triple. Each number in the triple ranges from 0 to 255,
where 0 indicates that none of that primary colour is present in the pixel and
255 indicates that a maximum amount of that primary colour. This means that an
RGB of 0 0 0 represents a complete absence of colour (i.e. black) and 255 255
255 is the opposite (i.e. white). Other examples: 255 0 0 represents red, 0 255
0 represents green and 0 0 255 represents blue.
An image is made up of a grid of rectangular areas (pixels) of
the displaying medium (a computer screen, printed paper etc.), where each
rectangle has one colour represented by an RGB triple. The following grid
represents 9 pixels where the first pixel is white:
255 255 255 142 160 210 142 160 210
136 158 208 135 158 209 136 156 207
140 153 206 142 151 206 142 151 206
Image Files
Image files contain a map of the image as a collection of bits.
They are known as bit map files and have the file extension .bmp. There are
other types of graphic bit map files which can store the same image, but in
different compression formats (.jpg, .gif). The Unix (or Linux) utility xv
converts a bit map to the equivalent ASCII file. Hence the bit map 11111111 is converted to ASCII 255 which
is the decimal equivalent of binary 11111111.
The following is an example of a converted bit map image:
255 255 255 142 160 210 142 160 210
136 158 208 135 158 209 136 156 207
140 153 206 142 151 206 142 151 206
Image Processing
----------------
Changing the hue of an image:
It's possible to modify an image by manipulating the pixel
values. For instance, if you want to make the image more red, you would
increase the value of the red component of the RGB triple.
For example, a redder version of the image pattern above would
be this:
255 255 255 255 160 210 255 160 210
255 158 208 255 158 209 255 156 207
255 153 206 255 151 206 255 151 206
Smoothing the image:
The process known as smoothing results in a blurred version of
the original image:
Original image:

Smoothed image:

Smoothing is a process which replaces the value of every pixel
with an average value of the neighbouring pixels.
Example
A two-dimensional array of pixels represents our image. Each
pixel has three numeric values that represents the amount of red, green and
blue. To perform the smoothing process on the image, we will take an average of
the current pixel and the four adjacent pixels. This requires taking an average
of each of the three colours for each pixel.
Consider the following:
243 159 211 142 160 210 142 160 210
136 158 208 135 158 208 136 156 207
140 153 206 142 151 206 142 151 206
The current pixel has a red value of 135, a green
value of 158, and a blue value of 208.
The smoothed value for this pixel is calculated as follows:
red value -> (135 + 136 + 142 + 136 + 142)/5 = 138,
green value -> (158 + 158 + 151 + 156 + 160 )/5 = 156,
blue value -> (208 + 208 + 206 + 207 + 210)/5 = 207,
Notice that the West, South, East and North pixel value of the
current pixel are summed to the
current pixel value. For example, the pixels averaged to
calculate the red value are:
243 159 211 142 160 210 142 160 210
136 158 208 135
158 208 136 156 207
140 153 206 142 151 206 142 151 206
This process is repeated for every interior pixel in the
array (one which is surrounded on each side by pixels).
Program Specification:
Your program should read an ASCII graphics file, and provide the
options to smooth the image, and to make the image more red, green or blue. The
resulting image must be sent to an output file.
For maximum points, your program should work with a file
containing any size of 2 dimensional grid of RGB decimal triples.
You must store the RGB triple in a structure defined as follows:
struct pixel
{
unsigned
int red;
unsigned
int green;
unsigned
int blue;
}
and you must use a two-dimensional array of these structures in
your program.
This document is subject to change without notice.
Submission
instructions
-----------------------
At the
start of class (Week 13 Class 2) you should save just your source code file to
your folder in \Week13\FA.
If you
are working in a team, both team members save the same file to their own
folder.
Marking
Scheme
--------------
The
following marking scheme applies:
Course
Code:
CSCI101A
Semester: FA04
Assignment
Code: Final Assignment
Lab
Specification: Image Processing (img.cpp)
Instructor
Name: Dr Anne Dawson
Student
1 Name:
Student
1 Number:
Student
2 Name:
Student
2 Number:
DESIGN
1. The program has appropriate modularity
i.e.
functions are used where it
makes sense to
use them.
/10
2. Appropriate data types and control
structures
are used.
/10
3. The program is robust
(handles exceptional
circumstances).
/10
4. The program is efficient
(does not contain
unnecessary statements)
/10
MAINTAINABILITY
5. The program is commented appropriately
- including
date, filename and pre- and
post-condition
comments.
/10
6. The program has meaningful
identifiers.
/10
7. The program is indented (spaced out)
correctly, to
aid the understanding of
the code.
/10
8. The code is easy to follow.
/10
CORRECTNESS:
9. The program runs as intended (is
accurate). /10
10.
Comprehensive test data and results are supplied. /10
% Complete:
Bonus:
Total: /100
Date: