Consider a raster grid having ๐๐-axes in positive ๐-direction and positiveโฆ
2016
Consider a raster grid havingย ๐๐-axes in positiveย ๐-direction and positive upwardย ๐-direction withย ๐๐๐๐ฅย = 10,ย ๐๐๐๐ย = โ5,ย ๐๐๐๐ฅย = 11, andย ๐๐๐๐ย = 6. What is the address of memory pixel with locationย (5,4)ย in raster grid assuming base addressย 1ย (one) ?
- A.
150
- B.
151
- C.
No valid address
- D.
untime error due to an invalid coordinate
Attempted by 124 students.
Show answer & explanation
Correct answer: C
Conclusion: The coordinate (5,4) is outside the defined raster grid because Ymin = 6 and 4 < 6. Therefore there is no valid memory address within the given grid for (5,4).
Number of columns = Xmax - Xmin + 1 = 10 - (-5) + 1 = 16.
Number of rows = Ymax - Ymin + 1 = 11 - 6 + 1 = 6.
Using row-major ordering with the origin at (Xmin, Ymin) (i.e., rows counted upward) and base address = 1, the address formula is:
Address = base + (y - Ymin) * (number of columns) + (x - Xmin).
Apply to (5,4): y - Ymin = 4 - 6 = -2, which is outside the valid row index range (0 to 5). Hence the point is outside the grid and the formula does not produce a valid in-grid address.
Example for a valid point: for (5,6) (lowest valid row), address = 1 + (6 - 6)*16 + (5 - (-5)) = 1 + 0 + 10 = 11.
Recommendation: Verify the intended coordinates. If a different y-value within 6..11 was intended, use the formula above to compute the correct address.