Twodimensional pattern matching - PowerPoint PPT Presentation

1 / 24
About This Presentation
Title:

Twodimensional pattern matching

Description:

Simply check for each position in the text whether there is a match there ... existing pattern matching toolkits (SPARE Time / SPARE Parts) or create a new ... – PowerPoint PPT presentation

Number of Views:132
Avg rating:3.0/5.0
Slides: 25
Provided by: mgwhvan
Category:

less

Transcript and Presenter's Notes

Title: Twodimensional pattern matching


1
Two-dimensional pattern matching
M.G.W.H. van de Rijdt
23 August 2005
2
Introduction
  • Problem description
  • Naive algorithm
  • Filter-based algorithms
  • A simple filter function
  • Takaoka-Zhu
  • Baker-Bird
  • Baeza-Yates RĂ©gnier
  • Polcar
  • Conclusions
  • Future work
  • Questions

3
Problem description
  • One-dimensional pattern matching finding all
    occurrences of a pattern string in a text string
  • Two-dimensional pattern matching finding all
    occurrences of a 2D pattern matrix in a 2D text
    matrix
  • Applications image processing, ...

4
Naive algorithm
  • Simply check for each position in the text
    whether there is a match there
  • Most straightforward, but inefficient, solution
  • Better algorithms
  • use gathered information to disregard a larger
    area of the text at onces
  • and/or
  • precompute information to determine more quickly
    whether a match exists on a position in the text

5
Filter-based algorithms (0)
  • Define a filter function, which transforms each
    row of the pattern matrix to a single value
  • Using this function, reduce the pattern matrix to
    a single (column) vector

6
Filter-based algorithms (1)
  • Apply the filter function to partial rows of the
    text matrix
  • There can only be an occurrence where the
    patterns column vector occurs in the reduced
    text
  • Use 1D pattern matching to find those occurrences

7
Filter-based algorithms a simple filter function
  • A simple example of a filter function f(x)
    x0
  • Pattern
  • Text

8
Filter-based algorithms Takaoka-Zhu
  • Filter function hash function from the (1D)
    Karp-Rabin algorithm

9
Filter-based algorithms Baker-Bird (0)
  • Based on Aho-Corasick automaton
  • Aho-Corasick is an algorithm for (1D)
    multipattern matching
  • It uses a special automaton, based on the pattern
    strings
  • Filter function for Baker-Bird state in the
    Aho-Corasick automaton, based on the patterns
    rows

10
Filter-based algorithms Baker-Bird (1)
  • Pattern
  • Trie based on pattern rows aaa, bab

a
a
q1
q2
q3
a
q0
b
a
b
q4
q5
q6
11
Filter-based algorithms Baker-Bird (2)
  • Pattern
  • Aho-Corasick automaton based on pattern rows
    aaa, bab

a
a
q1
q2
q3
a
b
b
a
b
q0
a
b
a
b
q4
q5
q6
a
b
b
b
12
Filter-based algorithms Baker-Bird (3)
  • Pattern
  • Text

13
Baeza-Yates RĂ©gnier (0)
  • Say our pattern has m rows
  • In the text, each occurrence of the pattern
    intersects with exactly one row of the form i m
    1

14
Baeza-Yates RĂ©gnier (1)
  • Algorithm idea
  • use 1D multipattern matching to search for
    occurrences of any pattern row in these rows of
    the text
  • where such a match occurs, check if there is a
    match with the entire pattern in the surrounding
    area

15
Polcar (0)
  • In some 1D pattern matching algorithms, we view
    an occurrence of the pattern as a suffix of a
    prefix of the text
  • For Polcar, we do the same in two dimensions

16
Polcar (1)
  • For each prefix of the text A, we compute the set
    of suffixes of A that are also a prefix of the
    pattern

17
Polcar (1)
  • For each prefix of the text A, we compute the set
    of suffixes of A that are also a prefix of the
    pattern

18
Polcar (1)
  • For each prefix of the text A, we compute the set
    of suffixes of A that are also a prefix of the
    pattern

19
Polcar (1)
  • For each prefix of the text A, we compute the set
    of suffixes of A that are also a prefix of the
    pattern

20
Polcar (2)
  • In derivations of the corresponding 1D pattern
    matching algorithms, sets of prefixes of the
    pattern are represented by their element of
    maximum length
  • In 2D there is not always one unique maximum
  • But these sets of matrices can be represented by
    their maximal elements

21
Conclusions
  • Presentation of several 2D pattern matching
    algorithms
  • All of them have been formally derived
  • derivation is a formal proof
  • derivations show the major design decisions
  • Similarities between the filter-based algorithms
  • Several improvements to existing algorithms
  • most notably in Polcars algorithm, sets of
    matrices can be represented by their maximal
    elements

22
Future work
  • Derive other existing algorithms
  • Construct a taxonomy
  • Find new algorithms
  • Expand existing pattern matching toolkits (SPARE
    Time / SPARE Parts) or create a new 2D pattern
    matching toolkit
  • Thorough performance analysis
  • Further generalisations of the 2D pattern
    matching problem
  • Multipattern matching
  • More than two dimensions
  • Approximate 2D pattern matching
  • Patterns of non-rectangular shapes
  • ...

23
Questions
24
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com