JPH0273478A - Retrieving method for plural 2-dimensional patterns - Google Patents

Retrieving method for plural 2-dimensional patterns

Info

Publication number
JPH0273478A
JPH0273478A JP63224796A JP22479688A JPH0273478A JP H0273478 A JPH0273478 A JP H0273478A JP 63224796 A JP63224796 A JP 63224796A JP 22479688 A JP22479688 A JP 22479688A JP H0273478 A JPH0273478 A JP H0273478A
Authority
JP
Japan
Prior art keywords
pattern
row
column
patterns
state
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
JP63224796A
Other languages
Japanese (ja)
Other versions
JP2783812B2 (en
Inventor
Noriyoshi Uratani
則好 浦谷
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Japan Broadcasting Corp
Original Assignee
Nippon Hoso Kyokai NHK
Japan Broadcasting Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nippon Hoso Kyokai NHK, Japan Broadcasting Corp filed Critical Nippon Hoso Kyokai NHK
Priority to JP63224796A priority Critical patent/JP2783812B2/en
Publication of JPH0273478A publication Critical patent/JPH0273478A/en
Application granted granted Critical
Publication of JP2783812B2 publication Critical patent/JP2783812B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Abstract

PURPOSE:To simultaneously retrieve plural 2-dimensional patterns with high efficiency by providing the state setting circuits for row and column patterns, etc., respectively, decomposing a gathering of input patterns in the row and column directions and replacing them with the state transition. CONSTITUTION:A row pattern state setting circuit 8 decides a row pattern symbol from an input gathering of patterns and at the same time sets the state transition method of a row pattern state deciding circuit 2. While a column pattern state setting circuit 9 sets the state transition method of a column pattern state deciding circuit 3 based on the row pattern symbol of the output of the circuit 8. Then a gathering of 2-dimensional patterns to be retrieved is received and decomposed into the row and column directions via the circuit 8 and a column direction pointer deciding circuit 7. These decomposed pattern gatherings are replaced with the state transition via the circuits 2 and 3, and the shift value of a pointer is previously calculated for a case where the collation of patterns fails. Thus the elements are collated with each other from the right to the left and from the bottom to the top. As a result, plural 2-dimensional patterns can be simultaneously retrieved with high efficiency.

Description

【発明の詳細な説明】 (産業上の利用分野) 本発明は、例えばコード化された画像中から複数のコー
ド化された2次元パターンを同時に検索する方法に関す
るものである。
DETAILED DESCRIPTION OF THE INVENTION (Field of Industrial Application) The present invention relates to a method for simultaneously searching for a plurality of coded two-dimensional patterns, for example, in a coded image.

(発明の概要) この発明は、2次元に配列されたデータ中から複数の2
次元パターンをデータの左上端から右下へ向けて検索す
る方法において、 検索すべき複数の2次元パターンを右下端でそろえ、下
端の行の右端から左方へ対応するデータと照合する方法
をとり、途中で照合に失敗した場合には、その状態から
次に探すべきパターンの候補を判断し、これに基づき検
索対象を切替えることにより、 パターンの照合回数を減じ、同時に複数の2次元パター
ンを短時間で検索できるようにしたものである。
(Summary of the Invention) The present invention provides a method for obtaining a plurality of data from two-dimensionally arranged data.
In the method of searching for dimensional patterns from the upper left corner of the data to the lower right corner, we align the multiple 2-dimensional patterns to be searched at the lower right corner and match them with the corresponding data from the right edge of the bottom row to the left. If matching fails midway through, the next pattern candidate to be searched is determined based on the situation, and the search target is switched based on this, thereby reducing the number of pattern matchings and shortening multiple 2D patterns at the same time. It allows you to search by time.

(従来の技術) この種技術は、例えばデータとしてコード化された画像
を考え、パターンとして別のコード化された画像を考え
た時、データがパターンをその一部分として含むか否か
を判定し、含むならば、その位置を検出することである
(Prior Art) This type of technology, for example, considers an image encoded as data and another encoded image as a pattern, and determines whether or not the data includes the pattern as a part thereof. If so, its position should be detected.

2次元パターンを効率よく検索する方法としてはBir
d (バード)の方法、例えば文献R,S、Bird’
Two Dimensional Pattern M
atching」Information Proce
ssing LettersIVOL、6+Nα5+ 
0ctober1977、 pp、168−170が知
られている。これは1次元パターンの検索で有名なAh
o−Corasick (エイホ・コラシック)法を2
次元パターンに拡張した方法である。これは検索したい
2次元パターンを行方向に分割し、これを行パターンと
し、それぞれを1つのコードで表わし、それを列方向に
並べたものを列パターンとして、行パターン、列パター
ンそれぞれに一種の有限オートマトンを作成し、それを
2次元データ上で左から右、上から下へ1回走査させて
パターンの出現位置をことごとく検出する方法である。
Bir is an efficient way to search for 2D patterns.
d (Bird) method, such as the literature R, S, Bird'
Two Dimensional Pattern M
"Atching" Information Process
ssing LettersIVOL, 6+Nα5+
October 1977, pp, 168-170 is known. This is Ah, which is famous for searching one-dimensional patterns.
o-Corasick method 2
This method is extended to dimensional patterns. This is done by dividing the two-dimensional pattern you want to search in the row direction, making it a row pattern, representing each with one code, and arranging them in the column direction as a column pattern. This is a method of creating a finite automaton and scanning it once on two-dimensional data from left to right and top to bottom to detect every position where a pattern appears.

この方法ではデータの要素数のオーダーで複数の2次元
パターンを検索することができる。
With this method, it is possible to search for a plurality of two-dimensional patterns on the order of the number of data elements.

また、複数の1次元パターンの検索ではAh。Also, when searching for multiple one-dimensional patterns, Ah.

Coras ick法以外の効率的な方法として、浦谷
の方法、例えば文献 浦谷則好「複数文字列照合アルゴ
リズム」電子情報通信学会5S87−27.および本願
人になる特願昭第62−231091号「複数パターン
の検索方法」がある。この方法はパターン群の照合を右
端から左方へ進めて行き、照合が途中で失敗した場合、
パターン群からあらかじめ計算しておいたテーブルに基
づいてデータ上の着目点を右に移動して、そこから次の
照合をパターン群の右端から再開する方法である。しか
し、この方法を複数の2次元パターンの検索に利用する
方法はいまだ提案されていない。
As an efficient method other than the Corasick method, there is the method of Uratani, for example, the document Noriyoshi Uratani, "Multiple string matching algorithm", Institute of Electronics, Information and Communication Engineers, 5S87-27. There is also Japanese Patent Application No. 62-231091 entitled "Multiple Pattern Search Method" filed by the applicant. In this method, matching of the pattern group proceeds from the right end to the left, and if matching fails midway,
This method moves the point of interest on the data to the right based on a table calculated in advance from a group of patterns, and then restarts the next matching from the right end of the group of patterns. However, no method has yet been proposed that uses this method to search for multiple two-dimensional patterns.

(発明が解決しようとする課題) 従来技術の項でも述べたごとく、従来のBird法では
データの要素数に比例して検索時間がかかり過ぎる欠点
があった。本発明の目的は浦谷の方法の考え方を取り入
れ、複数の2次元パターンを同時に効率よく検索できる
複数2次元パターン検索方法を提供せんとするものであ
る。
(Problems to be Solved by the Invention) As mentioned in the section of the prior art, the conventional Bird method has the disadvantage that the search time is too long in proportion to the number of data elements. An object of the present invention is to provide a multiple two-dimensional pattern search method that incorporates the idea of Uratani's method and can efficiently search for multiple two-dimensional patterns at the same time.

(課題を解決するための手段) この目的を達成するため、本発明複数2次元パターンの
検索方法は、検索すべき2次元パターンの集合が与えら
れた時、2次元に配列されたデータ中にそれらのパター
ンの存否を検索する方法において、前記パターンの集合
を列方向と行方向に分解し、その各々を、状態遷移に置
き換え、パターン照合に失敗した場合のポインタの移動
量をあらかじめ計算し、右から左へ、および下から上へ
データ中の要素を照合していく方法をとることによって
、同時に複数の2次元パターンを検索することを特徴と
するものである。
(Means for Solving the Problems) In order to achieve this object, the method for searching for multiple two-dimensional patterns of the present invention is such that when a set of two-dimensional patterns to be searched is given, In the method of searching for the presence or absence of those patterns, the set of patterns is decomposed into columns and rows, each of them is replaced with a state transition, and the amount of movement of the pointer in the case of failure in pattern matching is calculated in advance, This method is characterized by searching for multiple two-dimensional patterns at the same time by matching elements in data from right to left and from bottom to top.

(実施例) 以下添付図面を参照し実施例により本発明の詳細な説明
する。
(Examples) The present invention will be described in detail below by way of examples with reference to the accompanying drawings.

本発明を実施するに必要な略構成ブロック線図を第1図
に示す。
FIG. 1 shows a schematic block diagram of the structure necessary to carry out the present invention.

第1図においてデータバッファ1は検索対象のデータを
書き込んで保持する。行パターン用状態決定回路2は行
方向ポインタ決定回路6と列方向ポインタ決定回路7に
よって決められたポインタの値p、qに対応してデータ
バッファlから読み出された要素allIQと前の状態
から次の状態を決定する回路であり、第2図(a)、 
(b)に示すフローチャートのrstの値を決定するも
のである。列パターン用状態決定回路3は行パターン用
状態決定回路2の出力rstから行パターンの存否を判
定し、第2図に示すフローチャートの配列mapに相当
する行パターン検出結果保持バッファ5にそれを格納す
るとともに、rstとすでに行パターン検出結果保持バ
ッファ5に格納されているデータから次の状態、すなわ
ち第2図に示すフローチャートのcstの値を決定する
ものである。
In FIG. 1, a data buffer 1 writes and holds data to be searched. The row pattern state determining circuit 2 selects the elements allIQ read from the data buffer l corresponding to the pointer values p and q determined by the row pointer determining circuit 6 and the column pointer determining circuit 7 from the previous state. This is a circuit that determines the next state, and is shown in Fig. 2(a).
This is to determine the value of rst in the flowchart shown in (b). The column pattern state determination circuit 3 determines the presence or absence of a row pattern from the output rst of the row pattern state determination circuit 2, and stores it in the row pattern detection result holding buffer 5 corresponding to the array map in the flowchart shown in FIG. At the same time, the next state, that is, the value of cst in the flowchart shown in FIG. 2, is determined from rst and the data already stored in the row pattern detection result holding buffer 5.

出力判定回路4は列パターン用状態決定回路3の出力r
stから出力の有無を判定して、もしあればそれを出力
するものである。行パターン用状態決定回路2と列パタ
ーン用状態決定回路3のもう一方の出力は次のポインタ
の増−$iitを決めるものであり、それぞれ行方向ポ
インタ決定回路6と列方向ポインタ決定回路7によって
次のポインタの実際の値が決定される。行パターン用状
態設定回路8はパターンから行パターン記号を決めると
ともに行パターン用状態決定回路2の状態遷移の方法を
設定する回路である。列パターン用状態設定回路9は列
パターン用状態決定回路3り状態遷移の方法を行パター
ン用状態設定回路8の出力の1つである行パターン記号
から設定する回路である。
The output determination circuit 4 receives the output r of the column pattern state determination circuit 3.
The presence or absence of output is determined from st, and if there is, it is output. The other outputs of the row pattern state determination circuit 2 and the column pattern state determination circuit 3 determine the next pointer increment -$iit, and are determined by the row direction pointer determination circuit 6 and the column direction pointer determination circuit 7, respectively. The actual value of the next pointer is determined. The row pattern state setting circuit 8 is a circuit that determines a row pattern symbol from the pattern and also sets the state transition method of the row pattern state determination circuit 2. The column pattern state setting circuit 9 is a circuit that sets the state transition method of the column pattern state determining circuit 3 from the row pattern symbol, which is one of the outputs of the row pattern state setting circuit 8.

第2図(a)、 (b)は第1図の実施例におけるデー
タバンファ1から列方向ポインタ決定回路7までの動作
手順を示すフローチャートであり、データ中からパター
ンを検索する手順を示している。以下、これについて説
明する。
2(a) and 2(b) are flowcharts showing the operating procedure from the data buffer 1 to the column direction pointer determination circuit 7 in the embodiment of FIG. 1, and show the procedure for searching for a pattern from data. There is. This will be explained below.

第2図でrst、 cstはそれぞれ行パターン検索、
列パターン検索に対する現在の状態を、p、qはデータ
の読み出し位置を決定する行および列のポインタを示す
。配列rL Cgはそれぞれ行パターン検索、列パター
ン検索に対する次の状態(正のとき)またはポインタの
増分(負のとき)を示すためのものである。配列roは
行パターン検索の結果を示すもので、正のとき行パター
ン記号を出力するものである。配列coは列パターン検
索の結果を示すもので、空でないとき、検索されたパタ
ーン、つまり出力すべき2次元パターンを決定するため
のものである。
In Figure 2, rst and cst are row pattern search, respectively.
In the current state for column pattern search, p and q indicate row and column pointers that determine the data read position. The array rL Cg is for indicating the next state (when positive) or the increment of the pointer (when negative) for row pattern search and column pattern search, respectively. The array ro indicates the result of the row pattern search, and outputs a row pattern symbol when positive. The array co shows the results of the column pattern search, and when it is not empty, is used to determine the searched pattern, that is, the two-dimensional pattern to be output.

第2図(a)のステップSt、 S2においてcstと
qが初期化される。S3はデータの終りまで検索された
か否かを判断するステップである。84〜S7は行パタ
ーン検索のためにmm、 rst、 clo++ pを
初期化するステップであり、cmax、 cmin、 
r+*inはそれぞれ最大列パターン長、最小列パター
ン長、最小行パターン長を示す。S8は対象としていた
行の行パターン検索が終了したか否かを判断するステッ
プである。pがデータの行の長さmより大きければ、そ
の行の検索は終了しているので、S18で次に検索すべ
き行が決められ、それに合わせてS19で+mapの値
の再配置と初期化を行い、S3に戻る。
In steps St and S2 of FIG. 2(a), cst and q are initialized. S3 is a step of determining whether the data has been searched to the end. 84 to S7 are steps for initializing mm, rst, clo++p for row pattern search, and cmax, cmin,
r+*in indicates the maximum column pattern length, minimum column pattern length, and minimum row pattern length, respectively. S8 is a step of determining whether the line pattern search for the target line has been completed. If p is larger than the data row length m, the search for that row has ended, so the next row to be searched is determined in S18, and the value of +map is rearranged and initialized accordingly in S19. and return to S3.

行パターン探索では、S9において配列rgの正負が判
定され、負であればS16でその絶対値分だけpの値が
増やされ、S17でrstが0にリセットされてS8に
戻る。rgが正であれば、SIOで行パターン検索に対
する次の状態が決められ、Sllで行パターンの検出結
果が配列mapに格納され、S12で列パターン検索に
対する状態cstが決められる。
In the row pattern search, it is determined in S9 whether the array rg is positive or negative, and if it is negative, the value of p is increased by its absolute value in S16, rst is reset to 0 in S17, and the process returns to S8. If rg is positive, the next state for the row pattern search is determined in SIO, the row pattern detection result is stored in the array map in Sll, and the state cst for the column pattern search is determined in S12.

S13においてcstの正負が判定され、負であればS
14でdIIlが更新され、S15でポインタが1だけ
減じられてS8に戻る。csLが正であれば第2図(b
)に制御が移り、S20〜S40で列パターン探索を行
う。
In S13, it is determined whether cst is positive or negative, and if it is negative, S
14, dIIl is updated, the pointer is decremented by 1 in S15, and the process returns to S8. If csL is positive, Figure 2 (b
), and a column pattern search is performed in S20 to S40.

第2図ら)の520で検索された行パターンの長さがl
enに入れられ、S21で一時的な列ポインタSが列ポ
インタqに、S22でmapに対するポインタmcが+
nmに初期化される。S23は列パターン検索が終了し
たか否かを判断するステップで、終了していればS15
に戻る。
The length of the line pattern searched at 520 in Figure 2 et al.
en, the temporary column pointer S is changed to column pointer q in S21, and the pointer mc for map is changed to + in S22.
Initialized to nm. S23 is a step for determining whether or not the column pattern search has been completed; if it has been completed, the process proceeds to S15.
Return to

