The purpose of this lab is to convert an RGB image into a gray scale image. The input is an RGB triple of float values and the student will convert that triple to a single float grayscale intensity value. A pseudo-code version of the algorithm is shown bellow:
for ii from 0 to height do
for jj from 0 to width do
= ii * width + jj
idx # here channels is 3
= input[3*idx]
r = input[3*idx + 1]
g = input[3*idx + 2]
b [idx] = (0.21*r + 0.71*g + 0.07*b)
grayImageend
end
Before starting this lab, make sure that:
For people who are developing on their own system, the input image is
stored in PPM P6
format while the output grayscale image is
stored in PPM P5
format. Students can create their own
input images by exporting their image into PPM images. The easiest way
to create image is via external tools. On Unix, bmptoppm
converts BMP images to PPM images.
Edit the code in the code tab to perform the following:
Instructions about where to place each part of the code is demarcated
by the //@@
comment lines.
The most recent version of source code for this lab along with the build-scripts can be found on the Bitbucket repository. A description on how to use the CMake tool in along with how to build the labs for local development found in the README document in the root of the repository.
The executable generated as a result of compiling the lab can be run using the following command:
./ImageColorToGrayscale_Template -e <expected.pbm> \
-i <input.ppm> -o <output.pbm> -t image`.
where <expected.pbm>
is the expected output,
<input.ppm>
is the input dataset, and
<output.pbm>
is an optional path to store the
results. The datasets can be generated using the dataset generator built
as part of the compilation process.