
Multidimensional String Matching M 559
4. Amir, A., Benson, G., Farach, M.: The truth, the whole truth,
and nothing but the truth: Alphabet independent two di-
mensional witness table construction.Technical Report GIT-
CC-92/52, Georgia Institute of Technology (1992)
5. Amir, A., Benson, G., Farach, M.: An alphabet independent ap-
proach to two dimensional pattern matching. SIAM J. Comput.
23(2), 313–323 (1994)
6. Amir, A., Benson, G., Farach, M.: Optimal two-dimensional com-
pressed matching. J. Algorithms 24(2), 354–379 (1997)
7. Amir, A., Benson, G., Farach, M.: Optimal parallel two dimen-
sional text searching on a crew pram. Inf. Comput. 144(1), 1–
17 (1998)
8. Amir, A., Landau, G., Sokol, D.: Inplace 2d matching in com-
pressed images. J. Algorithms 49(2), 240–261 (2003)
9. Amir, A., Landau, G., Sokol, D.: Inplace run-length 2d com-
pressed search. Theor. Comput. Sci. 290(3), 1361–1383 (2003)
10. Berman, P., Karpinski, M., Larmore, L., Plandowski, W., Rytter,
W.: On the complexity of pattern matching for highly com-
pressed two dimensional texts. Proceeding of 8th AnnualSym-
posium on Combinatorial Pattern Matching (CPM 97). LNCS,
vol. 1264, pp. 40–51. Springer, Berlin (1997)
11. Crochemore, M., Galil, Z., Gasieniec, L., Hariharan, R., Muthukr-
ishnan,S.,Park,K.,Ramesh,H.,Rytter,W.:Paralleltwo-dimen-
sional pattern matching. In: Proceeding of 34th Annual IEEE
FOCS, 1993, pp. 248–258
12. Galil, Z., Park, K.: Alphabet-independent two-dimensional wit-
ness computation. SIAM. J. Comput. 25(5), 907–935 (1996)
13. Hennessy, J.L., Patterson, D.A.: Computer Architeture: A Quan-
titative Approach, 2nd edn. Morgan Kaufmann, San Francisco,
CA (1996)
14. Klein, S.T., Shapira, D.: Compressed pattern matching in jpeg
images. In: Proceeding Prague Stringology conference, 2005,
pp. 125–134
15. Klein, S.T., Wiseman, Y.: Parallel huffman decoding with appli-
cations to jpeg files. Comput. J. 46(5), 487–497 (2003)
16. Park, K., Galil, Z.: Truly alphabet-independent two-dimen-
sional pattern matching. In: Proceeding 33rd IEEE FOCS, 1992,
pp. 247–256
17. Régnier, M., Rostami, L.: A unifying look at d-dimensional peri-
odicities and space coverings. In: 4th Symp. on Combinatorial
Pattern Matching, 15, 1993
18. Vishkin, U.: Optimal parallel pattern matching in strings. In:
Proceeding 12th ICALP, 1985, pp. 91–113
19. Welch, T.A.: A technique for high-performance data compres-
sion. IEEE Comput. 17, 8–19 (1984)
20. Ziv, J.: Personal communication (1995)
Multidimensional String Matching
1999; Kärkkäinen , Ukkonen
JUHA KÄRKKÄINEN,ESKO UKKONEN
Department of Computer Science, University of Helsinki,
Helsinki, Finland
Keywords and Synonyms
Multidimensional array matching; Image matching; Tem-
plate registration
Problem Definition
Given two two-dimensional arrays, the text T[1 ::: n;
1 ::: n]andthepattern P[1 ::: m; 1 ::: m], m n,both
with element values from alphabet ˙ of size ,theba-
sic two-dimensional string matching (2DSM) problem is to
find all occurrences of P in T,i.e.,allm m subarrays of
T that are identical to P. In addition to the basic prob-
lem, several types of generalizations are considered: ap-
proximate matching (allow local errors), invariant match-
ing (allow global transformations), indexed matching (pre-
process the text), and multidimensional matching.
In approximate matching, an occurrence is a subarray
S of the text, whose distance d(S, P) from the pattern does
not exceed a threshold k. Different distance measures lead
to different variants of the problem. When no distance is
explicitly mentioned, the Hamming distance,thenumber
of mismatching elements, is assumed.
For one-dimensional strings, the most common dis-
tance is the Levenshtein distance, the minimum num-
ber of insertions, deletions and substitutions for trans-
forming one string into the other. A simple generalization
to two dimensions is the Krithivasan–Sitalakshmi (KS)
distance, which is the sum of row-wise Levenshtein dis-
tances. Baeza-Yates and Navarro [6] introduced several
other generalizations, one of which, the RC distance,isde-
fined as follows. A two-dimensional array can be decom-
posed into a sequence of rows and columns by remov-
ing either the last row or the last column from the array
until nothing is left. Different decompositions are possi-
ble depending on whether a row or a column is removed
at each step. The RC distance is the minimum cost of
transforming a decomposition of one array into a decom-
position of the other, where the minimum is taken over
all possible decompositions as well as all possible trans-
formations. A transformation consists of insertions, dele-
tions and modifications of rows and columns. The cost
of inserting or deleting a row/column is the length of
the row/column, and the cost of modification is the Lev-
enshtein distance between the original and the modified
row/column.
The invariant matching problems search for occur-
rences that match the pattern after some global transfor-
mation of the pattern. In the scaling invariant matching
problem, an occurrence is a subarray that matches the pat-
tern scaled by some factor. If only integral scaling fac-
tors are allowed, the definition of the problem is obvi-
ous. For real-valued scaling, a refined model is needed,
where the text and pattern elements, called pixels in this
case, are unit squares on a plane. Scaling the pattern means
stretching the pixels. An occurrence is a matching M be-