S24は列パターンの存否、すなわち2次元パターンの
存否を判断するステップで、もし存在していればS25
で行ポインタの値Pと列ポインタの値Sと検索された2
次元パターンが出力される。 S26゜S27で+wc
とSが1だけ減じられ、S28で配列mapのデータが
調べられる。配列a+apにすでに行パターンの検索結
果が格納されていれば、S39で次の列パターン検索に
対する状態cstが決められる。
S24 is a step of determining whether or not there is a column pattern, that is, whether there is a two-dimensional pattern.
The value P of the row pointer and the value S of the column pointer are searched in 2.
A dimensional pattern is output. +wc at S26゜S27
and S are decremented by 1, and the data in the array map is examined in S28. If the row pattern search results are already stored in the array a+ap, the state cst for the next column pattern search is determined in S39.

S40はcstの正負を判断するステップで、負でなけ
ればS23に戻り、負であればS41でdmの値が更新
されS15に戻る。配列mapが“未検索”であればS
29〜338でその値を求めるために部分的な行パター
ン探索が行われる。
S40 is a step of determining whether cst is positive or negative; if it is not negative, the process returns to S23; if it is negative, the value of dm is updated in S41, and the process returns to S15. S if the array map is “unsearched”
A partial row pattern search is performed at 29-338 to determine that value.

