Wednesday, February 8, 2012

Drawing a chessboard from morphological dilation



A special Drawing a chessboard using morphological dilation to try different structuring elements and observe their influence on the starting dots (acting as seeds).


1- Algorithm

We plan to create a chessboard with 64 cells of 33x33 pixels size, each. For that purpose, a 264x624 8-bit image is created and only one point is drawn corresponding to the center of each cell as shown in Fig. 1A.
Finally, we dilate these 'seeds' until we get the squared cells building a chessboard.
According to the definition of a dilation [see post], we need a 33x33 square structuring element, unfortunately, this isn't possible in ImageJ. However, we can use a small square structuring element and apply many cycles of dilation. Thus, from a 3x3 square structuring element, we need 16 (= 33/2) cycles of dilation to yield a 33x33 cell.

Fig. 1: From the 'seeds' image, a dilation is performed iteratively (n cycles) from a given structuring element defined by its radius.

Now, what about the influence of structuring element?
Try with various structuring elements of increased radius (from 0.5 to 16) and adjust the number of cycles ...

Fig.2: Chessboards calculating with cross (radius=0.5), square 3x3, octagonal 5x5 (radius=2), and circular 33x33 (radius=16) structuring elements, respectively. The number of cycles was tuned accordingly.

2- How can I use a 33x33 square structuring element?

TODO

3- The script


+++ IJ snippet +++ +++ End of IJ snippet +++

No comments:

Post a Comment