Assignment 2 3134
Assignment 2 3134
Overview
Part A: Goal is to get comfortable with the image format used for the course,
along with using this website as a “viewer”. You will stack the output produced by
the camera sensor into a grid, and assign each value a color by referencing the
bayer color filter pattern and the location of the intensity value in the grid.
Part B: Goal is to perform simple demosaicing and combine 4 neighboring
intensity values of their respective color into one RGB color; and do the same for
all pixels.
Part C: Goal is to perform a slightly more complicated demosaicing algorithm,
that involves a “sliding window”. You will notice how depending on the choice of
demosaicing algorithm the resolution of the image we produce differs.
Note that you are not to use any library outside of what is available by default in
the programming language you choose.
More details
Just like before there are 3 text files for you, you won’t have to change any code
or redo any work for each except for change the width and the height numbers.
You just have to run your code for each text file.
You will be given a list of intensity values, just like before; but this time instead of
representing raw data produced by each photodiode, each intensity value that is
scaled up to 0-255 to match 8-bit color.
For the previous assignment, the we treated each value, equally, without think
about color.
This time around, we will assume that each photodiode has a color filter installed
in front of it. You can figure out which color filter it is by consulting the bayer
color filter array pattern. There are multiple GIFs on this page that also serve as a
reference for the bayer pattern.
The _easy and the _medium images are meant to by 256 by 256 pixels.
According to the Bayer pattern, 4 photodiodes combine to produce a single color
pixel. Meaning you are supplied with 256 * 256 * 4 values.
Output Format
As an “output” for each Part of the assignment, you will be creating a text file
using the program you write. Each part is going to ask of you to create an image,
and each image will be in this following format ––
o The first line in the file will be RGB to represent that the image uses the
RGB colorspace. RGB will be followed by a newline \n, so - RGB\n.
o The second line will be a number representing the height of the image in
pixels, so 256\n for an image consisting of 256 pixels.
o The third line in the image would be the width of the image in pixels,
so 512\n for a 512 pixel wide image.
o From the fourth line onwards you will have the RGB color for each pixel,
so 144 72 44\n for the color rgb(144, 72, 44). You will have as many
lines as pixels in your image.
You can use the “Viewer” section of this website to look at these images.
Submission Format
You will submit as a zip ––
Part A
Part A is worth 50 points.
-The first task is simply to convert the list of intensity values given to the above image
format, take a screenshot of the images using the supplied binary, and attach both the
image text files and the screenshots and submit.
You are to also describe, briefly, what you see in the image and why you think it
looks the way it does.
Last time around you were given a list of voltage values, which you stacked
(either to make a CSV file, ASCII art, or something else), like so
-
Your task is to first stack the intensity values in a grid, so that you can use the
bayer pattern to figure out which value pertains to which color.
Once you’ve done that, you’ll turn each value into an RGB color. For instance,
the 83 when meant for a red color turns into 83 0 0; for a green color turns into 0
83 0 and for a blue color turns into 0 0 83.
Once you’ve figured out the RGB value for each intensity value, write it out to an
output file in the format mentioned above.
An example
Assume a 2 by 2 pixel image.
The sensor would have 4 by 4 photodiodes, producing 4 * 4 intensity values.
Let’s say those values are - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16]
You stack them in a grid to produce ––
[
[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12],
[13, 14, 15, 16]
]
Once you’ve done that, you can use the bayer pattern to realise that 1 is the
intensity for the color blue, 2 is for green, 3 is for blue again, and 4 is for green
again. For the next row, the patten tells us that 5 belongs to green, 6 belongs to
red, so on and so forth.
This would produce the following file, according to the format described above––
RGB
4
4
0 0 1
0 2 0
0 0 3
0 4 0
0 5 0
6 0 0
0 7 0
8 0 0
0 0 9
0 10 0
0 0 11
0 12 0
0 13 0
14 0 0
0 15 0
16 0 0
We used 4 pixels as the height for the image, and 4 pixels as the width, because
we’re not combining the individual intensities into color yet, so
a 4 by 4 photodiode grid produces a 4 by 4 image. When we do part B, we’ll
actually combine the intensities, and we’ll produce a 2 by 2 image instead.
Do make sure the resolution you enter in the file properly corresponds to the number of
pixels in the output image
Part B
Part B is worth 50 points
The second part is where you will actually perform the demosaicing, basically, this
––
You will be “combining” the intensity for 4 photodiodes into 1 by doing this ––
Again, take a screenshot of the image using the Viewer, and attach both the
image file and the screenshot and submit.
Do make sure the resolution you enter in the file properly corresponds to the number of
pixels in the output image
Part C
Part C is worth 50 points
This time around you will be doing this instead ––
This is a little tricky, and you’ll have to spend some time thinking about how the
colors are being combined and planning how you write the algorithm.
Again, take a screenshot of the image using the Viewer, and attach both the
image file and the screenshot and submit.
Do make sure the resolution you enter in the file properly corresponds to the number of
pixels in the output image