S29は列パターン検索が失敗した場合に備えてdll
を更新するステップでUMCは列パターン検索が必ず失
敗する要素を示している。S30は部分的に行パターン
検索を行うために一時的な行ポインタjを初期化するス
テップである。S31は部分的な行パターン検索に対す
る状態の初期化である。S32は行パターン検索が終了
したか否かを判定するステップで終了したならばS23
に戻る。そうでなければS33でデータの要素の値a3
0、と前の状態からtstを更新する。S34でtst
の正負が判断され、もし負であればS15に戻る。そう
でなければS35で行ポインタpの位置で行パターンが
検出されたか否かが判断される。もし行パターンが検出
されたならば536で列パターン検索に対する状態cs
tが求められ列パターン探索のためにS40へ行く。
S29 is a dll in case the column pattern search fails.
In the step of updating , the UMC indicates elements for which the column pattern search always fails. S30 is a step of initializing a temporary row pointer j in order to partially perform a row pattern search. S31 is initialization of the state for partial row pattern search. S32 is a step of determining whether or not the row pattern search has been completed, and if it has been completed, S23 is performed.
Return to Otherwise, in S33, the value a3 of the data element is
0, and updates tst from the previous state. tst in S34
It is determined whether the value is positive or negative, and if it is negative, the process returns to S15. If not, it is determined in S35 whether a row pattern is detected at the position of the row pointer p. If a row pattern is detected then the state cs for the column pattern search at 536
t is determined and the process goes to S40 for column pattern search.

