Wednesday, May 23, 2012

Drawing a chessboard using Stack Tools




A really non optimized way for Drawing a Chessboard but a good opportunity to explore the functions available in Image > Stacks, specially those located in the submenu Stacks > Tools.

In this algorithm, we use three functions available in Image > Stacks. They are:

  • Image > Stacks > Images to Stack
  • Image > Stacks > Tools > Concatenate... In this function, the two stacks can be the same. You don't need the duplication of the original stack.
  • Image > Stacks > Tools > Reverse
 Fig.1: Steps to create the chessboard from two black and white cells


The algorithm described in the scheme of Fig. 1 is the following:
  1. Create two cells: one in black and the other in white with newImage(...).
  2. Create a 2-slices stack.
  3. Concatenate two 2-slices stacks.
  4. Concatenate two 4-slices stacks to create a 8-slices stack: yes ! you get your first row.
  5. Duplicate the row and reverse the order of the cells.
  6. Then, concatenate the first two rows of the chessboard (16-slices stack).
  7. Finally, proceed by successive concatenation to get a 32-slices stack and the 64-slices stack. 
  8. To see the chessboard, compute a montage of 8 rows per 8 columns. Et voilĂ .
Here is the script
+++ IJ snippet +++ +++ End of IJ snippet +++

These functions are really useful to edit small videos loaded as stacks (maybe the subject of a post).

No comments:

Post a Comment