In this version, I create an 8x8 image with a black background and assign the white color by scanning this image in ONE loop. Indeed, there is 64 cells in the chessboard and they can be numbered from 0 (the top left cell) to 63 (the bottom right). The question is now: How can we extract the XY-coordinates from these indexes?
In the following figure, on the left, the chessboard contains the cell indexes. For example, the cell # 13 has XY-coordinates (5,1).
And to extract the coordinates,
- X is calculated from the remainder after division by the image width.
- Y is the result of the integer division of the cell index by the image width.
Here is the final code...
+++ IJ snippet: chessboard_v2_1_imagej.ijm +++
+++ End of IJ snippet +++
No comments:
Post a Comment