そうでなければS37でjが1だけ減じられ、338で
部分的な行パターン検索が終了したか否かが判断され、
終了ならばS15へ戻り、そうでなければS32に戻る
If not, j is decremented by 1 in S37, and it is determined in 338 whether the partial row pattern search has been completed;
If the process is finished, the process returns to S15; otherwise, the process returns to S32.

通常の場合には510〜S15の実行のバスより316
、 S17の実行のパスの方が多くなることが期待でき
、また520に進んだ場合も523〜540のループを
回ることは少なく、S40ですぐに541に抜けること
が多いことが期待できるので、照合回数が大幅に減じら
れる。
In normal case, 316 from the bus of execution of 510 to S15
, it can be expected that there will be more execution paths in S17, and even if it advances to 520, it will rarely go through the loop from 523 to 540, and it can be expected that it will often exit to 541 immediately at S40. The number of verifications is significantly reduced.

第3図(a)、 (b)、 (C)は特願昭第62−2
31091号「複数パターンの検索方法」添付図面の第
3図(a)、 (b)。
Figures 3 (a), (b), and (C) are Patent Application No. 62-2
No. 31091 ``Multiple Pattern Search Method'' Figures 3 (a) and (b) of the attached drawings.

(C)と全く同じであり、第1図の実施例における行パ
ターン用状態設定回路8と列パターン用状態設定回路9
の動作手順を示す一連のフローチャートであり、第2図
における配列’g+ cg+ ro、 coの値を決定
するものである。以下、これについて説明する。
(C), and the row pattern state setting circuit 8 and the column pattern state setting circuit 9 in the embodiment of FIG.
2 is a series of flowcharts showing the operating procedure for determining the values of the array 'g+cg+ro, co in FIG. 2. This will be explained below.

