Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in c++ r and c stand for rows and columns Determine the color of each pixel in the smaller images by averaging the appropriate 2
in c++
r and c stand for rows and columns
Determine the color of each pixel in the smaller images by averaging the appropriate 2 x 2 block of four pixels in the larger image. (Note that exceptions can occur at the boundaries. See below.) If the input and output both have their upper-left corner at (0,0), then the relationship between the images is usually: output(r, c) = (input(2r, 2c)+ input(2r+1, 2c) + input(2r, 2c+1) + input(2r+1, 2c+1))/4 Always round down (integer division is fine). For the flipped image, the relationship is similar. Again, assume the images have their upper-left corner at (0,0). Let maxR be one less than the number of rows in the input image and maxC be one less than the number of cols in the input image: output(r, c) = (input(maxR - 2r, maxC -2c) + input(maxR - 2r - 1, maxC - 2c) + input(maxR - 2r, maxC-2c-1) + input(maxR - 2r - 1, maxC - 2c-1))/4 If the image has an odd number of columns, then the subimages on the left should have one more column than the subimages on the right, so that the overall image size stays the same. Similarly, if the image has an odd number of rows, then the subimages on the top should have one more row than the subimages on the bottom. If the subimage is slightly larger than half the size of the input image, then the image boundaries will need to be handled slightly different. If any of the pixels in the formulas above are outside of the input image in these cases, then average only among the valid pixels. (For recursive calls, make sure that the averaging never crosses the boundary between quadrants.) Determine the color of each pixel in the smaller images by averaging the appropriate 2 x 2 block of four pixels in the larger image. (Note that exceptions can occur at the boundaries. See below.) If the input and output both have their upper-left corner at (0,0), then the relationship between the images is usually: output(r, c) = (input(2r, 2c)+ input(2r+1, 2c) + input(2r, 2c+1) + input(2r+1, 2c+1))/4 Always round down (integer division is fine). For the flipped image, the relationship is similar. Again, assume the images have their upper-left corner at (0,0). Let maxR be one less than the number of rows in the input image and maxC be one less than the number of cols in the input image: output(r, c) = (input(maxR - 2r, maxC -2c) + input(maxR - 2r - 1, maxC - 2c) + input(maxR - 2r, maxC-2c-1) + input(maxR - 2r - 1, maxC - 2c-1))/4 If the image has an odd number of columns, then the subimages on the left should have one more column than the subimages on the right, so that the overall image size stays the same. Similarly, if the image has an odd number of rows, then the subimages on the top should have one more row than the subimages on the bottom. If the subimage is slightly larger than half the size of the input image, then the image boundaries will need to be handled slightly different. If any of the pixels in the formulas above are outside of the input image in these cases, then average only among the valid pixels. (For recursive calls, make sure that the averaging never crosses the boundary between quadrants.)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started