Suppose we have a 5 x 5 image.The pixels in the top row are numbered 0 through 4 left to right,the ones in the second row from the to are numbered 5 through 9 left to right, and so on. Suppose there is a 'T' in the middle. The horizontal bar is in the middle of the second row, and 3 pixels wide. The vertical bar is in the middle of the third column and is also 3 pixels wide. Only pixels of the 'T' are black, rest are white.
Q1. Suppose we flatten the image into an array(let's call it A, and it is indexed from 0) such that pixel number i goes into the array at index i. What is the index of a pixel in column a and row b? (Note that first row has a=0 and first column has b=0)
 5 * j + i
 5 * j * i
 5 * i + j
 5 * i + 5 * j
Q2. Which of the indices in the array correspond to black pixels ?
 3
 8
 11
 13
Q3. What is the total number of white pixels?
For the pixel at index i in the array, what are the corresponding row and column number (first row has row number 0, and second row has 1)?
Note:Â floor(x) is the largest integer that is less than or equal to x. ceil(x) is the smallest
integer that is greater than or equal to x.
 floor(i/5), i%5
 i%5, floor(i/5)
 ceil(i/5), i%5
 floor(i/5)+1, i%5
Q1) "5j+i"
Q2) 8
Q3) 19
floor(i/5), i%5
Comments
Leave a comment