第3図で、配列gは第2図のrgまたはcgに、配列o
utは第2図のroまたはcoに相当する。またyjは
配列roを求める場合は行パターンを示し、配列coを
求める場合は列パターンを示すものとする。
In Figure 3, array g is added to rg or cg in Figure 2, and array o
ut corresponds to ro or co in FIG. Further, yj indicates a row pattern when determining the array ro, and indicates a column pattern when determining the array co.

したがってyJのi番目の要素を示すa4.、はyJが
行パターンの場合はパターンの要素の値を、y。
Therefore, a4. which indicates the i-th element of yJ. , is the value of the element of the pattern if yJ is a row pattern, y.

が列パターンの場合は行パターン記号を示している。k
は行パターンまたは列パターンの数である。
If is a column pattern, it indicates a row pattern symbol. k
is the number of row or column patterns.

配列depthは特定の状態におけるそこまでの検索要
素数、配列emapは検索する各パターンの最後の要素
に対する状態番号を示している。配列ddmと配列fは
gを求めるための補助関数を示している。
The array depth indicates the number of search elements up to that point in a specific state, and the array emap indicates the state number for the last element of each pattern to be searched. Array ddm and array f indicate auxiliary functions for determining g.

これらの配列は0または空に初期化されているものとす
る。第3図(a)のS42とS43は新しい状態番号と
パターン番号の初期化である。S44は状態番号の初期
化である。S45〜S55の間でパターンの右端の要素
から左へ順に各要素に対する次の状態番号と配列dep
thの値が計算される。S56では配列outO値が決
められる。S57では配列emapO値が決められ、S
59で全てのパターンがチエツクされたか否かが判定さ
れる。
It is assumed that these arrays are initialized to 0 or empty. S42 and S43 in FIG. 3(a) are initialization of new state numbers and pattern numbers. S44 is the initialization of the state number. The next state number and array dep for each element in order from the rightmost element of the pattern to the left between S45 and S55
The value of th is calculated. In S56, the array outO value is determined. In S57, the array emapO value is determined, and S
At step 59, it is determined whether all patterns have been checked.

第3回部)の560−579はある状態がそれより手前
のどの状態に対応するかを示す配列fの値を求めるため
のもので、配列gの部分的な更新も行っている。560
〜S62はqueueとfの初期化である。
560-579 in Part 3) are for finding the values of the array f indicating which state a certain state corresponds to before it, and also partially updating the array g. 560
~S62 is the initialization of queue and f.

queueはチエツクすべき状態を保持しておくための
スタックである。S63でqueueが空なら第3図(
C)に制御が移る。564〜575で第3図(a)で求
められた各状態に対して配列fの値を計算している。
A queue is a stack for holding the state to be checked. If the queue is empty in S63, see Figure 3 (
Control is transferred to C). In steps 564 to 575, the values of the array f are calculated for each state found in FIG. 3(a).

S76〜578で状態rにおいて次の状態番号Sが求め
られている要素Cに対する状態fstにおけるポインタ
の増分が計算される。
In S76 to S578, the increment of the pointer in the state fst for the element C for which the next state number S is being determined in the state r is calculated.

第3図(C)のS80は配列ddsの初期化であり、S
81はパターン番号の初期化である。S82〜S84で
S85以降で用いるbstとj tenの値を求めてい
る。S85はある状態で検索に失敗した場合、それより
手前に対応する状態がある場合は386以下を、ない場
合には次のパターンに操作が移ること(S95)を示し
ている。S86はqueueの初期化である。S87〜
S93でqueueに新しい候補を付は加え、dda+
の値を更新している。S96において全てのパターンに
対する上記の操作が終わったことが判定される(j>k
)と、S97において今まで求められたddmO値を用
いて照合失敗時のgの値を更新する。
S80 in FIG. 3(C) is the initialization of the array dds, and S80 is the initialization of the array dds.
81 is the initialization of the pattern number. In S82 to S84, the values of bst and j ten to be used in S85 and thereafter are determined. S85 indicates that when the search fails in a certain state, if there is a corresponding state before it, the operation moves to 386 or less, and if there is no corresponding state, the operation moves to the next pattern (S95). S86 is the initialization of the queue. S87~
At S93, add a new candidate to the queue and use dda+
The value of is being updated. In S96, it is determined that the above operations for all patterns have been completed (j>k
), and in S97, the value of g at the time of verification failure is updated using the ddmO value obtained so far.

