JP7242273B2 - Image processing device and image processing method - Google Patents
Image processing device and image processing method Download PDFInfo
- Publication number
- JP7242273B2 JP7242273B2 JP2018225931A JP2018225931A JP7242273B2 JP 7242273 B2 JP7242273 B2 JP 7242273B2 JP 2018225931 A JP2018225931 A JP 2018225931A JP 2018225931 A JP2018225931 A JP 2018225931A JP 7242273 B2 JP7242273 B2 JP 7242273B2
- Authority
- JP
- Japan
- Prior art keywords
- temporary label
- memory
- temporary
- labeling
- data
- 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.)
- Active
Links
Images
Landscapes
- Image Analysis (AREA)
Description
本発明は、二値化画像に対してラベリング処理を実行する画像処理装置及びこの画像処理装置の画像処理方法に関する。 The present invention relates to an image processing apparatus that performs labeling processing on a binarized image and an image processing method of this image processing apparatus.
従来、2値化画像に対する画像処理として、データが存在する連結した特徴画素に同一のラベルを付与するラベリング処理が知られている。ラベリング処理としては、仮ラベルとその結合情報(どの仮ラベルが、別のどの仮ラベルに置き換わるのかという情報)をメモリに記憶させ、2値化画像の全画素に仮ラベルを付与した後に、結合情報を基に仮ラベルを統合する処理が一般的である(例えば、特許文献1)。 Conventionally, as image processing for a binarized image, there is known a labeling process in which the same label is given to connected feature pixels in which data exists. In the labeling process, temporary labels and their combination information (information indicating which temporary label is to be replaced with which other temporary label) are stored in a memory. Processing for integrating temporary labels based on information is common (for example, Patent Document 1).
上記したようなラベリング処理において、2値化画像に付与された仮ラベルの数と、仮ラベルが付与された画素のバラツキ具合によっては、仮ラベルとその結合情報を記憶するためにメモリの消費量が過大になる場合がある。このため、メモリの容量を大きくするためにデバイスコストがかさみ、さらにはラベリングできる画像サイズが制限されてしまうなどの課題がある。 In the labeling process as described above, depending on the number of temporary labels assigned to the binarized image and the degree of variation in the pixels to which the temporary labels are assigned, the amount of memory consumed to store the temporary labels and their combined information may become excessive. For this reason, there are problems such as an increase in device cost due to an increase in memory capacity and a limitation on the image size that can be labeled.
以上のような事情に鑑み、本発明の目的は、メモリの消費量を抑制しつつ、2値化画像をラベリング処理可能な画像処理装置及び画像処理方法を提供することにある。 SUMMARY OF THE INVENTION In view of the circumstances as described above, an object of the present invention is to provide an image processing apparatus and an image processing method capable of labeling a binarized image while suppressing memory consumption.
上記目的を達成するため、本発明の一形態に係る画像処理装置は、2値化画像をラベリング処理する。
上記画像処理装置は、制御部を有する。
上記制御部は、上記2値化画像を一定方向に走査することによって上記2値化画像を構成する各画素に仮ラベルを付与する第1のラベリング処理と、上記仮ラベルを上記一定方向とは異なる方向に走査することによって上記仮ラベルを更新する第2のラベリング処理と、を同時に実行する。
To achieve the above object, an image processing apparatus according to one aspect of the present invention labels a binarized image.
The image processing apparatus has a control section.
The control unit performs a first labeling process of assigning a temporary label to each pixel constituting the binarized image by scanning the binarized image in a certain direction, and applying the temporary label to the certain direction. and a second labeling process of updating the temporary label by scanning in a different direction.
上記制御部は、上記第1及び第2のラベリング処理を実行可能に構成された複数のラベリングブロックを有し、上記複数のラベリングブロック各々にタイミングをずらして上記第1及び第2のラベリング処理を実行させてもよい。 The control unit has a plurality of labeling blocks configured to be capable of executing the first and second labeling processes, and performs the first and second labeling processes with different timings for each of the plurality of labeling blocks. may be executed.
上記制御部は、上記第1のラベリング処理を実行する第1の仮ラベル処理部と、上記第2のラベリング処理を実行する第2の仮ラベル処理部と、上記第1及び第2のラベリング処理により得られた仮ラベルデータを記憶する複数のラインメモリと、を有し、
上記第1の仮ラベル処理部は、上記第1のラベリング処理により得られた1ライン分の仮ラベルデータを上記ラインメモリに書き込む書き込み処理を実行し、
上記第2の仮ラベル処理部は、上記仮ラベルデータを当該ラインメモリとは異なるラインメモリから読み込む処理を上記書き込み処理と同時に実行してもよい。
The control unit includes a first temporary label processing unit that executes the first labeling process, a second temporary label processing unit that executes the second labeling process, and the first and second labeling processes. a plurality of line memories for storing temporary label data obtained by
The first temporary label processing unit executes a writing process to write temporary label data for one line obtained by the first labeling process into the line memory,
The second temporary label processing unit may execute a process of reading the temporary label data from a line memory different from the line memory at the same time as the write process.
上記制御部は、上記第2のラベリング処理において、連結している仮ラベル間の結合情報を更新し、上記第1のラベリング処理において、上記結合情報を作成しない
画像処理装置。
The image processing apparatus, wherein the control unit updates joint information between the concatenated temporary labels in the second labeling process and does not create the joint information in the first labeling process.
上記目的を達成するため、本発明の一形態に係る画像処理装置の画像処理方法は、
2値化画像を一定方向に走査することによって上記2値化画像を構成する各画素に仮ラベルを付与する第1のラベリング処理と、上記仮ラベルを上記一定方向とは異なる方向に走査することによって上記仮ラベルを更新する第2のラベリング処理と、が同時に実行される。
In order to achieve the above object, an image processing method for an image processing apparatus according to one aspect of the present invention comprises:
a first labeling process of applying a temporary label to each pixel constituting the binary image by scanning the binary image in a fixed direction; and scanning the temporary label in a direction different from the fixed direction. and a second labeling process for updating the temporary label by are executed at the same time.
以上のように、本発明によれば、メモリの消費量を抑制しつつ、2値化画像をラベリング処理可能な画像処理装置及び画像処理方法を提供することができる。 As described above, according to the present invention, it is possible to provide an image processing apparatus and an image processing method capable of labeling a binarized image while suppressing memory consumption.
以下、図面を参照しながら本実施形態を説明する。説明は以下の順序で行うものとする。 Hereinafter, this embodiment will be described with reference to the drawings. Explanation shall be given in the following order.
1.画像処理装置の全体構成
1-1.ラベリングブロックの構成
1-1-1.仮ラベル及び結合メモリ作成部の構成
2.画像処理方法
2-1.画像処理方法の概要
2-2.ラベリングブロックのラベリング処理
3.作用・効果
4.変形例
5.補足
1. Overall Configuration of Image Processing Apparatus 1-1. Configuration of labeling block 1-1-1. Configuration of Temporary Label and Combined Memory Creation Unit 2. Image processing method 2-1. Outline of image processing method 2-2. Labeling processing of labeling block 3 . Action/Effect 4. Modification 5. supplement
1.)画像処理装置の全体構成 1. ) Overall configuration of the image processing device
図1は、本実施形態に係る画像処理装置100の構成例を示すブロック図である。画像処理装置100は、図1に示すように、ラベリング処理ブロック及びメモリ制御部10と、外部メモリ20とを有する。画像処理装置100は、ラベリング処理ブロック及びメモリ制御部10及び外部メモリ20以外に、ROM(Read Only Memory)、HDD(Hard Disk Drive)等のコンピュータに必要なハードウェアを有する。
FIG. 1 is a block diagram showing a configuration example of an
[ラベリング処理ブロック及びメモリ制御部]
ラベリング処理ブロック及びメモリ制御部10は、ROMやHDDに格納されたプログラムを外部メモリ20にロードして実行することによって、後述するラベリング処理を実行する。当該ラベリング処理としては、例えば、二値化された画像の縦及び横方向に連続している画素に同じラベルを付与する4連結処理(4近傍処理)や、縦、横及び斜め方向に連続している画素に同じラベルを付与する8連結処理(8近傍処理)が挙げられる。
[Labeling processing block and memory controller]
The labeling processing block and
プログラムは、例えば種々の記憶媒体(内部メモリ)を介してラベリング処理ブロック及びメモリ制御部10にインストールされる。あるいは、インターネット等を介してプログラムのインストールが実行されてもよい。
The program is installed in the labeling processing block and
本実施形態では、ラベリング処理ブロック及びメモリ制御部10は、典型的にはマイクロプロセッサとして構成される。当該マイクロプロセッサとしては、例えば、SISD(Single Instruction stream Single Data stream)型、SIMD(Single Instruction stream Multiple Data stream)型、MISD(Multiple Instruction stream Single Data stream)型、MIMD(Multiple Instruction stream Multiple Data stream)型、SMP(Symmetric Multi Processor)型、AMP(Asymmetric Multi Processor)型又はMPP(Massively Parallel Processor)型などが採用可能であり、その種類は問わない。
In this embodiment, the labeling processing block and
ラベリング処理ブロック及びメモリ制御部10は、典型的にはマイクロプロセッサであるがこれに限られず、マイクロプロセッサに代えて、またはこれと共に、DSP(Digital Signal Processor)、ASIC(Application Specific Integrated Circuit)、またはFPGA(Field-Programmable Gate Array)などの処理回路を有してもよい。例えば、ラベリング処理ブロック及びメモリ制御部10がFPGAで構成される場合は、ROMからプログラムをFPGAにロードして実行することによって、後述するラベリング処理が実行される。
The labeling processing block and
ラベリング処理ブロック及びメモリ制御部10は、2値化画像の連結している特徴画素に対し同一のラベルを割り振るラベリング処理を実行する。そして、ラベリング処理ブロック及びメモリ制御部10はラベリング処理により得られたラベルデータをCPUメモリなどへ転送する。
The labeling processing block and
また、ラベリング処理ブロック及びメモリ制御部10は、図1に示すように、入出力データセレクタ101と、メモリコントローラ及びアービター105と、ラベリングブロック102,103,104とを有する。ラベリング処理ブロック及びメモリ制御部10は、特許請求の範囲の「制御部」の一例である。
The labeling processing block and
(入出力データセレクタ)
入出力データセレクタ101は、任意の撮像装置等により撮像された画像が2値化された2値化画像のデータ(以下、2値画像データ)と画像データ有効信号を取得し、これらをラベリングブロック102,103,104のうちどのラベリングブロックに出力するかを選択する。そして、入出力データセレクタ101は、選択したラベリングブロックに2値画像データ及び画像データ有効信号を出力する。また、入出力データセレクタ101は、ラベリングブロック102,103,104各々から2値化画像に付与された本ラベルに関する本ラベルデータと、ラベルデータ有効信号及びラベリング完了通知を取得し、これらをCPUメモリなどへ転送する。
(input/output data selector)
The input/
(メモリコントローラ及びアービター)
メモリコントローラ及びアービター105は、ラベリング処理ブロック及びメモリ制御部10上で外部メモリ20のデータの読み出し、書き出し、外部メモリ20のリフレッシュ等、ラベリング処理ブロック及びメモリ制御部10のインターフェースを統括する調停回路である。
(memory controller and arbiter)
The memory controller and
メモリコントローラ及びアービター105は、外部メモリ20を制御し、外部メモリ20との間でデータを送受信可能に構成される。メモリコントローラ及びアービター105は、2値化画像の各画素に付与された仮ラベルに関する仮ラベルデータを外部メモリ20に出力する。
The memory controller and
(ラベリングブロック)
ラベリングブロック102,103,104は、入出力データセレクタ101から2値画像データ及び画像データ有効信号を取得し、この2値画像データに基づいて、2値化画像の各画素に付与する仮ラベルに関する仮ラベルデータを生成する。ラベリングブロック102,103,104は、生成した仮ラベルデータとラベルデータ有効信号をメモリコントローラ及びアービター105を介して外部メモリ20に出力する。
(labeling block)
Labeling blocks 102, 103, and 104 acquire binary image data and an image data valid signal from input/
また、ラベリングブロック102,103,104は、メモリコントローラ及びアービター105を介して外部メモリ20から取得した仮ラベルデータ及びラベルデータ有効信号を取得し、この仮ラベルデータに基づいて、2値画像データの各画素に付与する本ラベルに関する本ラベルデータを生成する。そして、ラベリングブロック102,103,104は、生成した本ラベルデータと、ラベルデータ有効信号と、ラベリング完了通知とを入出力データセレクタ101に出力する。以下、ラベリングブロック102,103,104の構成を詳細に説明する。
The labeling blocks 102, 103, and 104 acquire the temporary label data and the label data valid signal from the
1-1.)ラベリングブロックの構成 1-1. ) labeling block configuration
図2は、ラベリングブロック102の構成例を示すブロック図である。図2では、ラベリングブロック102,103,104のうちラベリングブロック102を代表して図示するが、ラベリングブロック103,104は、ラベリングブロック102と同様の構成である。
FIG. 2 is a block diagram showing a configuration example of the
ラベリングブロック102は、図2に示すように、第1結合メモリ1022と、結合メモリ統合化部1023と、欠番穴埋め変換メモリ1024と、本ラベル作成部1025と、仮ラベル及び結合メモリ作成部1021とを有する。
The
第1結合メモリ1022は、2値化画像の各画素に付与された仮ラベル間の結合情報(どの仮ラベルが、別のどの仮ラベルに置き換わるのか示す情報)を記憶する。第1結合メモリ1022は、2値化画像のアドレスと、結合元及び結合先の仮ラベルデータとが対応づけられたテーブル(表1~10参照)を記憶する。
The
結合メモリ統合化部1023は、第1結合メモリ1022に記憶されたデータに基づき、第2結合メモリ1023aに記憶されたテーブル(表1~10参照)の仮ラベルの並び替えを実行する。結合メモリ統合化部1023は、第2結合メモリ1023aに記憶されたデータに基づき欠番穴埋め変換メモリ1024を生成する。
Based on the data stored in the first combined
結合メモリ統合化部1023は、結合メモリリード/ライト制御部1023bと、第2結合メモリ1023aとを有する。結合メモリリード/ライト制御部1023bは、第1及び第2結合メモリ1022,1023bとの間で仮ラベルデータの読み出し及び書き出しを実行する。
The combined
第2結合メモリ1023aは、2値化画像の各画素に付与された仮ラベルにおいて、結合している仮ラベルの数を記憶する。第2結合メモリ1023aは、2値化画像の結合元(アドレス)の仮ラベルデータと、結合先の仮ラベルデータとが対応づけられたテーブル(表1~10参照)を記憶する。
The
欠番穴埋め変換メモリ1024は、第2結合メモリ1023aに記憶された、仮ラベル統合後のテーブル(表16の左のテーブル)の欠番となった仮ラベルを補填するためのテーブル(表16の右のテーブル)を記憶する。当該テーブルでは、2値画像データの結合元(アドレス)の仮ラベルデータと、結合先の本ラベルデータとが対応づけられる。
The missing number filling
本ラベル作成部1025は、外部メモリ20に記憶された仮ラベルデータを読み出し、この仮ラベルデータを、第2結合メモリ1023a及び欠番穴埋め変換メモリ1024に記憶されたテーブルを参照することによって、本ラベルデータに変換する。
The main
本ラベル作成部1025は、仮ラベルデータから変換された本ラベルデータと、ラベルデータ有効信号及びラベリング完了通知を入出力データセレクタ101に出力する。また、本ラベル作成部1025は、第2結合メモリ/欠番穴埋め変換メモリリード/ライト制御部1025aを有する。第2結合メモリ/欠番穴埋め変換メモリリード/ライト制御部1025aは、第2結合メモリ1023a及び欠番穴埋め変換メモリ1024との間で仮ラベルデータの読み出し及び書き出しを実行する。
The real
仮ラベル及び結合メモリ作成部1021は、2値画像データ及び画像データ有効信号を取得し、2値画像データに基づき仮ラベルデータを生成する。仮ラベル及び結合メモリ作成部1021は、生成した仮ラベルデータとラベルデータ有効信号をメモリコントローラ及びアービター105を介して外部メモリ20に書き込む処理を実行する。第1及び第2結合メモリ1022,1023a及び欠番穴埋め変換メモリ1024としては、データを高速に読み書き可能な内部メモリが利用される。
A temporary label and combined
仮ラベル及び結合メモリ作成部1021は、仮ラベルデータを生成した後で、仮ラベルの作成が完了したことを結合メモリ統合化部1023に通知する。また、仮ラベル及び結合メモリ作成部1021は、生成した仮ラベルデータに基づき仮ラベル結合情報を生成し、この情報を第1及び第2結合メモリ1022,1023aに書き込む処理を実行する。以下、仮ラベル及び結合メモリ作成部1021の構成を詳細に説明する。
After generating the temporary label data, the temporary label and joint
1-1-1.)仮ラベル及び結合メモリ作成部の構成 1-1-1. ) Configuration of temporary label and combined memory creation unit
図3は、仮ラベル及び結合メモリ作成部1021の構成例を示すブロック図である。仮ラベルおよび結合メモリ作成部1021は、図3に示すように、ラインメモリ制御部1021aと、第1仮ラベル処理部1021bと、ラインメモリ選択部1021cと、第1~第4ラインメモリ1021d,1021e,1021f,1021gと、第2仮ラベル処理部1021hとを有する。
FIG. 3 is a block diagram showing a configuration example of the temporary label and combined
ラインメモリ制御部1021aは、ラインメモリ選択部1021c、第1及び第2仮ラベル処理部1021b,1021hの動作を制御する。
The line
第1仮ラベル処理部1021bは、2値画像データ及び画像データ有効信号を取得する。第1仮ラベル処理部1021bは、2値化画像の一番左上の画素から一番右下の画素まで、右方向にラスタスキャンを実行し、データのある画素に仮ラベルを付与する(第1のラベリング処理)。
The first temporary
第1仮ラベル処理部1021bは、ラスタスキャンの結果得られた仮ラベルと、2値化画像のどの画素に仮ラベルが付与されたのかその場所に関するアドレス情報をラインメモリ選択部1021cに出力する。また、第1仮ラベル処理部1021bは、2値化画像の画像データ有効信号をラインメモリ制御部1021aに出力する。
The first temporary
ラインメモリ選択部1021cは、第1及び第2仮ラベル処理部1021b,1021hから2値化画像の走査ライン毎の仮ラベルデータ及びアドレス情報を取得し、これらを第1~第4ラインメモリ1021d,1021e,1021f,1021gのうちどのラインメモリに書き出すかを選択する。
The line
また、ラインメモリ選択部1021cは、第1~第4ラインメモリ1021d,1021e,1021f,1021gのうちどのラインメモリから仮ラベルデータ及びアドレス情報を読み出すかを選択する。ラインメモリ選択部1021cは第1~第4ラインメモリ1021d,1021e,1021f,1021gのいずれかから読み出した仮ラベルデータ及びアドレス情報を第1及び第2仮ラベル処理部1021b,1021hに出力する。
Also, the line
第2仮ラベル処理部1021hは、第1仮ラベル処理部1021bによりラベリング処理された仮ラベルの一番右上の画素から一番左下の画素まで、左方向にラスタスキャンを実行し、データのある画素に付与された仮ラベルを更新する(第2のラベリング処理)。
The second temporary
第2仮ラベル処理部1021hは、ラスタスキャンの結果更新された仮ラベルと、2値画像化画像のどの画素の仮ラベルを更新したのかその場所に関するアドレス情報をラインメモリ選択部1021c及び外部メモリ20に出力する。
The second temporary
第2仮ラベル処理部1021hは、ラインメモリ選択部1021cから取得した仮ラベルデータ及びアドレス情報に基づいて仮ラベル結合情報を生成し、この情報を第1及び第2結合メモリ1022,1023aに書き込む。第2仮ラベル処理部1021hは、第1及び第2結合メモリ1022,1023aに記憶されたテーブル(表1~10の結合メモリ1,2)の値をラスタスキャンしながら逐次更新する。
The second temporary
[外部メモリ]
外部メモリ20は、半導体素子を使った記憶装置であり、データの書き込みと読み出しができるメモリである。外部メモリ20は、ラベリングブロック102,103,104各々から出力された仮ラベルデータをメモリコントローラ及びアービター105を介して取得し、これらを一時記憶する。本実施形態では、データの一時意記憶領域として単価の安い外部メモリ20利用することにより大容量メモリを構築しやすいという利点がある。
[External memory]
The
外部メモリ20は、典型的にはDRAM(Dynamic Random Access Memory)であるがこれに限られず、例えば、SRAM(Static Random Access Memory)、FeRAM(Ferroelectric Random Access Memory)、MRAM(Magnetoresistive Random Access Memory)、ReRAM(Resistive Random Access Memory)又はPRAM(Phase change Random Access Memory)などであってもよい。
The
2.)画像処理方法 2. ) image processing method
2-1.)画像処理方法の概要 2-1. ) Outline of image processing method
図4はラベリングブロック102,103,104の処理の流れを示すタイミングチャートであり、各ラベリングブロック102,103,104が2値画像データから本ラベルデータを生成するまでの処理の流れを示す図である。 FIG. 4 is a timing chart showing the flow of processing by the labeling blocks 102, 103 and 104, showing the flow of processing by each of the labeling blocks 102, 103 and 104 to generate label data from binary image data. be.
本実施形態の画像処理装置100の画像処理方法では、(1)仮ラベル及び結合メモリ作成、(2)結合メモリ統合化、(3)本ラベル作成が実行され、これらの処理が3つのラベリングブロックによりフレーム単位で間隔をずらして同時に実行されることで、連続したラベリング結果が得られる。
In the image processing method of the
具体的には、フレーム1ではラベリングブロック102の仮ラベル処理(ステップS102)が実行され、フレーム2ではラベリングブロック102の統合化処理(ステップS103)とラベリングブロック103の仮ラベル処理が実行され、フレーム3ではラベリングブロック102の本ラベル処理(ステップS105)と、ラベリングブロック103の統合化処理と、ラベリングブロック104の仮ラベル処理とが実行され、以降同様の処理が繰り返される。これにより、所定のフレームレートで撮像されたフレーム画像毎の本ラベルデータをリアルタイムに得ることができ、2値化された静止画だけではなく、動画もラベリングすることができる。
Specifically, the temporary label processing of the labeling block 102 (step S102) is executed in the frame 1, the integration processing of the labeling block 102 (step S103) and the temporary label processing of the
2-2.)ラベリングブロックのラベリング処理 2-2. ) Labeling processing of the labeling block
図5はラベリングブロック102の画像処理方法を示すフローチャートであり、図6~図15はラベリングブロック102の各ラインメモリ1021d,1021e,1021f,1021gの動作を示すブロック図である。以下、ラベリングブロック102のラベリング処理について図5~図15を適宜参照しながら説明する。
FIG. 5 is a flow chart showing the image processing method of the
なお、図5~図15では、ラベリングブロック102,103,104のうちラベリングブロック102のラベリング処理を代表して図示するが、ラベリングブロック103,104は、ラベリングブロック102と同様の処理を実行する。また、図6~図15中で使用されている語句を以下のように定義する。
5 to 15, the
・仮ラベル処理(右方向)・・・2値化画像を右方向に走査する処理。
・仮ラベル処理(左方向)・・・2値化画像を左方向に走査する処理。
・仮nライン(右方向):W・・・2値化画像を右方向に走査した場合のnライン目の仮ラベルデータをラインメモリに書き込む。
・仮nライン(右方向):R・・・2値化画像を右方向に走査した場合のnライン目の仮ラベルデータをラインメモリから読み込む。
・仮nライン(左方向):W・・・仮ラベルを左方向に走査した場合のnライン目の仮ラベルデータをラインメモリに書き込む。
・仮nライン(左方向):R・・・仮ラベルを左方向に走査した場合のnライン目の仮ラベルデータをラインメモリから読み込む。
・W・・・ラインメモリへの書き込み
・R・・・ラインメモリからの読み出し
• Temporary label processing (right direction): Processing for scanning the binarized image in the right direction.
• Temporary label processing (left direction): Processing for scanning the binarized image in the left direction.
• Temporary n-line (right direction): W: Temporary label data for the n-th line when the binarized image is scanned rightward is written in the line memory.
Temporary n-line (rightward direction): R: Temporary label data for the n-th line when the binarized image is scanned rightward is read from the line memory.
Temporary n-line (left direction): W Writes the temporary label data of the n-th line when the temporary label is scanned leftward into the line memory.
Temporary n-line (left direction): R Read the temporary label data of the n-th line when the temporary label is scanned leftward from the line memory.
・W: Writing to line memory ・R: Reading from line memory
[ステップS101:2値画像データの転送]
先ず、任意の撮像装置等により撮像された画像が2値化された2値画像データがラベリングブロック102に出力される。この際、2値化画像を構成する画素毎の情報が第1仮ラベル処理部1021bに出力される。これにより、後述する仮ラベル処理が実行される。
[Step S101: Transfer of Binary Image Data]
First, binary image data obtained by binarizing an image captured by an arbitrary imaging device or the like is output to the
[ステップS102:仮ラベル処理]
次に、ラベリングブロック102は、取得した2値化画像に対して下記の規則1~10に従って走査ライン毎に仮ラベル処理を実行する。ステップS102では、走査方向が右方向のラスタスキャン(4連結処理)と、走査方向は左方向のラスタスキャン(4連結処理)と、結合メモリの更新が同時進行で実行される。ここで、仮ラベルカウンタの値と結合メモリ1,2のカウンタ値は、ステップS102を実行される前に0に初期化される。なお、図16は第1仮ラベル処理部1021bの仮ラベル処理の参照範囲を示す図であり、図17は第2仮ラベル処理部1021hの仮ラベル処理の参照範囲を示す図である。
[Step S102: Temporary label processing]
Next, the
(走査方向が右方向のラスタスキャン)
規則1:仮ラベリングの処理対象として注目される画素(以下、注目画素)にデータがない場合
・仮ラベルカウンタ値:インクリメントなし
・注目画素の仮ラベル:なにもしない
(Raster scan with the scanning direction to the right)
Rule 1: When there is no data in a pixel targeted for temporary labeling processing (hereinafter referred to as target pixel) Temporary label counter value: No increment Temporary label for target pixel: Do nothing
規則2:注目画素の左隣と上部の画素にデータが無く、注目画素にデータがある場合
・仮ラベルカウンタ値:1インクリメント
・注目画素の仮ラベル:インクリメント後の仮ラベルのカウンタ値とする
Rule 2: When there is no data in the pixels to the left and above the pixel of interest, but there is data in the pixel of interest Temporary label counter value: Increment by 1 Temporary label of the pixel of interest: Counter value of temporary label after increment
規則:3:注目画素の左隣の画素の仮ラベルがAであり、上部の画素にデータが無く、注目画素にデータがある場合
・仮ラベルカウンタ値:なにもしない
・注目画素の仮ラベル:Aとする
Rule: 3: When the temporary label of the pixel to the left of the pixel of interest is A, the pixel above has no data, and the pixel of interest has data Temporary label counter value: Do nothing Temporary label of the pixel of interest : A
規則4:注目画素の左隣の画素にデータが無く、上部の画素の仮ラベルがBであり、注目画素にデータある場合
・仮ラベルカウンタ値:なにもしない
・注目画素の仮ラベル:Bとする
Rule 4: When there is no data in the pixel to the left of the target pixel, the temporary label of the upper pixel is B, and the target pixel has data Temporary label counter value: Do nothing Temporary label of target pixel: B to be
規則5:注目画素の左隣の画素の仮ラベルがAであり、上部の画素の仮ラベルがBであり、注目画素にデータがある場合
・仮ラベルカウンタ値:なにもしない
・注目画素の仮ラベル:AとBを比較した上での最小値とする
Rule 5: When the temporary label of the pixel to the left of the pixel of interest is A, the temporary label of the pixel above it is B, and there is data in the pixel of interest Temporary label counter value: Do nothing The pixel of interest Temporary label: The minimum value after comparing A and B
(走査方向が左方向のラスタスキャン)
規則6:注目画素にデータがない場合
・注目画素の仮ラベル:なにもしない
・結合メモリ1:更新しない
・結合メモリ2:更新しない
(Raster scan with left scanning direction)
Rule 6: When there is no data in the pixel of interest Temporary label of pixel of interest: Do nothing Join memory 1: Do not update Join memory 2: Do not update
規則7:注目画素の右隣と上部の画素にデータがなく、注目画素の仮ラベルがXの場合
・注目画素の仮ラベル:仮ラベルXを維持
・結合メモリ1:更新しない
・結合メモリ2:アドレス(結合元)及びデータ(結合先)の値をXに更新
Rule 7: When there is no data in the pixels to the right of and above the pixel of interest, and the temporary label of the pixel of interest is X. Temporary label of pixel of interest: Maintains temporary label X. Joint memory 1: Do not update. Joint memory 2: Update address (source) and data (destination) values to X
規則8:注目画素の右隣の画素の仮ラベルがAであり、上部の画素にデータがなく、注目画素の仮ラベルがXの場合
・注目画素の仮ラベル:AとXを比較した上での最小値に更新
Rule 8: When the temporary label of the pixel to the right of the target pixel is A, the upper pixel has no data, and the temporary label of the target pixel is X - Temporary label of target pixel: After comparing A and X updated to the minimum of
規則8-1:上記規則8に加えて、AとXを比較した上での最小値がAではない場合
・結合メモリ1:アドレスカウンタの値を1インクリメント
アドレスをインクリメント後のアドレスカウンタに更新
データ(結合元)の値をAとXを比較した上で最大値に更新
データ(結合先)の値をAとXを比較した上で最小値に更新
・結合メモリ2:アドレス(結合元)の値をAとXを比較した上で最大値に更新
データ(結合先)の値をAとXを比較した上で最小値に更新
Rule 8-1: In addition to rule 8 above, when the minimum value after comparing A and X is not A Combined memory 1: Increment the value of the address counter by 1
Update address to address counter after increment
Update the data (combination source) value to the maximum value after comparing A and X
Compare A and X and update the value of data (connection destination) to the minimum value ・Joint memory 2: Compare A and X and update the value of address (connection source) to the maximum value
Update the data (joint destination) value to the minimum value after comparing A and X
規則8-2:上記規則8に加えて、上記規則8-1以外の場合
・結合メモリ1:更新しない
・結合メモリ2:更新しない
Rule 8-2: In addition to rule 8 above, cases other than rule 8-1 above Linked memory 1: not updated Linked memory 2: not updated
規則9:注目画素の右隣の画素にデータがなく、上部の画素の仮ラベルがBであり、注目画素の仮ラベルがXの場合
・注目画素の仮ラベル:BとXを比較した上での最小値に更新
Rule 9: When there is no data in the pixel to the right of the target pixel, the temporary label of the upper pixel is B, and the temporary label of the target pixel is X ・Temporary label of target pixel: After comparing B and X updated to the minimum of
規則9-1:上記規則9に加えて、BとXを比較した上での最小値がBではない場合
・結合メモリ1:アドレスカウンタの値を1インクリメント
アドレスをインクリメント後のアドレスカウンタに更新
データ(結合元)の値をBとXを比較した上での最大値に更新
データ(結合先)の値をBとXを比較した上での最小値に更新
・結合メモリ2:アドレス(結合元)の値をBとXを比較した上での最大値に更新
データ(結合先)の値をBとXを比較した上での最小値に更新
Rule 9-1: In addition to rule 9 above, when the minimum value after comparing B and X is not B. Combined memory 1: Increment the value of the address counter by 1.
Update address to address counter after increment
Update the data (combination source) value to the maximum value after comparing B and X
Updates the value of the data (connection destination) to the minimum value after comparing B and X ・Joint memory 2: Updates the value of the address (connection source) to the maximum value after comparing B and X
Update the value of data (connection destination) to the minimum value after comparing B and X
規則9-2:上記規則9に加えて、上記規則9-1以外の場合
結合メモリ1:更新しない
結合メモリ2:更新しない
Rule 9-2: In addition to rule 9 above, cases other than rule 9-1 above Combined memory 1: Not updated Combined memory 2: Not updated
規則10:注目画素の右隣の画素の仮ラベルがAであり、上部の画素の仮ラベルがBであり、注目画素の仮ラベルがXの場合
注目画素の仮ラベル:AとBとXを比較した上での最小値に更新
Rule 10: When the temporary label of the pixel to the right of the pixel of interest is A, the temporary label of the pixel above it is B, and the temporary label of the pixel of interest is X. Temporary label of the pixel of interest: A, B, and X Updated to minimum value after comparison
規則10-1:上記規則10に加えて、AとBとXを比較した上での最小値がA,Bの場合
結合メモリ1:更新しない
結合メモリ2:更新しない
Rule 10-1: In addition to rule 10 above, when the minimum values after comparing A, B, and X are A and B Combined memory 1: Do not update Combined memory 2: Do not update
規則10-2:上記規則10に加えて、上記規則10-1以外の場合
結合メモリ1:アドレスカウンタの値を1インクリメント
アドレスをインクリメント後のアドレスカウンタに更新
データ(結合元)の値をAとBとXを比較した上での最大値に更新
データ(結合先)の値をAとBとXを比較した上での最小値に更新
結合メモリ2:アドレス(結合元)の値をAとBとXを比較した上での最大値に更新
データ(結合先)の値をAとBとXを比較して上での最小値に更新
Rule 10-2: In addition to rule 10 above, other than rule 10-1 above Combined memory 1: Increment the value of the address counter by 1
Update address to address counter after increment
Update the data (combination source) value to the maximum value after comparing A, B, and X
Update the value of the data (connection destination) to the minimum value after comparing A, B, and X. Join memory 2: Update the value of the address (connection source) to the maximum value after comparing A, B, and X.
Compare the value of data (connection destination) with A, B and X and update to the minimum value above
第1仮ラベル処理部1021bは、2値化画像の1ライン目を右方向にスキャンする。この際、第1仮ラベル処理部1021bは、規則1~3に従ってデータの有る画素に仮ラベルを付与する。これにより、表1に示すようにP(X1,Y1),P(X2,Y1),P(X3,Y1),P(X4,Y1)の画素にそれぞれ仮ラベル「1」が付与される。
The first temporary
第1仮ラベル処理部1021bは、2値化画像の1ライン目を右方向にスキャンすることにより得られた仮ラベルデータを図6に示すように第1ラインメモリ1021dに書き出す。
The first temporary
本実施形態では、8×8画素の2値化画像をスキャンすることを一例とし、当該画像の1ライン目の画素に仮ラベルが付与される様子を表1として示す。なお、表1の「●」はデータが存在する画素を意味し、以下の説明においても同義である。 In the present embodiment, scanning a binary image of 8×8 pixels is taken as an example, and Table 1 shows how temporary labels are assigned to pixels on the first line of the image. Note that "●" in Table 1 means a pixel in which data exists, and has the same meaning in the following description.
次に、第1仮ラベル処理部1021bは、第1ラインメモリ1021dに記憶されている仮ラベルデータを読み出し、この仮ラベルデータを参照しつつ2値化画像の2ライン目を右方向にスキャンする。この際、第1仮ラベル処理部1021bは、規則1,2に従ってデータのある画素に仮ラベルを付与する。これにより、表2に示すように画素P(X5,Y2)に仮ラベル「2」が付与される。
Next, the first temporary
第1仮ラベル処理部1021bは、2値化画像の2ライン目を右方向にスキャンすることにより得られた仮ラベルデータを図7に示すように第2ラインメモリ1021eに書き出す。2値化画像の2ライン目の画素に仮ラベルが付与される様子を表2として示す。
The first temporary
次いで、第1仮ラベル処理部1021bは、第2ラインメモリ1021eに記憶されている仮ラベルデータを読み出し、この仮ラベルデータを参照しつつ2値化画像の3ライン目を右方向にスキャンする。この際、第1仮ラベル処理部1021bは規則1,2,4に従ってデータの有る画素に仮ラベルを付与する。これにより、表3に示すように画素P(X1,Y3),P(X3,Y3),P(X5,Y3),P(X8,Y3)にそれぞれ仮ラベル「3」,「4」,「2」,「5」が付与される。第1仮ラベル処理部1021bは2値化画像の3ライン目を右方向にスキャンすることにより得られた仮ラベルデータを図8に示すように第3ラインメモリ1021fに書き出す。
Next, the first temporary
また、第2仮ラベル処理部1021hは、第1仮ラベル処理部1021bの3ライン目の仮ラベル処理と並行して第1ラインメモリ1021dに記憶されている仮ラベルデータを読み出し、この仮ラベルデータを参照しつつ仮ラベルの1ライン目を左方向にスキャンする。この際、第2仮ラベル処理部1021hは規則6,7,8,8-2に従って第1仮ラベル処理部1021bにより付与された仮ラベルを更新し、第2結合メモリ1023aに記憶された結合メモリ2を更新する。これにより、表3に示すように画素P(X1,Y1),P(X2,Y1),P(X3,Y1),P(X4,Y1)にそれぞれ付与された仮ラベル「1」が維持され、アドレス(結合元)及びデータ(結合先)の値がそれぞれ「1」に更新される。
Further, the second temporary
第2仮ラベル処理部1021hは仮ラベルの1ライン目を左方向にスキャンすることにより得られた仮ラベルデータを第1ラインメモリ1021dに上書きし、外部メモリ20に出力する。2値化画像の3ライン目が右方向にスキャンされ1ライン目が左方向にスキャンされる様子と、これに伴って結合メモリ2が更新される様子を表3として併記して示す。
The second temporary
続いて、第1仮ラベル処理部1021bは、第3ラインメモリ1021fに記憶されている仮ラベルデータを読み出し、この仮ラベルデータを参照しつつ2値化画像の4ライン目を右方向にスキャンする。この際、第1仮ラベル処理部1021bは規則1~5に従ってデータの有る画素に仮ラベルを付与する。これにより、表4に示すように画素P(X1,Y4),P(X2,Y4),P(X3,Y4),P(X4,Y4),P(X5,Y4),P(X7,Y4),P(X8,Y4)にそれぞれ仮ラベル「3」,「3」,「3」,「3」,「2」,「6」,「5」が付与される。第1仮ラベル処理部1021bは2値化画像の4ライン目を右方向にスキャンすることにより得られた仮ラベルデータを図9に示すように第4ラインメモリ1021gに書き出す。
Subsequently, the first temporary
また、第2仮ラベル処理部1021hは、第1仮ラベル処理部1021bの4ライン目の仮ラベル処理と並行して第1ラインメモリ1021dに記憶されている仮ラベルデータと第2ラインメモリ1021eに記憶されている仮ラベルデータとを読み出し、これらの仮ラベルデータを参照しつつ仮ラベルの2ライン目を左方向にスキャンする。この際、第2仮ラベル処理部1021hは規則6,7に従って第1仮ラベル処理部1021bにより付与された仮ラベルを更新し、第2結合メモリ1023aに記憶された結合メモリ2を更新する。これにより、表4に示すように画素P(X5,Y2)に付与された仮ラベル「2」が維持され、アドレス(結合元)及びデータ(結合先)の値がそれぞれ「2」に更新される。
In addition, the second temporary
第2仮ラベル処理部1021hは仮ラベルの2ライン目を左方向にスキャンすることにより得られた仮ラベルデータを第2ラインメモリ1021eに上書きし、外部メモリ20に出力する。2値化画像の4ライン目が右方向にスキャンされ2ライン目が左方向にスキャンされる様子とこれに伴って結合メモリ2が更新される様子を表4として併記して示す。
The second temporary
次に、第1仮ラベル処理部1021bは、第4ラインメモリ1021gに記憶されている仮ラベルデータを読み出し、この仮ラベルデータを参照しつつ2値化画像の5ライン目を右方向にスキャンする。この際、第1仮ラベル処理部1021bは規則1,2,4,5に従ってデータの有る画素に仮ラベルを付与する。これにより、表5に示すように画素P(X2,Y5),P(X6,Y5),P(X7,Y5),P(X8,Y5)にそれぞれ仮ラベル「3」,「7」,「6」,「5」が付与される。第1仮ラベル処理部1021bは2値化画像の5ライン目を右方向にスキャンすることにより得られた仮ラベルデータを図10に示すように第1ラインメモリ1021dに上書きする。
Next, the first temporary
また、第2仮ラベル処理部1021hは、第1仮ラベル処理部1021bの5ライン目の仮ラベル処理と並行して第2ラインメモリ1021eに記憶されている仮ラベルデータと第3ラインメモリ1021fに記憶されている仮ラベルデータとを読み出し、これらの仮ラベルデータを参照しつつ仮ラベルの3ライン目を左方向にスキャンする。この際、第2仮ラベル処理部1021hは規則6,7,9,9-2に従って第1仮ラベル処理部1021bにより付与された仮ラベルを更新し、第2結合メモリ1023aに記憶された結合メモリ2を更新する。これにより、表5に示すように画素P(X1,Y3),P(X3,Y3),P(X5,Y3),P(X8,Y3)にそれぞれ付与された仮ラベル「3」,「4」,「2」,「5」が維持され、アドレス(結合元)及びデータ(結合先)の値がそれぞれ「3」,「4」,「5」に更新される。
In addition, the second temporary
第2仮ラベル処理部1021hは2値化画像の3ライン目を左方向にスキャンすることにより得られた仮ラベルデータを第3ラインメモリ1021fに上書きし、外部メモリ20に出力する。2値化画像の5ライン目が右方向にスキャンされ3ライン目が左方向にスキャンされる様子とこれに伴って結合メモリ2が更新される様子を表5として併記して示す。
The second
次いで、第1仮ラベル処理部1021bは、第1ラインメモリ1021dに記憶されている仮ラベルデータを読み出し、この仮ラベルデータを参照しつつ2値化画像の6ライン目を右方向にスキャンする。この際、第1仮ラベル処理部1021bは規則1,2,4,5に従ってデータの有る画素に仮ラベルを付与する。これにより、表6に示すように画素P(X2,Y6),P(X5,Y6),P(X6,Y6),P(X7,Y6),P(X8,Y6)にそれぞれ仮ラベル「3」,「8」,「7」,「6」,「5」が付与される。第1仮ラベル処理部1021bは2値化画像の6ライン目を右方向にスキャンすることにより得られた仮ラベルデータを図11に示すように第2ラインメモリ1021eに上書きする。
Next, the first temporary
また、第2仮ラベル処理部1021hは、第1仮ラベル処理部1021bの6ライン目の仮ラベル処理と並行して第3ラインメモリ1021fに記憶されている仮ラベルデータと第4ラインメモリ1021gに記憶されている仮ラベルデータとを読み出し、これらの仮ラベルデータを参照しつつ2値化画像の4ライン目を左方向にスキャンする。この際、第2仮ラベル処理部1021hは規則6,8,8-2,9,9-2,10,10-2に従って第1仮ラベル処理部1021bにより付与された仮ラベルを更新し、第1,2結合メモリ1022,1023aに記憶された結合メモリ1,2を更新する。これにより、表6に示すように画素P(X1,Y4),P(X2,Y4),P(X3,Y4),P(X4,Y4),P(X7,Y4)に付与された仮ラベルがそれぞれ「2」,「2」,「2」,「2」,「5」に更新され、画素P(X5,Y4),P(X8,Y4)にそれぞれ付与された仮ラベル「2」,「5」が維持される。
In addition, the second temporary
また、結合メモリ1のアドレス値が「1」,「2」にインクリメントし、これらのアドレス値にそれぞれ対応した結合元及び結合先のカウンタ値が「4」,「2」及び「3」,「2」に更新される。また、結合メモリ2のアドレス(結合元)の値「3」に対応したデータ(結合先)の値が2に更新され、アドレス(結合元)の値「4」に対応したデータ(結合先)の値が「2」に更新される。 Also, the address values of the coupling memory 1 are incremented to "1" and "2", and the counter values of the coupling source and coupling destination corresponding to these address values are "4", "2" and "3", " 2” is updated. Also, the value of the data (coupling destination) corresponding to the address (coupling source) value "3" in the coupling memory 2 is updated to 2, and the data (coupling destination) corresponding to the address (coupling source) value "4" is updated. is updated to "2".
第2仮ラベル処理部1021hは仮ラベルの4ライン目を左方向にスキャンすることにより得られた仮ラベルデータを第4ラインメモリ1021gに上書きし、外部メモリ20に出力する。2値化画像の6ライン目が右方向にスキャンされ4ライン目が左方向にスキャンされる様子とこれに伴って結合メモリ1,2が更新される様子を表6として併記して示す。
The second temporary
続いて、第1仮ラベル処理部1021bは、第2ラインメモリ1021eに記憶されている仮ラベルデータを読み出し、この仮ラベルデータを参照しつつ2値化画像の7ライン目を右方向にスキャンする。この際、第1仮ラベル処理部1021bは規則1,3,4に従ってデータの有る画素に仮ラベルを付与する。これにより、表7に示すように画素P(X2,Y7),P(X3,Y7),P(X4,Y7),P(X5,Y7)にそれぞれ仮ラベル「3」,「3」,「3」,「3」が付与される。第1仮ラベル処理部1021bは2値化画像の7ライン目を左方向にスキャンすることにより得られた仮ラベルデータを図12に示すように第3ラインメモリ1021fに上書きする。
Subsequently, the first temporary
また、第2仮ラベル処理部1021hは、第1仮ラベル処理部1021bの7ライン目の仮ラベル処理と並行して第1ラインメモリ1021dに記憶されている仮ラベルデータと第4ラインメモリ1021gに記憶されている仮ラベルデータとを読み出し、これらの仮ラベルデータを参照しつつ仮ラベルの5ライン目を左方向にスキャンする。この際、第2仮ラベル処理部1021hは規則6,8,8-2,9,9-2,10,10-1に従って第1仮ラベル処理部1021bにより付与された仮ラベルを更新する。これにより、表7に示すように画素P(X2,Y5),P(X6,Y5),P(X7,Y5)に付与された仮ラベルがそれぞれ「2」,「5」,「5」に更新され、画素P(X8,Y5)に付与された仮ラベル「5」が維持される。
In addition, the second temporary
第2仮ラベル処理部1021hは2値化画像の5ライン目を左方向にスキャンすることにより得られた仮ラベルデータを第1ラインメモリ1021dに上書きし、外部メモリ20に出力する。2値化画像の7ライン目が右方向にスキャンされ5ライン目が左方向にスキャンされる様子を表7として示す。
The second
次に、第1仮ラベル処理部1021bは、第3ラインメモリ1021fに記憶されている仮ラベルデータを読み出し、この仮ラベルデータを参照しつつ2値化画像の8ライン目を右方向にスキャンする。この際、第1仮ラベル処理部1021bは規則1,2,3に従ってデータの有る画素に仮ラベルを付与する。これにより、表8に示すように画素P(X7,Y8),P(X8,Y8)にそれぞれ仮ラベル「9」,「9」が付与される。第1仮ラベル処理部1021bは2値化画像の8ライン目を右方向にスキャンすることにより得られた仮ラベルデータを図13に示すように第4ラインメモリ1021gに上書きする。
Next, the first temporary
また、第2仮ラベル処理部1021hは、第1仮ラベル処理部1021bの8ライン目の仮ラベル処理と並行して第1ラインメモリ1021dに記憶されている仮ラベルデータと第2ラインメモリ1021eに記憶されている仮ラベルデータとを読み出し、これらの仮ラベルデータを参照しつつ仮ラベルの6ライン目を左方向にスキャンする。この際、第2仮ラベル処理部1021hは規則6,8,8-2,9,9-2,10,10-2に従って第1仮ラベル処理部1021bにより付与された仮ラベルを更新する。これにより、表8に示すように画素P(X2,Y6),P(X5,Y6),P(X6,Y6),P(X7,Y6)に付与された仮ラベルがそれぞれ「2」,「5」,「5」,「5」に更新され、画素P(X8,Y6)に付与された仮ラベル「5」が維持される。
In addition, the second temporary
第2仮ラベル処理部1021hは2値化画像の6ライン目を左方向にスキャンすることにより得られた仮ラベルデータを第2ラインメモリ1021eに上書きし、外部メモリ20に出力する。2値化画像の8ライン目が右方向にスキャンされ6ライン目が左方向にスキャンされる様子を表8として示す。
The second
次いで、第2仮ラベル処理部1021hは、第2ラインメモリ1021eに記憶されている仮ラベルデータと第3ラインメモリ1021fに記憶されている仮ラベルデータとを読み出し、これらの仮ラベルデータを参照しつつ仮ラベルの7ライン目を左方向にスキャンする。この際、第2仮ラベル処理部1021hは規則6,8,8-2,9,9-1,10,10-2に従って第1仮ラベル処理部1021bにより付与された仮ラベルを更新し、第1,2結合メモリ1022,1023aに記憶された結合メモリ1,2を更新する。これにより、表9に示すように画素P(X2,Y7)に付与された仮ラベルが「2」に更新され、画素P(X3,Y7),P(X4,Y7),P(X5,Y7)にそれぞれ付与された仮ラベル「3」,「3」,「3」が維持される。
Next, the second temporary
また、結合メモリ1のアドレス値が「3」,「4」にインクリメントし、これらのアドレス値にそれぞれ対応した結合元及び結合先のカウンタ値が「5」,「3」及び「3」,「2」に更新される。また、結合メモリ2のアドレス(結合元)の値「5」に対応したデータ(結合先)の値が「3」に更新される。 Also, the address values of the coupling memory 1 are incremented to "3" and "4", and the counter values of the coupling source and coupling destination corresponding to these address values are "5", "3" and "3", " 2” is updated. Also, the value of the data (coupling destination) corresponding to the value "5" of the address (coupling source) of the coupling memory 2 is updated to "3".
第2仮ラベル処理部1021hは2値化画像の7ライン目を左方向にスキャンすることにより得られた仮ラベルデータを図14に示すように第3ラインメモリ1021fに上書きし、外部メモリ20に出力する。2値化画像の7ライン目が左方向にスキャンされる様子とこれに伴って結合メモリ1,2が更新される様子を表9として併記して示す。
The second temporary
続いて、第2仮ラベル処理部1021hは、第3ラインメモリ1021fに記憶されている仮ラベルデータと第4ラインメモリ1021gに記憶されている仮ラベルデータとを読み出し、これらの仮ラベルデータを参照しつつ仮ラベルの8ライン目を左方向にスキャンする。この際、第2仮ラベル処理部1021hは規則6,7,8,8-2に従って第1仮ラベル処理部1021bにより付与された仮ラベルを更新し、第2結合メモリ1023aに記憶された結合メモリ2を更新する。これにより、表10に示すように画素P(X7,Y8),P(X8,Y8)付与された仮ラベル「9」,「9」が維持され、結合メモリ2のアドレス(結合元)及びデータ(結合先)の値がそれぞれ「9」,「9」に更新される。
Subsequently, the second temporary
第2仮ラベル処理部1021hは仮ラベルの8ライン目を左方向にスキャンすることにより得られた仮ラベルデータを図15に示すように第4ラインメモリ1021gに上書きし、外部メモリ20に出力する。これにより、データの有る画素の全てに仮ラベルが付与された2値化画像のデータが外部メモリに記憶される。仮ラベルの8ライン目が左方向にスキャンされる様子とこれに伴って結合メモリ2が更新される様子を表10として併記して示す。
The second
[ステップS103:結合メモリ統合化]
結合メモリ統合化部1023は、第1及び第2結合メモリ1022,1023aに記憶されている結合メモリ1,2を読み出し、これらを統合する処理を実行する。具体的には、結合メモリ統合化部1023は、結合メモリ1の情報を基に結合メモリ2の情報をグループ毎に最小値になるような処理を実行する。以下、その手順の一例について述べる。
[Step S103: Combined memory integration]
The joint
(手順1)
結合メモリ1の結合情報の結合元仮ラベルをmとし、結合先仮ラベルをnとする。表11の場合、結合メモリ1のアドレス3に対応する結合元及び結合先の仮ラベルを(m,n)とする。表11は、手順1の一例を示す表であり、結合メモリ1,2のテーブルを併記して示す。なお、表11では、アドレス1,2の処理は終了済みとする。
(Step 1)
Assume that the connection source temporary label of the connection information in the connection memory 1 is m, and the connection destination temporary label is n. In the case of Table 11, the temporary labels of the connection source and connection destination corresponding to the address 3 of the connection memory 1 are (m,n). Table 11 is a table showing an example of procedure 1, and also shows tables of coupling memories 1 and 2. In Table 11, it is assumed that the processing of addresses 1 and 2 has been completed.
(手順2)
次に、mを結合メモリ2の結合元仮ラベルとし、結合元仮ラベルと結合先仮ラベルとが一致するまで結合情報の連鎖をたどり、連鎖の末の結合先仮ラベルをdmとする。表12の場合、mを結合メモリ2のアドレスとし、アドレス=データになるまで結合メモリ2において連鎖をたどり、連鎖の末、最終的にたどり着いたデータ(結合先)の値をdmとする。表12は手順2の一例を示す表であり、結合メモリ1,2のテーブルを併記して示す。
(Step 2)
Next, let m be the temporary label of the connection source of the connection memory 2, trace the chain of connection information until the temporary label of the connection source and the temporary label of the connection destination match, and set the temporary label of the connection destination at the end of the chain to dm. In the case of Table 12, let m be the address of the coupling memory 2, follow the chain in the coupling memory 2 until address=data, and let dm be the value of the finally reached data (coupling destination) at the end of the chain. Table 12 is a table showing an example of procedure 2, and also shows tables of coupling memories 1 and 2.
(手順3)
次いで、nを結合メモリ2の結合元仮ラベルとし、結合元の仮ラベルと結合先の仮ラベルとが一致するまで結合情報の連鎖をたどり、連鎖の末の結合先仮ラベルをdnとする。表13の場合、nを結合メモリ2のアドレスとし、アドレス=データになるまで結合メモリ2において連鎖をたどり、連鎖の末、最終的にたどり着いたデータ(結合先)の値をdnとする。表13は、手順3の一例を示す表であり、結合メモリ1,2のテーブルを併記して示す。
(Step 3)
Next, let n be the temporary label of the connection source in the connection memory 2, trace the chain of connection information until the temporary label of the connection source and the temporary label of the connection destination match, and set the temporary label of the connection destination at the end of the chain to dn. In the case of Table 13, let n be the address of the coupling memory 2, follow the chain in the coupling memory 2 until the address=data, and let dn be the value of the data (coupled destination) finally reached at the end of the chain. Table 13 is a table showing an example of procedure 3, and also shows tables of coupling memories 1 and 2.
(手順4)
続いて、dmとdnの小さいほうの値を(m,n)を初期値として、結合メモリ2の連鎖をたどったすべてのデータに対してその経過をたどる。ここで、(m,n)=(5,3)の場合、dm=2,dn=2となり、結合メモリ2の連鎖をたどった結合先仮ラベルが2に書き換えられる。表14は、手順4の一例を示す表であり、結合メモリ1,2のテーブルを併記して示す。
(Step 4)
Then, with the smaller value of dm and dn set to (m, n) as an initial value, all the data traced along the chain of the coupling memory 2 are tracked. Here, when (m, n)=(5, 3), dm=2 and dn=2, and the connection destination temporary label following the chain of connection memory 2 is rewritten to 2. Table 14 is a table showing an example of procedure 4, and also shows tables of coupling memories 1 and 2.
(手順5)
次に、結合メモリ1の結合情報の数だけ、手順(1)~(4)の処理を繰り返す。表11の場合、アドレス4についても手順(1)~(4)を実行する。これにより、先のステップS102において2値化画像の各画素に付与された仮ラベルが最終的にどのグループに属するのかを示す結合メモリ2(表14の右のテーブル)が得られる。
(Step 5)
Next, steps (1) to (4) are repeated by the number of pieces of joint information in the joint memory 1. FIG. In the case of Table 11, procedures (1) to (4) are also executed for address 4. As a result, a combined memory 2 (right table of Table 14) is obtained which indicates to which group the temporary label assigned to each pixel of the binarized image in the previous step S102 finally belongs.
[ステップS104:欠番変換穴埋めメモリ作成]
結合メモリ統合化部1023は、先のステップS103において得られた結合メモリ2(表14の右のテーブル)の欠番を穴埋めするための結合情報を生成する。この情報を生成する手順としては、結合メモリ2の結合元の仮ラベルが0になるまで結合元の仮ラベルを1から昇順にインクリメントしながら下記の(1)又は(2)の処理を実行する。これにより、表15に示すような欠番穴埋め変換テーブルが作成される。
[Step S104: Create missing number conversion fill-in-the-blank memory]
The joint
処理(1):結合メモリ2のアドレスの値=結合メモリ2のデータの値の場合
・本ラベルのカウンタ値を1インクリメントする
・その時の結合メモリ2のアドレスを欠番穴埋め変換テーブルのアドレスに書き込み、インクリメント後の本ラベルのカウンタ値を欠番穴埋め変換テーブルのデータに書き込む
処理(2):結合メモリ2のアドレスの値≠結合メモリ2のデータの値の場合
・結合メモリ2の次のアドレスを参照
Process (1): When address value of link memory 2 = data value of link memory 2 - Increment the counter value of this label by 1 - Write the address of link memory 2 at that time to the address of the missing number filling conversion table, Write the incremented counter value of this label to the data of the missing number filling conversion table. Processing (2): When the address value of link memory 2 ≠ the data value of link memory 2 ・Refer to the next address of link memory 2
表15は、結合メモリ2の情報に基づき、欠番穴埋め変換テーブルを作成する一例を示す表であり、結合メモリ2のテーブルと欠番穴埋め変換テーブルとを併記して示す。なお、ステップS104では、処理(1),(2)の実行前にこの処理に必要となる本ラベルのカウンタ値を0に初期化し、欠番穴埋め変換テーブルを0に初期化しておく。 Table 15 is a table showing an example of creating a missing number filling conversion table based on the information of the join memory 2, and shows both the table of the joining memory 2 and the missing number filling conversion table. Note that in step S104, the counter value of the label required for this process is initialized to 0, and the missing number filling conversion table is initialized to 0 before the processes (1) and (2) are executed.
[ステップS105:本ラベル処理]
本ラベル作成部1025は、結合メモリ2と欠番穴埋め変換テーブルとに基づき、2値化画像の各画素に付与された仮ラベルを本ラベルに書き換える。表16は、仮ラベルを本ラベルに変換する一例として、仮ラベル9を本ラベル3に変換する様子を示す表である。
[Step S105: Main label processing]
The full
ここで、表16に示すように、先のステップS103,S104において得られた結合メモリ2と欠番穴埋め変換テーブルとに基づいて仮ラベルを本ラベルに変換したとすると、仮ラベル「3」,「4」,「5」は本ラベル「2」に変換され、仮ラベル「9」は本ラベル「3」に変換される。これにより、表17に示すような、各画素に本ラベルが付与された2値化画像が得られる。表17を参照すると、本実施形態のラベリングブロック102は4連結処理を実行していることから、二値化画像の縦、横方向に連続している部分が同じ領域としてラベリングされていることがわかる。
Here, as shown in Table 16, if the temporary labels are converted into real labels based on the combined memory 2 and the missing number filling conversion table obtained in the previous steps S103 and S104, the temporary labels "3" and " 4” and “5” are converted to the real label “2”, and the temporary label “9” is converted to the real label “3”. As a result, a binarized image in which each pixel is given the main label as shown in Table 17 is obtained. Referring to Table 17, since the
3.)作用・効果 3. ) action and effect
本実施形態の画像処理装置100は、2値化画像の一つの走査ラインを右方向にラスタスキャンすることによってこの走査ラインを構成する各画素に仮ラベルを付与する仮ラベル処理と、当該走査ラインを左方向にラスタスキャンすることによってこの走査ラインを構成する各画素に付与された仮ラベルを更新する仮ラベル処理とを同時進行で実行する。これにより、仮ラベルの付与及び更新を走査ライン毎に1つずつ実行するよりも処理スピードが向上し、2値化画像をリアルタイムにラベリングすることが可能となる。
The
また、本実施形態のラベリング処理においては、2値化画像の各ラインにおいて、右方向と左方向とで仮ラベル処理が2度実行される。これにより、走査ラインのなかで連結している画素全てに同一の仮ラベルを付与することになるので、結合情報を削減することができ、この結合情報を記憶するメモリの消費量を削減することができる。特に、本実施形態では、右方向の仮ラベル処理の際には結合情報が記憶されないため、重複を許して全ての結合情報が記憶されることがなくなる。よって、メモリの消費量をさらに抑えることができる。 Further, in the labeling process of the present embodiment, temporary labeling is performed twice in the right direction and the left direction for each line of the binarized image. As a result, the same temporary label is given to all the pixels that are connected in the scanning line, so that the joint information can be reduced, and the memory consumption for storing this joint information can be reduced. can be done. In particular, in this embodiment, since joint information is not stored during rightward temporary label processing, duplication is not allowed and all joint information is not stored. Therefore, memory consumption can be further reduced.
さらに、メモリの消費量を抑えることができることから、安価なデバイスでリアルタイムにラベリング処理が可能になり、さらに、サイズが大きい2値化画像もラベリング処理することができる。 Furthermore, since memory consumption can be suppressed, labeling processing can be performed in real time using an inexpensive device, and furthermore, it is possible to perform labeling processing on a large-sized binarized image.
4.)変形例 4. ) Modification
以上、本発明の実施形態について説明したが、本発明は上述の実施形態にのみ限定されるものではなく種々変更を加え得ることは勿論である。 Although the embodiments of the present invention have been described above, it is needless to say that the present invention is not limited to the above-described embodiments and can be modified in various ways.
例えば、上記実施形態の画像処理装置100は、2値化画像を走査する際の走査方向が典型的には横方向であるがこれに限られない。画像処理装置100は、例えば、2値化画像を縦又は横方向に走査してもよく、その走査方向は特に限定されない。
For example, the
また、上記実施形態の画像処理装置100は、典型的には2値化画像をラベリング処理するがこれに限られない。画像処理装置100は、例えば2値化画像以外の画像のラベリング処理に適用されてもよくその用途は問わない。
Further, although the
5.)補足 5. )supplement
本明細書に記載された効果は、あくまで説明的または例示的なものであって限定的ではない。つまり、本発明は、上記の効果とともに、または上記の効果に代えて、本明細書の記載から当業者には明らかな他の効果を奏しうる。 The effects described herein are merely illustrative or exemplary and not limiting. In other words, in addition to the above effects, or in place of the above effects, the present invention can have other effects that are obvious to those skilled in the art from the description of this specification.
以上、添付図面を参照しながら本発明の好適な実施形態について詳細に説明したが、本発明はかかる例に限定されない。本発明の技術分野における通常の知識を有する者であれば、特許請求の範囲に記載された技術的思想の範疇内において、各種の変更例または修正例に想到し得ることは明らかであり、これらについても、当然に本発明の技術的範囲に属するものと了解される。 Although the preferred embodiments of the present invention have been described in detail above with reference to the accompanying drawings, the present invention is not limited to such examples. It is obvious that a person having ordinary knowledge in the technical field of the present invention can conceive of various modifications or modifications within the scope of the technical idea described in the claims. is naturally within the technical scope of the present invention.
10・・ラベリング処理ブロック及びメモリ制御部
100・・画像処理装置
102,103,104・・・ラベリングブロック
1021・・・第1仮ラベル処理部
1021d・・第1ラインメモリ
1021e・・第2ラインメモリ
1021f・・第3ラインメモリ
1021g・・第4ラインメモリ
1022・・・第2仮ラベル処理部
10 Labeling processing block and
Claims (4)
前記2値化画像を一定方向に走査することによって前記2値化画像を構成する各画素に仮ラベルを付与する第1のラベリング処理と、前記仮ラベルを前記一定方向とは異なる方向に走査することによって前記仮ラベルを更新する第2のラベリング処理と、を同時に実行し、前記第2のラベリング処理において、連結している仮ラベル間の結合情報を更新し、前記第1のラベリング処理において、前記結合情報を作成しない制御部
を具備する画像処理装置。 An image processing device for labeling a binarized image,
a first labeling process of applying a temporary label to each pixel forming the binary image by scanning the binary image in a fixed direction; and scanning the temporary label in a direction different from the fixed direction. simultaneously executing a second labeling process for updating the temporary label by, in the second labeling process, updating connection information between the concatenated temporary labels; and in the first labeling process, An image processing apparatus comprising: a control unit that does not create the combined information .
前記制御部は、前記第1及び第2のラベリング処理を実行可能に構成された複数のラベリングブロックを有し、前記複数のラベリングブロック各々にタイミングをずらして前記第1及び第2のラベリング処理を実行させる
画像処理装置。 The image processing device according to claim 1,
The control unit has a plurality of labeling blocks configured to be capable of executing the first and second labeling processes, and performs the first and second labeling processes with different timings for each of the plurality of labeling blocks. Image processing device to be executed.
前記制御部は、前記第1のラベリング処理を実行する第1の仮ラベル処理部と、前記第2のラベリング処理を実行する第2の仮ラベル処理部と、前記第1及び第2のラベリング処理により得られた仮ラベルデータを記憶する複数のラインメモリと、を有し、
前記第1の仮ラベル処理部は、前記第1のラベリング処理により得られた1ライン分の仮ラベルデータを前記ラインメモリに書き込む書き込み処理を実行し、
前記第2の仮ラベル処理部は、前記仮ラベルデータを当該ラインメモリとは異なるラインメモリから読み込む処理を前記書き込み処理と同時に実行する
画像処理装置。 The image processing device according to claim 1 or 2,
The control unit includes a first temporary label processing unit that executes the first labeling process, a second temporary label processing unit that executes the second labeling process, and the first and second labeling processes. a plurality of line memories for storing temporary label data obtained by
The first temporary label processing unit executes a writing process to write temporary label data for one line obtained by the first labeling process into the line memory,
The image processing device, wherein the second temporary label processing unit executes a process of reading the temporary label data from a line memory different from the line memory at the same time as the writing process.
2値化画像を一定方向に走査することによって前記2値化画像を構成する各画素に仮ラベルを付与する第1のラベリング処理と、前記仮ラベルを前記一定方向とは異なる方向に走査することによって前記仮ラベルを更新する第2のラベリング処理と、を同時に実行し、
前記第2のラベリング処理において、連結している仮ラベル間の結合情報を更新し、前記第1のラベリング処理において、前記結合情報を作成しない
画像処理方法。 The image processing device
a first labeling process of applying a temporary label to each pixel forming the binary image by scanning the binary image in a fixed direction; and scanning the temporary label in a direction different from the fixed direction. Simultaneously executing a second labeling process for updating the temporary label by
In the second labeling process, joint information between concatenated temporary labels is updated, and in the first labeling process, the joint information is not created.
Image processing method.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2018225931A JP7242273B2 (en) | 2018-11-30 | 2018-11-30 | Image processing device and image processing method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2018225931A JP7242273B2 (en) | 2018-11-30 | 2018-11-30 | Image processing device and image processing method |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2020087356A JP2020087356A (en) | 2020-06-04 |
JP7242273B2 true JP7242273B2 (en) | 2023-03-20 |
Family
ID=70908453
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2018225931A Active JP7242273B2 (en) | 2018-11-30 | 2018-11-30 | Image processing device and image processing method |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP7242273B2 (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2000339456A (en) | 1999-03-19 | 2000-12-08 | Japan Radio Co Ltd | Picture processing method |
JP2001043364A (en) | 1999-08-03 | 2001-02-16 | Fujitsu Ltd | Labeling circuit |
JP2005267362A (en) | 2004-03-19 | 2005-09-29 | Ricoh Co Ltd | Image processing method using simd processor and image processor |
JP2008228338A (en) | 2008-05-07 | 2008-09-25 | Ricoh Co Ltd | Image processing circuit |
JP2009070250A (en) | 2007-09-14 | 2009-04-02 | Fuji Xerox Co Ltd | Image processor and program |
JP2014135667A (en) | 2013-01-11 | 2014-07-24 | Seiko Epson Corp | Video processing apparatus, display apparatus, and video processing method |
-
2018
- 2018-11-30 JP JP2018225931A patent/JP7242273B2/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2000339456A (en) | 1999-03-19 | 2000-12-08 | Japan Radio Co Ltd | Picture processing method |
JP2001043364A (en) | 1999-08-03 | 2001-02-16 | Fujitsu Ltd | Labeling circuit |
JP2005267362A (en) | 2004-03-19 | 2005-09-29 | Ricoh Co Ltd | Image processing method using simd processor and image processor |
JP2009070250A (en) | 2007-09-14 | 2009-04-02 | Fuji Xerox Co Ltd | Image processor and program |
JP2008228338A (en) | 2008-05-07 | 2008-09-25 | Ricoh Co Ltd | Image processing circuit |
JP2014135667A (en) | 2013-01-11 | 2014-07-24 | Seiko Epson Corp | Video processing apparatus, display apparatus, and video processing method |
Also Published As
Publication number | Publication date |
---|---|
JP2020087356A (en) | 2020-06-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
RU2623806C1 (en) | Method and device of processing stereo images | |
JP2019508802A (en) | Compiler techniques for mapping program code to high-performance, power-efficient, programmable image processing hardware platforms | |
CN102460503A (en) | Apparatus and method for displaying warped version of source image | |
JP5455213B2 (en) | Image drawing apparatus, image drawing method, and program | |
KR102278021B1 (en) | Program code transformation to improve image processor runtime efficiency | |
JP2010282429A (en) | Image processing device and control method thereof | |
JP2015529363A (en) | Processor, system and method for efficient and fast processing of interrelated two-dimensional data sets | |
JP5548087B2 (en) | Arithmetic apparatus and arithmetic method | |
JP2011053671A (en) | Semiconductor integrated circuit | |
JP6532334B2 (en) | Parallel computing device, image processing device and parallel computing method | |
JP6442867B2 (en) | Image processing apparatus, imaging apparatus, and image processing method | |
JP2007535267A (en) | Image processing apparatus and method | |
JP7242273B2 (en) | Image processing device and image processing method | |
US11775809B2 (en) | Image processing apparatus, imaging apparatus, image processing method, non-transitory computer-readable storage medium | |
US11704546B2 (en) | Operation processing apparatus that calculates addresses of feature planes in layers of a neutral network and operation processing method | |
JP5947143B2 (en) | Fisheye image correction apparatus and correction method | |
JP5671635B2 (en) | Image processing apparatus and control method thereof | |
JP2007087425A5 (en) | ||
JP5325744B2 (en) | Image processing apparatus and image processing program | |
JP2005311745A (en) | Image processor | |
JP2013195963A (en) | Image processing device, integrated circuit apparatus, and image display system | |
JP5605225B2 (en) | MEMORY CONTROL DEVICE, MEMORY MAPPING METHOD, AND PROGRAM | |
JP2016103169A (en) | Image processing apparatus, image processing method, and electronic apparatus | |
JP2012164108A (en) | Labeling processing device and labeling processing method | |
JP6084000B2 (en) | Image processing device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20211109 |
|
RD02 | Notification of acceptance of power of attorney |
Free format text: JAPANESE INTERMEDIATE CODE: A7422 Effective date: 20211109 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20221122 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20221220 |
|
A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20230215 |
|
TRDD | Decision of grant or rejection written | ||
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20230228 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20230308 |
|
R150 | Certificate of patent or registration of utility model |
Ref document number: 7242273 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 |