Professional Documents
Culture Documents
HujanenWaltz SPIEConfMachVisionAppIndInspec1995 PipelinedImplementation
HujanenWaltz SPIEConfMachVisionAppIndInspec1995 PipelinedImplementation
HujanenWaltz SPIEConfMachVisionAppIndInspec1995 PipelinedImplementation
1995
Revised and republished January 1998. Copyright Jan. 1998 by F. M. Waltz & A. A. Hujanen. Duplication by permission only.
Pipelined implementation of binary skeletonization using finite-state machines, SPIE Paper 2423-2 Hujanen & Waltz SK8-1
SPIE Conf. on Machine Vision Applications in Industrial Inspection Originally published San Jose, Feb. 1995
Revised and republished January 1998. Copyright Jan. 1998 by F. M. Waltz & A. A. Hujanen. Duplication by permission only.
other non-convex shapes can be applied in a single pipelined pass. In Out In Out
• Multiple SEs can be applied simultaneously in a single pipelined pass. For Row Column
example, six or more stages of the “Grassfire Transform” have been carried out CS Machine NS CS Machine NS
in one pass, and even larger numbers of stages are possible.
• Grey-level morphology, if the number of grey levels is not too large.
• Various “smearing” operations, including row, column, and diagonal
Pixel Delay Line Delay
summations and Hough transforms.
• Certain operations previously thought to be impossible in a pipelined system,
In Out In Out
such as “blob fill” and “patterned blob fill.”
• The subject of this paper — Binary skeletonization with one pipelined pass per Column Row
erosion stage, using a 4 pixel-by-4 pixel neighborhood to prevent the breaking CS Machine NS CS Machine NS
of connectivity (and hence failure of the algorithm) that occurs with algorithms
attempting to use a single pass per stage with a 3-by-3 neighborhood.
Figure 1 shows two versions of the general SKIPSM block diagram, applicable to Line Delay Pixel Delay
both hardware and software implementations. It is also possible to use
configurations operating along the diagonals of the image. For the remainder of Figure 1. Two versions of the basic SKIPSM
this paper, detailed discussion will be limited to the first configuration shown in architecture for a row-by-row raster scan pattern.
Figure 1, which is based on a row-by-row raster-scan input sequence. The other configurations can be handled in an analogous
manner. Binary skeletonization and all the other operations noted above can be implemented using this same hardware configuration,
some variations of which are shown in Figure 2. Note that this approach also offers great advantages for software implementations.
Row Machine Column Machine Row Machine Column Machine
Rule Rule R R
Input Row Output Input A Row A Output
Circuit Values Circuit Values
M M
Delay Delay
(a) Rule-based configuration. (b) Minimum RAM-based configuration.
Pipelined implementation of binary skeletonization using finite-state machines, SPIE Paper 2423-2 Hujanen & Waltz SK8-2
SPIE Conf. on Machine Vision Applications in Industrial Inspection Originally published San Jose, Feb. 1995
Revised and republished January 1998. Copyright Jan. 1998 by F. M. Waltz & A. A. Hujanen. Duplication by permission only.
Pipelined implementation of binary skeletonization using finite-state machines, SPIE Paper 2423-2 Hujanen & Waltz SK8-3
SPIE Conf. on Machine Vision Applications in Industrial Inspection Originally published San Jose, Feb. 1995
Revised and republished January 1998. Copyright Jan. 1998 by F. M. Waltz & A. A. Hujanen. Duplication by permission only.
Base Address
Current State Input Next State Output
raw Output Values LUT LUT LUT
Offset from
Next State
pressed
weights: 1 2 4 weights: 1 2 4 weights: 1 2 4 8 Option 1 Option 2 Option 3
Output
weights
stacked: stacked:
0 000 0 0000 0 0 1 2 4 8
output state packed:
000 0 1 001 4 0001 8 5 0,1 0 = hi bits = hi bits 10S+O
0 000 0 1000 1 0 2,3 1 0 0 0 0 0 0
100 1 1 001 4 1001 9 5 1 4 5 44 69 45
4,5 2
0 100 1 0100 2 1 2 0 0 0 0 0
010 2 6 3 3 4 5 44 69 45
1 101 5 0101 10 6
7 4 4 1 1 9 17 11
0 100 1 1100 3 1 5 5 6 53 86 56
110 3 1 101 5 1101 11 6 8,9 5
6 1 1 9 17 11
0 010 2 0010 4 2 10,11 6 7 5 6 53 86 56
001 4 1 011 6 0011 12 7 12,13 7 8 2 2 18 34 22
0 010 2 1010 5 2 14 8 9 6 7 62 103 67
101 5 1 011 6 1011 13 7 10 2 2 18 34 22
15 9 11 6 7 62 103 67
0 110 3 0110 6 3 12 3 3 27 51 33
011 6 1 111 7 0111 14 8
raw values 13 7 8 71 120 78
0 110 3 1110 7 4 14 3 4 35 52 34
111 7 1 111 7 1111 15 9
compressed values
15 7 9 79 121 79
Figure 7. State transition and output tables for the row machine.
The table was generated by identifying the next state and output value for all possible current state values and input values. For a
given input value and state value, the next state is found simply by discarding the “oldest” pixel value and appending the input pixel
value. The output value is found simply by appending the input pixel to the binary state.
A graphical diagram of the row machine is shown in Figure 8. Each box in the diagram represents a state. The box contains state
number and corresponding pixel pattern. The connecting lines represent the transitions between states. The values accompanying each
transition are the input pixel value causing the transition and resulting output value of the row machine.
0/0 1/9
0 1/5 4 1/7 6 1/8 7
000 001 011 111
0/1
Figure 8. State transition diagram for the row machine. Only eight states are required.
Assuming that, to reduce hardware cost, a single lookup table (LUT) is to be used to contain both next-state and output information,
the numbers actually loaded into the LUT can be obtained in various ways. Three possibilities are shown in Figure 7. The first is
obtained by assigning the state values to the lowest three bits (weight = 1) and the output values to the next four higher bits (weight =
8), giving a range of 0-to-79 (decimal) and a 7-bit overall LUT word length. This is called “stacking.” The values can also be stacked
Pipelined implementation of binary skeletonization using finite-state machines, SPIE Paper 2423-2 Hujanen & Waltz SK8-4
SPIE Conf. on Machine Vision Applications in Industrial Inspection Originally published San Jose, Feb. 1995
Revised and republished January 1998. Copyright Jan. 1998 by F. M. Waltz & A. A. Hujanen. Duplication by permission only.
in the opposite order, as in Option 2, giving a range of 0-to-121 but the same 7-bit overall LUT word length. Option 3 shows the
values being “packed” without regard to bit boundaries, again giving a range of 0-to-79 and a 7-bit overall LUT word length.
“Packing” can sometimes reduce the overall LUT word length, but requires the column machine to do additional decoding steps, and
is therefore usually avoided. The choice depends on the hardware configuration of the column machine. The standard SKIPSM
architecture uses stacking, with the highest bits as output bits, as in Option 1.
5. THE COLUMN MACHINE
In Section 4, we developed a finite state machine to uniquely identify each of the four pixel patterns present in the skeletonization
templates. However, we must be able to identify when we get four rows matching one of the templates. To perform this operation, we
will build a second finite state machine. This is the column machine.
We know the column machine must produce a black pixel whenever pixel C3 (as labeled in Figure 4) is black. That is, if pixel C3 is
black it remains black. Additionally, if the neighborhood matches one of the templates, the output should be a black pixel. Otherwise,
the column machine should produce a white pixel. This is as prescribed by the Floeder algorithm.
To uniquely identify a neighborhood pattern, we simply concatenate the row machine A B C D Row Machine
output values. This becomes the state value. This is the same procedure we followed for Output
1 7
the row machine, but instead of binary pixel values, we have the row values provided by
the row machine. For example, if we have the pixel pattern shown in Figure 9. The row 2 0 State = 702
machine would produce the values 7, 0, 2 and 4 for the rows in this pattern. The first 3 2
three values are concatenated to produce the column machine state. The last value is the
column machine input. This pixel pattern would drive the column machine to state 702. 4 4 Input = 4
Then, with the input from the fourth row, the machine would move to state 24. Since the
pattern 7, 0, 2, 4 matches template 1, the output for the transition from 702 to 024 is 0. Figure 9. Column encoding for a particular
(See Figure 5.) pixel pattern.
Note that, as with the row machine, the next state is generated simply by discarding the "oldest" row machine value and appending the
input row value. Using this method we can generate a LUT for the column machine consisting of 1,000 entries. Figure 9 shows the
form and a few of the entries of the state transition table for this (“uncompressed”) column machine.
Notice, however, that the top row of the templates only use six of the 10 possible row values. Therefore, we can reduce the table to
600 state values (6,000 lines) by translating the most significant (“oldest”) value through a compression LUT. (See Figure 10.) It
should be noted that while translating adds some preliminary work in generating the column machine LUT, it adds no additional
complexity or execution time to the implementation. This compression is embedded in the final finite state machine.
Current State Input Next State Output Input Output
000 0 000 0 0 0
000 1 001 0 1 0
000 2 002 0 2 1
000 3 003 0 3 2
000 4 004 0 4 2
… … … … 5 0
702 4 024 0 6 3
… … … … 7 4
999 8 998 1 8 5
999 9 999 1 9 5
Figure 9. Uncompressed column machine LUT. Figure 10. Compression LUT.
There is one more consideration when producing the column machine LUT. When pixel C3 is black, the output should be a black
pixel. Thus any state in the column machine ending in 0, 1, 5 or 6 should have an output value of 0.
6. FURTHER COMMENTS
Figure 11 shows the minimum hardware required to realize the skeletonization implementation presented here. Notice that it requires
only 180,336 bits of memory. This is over 65 percent less memory than is required by Floeder's original implementation.
Of course, these results can be implemented in many other forms. Of particular interest to software-based systems is the fact that, at
the cost of a modest amount of RAM devoted to two lookup tables, each pass of the skeletonization operation is reduced to a few
Pipelined implementation of binary skeletonization using finite-state machines, SPIE Paper 2423-2 Hujanen & Waltz SK8-5
SPIE Conf. on Machine Vision Applications in Industrial Inspection Originally published San Jose, Feb. 1995
Revised and republished January 1998. Copyright Jan. 1998 by F. M. Waltz & A. A. Hujanen. Duplication by permission only.
steps: fetching the next input value, two bit concatenation or mask-and-add 4x7 14x11
steps to generate the LUT addresses, two fetches from fast RAM, and an output RAM RAM
Input Output
operation. Figures 12 and 13 show the results of applying our software 112 176
implementation of the algorithm to two images: one very simple and the other bits KBits
very complex. 10
Delay
Lines are 1 bit except as noted.
Figure 11. The minimized hardware version of the
architecture needed for binary skeletonization.
Figure 12. Skeletonized image of a simple object: (a) Source image (b) Skeletonized image
Figure 13. Skeletonized magnetic resonance image (a) Source image (b) Skeletonized image
Pipelined implementation of binary skeletonization using finite-state machines, SPIE Paper 2423-2 Hujanen & Waltz SK8-6
SPIE Conf. on Machine Vision Applications in Industrial Inspection Originally published San Jose, Feb. 1995
Revised and republished January 1998. Copyright Jan. 1998 by F. M. Waltz & A. A. Hujanen. Duplication by permission only.
7. CONCLUSIONS
In this paper, we have demonstrated the application of the SKIPSM method to binary skeletonization. The SKIPSM implementation
yields a 65 percent memory savings over the "direct" implementation while producing the same skeleton. Additionally, the
skeletonization operation offers all the advantages of the SKIPSM method, which include a pipelined implementation, a standard
inexpensive flexible hardware realization, and an efficient software implementation. Furthermore, this exact same hardware
configuration can be programmed to perform hundreds of other image processing operations, simply by loading different lookup
tables.
8. ACKNOWLEDGMENT
We hereby express appreciation to Steven P. Floeder, Engineering Systems & Technology Labs, 3M Company, Saint Paul, Minnesota,
for the excellent work20 on skeletonization which was incorporated into this paper and which made this implementation possible.
9. REFERENCES
1. F. M. Waltz, “SKIPSM: separated-kernel image processing using finite-state machines,” Paper No. 36, Proc. SPIE Conf. on
Machine Vision Applications, Architectures, and Systems Integration III, Vol. 2347, Boston, Nov. 1994
2. F. M. Waltz and H. H. Garnaoui, “Application of SKIPSM to binary morphology,” Paper No. 37, Proc. SPIE Conf. on Machine
Vision Applications, Architectures, and Systems Integration III, Vol. 2347, Boston, Nov. 1994
3. F. M. Waltz and H. H. Garnaoui, “Fast computation of the Grassfire Transform using SKIPSM,” Paper No. 38, Proc. SPIE Conf.
on Machine Vision Applications, Architectures, and Systems Integration III, Vol. 2347, Boston, Nov. 1994
4. F. M. Waltz, “Application of SKIPSM to binary template matching,” Paper No. 39, Proc. SPIE Conf. on Machine Vision
Applications, Architectures, and Systems Integration III, Vol. 2347, Boston, Nov. 1994
5. F. M. Waltz, “Application of SKIPSM to grey-level morphology,” Paper No. 40, Proc. SPIE Conf. on Machine Vision
Applications, Architectures, and Systems Integration III, Vol. 2347, Boston, Nov. 1994
6. F. M. Waltz, “Application of SKIPSM to the pipelining of certain global image processing operations,” Paper No. 41, Proc. SPIE
Conf. on Machine Vision Applications, Architectures, and Systems Integration III, Vol. 2347, Boston, Nov. 1994
7. Rozenfield, A., "Connectivity in Digital Pictures," Journal of the ACM, vol. 17, no. 1, pp. 153-155, January 1970.
8. Beun, M., "A Flexible Method for Automatic Reading of Hand-Written Numerals," Phillips Tech. Rev., vol. 31, no. 4, pp. 89-
101, 130-137, 1973.
9. Gudsen, A., "A Quantitative Analysis of Preprocessing Techniques for the Recognition of Hand-Printed Characters," Pattern
Recognition, vol. 8, pp. 219-227, 1976.
10. Moayer, B., Fu, K. S., "A Tree System Approach for Fingerprint Pattern Recognition," IEEE Trans. Comput., vol. C-25, pp. 262-
275, 1976.
11. Tamura, H., "A Comparison of Line Thinning Algorithms from Digital Geometry Viewpoint.", Proc. 4th Int. Joint Conf. on
Pattern Recognition, pp. 715-719, 1978.
12. Hilditch, C. J., "Linear Skeletons from Square Cupboards," Machine Intelligence, vol. 4, pp. 403-420, 1969.
13. Lee, D. T., "Medial Axis Transformation of Planar Shape," IEEE Trans. on Pattern Anal. and Mach. Intel., vol. PAMI-4, no. 4,
pp. 363-369, July 1982.
14. Naccache, N. J., Shinghal, R., STPA: "A Proposed Algorithm for Thinning Binary Patterns," IEEE Trans. Syst. Man. Cybernt.,
vol. 14, no. 3, p. 409, June 1984.
15. Zhang, T. Y., Suen, C. Y., "A Fast Parallel Algorithm for Thinning Digital Patterns," Communications of the ACM, vol. 27, no.
3., pp. 236-239, March 1984.16.
16. Holt, C., "An Improved Parallel Thinning Algorithm," Communications of the ACM, vol. 30, no. 0.2, pp. 156-160, February
1987.
17. Suzuki, S., Abe, K., "Binary Picture Thinning by an Interative Parallel Two-Subcycle Operation," Pattern Recognition, vol. 20,
no. 3, pp. 297-307, 1987.
18. Chin, Roland T., and Iverson, Rolf, “Automated Visual Inspection of Printed Wiring Boards: A Critical Overview,” in Machine
Vision Systems Integration, SPIE Critical Reviews of Optical Science & Technology, Volume CR36, Boston, Nov. 1990. This
paper includes a list of 45 references, many of which pertain to skeletonization.
19. Chin, Roland T. et al., U. S. Patent No. 494930. This patent describes hardware implementations for printed wiring inspection,
inclusing skeletonization.
20. S. P. Floeder, “A reprogrammable image processing system”, M. S. Thesis, Electrical Engineering Department, University of
Minnesota, Minneapolis, 1990
Pipelined implementation of binary skeletonization using finite-state machines, SPIE Paper 2423-2 Hujanen & Waltz SK8-7