以下に第4図に示す具体的なパターンを用いて実施例を
1つ示す。第4図のパターンを行方向に分解してそれぞ
れを行パターンと呼び行パターン記号をつける。例えば
、行パターン“”abc ’”にA、”efg ”にB
、“abcd”にC1+* cdh g−+にD、“h
ebc”にEという記号をつける。これを列方向に並べ
たもの、すなわち”ABAB’”と“CDE ”を列パ
ターンと呼ぶ。第3図に示した手順で配列rg。
One example will be described below using a specific pattern shown in FIG. The pattern shown in Figure 4 is broken down into rows and each is called a row pattern and given a row pattern symbol. For example, A for the row pattern ""abc '" and B for "efg".
, “abcd” to C1+* cdh g-+ to D, “h
Add the symbol E to "ebc".The arrangement of these patterns in the column direction, that is, "ABAB'" and "CDE" is called a column pattern.The procedure shown in FIG. 3 is used to create an array rg.

cg、 ro、 coが求められる。こうして求められ
た配列fgO例を第1表に、配列cgO例を第2表に示
す。
cg, ro, and co are required. Examples of the array fgO thus obtained are shown in Table 1, and examples of the array cgO are shown in Table 2.

ココで要素の集合は(a、  b、  c、  d、 
 e、  fg、 h、  o)と(A、 B、 C,
D、 E、 O)とした。配列roはro(3) =’
A’、 ro(6)=’B’、 ro(10)=’C’
、 ro(13) =’D’、 ro(15) =’E
’  となり、他の引数(本)に対してはro(−) 
=”0” とする。ここでO゛は行パターン記号が何も
検出されないことを示している。配列coはco(4)
= ”ABAB”  、 co(7)”CDE ’で他
は空である。
The set of elements here is (a, b, c, d,
e, fg, h, o) and (A, B, C,
D, E, O). Array ro is ro(3) ='
A', ro(6)='B', ro(10)='C'
, ro(13) ='D', ro(15) ='E
', and for other arguments (books) ro(-)
= “0”. Here, O'' indicates that no row pattern symbol is detected. Array co is co(4)
= ``ABAB'', co(7) ``CDE'' and the others are empty.

第2表 本発明における配列cgの一実施例第2図に示
した検索手順はまず行パターンを対象に検索を行い、行
パターンが見つかると行パターン記号を対象に列パター
ン検索を行うというもので、列パターンの検出はそのま
ま2次元パターンの検出を示している。第5図のデータ
に対して上記の方法を適用した場合の動作の概要を示す
Table 2 An example of an embodiment of an array CG according to the present invention The search procedure shown in Figure 2 is to first search for row patterns, and when the row pattern is found, perform a column pattern search for row pattern symbols. , detection of a column pattern directly indicates detection of a two-dimensional pattern. An outline of the operation when the above method is applied to the data shown in FIG. 5 will be shown.

第2図のrminもcminも3であるから最初に39
で照合される要素は第3行第3列目の”f′になる。
Since both rmin and cmin in Figure 2 are 3, the first value is 39.
The element to be matched is "f" in the third row and third column.

すると第1表から配列rgは−1となるので行ポインタ
は第2図(a)のS16で1だけ増やされS8に戻り次
の照合に移る。すると次はg°が照合対象になるので今
度はr(Hは4となりS10以下が実行される。
Then, from Table 1, the array rg becomes -1, so the row pointer is incremented by 1 in S16 of FIG. 2(a), and the process returns to S8 to proceed to the next collation. Then, since g° becomes the matching target, this time r(H becomes 4, and S10 and subsequent steps are executed.

SIOで行パターン検索の状態は4になり、Sllで配
列mapが更新される。状態4では行パターンが検出さ
れないので512のro (rs t) はOとなって
cstは−3にセットされる。したがってS14ではd
lllの値は変わらず、S15で行ポインタpが1だけ
減じられてS8に戻る。
The state of row pattern search becomes 4 in SIO, and the array map is updated in SLL. In state 4, no row pattern is detected, so ro (rs t) in 512 becomes O and cst is set to -3. Therefore, in S14, d
The value of lll remains unchanged, the row pointer p is decremented by 1 in S15, and the process returns to S8.

処理を続けると行パターン“efg”が第3行第2列目
で見つかるのでS12のro(rst) 、すなわち行
パターン記号はBとなり第2表からcstは1となり、
列パターン検索に入る。第2図(b)の328でIII
apは“未検索°”であるから仮の列ポインタSを用い
て第2行目に対してS30以下の部分的な行パターン検
索が行われる。処理を続けると535で行パターン“a
bc”が見つかり行パターン記号はAとなり、S36で
列パターンの状態cstは2に変わり、540を経てS
23に戻る。
As the process continues, the row pattern "efg" is found in the third row and second column, so ro(rst) in S12, that is, the row pattern symbol becomes B and cst becomes 1 from Table 2,
Enter column pattern search. III at 328 in Figure 2(b)
Since ap is "unsearched °", a partial row pattern search is performed for the second row using the temporary column pointer S from S30 onwards. Continuing the process, the line pattern “a” is displayed at 535.
bc” is found, the row pattern symbol becomes A, the column pattern status cst changes to 2 in S36, and after 540, S
Return to 23.

次の行(第1行目)も“未検索パであるのでS29でd
llを2に更新してから330以下の部分的な行パター
ン検索が行われる。この行パターン検索は失敗して第2
図(a)の315に戻る。ここで再び第3行目の行パタ
ーン検索の続きが行われる。この行ではもう行パターン
が見つからないのでやがて318へ移る。ここでdmは
2であるので列ポインタは2だけ増やされる。S19で
は次の検索に備えてmapの各要素の並べ直しを行う。
The next line (first line) is also “unsearched, so d in S29.
After updating ll to 2, a partial row pattern search below 330 is performed. This line pattern search fails and the second
Returning to 315 in Figure (a). Here, the row pattern search for the third row is continued again. Since no more row patterns are found in this row, the process moves to 318 soon. Here, dm is 2, so the column pointer is incremented by 2. In S19, each element of the map is rearranged in preparation for the next search.

S3から再開される行パターン検索の対象は第5行目と
なる。この行でも行パターン“efg” (行パターン
記号はB)が見つかるので前述と同様に列パターン検索
が行われる。ただし第3行の行パターン検索の結果は配
列mapに格納されているのでこの行の部分的行パター
ン検索は不要でS39でその値を利用するだけで済む。
The target of the row pattern search restarted from S3 is the fifth row. Since the row pattern "efg" (row pattern symbol is B) is also found in this row, the column pattern search is performed in the same manner as described above. However, since the result of the row pattern search for the third row is stored in the array map, there is no need to perform a partial row pattern search for this row, and it is sufficient to simply use the value in S39.

処理を続けるとS24で列パターン“ABAB”が見つ
かるので2次元パターンが検出されることになる。
As the process continues, the column pattern "ABAB" is found in S24, so a two-dimensional pattern is detected.

全体では第5図のデータの場合、第3行第2列目で1つ
の2次元パターンが、第6行第7列目でもう1つの2次
元パターンが検出される。このときの照合回数は行パタ
ーン検索で57回、列パターン検索で28回で合わせて
85回となりB’rrdの方法の108回(要素数と同
じ)より少ない。実際のデータではパターンの出現頻度
は通常もっと少ないのでさらに旧rdの方法より効率が
良くなることが期待できる。
Overall, in the case of the data shown in FIG. 5, one two-dimensional pattern is detected in the third row, second column, and another two-dimensional pattern is detected in the sixth row, seventh column. The number of matchings in this case is 57 times in the row pattern search and 28 times in the column pattern search, for a total of 85 times, which is less than the 108 times (same as the number of elements) of the B'rrd method. In actual data, patterns usually appear less frequently, so it can be expected that this method will be even more efficient than the old RD method.

上記の説明では状US!移とポインタの増減量を状態番
号と要素を引数とする同一の2次元配列rgとcgとに
よって示したが、これらを別々の配列で表わしてもよい
し、配列やリストの値を(要素、次の状態番号)の組な
どにすることによって一次元配列やリストで表わしても
よい。また、検索の目的によっては上述のように1つの
パターンが見つかっても次のパターンを探しに行くこと
はしないで、この時点で検索を中止してもよい。
In the above explanation, the status is US! Although the movement and pointer increase/decrease are shown using the same two-dimensional arrays rg and cg that take state numbers and elements as arguments, these may be represented in separate arrays, or the values of arrays and lists can be expressed as (elements, It may also be expressed as a one-dimensional array or list by creating a set of (next state number). Furthermore, depending on the purpose of the search, even if one pattern is found as described above, the search may be stopped at this point without searching for the next pattern.

(発明の効果) 以上のように、2次元パターンの集合が与えられたとき
、パターンの各行を1次元パターンと見なしてそれぞれ
の行パターンに固有の記号を割り当て、・この記号を列
方向に並べたものを列パターンとし、検索の第一段階で
は行方向に行パターンを浦谷の方法で検索し、行パター
ンが見つかれば列方向に列パターンを浦谷の方法で検索
することによって、従来法に比べて複数の2次元パター
ンを同時に効率よく検索することができる。
(Effect of the invention) As described above, when a set of two-dimensional patterns is given, each row of the pattern is regarded as a one-dimensional pattern, a unique symbol is assigned to each row pattern, and the symbols are arranged in the column direction. In the first step of the search, the row pattern is searched in the row direction using Uratani's method, and once the row pattern is found, the column pattern is searched in the column direction using Uratani's method. multiple two-dimensional patterns can be searched simultaneously and efficiently.

【図面の簡単な説明】[Brief explanation of the drawing]

第1図は本発明の検索方法を実施するに必要な装置の略
構成ブロック線図を示し、 第2図(a)、ら)は第1図の構成例におけるデータバ
ッファlから列ポインタ決定回路7までの動作手順のフ
ローチャートを示し、 第3図(a)、 (b)、 (C)は行パターン用状態
設定回路8および列パターン用状態設定回路9の操作手
順を示す一連のフローチャートを示し、 第4図は2次元パターンの一例を示し、第5図は2次元
データの一例を示す図である。 第4図 具a的lマダーン0−り・1 Lbc αbCd efチ Jl avIr−1yty> −停+ b)チc d o )d b f ahhcLbce9
−(10hdOe def%0hc1bヂLfe。 チ(LbCefOhdo9.(1 deftlcbaohdce hecfOd(L bCdCf hチahfbcdf9−eb ohbobahebccd Of;!cLf(lcdef00Le
FIG. 1 shows a schematic block diagram of a device necessary to carry out the search method of the present invention, and FIG. FIGS. 3(a), 3(b), and 3(C) show a series of flowcharts showing the operating procedures of the row pattern state setting circuit 8 and the column pattern state setting circuit 9. , FIG. 4 shows an example of a two-dimensional pattern, and FIG. 5 shows an example of two-dimensional data. Fig. 4 a of l madan 0-ri・1 Lbc αbCd efchiJl avIr-1yty> -stop+ b)chic d o )d b f ahhcLbce9
-(10hdOe def%0hc1bdiLfe.

Claims (1)

【特許請求の範囲】[Claims] 1、検索すべき2次元パターンの集合が与えられた時、
2次元に配列されたデータ中にそれらのパターンの存否
を検索する方法において、前記パターンの集合を列方向
と行方向に分解し、その各々を、状態遷移に置き換え、
パターン照合に失敗した場合のポインタの移動量をあら
かじめ計算し、右から左へ、および下から上へデータ中
の要素を照合していく方法をとることによって、同時に
複数の2次元パターンを検索することを特徴とする複数
2次元パターンの検索方法。
1. Given a set of two-dimensional patterns to be searched,
A method for searching for the presence or absence of such patterns in two-dimensionally arranged data, the set of patterns is decomposed into columns and rows, each of which is replaced with a state transition,
Search for multiple two-dimensional patterns at the same time by calculating in advance the amount of movement of the pointer in case pattern matching fails and matching elements in the data from right to left and from bottom to top. A search method for multiple two-dimensional patterns, characterized by the following.
JP63224796A 1988-09-09 1988-09-09 Search method for multiple 2D patterns Expired - Lifetime JP2783812B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP63224796A JP2783812B2 (en) 1988-09-09 1988-09-09 Search method for multiple 2D patterns

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP63224796A JP2783812B2 (en) 1988-09-09 1988-09-09 Search method for multiple 2D patterns

Publications (2)

Publication Number Publication Date
JPH0273478A true JPH0273478A (en) 1990-03-13
JP2783812B2 JP2783812B2 (en) 1998-08-06

Family

ID=16819338

Family Applications (1)

Application Number Title Priority Date Filing Date
JP63224796A Expired - Lifetime JP2783812B2 (en) 1988-09-09 1988-09-09 Search method for multiple 2D patterns

Country Status (1)

Country Link
JP (1) JP2783812B2 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPWO2020213164A1 (en) * 2019-04-19 2020-10-22
JPWO2020213165A1 (en) * 2019-04-19 2020-10-22

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPWO2020213164A1 (en) * 2019-04-19 2020-10-22
JPWO2020213165A1 (en) * 2019-04-19 2020-10-22
WO2020213164A1 (en) * 2019-04-19 2020-10-22 日本電気株式会社 Order preserving pattern matching device, order preserving pattern matching method, and computer-readable medium having program stored thereon
WO2020213165A1 (en) * 2019-04-19 2020-10-22 日本電気株式会社 Order preserving pattern matching device, order preserving pattern matching method, and computer-readable medium in which program is stored
US11899724B2 (en) 2019-04-19 2024-02-13 Nec Corporation Order preserving pattern matching apparatus, order preserving pattern matching method, and computer-readable medium storing program

Also Published As

Publication number Publication date
JP2783812B2 (en) 1998-08-06

Similar Documents

Publication Publication Date Title
US6466694B2 (en) Document image processing device and method thereof
US5428694A (en) Data processing system and method for forms definition, recognition and verification of scanned images of document forms
EP0866409A1 (en) Image retrieval apparatus and method
US8411961B1 (en) Method and apparatus for image feature matching in automatic image stitching
JPH10116316A (en) Character recognition method/device
JP2003228581A (en) Method of retrieving similarity by compatibility feedback
JPH05151394A (en) Method and apparatus for high-speed character recognition of slant text row for optical character recognition
JP2001125917A (en) Method and device for retrieving image
JPH11312248A (en) Image retrieval device and its method
JP2006099602A (en) Image construction method, fingerprint image construction apparatus and program
CN100375107C (en) Fingerprint image fragment splicing method
US6208755B1 (en) Method and apparatus for developing a character recognition dictionary
JPH0273478A (en) Retrieving method for plural 2-dimensional patterns
JPH0713666A (en) Data processor
JPH09147055A (en) Character processor
JP2007018178A (en) Character input device, character input program, and recording medium for recording character input program
CN117273129B (en) Behavior pattern creation and generation method and system
JP4614582B2 (en) Partial template generator
JP2001022886A (en) Device and method for handwriting input
CN112560273A (en) Method and device for determining execution sequence of model components facing data flow model
CN114461130A (en) Character input method, device and storage medium
JPH0146912B2 (en)
JPH0492973A (en) Image information registration/retrieval device
JPH1069494A (en) Image retrieval method and device therefor
JPH0765169A (en) Image retrieving method