CS203_HW8.docx

# Then the green and blue values will be equal to 0

• Homework Help
• 9

This preview shows page 4 - 6 out of 9 pages.

Then, the green and blue values will be equal to 0 before your demosaicing filter is executed. Then, you would need to assign the green and blue values based on the neighboring pixels. Your job is to calculate the values for the two colors that did not get accurately sensed as the camera took the picture for each pixel in the image. To perform the calculation, look at the surrounding adjacent pixel neighbors, find the ones that captured the color you are trying to calculate, and average these values. o Remember, color values go from 0 to 255. The values are integers. o Also, remember not to go out of bounds (off the array) in the 2-dimensional array of Pixel objects. o In the Pixel class, the getFilterColor() method returns the color that was captured at a pixel location. If p is a Pixel object, you may test if its accurate color is red by doing p.getFilterColor() == Pixel.RED . o The following image shows how to calculate the green and red values for a pixel whose accurate color value (color sensor used when taking picture) is blue. Below is a description of the code you should implement.

Subscribe to view the full document.

Description of digital camera filter algorithm: For each pixel p in image // for each row and column in the image Set green count, blue count, and red count to 0 Set green total, blue total, and red total to 0 For each of 8 possible direct neighbors If neighbor pixel has filter color of green Update green total by adding neighbor’s green value Add one to green count If neighbor pixel has filter color of blue Update blue total by adding neighbor’s blue value Add one to blue count If neighbor pixel has filter color of red Update red total by adding neighbor’s red value Add one to red count If pixel p’s filter color is red Set blue in p to (blue total / blue count) Set green in p to (green total / green count) Else if pixel p’s filter color is green Set blue in p to (blue total / blue count) Set red in p to (red total / red count) Else if pixel p’s filter color is blue Set red in p to (red total / red count) Set green in p to (green total / green count) // after going through the entire image, state that all pixels now have all colors For each pixel p in image Set filter color to ALL Hint : Be sure to check the neighbor pixel exists before accessing the position in the array. Otherwise, you will go off the end of the array. For example, if the pixel p is in the top row, then there are no neighbors
above it. So, you might have something like if(row > 0) {// get pixel at data[row-1] [col]}. PART B (1 point per filter below) 1. Write a class called Mirror that implements the Filter interface which mirrors the image across the vertical midline by reflecting the values on the left this midline to be the values on the right. The pixel values on the right-hand side of the image should be removed; instead, these values are found from the left-side of the image. See the FlipVerticallFilter class for an example of how to flip the picture vertically across the horizontal midline. Test your filter on an image after it has been demosaiced to be sure that it works as expected.
You've reached the end of this preview.
• Spring '14
• AndrewM.Nuxoll

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern