JP2008243226A - Object image extraction method - Google Patents
Object image extraction method Download PDFInfo
- Publication number
- JP2008243226A JP2008243226A JP2008140592A JP2008140592A JP2008243226A JP 2008243226 A JP2008243226 A JP 2008243226A JP 2008140592 A JP2008140592 A JP 2008140592A JP 2008140592 A JP2008140592 A JP 2008140592A JP 2008243226 A JP2008243226 A JP 2008243226A
- Authority
- JP
- Japan
- Prior art keywords
- block
- image
- shape
- alpha mask
- contour
- 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.)
- Abandoned
Links
Images
Landscapes
- Image Analysis (AREA)
Abstract
Description
本発明は、画像中の物体領域を求める物体画像抽出方法及び物体画像抽出プログラムに関する。 The present invention relates to an object image extraction method and an object image extraction program for obtaining an object region in an image.
画像中から任意の物体の領域を抽出する技術は、例えば、背景を別の画像に置き換えるといった画像の加工を行う際に有用である。そのためには物体の領域をその輪郭に沿って正しく求める必要がある。 A technique for extracting a region of an arbitrary object from an image is useful when processing an image, for example, replacing a background with another image. For this purpose, it is necessary to correctly determine the region of the object along its contour.
物体の領域は具体的にはアルファマスク(あるいはシェイプデータ)と呼ばれる画像で表される。アルファマスクは物体が存在する領域(物体領域)とそれ以外の領域とで異なる画素値が設定された画像である。原画とそのアルファマスクの一例をそれぞれ、図3と図4に示す。図3の原画に写った右側の船031のアルファマスクが図4である。
Specifically, the object region is represented by an image called an alpha mask (or shape data). An alpha mask is an image in which different pixel values are set in an area where an object exists (object area) and other areas. An example of the original picture and its alpha mask are shown in FIGS. 3 and 4, respectively. FIG. 4 shows the alpha mask of the
言い換えれば、物体を抽出することはアルファマスクを生成することである。 In other words, extracting an object is creating an alpha mask.
アルファマスクが一度求まれば、それを参照することで簡単に物体領域以外の背景領域を別の画像に置き換えることができる。 Once the alpha mask is obtained, the background area other than the object area can be easily replaced with another image by referring to it.
このような物体抽出の際、何らかの方法で暫定的に物体の概略形状が予め求まっている場合に、その概略形状を元に物体の正確な形状を求める技術が求められている。その手法の一つとして、自己相似写像を用いる物体抽出方法(フラクタル法)を提案されている(例えば、特許文献1、特許文献2、非特許文献1を参照)。この技術の概要を図5、図6、図7、図8を用いて説明する。
There is a need for a technique for obtaining an accurate shape of an object based on the approximate shape when the approximate shape of the object is tentatively obtained in advance by some method during such object extraction. As one of the methods, an object extraction method (fractal method) using a self-similar map has been proposed (see, for example,
図5は船031に概略形状051が与えられた様子であり、そのアルファマスクが図6である。この段階では、アルファマスクの輪郭は物体の輪郭とずれている。フラクタル法では、このような原画像データとアルファマスクの入力に対し、まず、アルファマスクを用いて物体の概略形状に沿って複数の正方形のブロックを設定する。これらのブロックをチャイルドブロックと呼ぶ。そして、原画像データの同じ位置にアルファマスクと同様にチャイルドブロックを設定する。図7は原画像データにチャイルドブロックを設定した様子である。分かりやすくするために原画像データに概略形状も示してある。
FIG. 5 shows a state in which a
次に、原画像データを用いて各チャイルドブロックに対応するペアレントブロックを求める。ペアレントブロックのサイズは、チャイルドブロックの縦横2倍とし、ペアレントブロックの中の画像パターン(図柄)は、チャイルドブロックの中の画像パターンと同じになるようにする。 Next, a parent block corresponding to each child block is obtained using the original image data. The size of the parent block is twice the height and width of the child block, and the image pattern (design) in the parent block is the same as the image pattern in the child block.
このようなチャイルドブロックの図柄と相似なペアレントブロックを見つけるためには、原画像データ上でチャイルドブロックの近くで縦横2倍のブロックを候補ブロックとして仮に設定する。そして、その候補ブロックを縦横1/2に縮小した縮小ブロックとチャイルドブロックの誤差を求める。 In order to find a parent block similar to the child block pattern, a double-vertical block is set as a candidate block near the child block on the original image data. Then, the error between the reduced block and the child block obtained by reducing the candidate block to 1/2 in the vertical and horizontal directions is obtained.
誤差は濃淡画像の場合、例えば、絶対値誤差(各画素の差の絶対値をブロック内の全画素で加算)を用いる。このような誤差評価をいくつかの候補ブロックに対して行い、チャイルドブロックと最も誤差が小さかった候補ブロックをペアレントブロックと決定する。このようなペアレントブロックを図7に示した全てのチャイルドブロックに対して求める。 In the case of a grayscale image, for example, an absolute value error (the absolute value of the difference between pixels is added to all the pixels in the block) is used as the error. Such error evaluation is performed on several candidate blocks, and the candidate block having the smallest error from the child block is determined as the parent block. Such parent blocks are obtained for all the child blocks shown in FIG.
図8は、船031の先端部分に設定されたチャイルドブロック081に対して求まったペアレントブロック082の例である。それぞれのブロックの中の図柄が相似であることが分かる。図8では、2値画像を示しているが、画素に256レベルの画素値が与えられる濃淡画像でも同様である。
FIG. 8 is an example of the
以上の処理で、チャイルドブロックとこれと相似な図柄を持つペアレントブロックの組のデータが得られるので、次に、求めたペアレントブロックをアルファマスクの同じ位置に原画像データと同様にペアレントブロックを設定する。 With the above processing, data of a child block and a parent block with a similar pattern can be obtained. Next, set the parent block at the same position of the alpha mask as the original image data. To do.
物体の抽出は、チャイルドブロックとペアレントブロックを利用してアルファマスクを補正することで行う。具体的には、各チャイルドブロックのアルファマスクのデータを、それぞれに対応するペアレントブロックのアルファマスクのデータを縦横1/2に縮小したもので置き換える処理を行えば良い。 The object extraction is performed by correcting the alpha mask using the child block and the parent block. Specifically, the alpha mask data of each child block may be replaced with the alpha block data of the parent block corresponding to each child block reduced to 1/2 in the vertical and horizontal directions.
この置き換え変換(自己相似写像)を1回行うと、概略形状は正しい形状に少し近づく。この近づいたアルファマスクに同じ置き換え変換を再度施す。このようにアルファマスクに再帰的に置き換え変換を繰り返すとほぼ正しい形状に収束する。置き換え変換を一定の回数行ったアルファマスクを物体抽出結果とする。
しかし、従来のフラクタル法では、他の物体が近くにある場合に他の物体の輪郭を抽出してしまうことがある。また、物体形状が細い場合には、物体形状が消滅してしまうことがあるなど、必ずしも正確に物体の形状を抽出できないことがある。 However, in the conventional fractal method, when another object is nearby, the contour of the other object may be extracted. In addition, when the object shape is thin, the object shape may disappear, and the object shape may not always be accurately extracted.
そこで、本発明では他の物体が近くにある場合や、物体形状が細い場合でも正確に物体の形状を抽出することができる方法およびプログラムを提供することを目的とする。 Therefore, an object of the present invention is to provide a method and program that can accurately extract the shape of an object even when another object is nearby or the object shape is thin.
本発明は、抽出すべき対象物体を含む画像データと、前記画像データ中の対象物体の概略形状の領域を表すシェイプデータとを受け、前記画像データと前記シェイプデータの両方の上下左右の少なくとも一辺を前記各画像の外側に所定の幅だけそれぞれ拡張する第1のステップと、前記拡張したシェイプデータによって表される概略形状の輪郭に沿って、複数の探索基準ブロックを互いの位置をずらして設定する第2のステップと、前記探索基準ブロック毎に、前記探索基準ブロックより大きくて、前記拡張した画像データ上におけるそのブロックに対応する領域の図柄が前記探索基準ブロックに対応する領域の図柄と最も相似した相似ブロックを探索する第3のステップと、前記拡張したシェイプデータにおいて前記各探索基準ブロックに対応する領域のデータをそれぞれの相似ブロックに対応する領域のデータを縮小したもので置き換える処理を、所定の条件を満たすまで繰り返し行う第4のステップと、を有する物体画像抽出方法である。 The present invention receives image data including a target object to be extracted, and shape data representing a region of a schematic shape of the target object in the image data, and at least one side of both the upper and lower sides and the right and left of the image data and the shape data A plurality of search reference blocks are set by shifting the positions of each of the search reference blocks along the outline of the outline shape represented by the expanded shape data. And for each of the search reference blocks, the pattern of the area corresponding to the block on the expanded image data that is larger than the search reference block is the most similar to the pattern of the area corresponding to the search reference block. A third step of searching for similar blocks, and for each search reference block in the expanded shape data The process of replacing the data in response to region obtained by reducing the data of the region corresponding to each of the similar block, a fourth step and, the object image extraction method having a repeating until a predetermined condition is satisfied.
以上、本発明によれば、フラクタル法において、他の物体輪郭などのエッジが近くにある場合や物体領域が細い場合でも、物体の輪郭を正確に求めることができる。 As described above, according to the present invention, in the fractal method, the contour of an object can be accurately obtained even when the edge of another object contour or the like is near or the object region is thin.
以下、図面を参照して本発明の複数の実施形態についてそれぞれ説明する。 Hereinafter, a plurality of embodiments of the present invention will be described with reference to the drawings.
(各実施形態に共通な事項)
図40は本発明の各実施形態で用いるPC(パーソナルコンピュータ)やWS(ワークステーション)等の図である。各実施形態で用いるPCやWSは、マウス等のポインティングデバイスやキーボードやその他の外部機器(例えばデジタルカメラ)等の入力装置4007と、入力装置4007からの入力を受け付ける入力受付部4004、CRTやLCD等の画像表示装置4008とこれに画像信号を出力する画像出力部4006を備える。
(Matters common to each embodiment)
FIG. 40 is a diagram of a PC (personal computer), WS (workstation), etc. used in each embodiment of the present invention. The PC and WS used in each embodiment include an
また、各実施形態で用いるPCやWSは、ハードディスク等の磁気ディスクドライブ4002、メモリ4005、中央演算装置4001、光ディスクドライブ4003を備える。
The PC and WS used in each embodiment include a magnetic disk drive 4002 such as a hard disk, a memory 4005, a
本発明の各実施形態はいずれも、PC(パーソナルコンピュータ)あるいはWS(ワークステーション)上で動作させる物体画像抽出プログラムである。利用者は予め磁気ディスクドライブ4002に格納しておいたプログラムをメモリ4005に読み出してPCやWSに実行させる。 Each of the embodiments of the present invention is an object image extraction program that runs on a PC (personal computer) or WS (workstation). The user reads a program stored in advance in the magnetic disk drive 4002 into the memory 4005 and causes the PC or WS to execute it.
利用者は物体画像抽出プログラムを実行する前に、予め物体形状の抽出処理対象の画像データを取得して磁気ディスクドライブ4002に格納しておく。物体画像抽出プログラムは、実行時に、この画像データを磁気ディスクドライブ4002から読み出してメモリ4005に記憶させる。 Before executing the object image extraction program, the user acquires image data to be subjected to object shape extraction processing and stores it in the magnetic disk drive 4002 in advance. At the time of execution, the object image extraction program reads this image data from the magnetic disk drive 4002 and stores it in the memory 4005.
そして、表示装置4008に画像データを表示し、物体の概略形状を指定した概略形状のアルファマスクのデータを利用者にマウスを用いて入力してもらう。入力されたアルファマスクのデータもメモリ4005に記憶させておく。
Then, the image data is displayed on the
さらに、物体画像抽出プログラムは、画像データと概略形状のアルファマスクのデータをもとにして物体形状の抽出を行う。物体形状の抽出によって正確な形状のアルファマスクが生成され、これを抽出結果として出力する。 Further, the object image extraction program extracts the object shape based on the image data and the alpha mask data of the approximate shape. By extracting the object shape, an alpha mask having an accurate shape is generated and output as an extraction result.
輪郭抽出結果のアルファマスクは、PCやWSが備える磁気ディスクドライブ4002やメモリ4005に記憶させておく。そして、例えば画像中から物体の画像を切り出す他のプログラムや装置で用いる。 The alpha mask of the contour extraction result is stored in the magnetic disk drive 4002 or the memory 4005 provided in the PC or WS. For example, it is used in another program or apparatus that cuts out an image of an object from an image.
尚、PCやWSにカメラを接続して利用者が任意のタイミングで画像を取得できるようにしておいても良い。また、概略形状のアルファマスクのデータを背景差分法等を用いて自動的に生成するようにしても構わない。 Note that a camera may be connected to a PC or WS so that the user can acquire an image at an arbitrary timing. Further, the data of the substantially shaped alpha mask may be automatically generated using a background difference method or the like.
尚、以下の説明では探索基準ブロックをチャイルドブロックと呼び、探索基準ブロックより大きく(例えば縦横2倍)て、かつ、図柄が相似なブロックである相似ブロックをペアレントブロックと呼ぶ。 In the following description, the search reference block is referred to as a child block, and a similar block that is larger than the search reference block (for example, twice in the vertical and horizontal directions) and similar in design is referred to as a parent block.
(第1の実施形態)
本実施形態は、輪郭抽出対象物体の近くに他の物体輪郭などのエッジがある場合に、物体形状の抽出が正確に行えないことがあるのを改善するものである。
(First embodiment)
This embodiment improves that the object shape may not be accurately extracted when there is an edge such as another object contour near the contour extraction target object.
以下、図1のフローチャートを用いて本実施形態の処理を説明する。 Hereinafter, the processing of this embodiment will be described with reference to the flowchart of FIG.
(ステップ010)画像データと、概略形状のアルファマスクと、ラベルデータをメモリ上に準備する。 (Step 010) Image data, a substantially shaped alpha mask, and label data are prepared on a memory.
画像データは、例えば利用者が予めデジタルカメラ等で撮影してハードディスクに記憶させておいた画像データを読み出す。 As the image data, for example, image data that has been captured by a user with a digital camera or the like and stored in the hard disk is read out.
アルファマスクは、例えば利用者が画像表示装置に表示された画像データを見ながらマウスで指定して作成する物体の形状を表すデータである。アルファマスクは画像データと同じ画素数のデータで、物体が存在する場所は画素値1、存在しない場所は画素値0となっている。 The alpha mask is data representing the shape of an object created by the user specifying, for example, a mouse while viewing the image data displayed on the image display device. The alpha mask is data having the same number of pixels as the image data. The pixel value is 1 when the object is present and the pixel value is 0 when the object is not present.
ラベルデータはアルファマスクとは別の物体領域や背景領域に関する情報を表すデータであり、利用者が画像データを見ながらマウスを利用して指定して作成するものである。画素毎に、例えば、予め必ず背景や対象物以外の物体だと分かっている領域は非対象物体確定領域(背景確定領域)として各画素の画素値を0とし、予め物体だと分かっている領域は対象物体確定領域(物体確定領域)として各画素の画素値を1とし、背景か物体か未定の領域は未定領域として各画素の画素値を2とする。尚、ラベルデータの生成は、例えばアルファマスクを参照して、自動的に行っても良い。 The label data is data representing information related to an object region and a background region different from the alpha mask, and is created by a user using a mouse while viewing image data. For each pixel, for example, a region that is known to be an object other than the background or the object in advance is a non-target object determination region (background determination region), and the pixel value of each pixel is 0, and the region is known to be an object in advance. The pixel value of each pixel is set to 1 as the target object fixed region (object fixed region), and the pixel value of each pixel is set to 2 as the undefined region for the background or the object. The label data may be automatically generated with reference to, for example, an alpha mask.
(ステップ011)
アルファマスクの輪郭部分にチャイルドブロックCを設定する。本実施形態ではチャイルドブロックCは図7のように互いに重なり合うように設定するが、重ねずに接するように設定しても良い。設定したチャイルドブロックCの位置情報(例えば、左上角の座標と右下角の座標)をメモリに記憶しておく。
(Step 011)
Child block C is set in the contour portion of the alpha mask. In the present embodiment, the child blocks C are set so as to overlap each other as shown in FIG. 7, but may be set so as to contact each other without overlapping. The position information (for example, the coordinates of the upper left corner and the coordinates of the lower right corner) of the set child block C is stored in the memory.
(ステップ012)
各々のチャイルドブロックと相似なブロックであるペアレントブロックPをラベルデータと画像データを参照しながら見つける。
(Step 012)
A parent block P, which is a block similar to each child block, is found with reference to the label data and the image data.
まず、チャイルドブロックの近傍にペアレントブロック候補となる候補ブロックを設定する。そして、画像データ上で、チャイルドブロックの領域のパターンと候補ブロックとの領域のパターンとのラベルデータを参照して誤差を求める。 First, a candidate block that is a parent block candidate is set in the vicinity of the child block. Then, on the image data, the error is obtained by referring to the label data of the child block region pattern and the candidate block region pattern.
複数の候補ブロックについて誤差を計算し、誤差が最小となるものをペアレントブロックとする。候補ブロックはペアレントブロックと同じ画素数のブロックであるので、チャイルドブロックと候補ブロックとの誤差を求める際には、候補ブロックを縮小してチャイルドブロックと同じ画素数にして行う。 An error is calculated for a plurality of candidate blocks, and a block having the smallest error is defined as a parent block. Since the candidate block is a block having the same number of pixels as the parent block, when the error between the child block and the candidate block is obtained, the candidate block is reduced to have the same number of pixels as the child block.
ラベルデータを参照した誤差計算は次のようにして行う。例えば、利用者が図15の領域151の内側の物体を抽出しない領域として指定した場合、ラベルデータは、この内部が0の画素値(背景確定領域)、それ以外が2の画素値(未定領域)とする。そして、チャイルドブロックのある画素をXc、それに対応する縮小ブロックの画素をXpと表すとして、XcとXpの誤差を以下のように定義する。
The error calculation with reference to the label data is performed as follows. For example, if the user designates an area inside the
(1) XcとXpの両方が背景確定領域内の時は「XcとXpの誤差」を無視して「0」とする。 (1) When both Xc and Xp are within the background determined region, the “error between Xc and Xp” is ignored and set to “0”.
(2) XcとXpの両方が物体確定領域内の時も「XcとXpの誤差」を無視して「0」とする。 (2) Even when both Xc and Xp are within the object fixed region, the “error between Xc and Xp” is ignored and set to “0”.
(3) 前記(1)でも(2)でもないときは、「XcとXpの誤差」=「XcとXpの画素値の差の絶対値」とする。 (3) When neither (1) nor (2) is satisfied, “the error between Xc and Xp” = “the absolute value of the difference between the pixel values of Xc and Xp”.
このようにして求めたXcとXpの誤差をブロック内で加算し、その候補ブロックとチャイルドブロックの誤差とする。そして、最も小さい誤差が得られた候補ブロックをペアレントブロックとして決定する。そして、決定したペアレントブロックの位置情報をチャイルドブロックと対応付けてメモリに記憶しておく。 The errors of Xc and Xp obtained in this way are added within the block to obtain an error between the candidate block and the child block. Then, the candidate block with the smallest error is determined as the parent block. Then, the determined parent block position information is stored in the memory in association with the child block.
(ステップ013)
全てのチャイルドブロックに対するペアレントブロックが決定するまで、前記ステップ012を繰り返す。
(Step 013)
Step 012 is repeated until the parent blocks for all child blocks are determined.
(ステップ014)
アルファマスク上において、各々のチャイルドブロックに対応する領域のデータを、それに対応するペアレントブロックのデータをチャイルドブロックと同じ画素数に縮小したもので置き換える。
(Step 014)
On the alpha mask, the data of the area corresponding to each child block is replaced with the data of the parent block corresponding to the child block reduced to the same number of pixels as the child block.
(ステップ015)
全てのチャイルドブロックに対して、前記ステップ014を行う。これにより、アルファマスクの全てのチャイルドブロックが一度置き換えられたことになる。
(Step 015)
Step 014 is performed for all child blocks. As a result, all child blocks of the alpha mask are replaced once.
(ステップ016)
ステップ014とステップ015を再帰的に所定の回数繰り返す。これにより、アルファマスクの輪郭が物体の輪郭に漸近する。
(Step 016)
尚、ステップ12で誤差計算にあたっては、(1)と(2)のケースでは誤差を無視して0としたが、誤差を軽視、すなわち、0より大きくて1より小さい所定の係数を乗じても良い。あるいは、(1)と(2)のケースでは、誤差を無視して計算そのもの省略しても良い。
In the error calculation in
以下、従来のフラクタル法による物体形状の抽出例と本実施形態の物体形状の抽出例を比較を行う。 Hereinafter, an example of extracting an object shape by a conventional fractal method and an example of extracting an object shape according to the present embodiment will be compared.
他の物体が近くにある場合に、従来のフラクタル法を用いて物体形状の抽出を行った例を説明する。図9に示したチャイルドブロック091には、右下の船031の領域に加えて左上の船032の領域も含まれている。この場合、チャイルドブロック091と完全に相似な、つまり絶対値誤差が0となる候補ブロックは見つからない可能性が高いが、誤差が最小となる候補ブロックがペアレントブロックとして選ばれることになる。
An example will be described in which an object shape is extracted using a conventional fractal method when another object is nearby. The
船031を抽出するためには、ペアレントブロックには船031の領域に関して相似になるようなブロック093が選ばれるのが都合がよい。このようになれば、アルファマスクの輪郭は置き換え変換によって船031の輪郭に収束するからである。しかし、必ずしもブロック093が選ばれるとは限らない。
In order to extract the
図11(a)はチャイルドブロック091の周囲を拡大した図であり、ペアレントブロック候補のブロック093、船032の輪郭114、船031の輪郭115が示されている。尚、図11(a)では、ペアレントブロック候補のブロック093は、船031の輪郭115に関して相似になるように設定されている。
FIG. 11A is an enlarged view of the periphery of the
図11(b)には、チャイルドブロック091の画像パターン111、ブロック093を縮小した画像パターン112、および画像パターン111と画像パターン112の差分パターン113が示されている。
FIG. 11B shows an image pattern 111 of the
ここで、横線で塗った船032の領域及び船031の領域の画素値は同じ値とし、それら以外の領域は別の画素値で一定とする。差分パターン113では、画像パターン111と画像パターン112で画素値の誤差が生じる部分を黒く塗ってある。絶対値誤差はこの黒い領域の面積に比例する。
Here, the pixel values of the area of the
一方、図12(a)及び図12(b)は、ペアレントブロック候補であるブロック121が輪郭114に関して相似になるように設定した場合である。この場合の差分パターン122の黒領域の面積は図11(b)の差分パターン113よりも小さくなってしまう。この結果、図10のようにブロック121がペアレントブロックとして選ばれ、船031のアルファマスクの輪郭はこの部分については置き換え変換によって船032に近づいてしまうため、正しい輪郭が求まらない。
On the other hand, FIGS. 12A and 12B show a case where the
これに対し、ステップ012のようにラベルデータを用いて処理することにより、物体抽出に都合のよいペアレントブロックが選択される。このことを図3の原画像から図4のようなアルファマスクを生成する場合を例に説明する。
On the other hand, a parent block convenient for object extraction is selected by processing using label data as in
図5は物体の概略形状が与えられた状態であり、この概略形状のアルファマスクが図6である。そして、チャイルドブロックが配置された結果が図7である。 FIG. 5 shows a state in which a rough shape of an object is given, and FIG. 6 shows an alpha mask of this rough shape. FIG. 7 shows the result of arranging child blocks.
図13(a)はチャイルドブロック091の周辺を拡大した図である。輪郭114は船032の輪郭であり、輪郭115は船031の輪郭である。また、ペアレントブロック093は船031輪郭115に関して相似になるように配置されている。背景確定領域の境界線である背景確定領域ライン131の左上側が前述の図15で示した背景確定領域151である。
FIG. 13A is an enlarged view of the periphery of the
図13(b)はチャイルドブロック091の画像パターン132と、ペアレントブロック093の画像パターン133(チャイルドブロックと同じ大きさに縮小したもの)と、画像パターン132と画像パターン133の差分パターン134とを示した図である。
FIG. 13B shows an
尚、図13(b)では、画像パターン132及び画像パターン133には背景確定領域ライン131も示し、差分パターン134には、画像パターン132における背景確定領域と画像パターン133における背景確定領域の共通領域の境界ライン135も示した。
In FIG. 13B, the
図11(a)及び図11(b)で説明したように、従来、このようなペアレントブロックの配置では、左上側に多くの誤差が発生していた。しかし、本実施形態では、画像パターン132と画像パターン133においてどちらも背景確定領域である画素の誤差はゼロとしているため、差分パターン134の境界ライン135よりも左上側の領域には誤差が現れない。そのため、従来に比べて差分パターン134のようにブロック全体での誤差が小さくなる。
As described with reference to FIGS. 11A and 11B, in the conventional arrangement of such parent blocks, many errors have occurred on the upper left side. However, in the present embodiment, in both the
図14(a)及び図14(b)は、ペアレントブロックを図12(a)及び図12(b)と同様に、船032の輪郭114に関して相似になるように配置した場合の図である。この場合も図13のケースと同様にライン135の左上側の誤差がキャンセルされるが、元々ライン135の左上側には誤差がないので、全体としては図12のケースと同様に右下側の誤差が生じる。
FIGS. 14A and 14B are diagrams in the case where the parent blocks are arranged so as to be similar with respect to the
図13と図14とを比較すると、本実施形態では図13のケースの方が図14のケースよりも誤差が小さくなり、図13のケース、すなわち、輪郭115に関して自己相似になるようにペアレントブロックが選ばれるので、船031の輪郭が正しく抽出される。
Comparing FIG. 13 and FIG. 14, in this embodiment, the case of FIG. 13 has a smaller error than the case of FIG. 14, and the parent block so as to be self-similar with respect to the case of FIG. Is selected, the contour of the
本実施形態では、ラベルデータは利用者がマウスを利用して予め指定しておくとしたが、以下に説明するラベルデータを自動的に求める方法を利用してラベルデータを求めても良い。 In the present embodiment, the label data is specified in advance by the user using the mouse, but the label data may be obtained by using a method for automatically obtaining the label data described below.
また本実施形態では、ステップ014とステップ015を所定の回数繰り返すとしたが、繰り返しの条件は「回数」に限られない。例えば、ステップ015で置き換えを行う際にチャイルドブロックのアルファマスクとペアレントブロックのアルファマスクを縮小したものとの絶対値差分の和を計算し、絶対値差分の和が所定の閾値以下になるまで繰り返すようにしても良い。
In this embodiment,
(第1のラベルデータ生成方法)
例えば、予め、物体の色や背景の色が分かっている場合には、その色の領域をそれぞれ物体確定領域、背景確定領域とする方法もある。
(First label data generation method)
For example, when the color of an object or the color of a background is known in advance, there is a method in which the color areas are set as an object determination area and a background determination area, respectively.
この方法について、上述のように概略形状051が与えられた場合を例に説明する。
This method will be described by taking as an example the case where the
(1) 図37に示すように概略形状051を一定の幅Wで膨張させて形状371を求める。同様にして2Wの幅で膨張させて形状372を求める。
(1) As shown in FIG. 37, the
ここで、膨張とはモルフォロジーフィルタによる処理の一種であり、処理対象領域(ここでは物体領域)以外の画素を走査しながら、注目画素から一定の距離以内に処理対象領域がある場合にはその画素を処理対象領域に加える処理である。 Here, expansion is a type of processing by a morphological filter. When a pixel other than the processing target region (here, the object region) is scanned and the processing target region is within a certain distance from the target pixel, the pixel Is a process of adding to the processing target area.
(2) 概略形状051をWと2Wの幅で収縮させてそれぞれ形状373と形状374を求める。
(2) The
ここで、収縮もモルフォロジーフィルタによる処理の一種であり、処理対象領域の画素を走査しながら、注目画素から一定の距離以内に処理対象領域以外がある場合にはその画素を処理対象領域から除く処理である。 Here, contraction is also a type of processing by the morphological filter. When there is a region other than the processing target region within a certain distance from the target pixel while scanning the pixel of the processing target region, processing for removing the pixel from the processing target region It is.
(3) 形状371と形状372に挟まれた領域381(図38の斜線で示した領域)を背景色サンプリング領域とする。また、形状373と形状374にはさまれた領域382(図38の横線で示した領域)を前景色サンプリング領域とする。ここで、概略形状051から一定距離離れた部分から色をサンプリングするのは、概略形状が正しい形状とずれていることを考慮しているためである。
(3) A region 381 (region indicated by hatching in FIG. 38) sandwiched between the
(4) 元画像において背景色サンプリング領域にある画素の色をすべて取り出すことで背景色テーブルを作成する。また、同様にして前景色テーブルを作成する。 (4) A background color table is created by extracting all the colors of the pixels in the background color sampling area in the original image. Similarly, a foreground color table is created.
尚、全ての色を取り出すのではなく、一定数以上の画素が同じ色であった場合にその色を登録しても良い。 Instead of extracting all the colors, when a certain number of pixels are the same color, the colors may be registered.
(5) 背景色テーブルと前景色テーブルとを比較して、同じ色が登録されていたら、その色を両テーブルから除く。 (5) The background color table and the foreground color table are compared, and if the same color is registered, that color is removed from both tables.
(6) このようにして得られた2つの色テーブルを用いて元画像の各画素を走査する。そして、背景色テーブルにある色の画素を背景確定領域とし、前景色テーブルにある色の画素は物体確定領域とし、いずれのテーブルにない色の画素は未定領域としてラベルデータを作成する。 (6) Each pixel of the original image is scanned using the two color tables obtained in this way. Then, label data is created by setting the color pixel in the background color table as the background determination area, the color pixel in the foreground color table as the object determination area, and the color pixel not in any table as the undetermined area.
上記(1)〜(6)のようにすることで色の観点で背景や物体と推定できる領域をそれぞれの確定領域とすることができる。 By doing as said (1)-(6), the area | region which can be estimated as a background or an object from a viewpoint of a color can be made into each definite area | region.
尚、似た色を個別に登録するのではなく、予め元画像の色レベルを量子化してから色テーブルの作成、ラベルデータの作成を行うと扱う色数が減るので処理量を減らすことができ、処理の高速化に資する。 Rather than registering similar colors individually, if the color level is created beforehand and the label data is created after the color level of the original image is quantized in advance, the number of colors handled will be reduced and the amount of processing can be reduced. Contributes to faster processing.
(第2のラベルデータ生成方法)
画面内で局所的に色テーブルを作成し、それぞれ切換えながらラベルデータを作成すれば、局所的に最適化された情報が得られる。
(Second label data generation method)
Locally optimized information can be obtained by creating a color table locally on the screen and creating label data while switching between them.
局所的に色テーブルを作成する例としては、次のような方法が考えられる。例えば、図39に示したように、概略形状051に沿ってブロック391、392などを配置し、各ブロックの内部だけで前述した色テーブルを作成する。そして、ラベルデータを作成する際には各画素が属するブロックの色テーブルを用いて、背景確定、物体確定、未定のいずれかに決定する。その際、ブロック391と392とが重なっている部分では、まず、どちらかのブロックの色テーブルでラベルを決め、そのラベルが未定であったときには、他方の色テーブルでラベルを付け直す。
As an example of creating a color table locally, the following method can be considered. For example, as shown in FIG. 39, blocks 391, 392 and the like are arranged along a
(第3のラベルデータ生成方法)
景色テーブルや物体色テーブルの生成にあたっては、モルフォロジーフィルタを用いる代わりに、利用者が背景あるいは物体として画面を指示した画素の色を登録して生成する方法もある。
(Third label data generation method)
When generating a landscape table or an object color table, there is a method of registering and generating the color of a pixel instructed by the user as a background or object instead of using a morphological filter.
(第3のラベルデータ生成方法)
予め輪郭抽出対象の物体が写っていない背景画像が取得できている場合には、背景画像と現在の画像の差を求め、差が一定値以上の画素を物体確定とする方法もある。
(Third label data generation method)
In the case where a background image in which an object to be contour extracted is not captured can be acquired in advance, there is a method in which a difference between the background image and the current image is obtained and pixels whose difference is a certain value or more are determined.
(第4のラベルデータ生成方法)
概略形状の輪郭から一定の範囲内に正しい輪郭があると仮定できる場合には、概略形状の背景領域を収縮した結果を背景確定領域としたり、概略形状の物体領域を収縮した結果を物体確定領域とすることもできる。この方法ならば、処理対象領域の周囲が縮められる。
(Fourth label data generation method)
When it can be assumed that there is a correct outline within a certain range from the outline of the approximate shape, the result of contracting the background area of the approximate shape is used as the background determination area, or the result of contracting the object area of the approximate shape is the object determination area It can also be. With this method, the periphery of the processing target area is reduced.
(第5のラベルデータ生成方法)
概略形状の物体領域が必ず物体の全体を含むことが分かっている場合には、概略形状の背景領域をそのまま、あるいは、1〜2画素収縮したものを背景確定領域とする。一方、概略形状の物体領域を数画素、例えば、チャイルドブロックの1辺の画素数の1/2程度収縮した領域を物体確定領域とする。
(Fifth label data generation method)
When it is known that the object area of the approximate shape necessarily includes the entire object, the background area of the approximate shape is used as it is or the one contracted by 1 to 2 pixels is set as the background determination area. On the other hand, an object region having a substantially shaped shape is defined as an object determination region by contracting several pixels, for example, about ½ of the number of pixels on one side of a child block.
さらに、このようにして決めた物体確定領域や背景確定領域を領域成長法を用いて、広げても良い。逆に、概略形状の物体領域の全体が必ず物体に含まれる場合も同様である。 Furthermore, the object determination area and the background determination area determined in this way may be expanded using the area growth method. On the other hand, the same applies to the case where the entire object region having a substantially shape is always included in the object.
ここで、領域成長法とは、成長対象の領域の境界部分において領域内部と外部の画素値を比較し、画素値の差が一定値以下である場合には、外部の画素を領域内にとりこんでいくというものである。この処理を繰り返すことにより、画素値が近い部分が領域に取り込まれる。 Here, the area growth method compares the pixel values inside and outside the area at the boundary of the growth target area, and if the difference between the pixel values is less than a certain value, the outside pixel is taken into the area. It is to go. By repeating this process, a portion having a close pixel value is taken into the region.
(第6のラベルデータ生成方法)
利用者によって物体上の1点が入力されたときに、その点を起点として領域成長法により物体領域を求め、それを物体確定領域としてもよい。背景についても同様に領域成長法を用いて背景確定領域を設定できる。
(Sixth label data generation method)
When a point on the object is input by the user, the object region may be obtained by the region growth method using that point as a starting point, and may be used as the object determination region. Similarly, for the background, the background definite region can be set using the region growing method.
(ラベルデータの段階数)
ここまでのラベルデータ生成方法では、背景確定、物体確定、未定の3段階のデータを生成する例を述べたが、段階数を増やしてもよい。例えば、背景である確率が高いほどラベルデータの画素値を0に近づけ、物体である確率が高いほど画素値を255に近づけ、未定領域は画素値128に対応させるような段階付けが考えられる。
(Number of label data stages)
In the label data generation method so far, the example of generating the data of three stages of background determination, object determination, and undetermined has been described, but the number of stages may be increased. For example, the pixel value of the label data is brought closer to 0 as the probability of being the background is higher, the pixel value is brought closer to 255 as the probability of being the object is higher, and the undetermined region is considered to correspond to the pixel value 128.
何らかの方法で(例えば上述第1のラベルデータ生成方法における背景色サンプリングと物体色サンプリングの方法などにより)背景と物体の色を調べておく。そして、各画素が背景と物体の色のどちらに近いかに応じてラベルデータの画素値を決めてラベルデータを生成する。 The background and object colors are examined in some way (for example, by the background color sampling and object color sampling methods in the first label data generation method described above). Then, label data is generated by determining the pixel value of the label data according to whether each pixel is closer to the background or the color of the object.
このようにして生成したラベルデータを用いたペアレントブロック探索は、チャイルドブロックのある画素の画素値をXc、ペアレントブロック候補の縮小ブロックの画素の画素値をXp、「XcとXpの画素値の差の絶対値」をE、誤差計算用の重み係数をWとして、
「XcとXpの誤差」=W×E
を各画素毎に計算して和を求め、「XcとXpの誤差」が最小となるものをペアレントブロックとして採用する。
In the parent block search using the label data generated in this way, the pixel value of a pixel in the child block is Xc, the pixel value of the reduced block pixel of the parent block candidate is Xp, and the difference between the pixel values of Xc and Xp The absolute value of E is E, and the weighting coefficient for error calculation is W.
“Error between Xc and Xp” = W × E
Is calculated for each pixel to obtain the sum, and the one that minimizes the “error between Xc and Xp” is adopted as the parent block.
ここで重み係数Wは、
(A) XcとXpの両方のラベルデータの画素値が0にも255にも近くない場合には常に1に保つ。
Here, the weighting factor W is
(A) When the pixel values of both Xc and Xp label data are not close to 0 or 255, they are always kept at 1.
(B) XcかXpのいずれか一方のラベルデータの画素値が0に近い場合には、他方のラベルが小さいほど重み係数Wを1より小さくする。 (B) When the pixel value of one of the label data of Xc or Xp is close to 0, the weighting factor W is made smaller than 1 as the other label is smaller.
(C) XcかXpのいずれか一方のラベルデータの画素値が255に近い場合には、他方のラベルが大きいほど重み係数Wを1より小さくする。 (C) When the pixel value of one of the label data of Xc or Xp is close to 255, the weighting factor W is made smaller than 1 as the other label is larger.
このようにWを制御することで、物体である確率が高い画素同士や背景である確率が高い画素同士の誤差の影響を多段階で軽減できる。 By controlling W in this way, it is possible to reduce the influence of errors between pixels having a high probability of being an object and pixels having a high probability of being a background in multiple stages.
以上、本実施形態では、物体の輪郭抽出にあたってラベルデータというマスキング情報を用いることにより、複数の物体が近接している場合でも正確に輪郭を抽出できる。 As described above, in the present embodiment, by using the masking information called label data when extracting the contour of the object, the contour can be accurately extracted even when a plurality of objects are close to each other.
(第2の実施形態)
以下、本発明の第2の実施形態について図3と図26を用いて説明する。本実施形態は、複数の物体を個別に順次抽出するときに有効な実施形態である。尚、ここでは第1の実施形態と異なる部分を中心に説明する。
(Second Embodiment)
Hereinafter, a second embodiment of the present invention will be described with reference to FIGS. This embodiment is an embodiment that is effective when a plurality of objects are extracted sequentially one after another. Here, the description will focus on the parts different from the first embodiment.
図3に示した画像には船032と船031とが存在し、本実施形態ではこれらの輪郭を順次抽出する。ここではまず、船032は第1の実施形態で説明した方法で抽出し、それから船031を抽出する。
In the image shown in FIG. 3, there are a
図26は、第1の実施形態で説明した方法で抽出した船032の物体領域261を黒く塗りつぶした図である。この状況に対して、第1の実施形態と同様にして、図5のように概略形状を設定し、チャイルドブロックを図7のように配置する。
FIG. 26 is a diagram in which the
そして、チャイルドブロックのある画素の画素値をXc、それに対応する縮小ブロックの画素の画素値をXpとして、XcとXpの誤差の計算式を、
(1) XcあるいはXpのいずれか一方が領域261内のときは、「XcとXpとの誤差」=「0」
(2) 前記(1)に該当しない時は、「XcとXpとの誤差」=「XcとXpとの画素値の差の絶対値」
のように定義する。
Then, assuming that the pixel value of a pixel in the child block is Xc and the pixel value of the corresponding pixel in the reduced block is Xp, an equation for calculating an error between Xc and Xp is as follows:
(1) When either Xc or Xp is in the
(2) When the above (1) is not satisfied, “error between Xc and Xp” = “absolute value of the difference between pixel values of Xc and Xp”
Define as follows.
このように定義することで、図11における画像パターン112の左上の横線領域内では誤差がカウントされなくなり、ブロック093の誤差がゼロとなりこれがペアレントブロックとして選択される。すなわち、図9のチャイルドブロック091に対して船031の輪郭に関して相似なペアレントブロック093が求まるような誤差の計算式になる。
By defining in this way, the error is not counted in the horizontal line region at the upper left of the
以上、本実施形態によれば複数の物体の輪郭を順次抽出する際に、既に検出済みの物体の輪郭の情報を利用して検出済み物体をマスキングするので、複数の物体が近接している場合でも正確に物体の輪郭を抽出可能である。 As described above, according to the present embodiment, when the contours of a plurality of objects are sequentially extracted, the detected objects are masked using information on the contours of the already detected objects, so that the plurality of objects are close to each other. However, it is possible to accurately extract the contour of the object.
(第3の実施形態)
本発明の第3の実施形態について図面を参照して説明する。本実施形態は、従来、物体領域が細い場合に輪郭の検出が困難な場合があったが、これを解決するためのものである。尚、ここでは第1の実施形態と異なる部分を中心に説明する。
(Third embodiment)
A third embodiment of the present invention will be described with reference to the drawings. Conventionally, the present embodiment is intended to solve the problem that it is difficult to detect the contour when the object region is thin. Here, the description will focus on the parts different from the first embodiment.
従来のフラクタル法では、図16のチャイルドブロック161周辺のような物体形状が細い場合の物体抽出を行うことが困難である。
In the conventional fractal method, it is difficult to perform object extraction when the object shape is thin, such as around the
細い部分に配置されたチャイルドブロック161に対しては、完全に相似なペアレントブロックは存在しない。チャイルドブロック161に対しては、例えば、ブロック162がペアレントブロックとして選ばれる。
There is no completely similar parent block for the child block 161 arranged in the narrow portion. For the
このチャイルドブロック161とペアレントブロック162を用いて、概略形状051のアルファマスクに対してペアレントブロック162からチャイルドブロック161への置き換え変換を行うと、その度にこの部分の物体領域の幅が1/2になり、置き換え変換を繰り返し行うといずれ物体領域は消滅してしまう。
When the
本実施形態は上述の問題に対応することができるものである。以下、図2のフローチャートを用いて本実施形態における処理の流れを説明する。 This embodiment can cope with the above-mentioned problem. Hereinafter, the flow of processing in the present embodiment will be described with reference to the flowchart of FIG.
(ステップ020)
第1の実施形態のステップ010と同じ処理を行う。
(Step 020)
The same processing as in
(ステップ021)
概略形状のアルファマスクの輪郭部分に沿って、図7のようにチャイルドブロックを配置する。
(Step 021)
A child block is arranged along the outline portion of the substantially shaped alpha mask as shown in FIG.
(ステップ022)
ステップ021で配置されたチャイルドブロックのうち、物体の細い部分に配置されていると判定されたものを除去する。細い部分であるか否かの判定方法については後述する。
(Step 022)
Of the child blocks arranged in
(ステップ023)
ステップ022でキャンセルされなかったチャイルドブロックと相似なペアレントブロックを画像データを参照しながら見つける。本実施形態では、第1の実施例のようにラベルデータも参照しながら相似ブロックを求める。
(Step 023)
A parent block similar to the child block not canceled in
(ステップ024)
全てのチャイルドブロックに対するペアレントブロックを決定するまで、前記ステップ023を繰り返す。
(Step 024)
Step 023 is repeated until parent blocks for all child blocks are determined.
(ステップ025)
アルファマスク上で、各々のチャイルドブロックに対応する領域のデータを、それに対応するペアレントブロックの領域のデータをチャイルドブロックと同じ画素数に縮小したもので置き換える。
(Step 025)
On the alpha mask, the data of the area corresponding to each child block is replaced with the data of the area of the corresponding parent block reduced to the same number of pixels as the child block.
(ステップ026)
全てのチャイルドブロックに対して、ステップ025を行う。これにより、アルファマスクの全てのチャイルドブロック内部が一度置き換えられたことになる。
(Step 026)
Step 025 is performed for all child blocks. As a result, all child blocks in the alpha mask are replaced once.
(ステップ027)
ステップ025と026を再帰的に所定の回数繰り返す。これにより、アルファマスクの輪郭が物体の輪郭に漸近する。
(Step 027)
尚、本実施形態ではラベルデータを用いるとしたが必須ではない。従来と同じくラベルデータを用いなくても良い。 In this embodiment, label data is used, but it is not essential. It is not necessary to use label data as in the past.
このように処理することにより、細い物体部分ではチャイルドブロックが配置されないため、その部分が消滅するという不具合を多くの場合に回避できる。 By processing in this way, since the child block is not arranged in the thin object portion, the problem that the portion disappears can be avoided in many cases.
上記ステップ022における、物体の細い部分であるか否かの判定は、判定対象のチャイルドブロックのアルファマスクでの画素値を用いて行う。以下、具体的な処理方法を図18、図19、図20、図21、図22を用いて説明する。
The determination in
図18は16×16画素のチャイルドブロックのアルファマスクを拡大したものである。白い画素は物体を表し、黒い画素は背景を表す。 FIG. 18 is an enlarged view of an alpha mask of a child block of 16 × 16 pixels. White pixels represent the object, and black pixels represent the background.
このチャイルドブロックのアルファマスクに対して、左上端の画素から右上端の画素まで順に1画素ずつ走査して、画素値の変化の回数を数える。さらに、右上端の画素から右下端の画素、右下端の画素から左下端の画素、左下端の画素から左上端の画素と4辺を走査し、変化の回数を全て数え上げる。 The child block alpha mask is scanned one pixel at a time from the upper left pixel to the upper right pixel, and the number of pixel value changes is counted. Further, four sides are scanned from the upper right end pixel to the lower right end pixel, the lower right end pixel to the lower left end pixel, and the lower left end pixel to the upper left end pixel, and all the changes are counted.
このようにして求める変化回数は必ず偶数になる。そして、変化回数が4回以上である場合には、そこは物体の細い部分であると判定する。 The number of changes required in this way is always an even number. And when the frequency | count of a change is 4 times or more, it determines with there being a thin part of an object.
図18の場合、左上端の画素から右上端の画素までの走査と、右下端の画素から左下端の画素までの走査でそれぞれ黒から白、白から黒の2回ずつ変化し、変化回数は合計で4回となるので、細い部分であると判定される。 In the case of FIG. 18, the scanning from the upper left pixel to the upper right pixel and the scanning from the lower right pixel to the lower left pixel each change twice from black to white and from white to black. Since it is a total of 4 times, it is determined to be a thin portion.
チャイルドブロックは概略形状の輪郭に沿って配置されているため、このようにブロックの周囲を走査すると、細い部分でなければ通常は図21に示したような変化回数が2回のケースとなる。変化回数が2回の場合にはフラクタル法により抽出可能である。 Since the child block is arranged along the outline of the general shape, when the periphery of the block is scanned in this way, if it is not a thin portion, the number of changes as shown in FIG. 21 is usually two. When the number of changes is two, it can be extracted by the fractal method.
変化回数が2回よりも多い場合は、複雑な形状をしていたり細い部分であると推定される。複雑な形状の場合、フラクタル法では対応できないことが多い。 When the number of changes is more than 2, it is estimated that the shape is a complicated shape or a thin portion. In the case of complicated shapes, the fractal method often cannot cope.
図19に変化回数が6回、図20に変化回数が4回の例を示す。このようなケースでは、自己相似性がないため無理にフラクタル法を適用せずに、チャイルドブロックをキャンセルして概略形状をそのまま残すことにより、物体領域の消滅を回避した方が良いと考えられる。 FIG. 19 shows an example in which the number of changes is 6 and FIG. 20 shows an example in which the number of changes is 4. In such a case, since there is no self-similarity, it is considered better to avoid extinction of the object region by canceling the child block and leaving the approximate shape as it is without forcibly applying the fractal method.
図22に示したケースでは変化回数が0回となり、この場合は置き換え変換によりこの白い物体領域は消滅する。この小さい物体がノイズなどであり、消滅して構わない場合にはチャイルドブロックはこのまま残して構わないが、これが小さな物体であることが分かっている場合には、利用者がマウスで指定する等の手法で情報を与えてこのチャイルドブロックをキャンセルする。 In the case shown in FIG. 22, the number of changes is 0. In this case, the white object region disappears due to replacement conversion. If this small object is noise and can be eliminated, the child block can be left as it is, but if it is known that this is a small object, the user can specify it with the mouse, etc. Give this information to cancel this child block.
上述の例では、ステップ022でチャイルドブロックの4辺を走査した。この方法は簡便でよいのだが、細い物体部分の消滅を完全には回避できない。
In the above example, four sides of the child block are scanned in
例えば、チャイルドブロックのパターンは、図21(a)であっても、そのペアレントブロックが図20(a)であるような場合には、1回の置き換え変換でそのチャイルドブロックが上書きされ、置き換え変換の繰り返しによって物体領域は消滅してしまう。 For example, even if the child block pattern is FIG. 21 (a), if the parent block is the one shown in FIG. 20 (a), the child block is overwritten by one replacement conversion, and the replacement conversion is performed. The object region disappears by repeating the above.
このような状況を避けるには、とりあえずペアレントブロックを求め、そのペアレントブロックの4辺を走査してアルファマスクの画素値の変化回数を数える。そして、変化回数が2より大きい場合にはそのペアレントブロックとチャイルドブロックをキャンセルする。 In order to avoid such a situation, a parent block is first obtained, and four sides of the parent block are scanned to count the number of changes in the pixel value of the alpha mask. If the number of changes is greater than 2, the parent block and child block are canceled.
この場合のフローチャートを図23に示す。チャイルドブロックとペアレントブロックを除去するステップ234以外は図2と同じなので他のステップの説明は省略する。
A flowchart in this case is shown in FIG. Except for the
図17は、チャイルドブロック161とペアレントブロック162の位置関係の一例を表す図である。これまでに、チャイルドブロック161の4辺を走査する例とペアレントブロック162を走査する例を述べた。
FIG. 17 is a diagram illustrating an example of the positional relationship between the
この他に、チャイルドブロックと中心を共有しペアレントブロック162と同じ大きさのブロック163の4辺を走査して、同様に変化回数によって細い部分であるか否かの判定を行ってもよい。ブロック163であれば、ペアレントブロックの探索前に判定できるので処理量を削減できる。また、チャイルドブロック161を用いるよりもペアレントブロック162を用いた判定に近い結果が得られる。
In addition, the four sides of the
以上、本実施形態ではペアレントブロックの4辺の画素を走査して、ペアレントブロック内に含まれている物体の形状を推定した上で置き換え処理を行うか否かを決定しているので、物体の細い部分や複雑な形状の部分等の輪郭を残すことができる。 As described above, in this embodiment, the pixels on the four sides of the parent block are scanned, the shape of the object included in the parent block is estimated, and it is determined whether or not to perform the replacement process. It is possible to leave a contour such as a thin part or a part having a complicated shape.
(第4の実施形態)
置き換え変換の繰り返しによって消滅する物体領域は、ペアレントブロックの幅よりも細い形状の物体領域である。従って、物体領域の消滅を回避するには、概略形状の許容誤差は小さくなるが、ペアレントブロックとチャイルドブロックを小さくすれば良いと考えられる。
(Fourth embodiment)
The object region that disappears by repeating the replacement conversion is an object region having a shape narrower than the width of the parent block. Therefore, in order to avoid the disappearance of the object area, the tolerance of the schematic shape is reduced, but it is considered that the parent block and the child block should be reduced.
しかし、もともと、チャイルドブロックが例えば4×4画素というような小さなブロックの場合、これ以上小さくすると、解像度が粗くなり、自己相似性を利用するのに十分な画像パターンが得られなくなってしまう。 However, when the child block is originally a small block such as 4 × 4 pixels, if it is made smaller than this, the resolution becomes coarse and an image pattern sufficient to use self-similarity cannot be obtained.
そこで本実施形態では、ペアレントブロックのサイズを変えずに原画像と概略形状を拡大し、物体領域をペアレントブロックの幅よりも太くすることで消滅を回避する。そして、必要であれば、抽出結果のアルファマスクを元のサイズに縮小する。 Therefore, in this embodiment, disappearance is avoided by enlarging the original image and the schematic shape without changing the size of the parent block, and making the object region thicker than the width of the parent block. If necessary, the extracted alpha mask is reduced to the original size.
本実施形態のフローチャートを図27に示す。これまでの実施形態と異なるのは、処理の一番最初に原画像と概略形状を拡大するステップ271を行う点である。ステップ271における原画像の拡大は、例えば0次内挿、線形(1次)内挿、あるいは、もっと高次の画素内挿法を用いて行う。アルファマスクである概略形状の拡大には、例えば0次内挿を用いる。以降のステップは、これまでの実施形態と同様なので説明を省略する。
A flowchart of this embodiment is shown in FIG. The difference from the previous embodiments is that
以上、本実施形態では元画像を拡大して輪郭抽出を行うので、従来の輪郭抽出処理法では形状が消滅してしまう可能性が高い、物体の細い部分の輪郭であっても正確に抽出できるようになる。 As described above, in this embodiment, the contour is extracted by enlarging the original image. Therefore, the contour of a thin part of an object can be accurately extracted even if the shape is likely to disappear in the conventional contour extraction processing method. It becomes like this.
(第5の実施形態)
本実施形態は画像の端にある物体の輪郭を抽出するのに好適な輪郭抽出処理に関する実施形態である。
(Fifth embodiment)
This embodiment is an embodiment relating to a contour extraction process suitable for extracting the contour of an object at the edge of an image.
フラクタル法においては、原画像の外側に一定の幅をパディングした方が高い抽出精度が得られる場合がある。例えば、図24に示すように原画像241の中に斜線で示した部分に物体242があり、物体242の輪郭と多少ずれた概略形状243が与えられたとする。
In the fractal method, high extraction accuracy may be obtained by padding a certain width outside the original image. For example, as shown in FIG. 24, it is assumed that an
図24のように配置されたチャイルドブロック244の場合、概略形状243を物体242の輪郭に近づけるためには、ペアレントブロックは、その内部の画像パターンがチャイルドブロックと相似になるように、図示した位置のブロック245に配置するのが望ましい。
In the case of the child block 244 arranged as shown in FIG. 24, in order to bring the
ペアレントブロックの探索はチャイルドブロックを中心とした一定の範囲で行われるので、その範囲にブロック245があればよい。しかし、図24の場合はブロック245の右側が画像からはみ出してしまうため、ブロック245はたとえ探索範囲内であっても誤差評価が行われず、ペアレントブロックの候補から除かれる。そのため、チャイルドブロック244の部分ではペアレントブロックとして、図示したものとは別のブロックが選ばれ、輪郭が正確に求まらなくなってしまう。
Since the parent block search is performed within a certain range centered on the child block, it is sufficient that the
そこで、本実施形態では図25に横線で示した領域253のように、探索範囲となる可能性がある分だけ予め画像を外側に拡張しておく。これをパディングと呼ぶ。 Therefore, in the present embodiment, the image is expanded in advance to the extent that there is a possibility of becoming a search range, as in a region 253 indicated by a horizontal line in FIG. This is called padding.
本実施形態では、パディングの画素値は画像の最も外側の画素値で外挿し、パディングを行う位置と幅は以下のように決める。 In the present embodiment, the padding pixel value is extrapolated by the outermost pixel value of the image, and the position and width for padding are determined as follows.
概略形状の輪郭上にチャイルドブロックを配置することが予め分かっている場合、物体抽出に先立って、まず、概略形状243に外接する矩形251を求める。矩形251が求まれば、この内部を中心にチャイルドブロックが配置された場合に、ペアレントブロックの探索範囲となりうる部分の外枠252が決まる。
When it is known in advance that the child block is arranged on the outline of the approximate shape, a
外枠252の内部は、ペアレントブロックの探索時に候補ブロックとして誤差を計算する可能性がある。そこで、外枠252が画像241からはみでた幅だけパディングを行う。その際、画像241の左上側や右下側のように外枠252がはみだしていない部分のパディングは必要ないが、画像データを記憶させるためのメモリの容量に特に制限がない場合には、上下左右の全ての側に十分な幅のパディングを行ってもよい。このように画像の外側をパディングすることで、画像の端の近くの輪郭線を正確に抽出できない問題を回避できる。
The inside of the
図28は本実施形態の物体抽出処理のフローチャートである。いわゆるフラクタル法による物体抽出の最初にステップ281を実行してパディングを行う。他のステップは、これまでの実施形態と同様である。
FIG. 28 is a flowchart of the object extraction process of this embodiment. At the beginning of object extraction by the so-called fractal method,
以上、本実施形態では原画像の外側に所定の幅でパディングを設けることにより、画像の端に存在する輪郭の抽出を正確に行えるようになる。 As described above, in the present embodiment, by providing padding with a predetermined width outside the original image, the contour existing at the edge of the image can be accurately extracted.
(第6の実施形態)
本実施形態は概略形状と正しい形状のズレが大きい場合の輪郭抽出処理に関する実施形態である。
(Sixth embodiment)
The present embodiment is an embodiment relating to the contour extraction process when the difference between the approximate shape and the correct shape is large.
図30は、従来のフラクタル法では正しく物体輪郭を抽出できないケースの一例である。図30は、物体の輪郭301とその概略形状302と、概略形状302の輪郭上に中心がくるように配置したチャイルドブロックの一つであるチャイルドブロック303を示した図である。
FIG. 30 is an example of a case where an object contour cannot be correctly extracted by the conventional fractal method. FIG. 30 is a diagram showing a
チャイルドブロック303には物体輪郭301が含まれていないので、ペアレントブロックの探索ではチャイルドブロック303と相似なブロックとして、例えば、図31に示したブロック311が選ばれてしまう。このように、概略形状と正しい形状のズレが大きい場合には、物体の自己相似構造を抽出できず、その結果、物体の輪郭が正しく抽出されないことがある。
Since the
そこで、本実施形態ではペアレントブロックを先に配置する。これを図32と図33に示す。まず、図32のブロック321のように概略形状302の輪郭上に中心がくるようにペアレントブロックを配置する。そして、このペアレントブロックと相似な縦横1/2のブロックを探索する。
Therefore, in this embodiment, the parent block is arranged first. This is shown in FIG. 32 and FIG. First, the parent block is arranged so that the center is located on the outline of the
この場合、ブロック321の左下に物体輪郭301が含まれるので、このブロック321と相似な縦横1/2のブロックを探索すると図33ようにブロック331がチャイルドブロックとして選ばれる。
In this case, the
図29は本実施形態の輪郭抽出処理のフローチャートである。ステップ291〜ステップ293までがペアレントブロックを先に配置して相似なチャイルドブロックを探索する処理である。これ以降の置き換え処理は、先の実施形態のものと同様である。
FIG. 29 is a flowchart of the contour extraction process of the present embodiment.
(ステップ291)
アルファマスクの輪郭部分にペアレントブロックPを配置する。チャイルドブロックを配置する例を示した図7と同様、ペアレントブロックPの各々の中心を概略形状の輪郭が通り、隣り合うペアレントブロックは重なり合うよう配置する。
(Step 291)
The parent block P is arranged in the contour portion of the alpha mask. Similar to FIG. 7 showing an example of arranging child blocks, the outlines of the parent blocks P are arranged so that outlines of the outline shape pass, and adjacent parent blocks overlap.
(ステップ292)
ペアレントブロックPと相似なチャイルドブロックCを見つける。
(Step 292)
A child block C similar to the parent block P is found.
(ステップ293)
全てのペアレントブロックに対して前記ステップ292を行い、それぞれチャイルドブロックを決定する。
(Step 293)
Step 292 is performed on all parent blocks to determine child blocks.
以下は、これまでと同様な置き換え処理なので説明を省略する。 Since the following is a replacement process similar to the above, description thereof will be omitted.
以上本実施形態では、ペアレントブロックを先に概略形状の輪郭に配置し、後でチャイルドブロックを探索することので、チャイルドブロックを先に配置した場合よりも概略形状と正しい形状との間の許容誤差が大きくなるので、従来よりも物体の自己相似構造を抽出しやすくなる。その結果、物体が正しく抽出しやすくなる。 As described above, in the present embodiment, the parent block is first arranged on the outline of the approximate shape, and the child block is searched later, so that the allowable error between the approximate shape and the correct shape is higher than when the child block is arranged first. Therefore, it becomes easier to extract the self-similar structure of the object than before. As a result, the object can be easily extracted correctly.
(第7の実施形態)
本実施形態は物体領域と背景領域の中間状態も表すアルファマスクを得るのに好適な輪郭抽出処理に関する実施形態である。以下、本実施形態について説明する。
(Seventh embodiment)
This embodiment is an embodiment relating to a contour extraction process suitable for obtaining an alpha mask that also represents an intermediate state between an object region and a background region. Hereinafter, this embodiment will be described.
図36は本実施形態による輪郭抽出処理のフローチャートである。 FIG. 36 is a flowchart of contour extraction processing according to this embodiment.
(ステップ361)
図34に示すように、画像データ342及び概略形状のアルファマスク341を所定の倍率で拡大して、拡大画像データ344及び拡大アルファマスク343を生成する。本実施形態では拡大率は縦横2倍とする。
(Step 361)
As shown in FIG. 34, the
(ステップ362)
拡大画像データ344および拡大アルファマスク343に対し前述したフラクタル法の処理を行って、正確なアルファマスクを抽出する。ここで、アルファマスクの各画素の画素値は背景を0、物体を255とする。
(Step 362)
The fractal method described above is performed on the
(ステップ363)
フラクタル法により得られたアルファマスクを元のサイズに縮小して、画像データ342に対するアルファマスクを得る。
(Step 363)
An alpha mask for the
図35はステップ363の拡大アルファマスクの元サイズへの縮小処理を説明する図である。本実施形態では元サイズの画像を縦横2倍に拡大してフラクタル法の処理を行っているので、拡大アルファマスクの4つの画素353が縮小して得られるアルファマスクの画素352に対応する。本実施形態では、縮小して得られるアルファマスクの画素352の画素値には画素353の画素値の平均値を用いることとする。従って、縮小して得られるアルファマスクの各画素の画素値は4個の画素の平均値となる。 FIG. 35 is a diagram for explaining the reduction processing of the enlarged alpha mask to the original size in step 363. In the present embodiment, since the original size image is enlarged twice and vertically and the fractal method is performed, the four pixels 353 of the enlarged alpha mask correspond to the pixels 352 of the alpha mask obtained by reduction. In the present embodiment, the average value of the pixel values of the pixel 353 is used as the pixel value of the pixel 352 of the alpha mask obtained by reduction. Accordingly, the pixel value of each pixel of the alpha mask obtained by reduction is an average value of four pixels.
本実施形態では、拡大アルファマスクの各画素は、背景の場合は画素値0を与え、物体の場合は画素値255を与えておく。従って、縮小して得られるアルファマスクの各画素に対応する4個の拡大アルファマスクの画素のうち、物体画素が0個、1個、2個、3個、4個の場合、平均値はそれぞれ、0、64、128、192、255となる。 In this embodiment, each pixel of the enlarged alpha mask is given a pixel value of 0 for the background and a pixel value of 255 for the object. Therefore, among the four enlarged alpha mask pixels corresponding to each pixel of the alpha mask obtained by reduction, the average value is 0, 1, 2, 3, and 4, respectively. , 0, 64, 128, 192, 255.
図35では、画素352には物体画素が2個含まれるので画素352の画素値は128となる。また、画素354のように対応画素の値がすべて同じであれば、それらに対応する画素351はその値と同じになる。
In FIG. 35, since the pixel 352 includes two object pixels, the pixel value of the pixel 352 is 128. Further, if the values of the corresponding pixels are all the same as in the pixel 354, the corresponding
このようにして得られたアルファマスクの各画素の画素値を抽出物体を別の画像に合成するときの画素混合比率として用いることにより、輪郭線が与えるギザギザ感が改善された、より自然な合成画像を得ることができる。 By using the pixel value of each pixel of the alpha mask obtained in this way as the pixel mixture ratio when combining the extracted object with another image, the jagged feeling given by the contour line is improved and more natural composition An image can be obtained.
合成画像の画素値の計算式は、抽出物体が写っている画像の画素の画素値をX、その画素に対応するアルファマスクの値をA、合成相手となる別の画像による同じ位置の画素の画素値をYとすると、
「合成画像の画素値」=(A×X+(255−A)×Y)/255
のようなる。このように、アルファマスクの各画素の画素値は0を完全な透明、255を完全な不透明とした透明度を表したものと見なせる。
The calculation formula of the pixel value of the composite image is as follows: X is the pixel value of the pixel of the image in which the extracted object is shown, A is the value of the alpha mask corresponding to that pixel, and the pixel at the same position by another image to be combined If the pixel value is Y,
“Pixel value of composite image” = (A × X + (255−A) × Y) / 255
It becomes like this. In this way, the pixel value of each pixel of the alpha mask can be regarded as representing transparency with 0 being completely transparent and 255 being completely opaque.
なお、前述した拡大処理においては、画像データに対しては、例えば1次内挿、アルファマスクに対しては例えば0次内挿によって画素内挿を行う。また、例えばサムネイル画像と呼ばれる縮小画像のためのアルファマスクを生成するような場合には、元画像を拡大する必要は無く、元のサイズで0と255の値を持つアルファマスクを生成した後に前述した要領で縮小すれば良い。 In the above-described enlargement process, pixel interpolation is performed on the image data by, for example, first-order interpolation and for the alpha mask, for example, by zero-order interpolation. For example, when generating an alpha mask for a reduced image called a thumbnail image, it is not necessary to enlarge the original image, and after generating an alpha mask having values of 0 and 255 in the original size, You can reduce it as you did.
また、画像データと生成したアルファマスクとを用いて、例えば画像圧縮規格PNGやGIFなど、透明度に対応した画像を生成して保存しておけば汎用の物体画像となり、再利用が可能となる。 Further, if an image corresponding to transparency, such as image compression standards PNG and GIF, is generated and stored using the image data and the generated alpha mask, for example, it becomes a general-purpose object image and can be reused.
以上、本実施形態では元画像を拡大して輪郭抽出を行って得られる拡大アルファマスクを縮小してアルファマスクを生成する際に、拡大アルファマスクの複数の画素値を参照して求めた多段階の値をアルファマスクの各画素値として用いている。よって、物体を抽出する際にアルファマスクの画素値を透明度として用いることで、滑らかな物体の輪郭線を得ることが可能である。 As described above, in the present embodiment, when generating an alpha mask by reducing the enlarged alpha mask obtained by enlarging the original image and performing contour extraction, the multistage obtained by referring to the plurality of pixel values of the enlarged alpha mask Is used as each pixel value of the alpha mask. Therefore, by using the pixel value of the alpha mask as the transparency when extracting the object, it is possible to obtain a smooth contour line of the object.
031 輪郭抽出対象である船
032 船031の近くに写っている別の船
051 船031の概略形状
081、091、161、244、303、331 チャイルドブロック
082、093、121、162、245、311、321 ペアレントブロック
114 船032の輪郭の一部
115 船031の輪郭の一部
111、132 チャイルドブロック
112、133 縮小したペアレントブロック
113、122、134 差分
131、135 ラベルデータの境界線の一部
151 ラベルデータの境界
241 画像
242 物体
243 物体242の概略形状
253 パディング処理による拡張領域
301 物体輪郭の一部
302 概略形状の一部
031
Claims (3)
前記拡張したシェイプデータによって表される概略形状の輪郭に沿って、複数の探索基準ブロックを互いの位置をずらして設定する第2のステップと、
前記探索基準ブロック毎に、前記探索基準ブロックより大きくて、前記拡張した画像データ上におけるそのブロックに対応する領域の図柄が前記探索基準ブロックに対応する領域の図柄と最も相似した相似ブロックを探索する第3のステップと、
前記拡張したシェイプデータにおいて前記各探索基準ブロックに対応する領域のデータをそれぞれの相似ブロックに対応する領域のデータを縮小したもので置き換える処理を、所定の条件を満たすまで繰り返し行う第4のステップと、
を有する物体画像抽出方法。 Receiving image data including a target object to be extracted and shape data representing a region of a schematic shape of the target object in the image data, and at least one side of each of the image data and the shape data on each of the upper, lower, left and right sides of each image A first step of extending each outside a predetermined width,
A second step of setting a plurality of search reference blocks by shifting their positions along the outline of the schematic shape represented by the expanded shape data;
For each search reference block, a search is made for a similar block that is larger than the search reference block and whose pattern in the expanded image data is most similar to the pattern in the area corresponding to the search reference block. A third step;
A fourth step of repeatedly performing the process of replacing the data of the area corresponding to each search reference block with the reduced data of the area corresponding to each similar block in the expanded shape data until a predetermined condition is satisfied; ,
An object image extraction method comprising:
請求項1記載の物体画像抽出方法。 The pixel value of the expanded part extrapolates the pixel value of the outermost pixel of each image,
The object image extraction method according to claim 1.
請求項2記載の物体画像抽出方法。 Obtain a rectangle circumscribing the approximate shape of the target object, place a search reference block at the center of the rectangle, and determine an outer frame of a portion that can be a search range of the similar block.
The object image extraction method according to claim 2.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2008140592A JP2008243226A (en) | 2008-05-29 | 2008-05-29 | Object image extraction method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2008140592A JP2008243226A (en) | 2008-05-29 | 2008-05-29 | Object image extraction method |
Related Parent Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2002250058A Division JP4150554B2 (en) | 2002-08-29 | 2002-08-29 | Object image extraction method, object image extraction program |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2008243226A true JP2008243226A (en) | 2008-10-09 |
Family
ID=39914400
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2008140592A Abandoned JP2008243226A (en) | 2008-05-29 | 2008-05-29 | Object image extraction method |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2008243226A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2010224592A (en) * | 2009-03-19 | 2010-10-07 | Pioneer Electronic Corp | Object extraction device and method |
US9154772B2 (en) | 2011-09-26 | 2015-10-06 | Samsung Electronics Co., Ltd. | Method and apparatus for converting 2D content into 3D content |
WO2020004073A1 (en) * | 2018-06-28 | 2020-01-02 | ソニー株式会社 | Image processing device and method |
CN117911405A (en) * | 2024-03-19 | 2024-04-19 | 济南科汛智能科技有限公司 | X-ray image processing method for dental pulp and dental body detection |
-
2008
- 2008-05-29 JP JP2008140592A patent/JP2008243226A/en not_active Abandoned
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2010224592A (en) * | 2009-03-19 | 2010-10-07 | Pioneer Electronic Corp | Object extraction device and method |
US9154772B2 (en) | 2011-09-26 | 2015-10-06 | Samsung Electronics Co., Ltd. | Method and apparatus for converting 2D content into 3D content |
WO2020004073A1 (en) * | 2018-06-28 | 2020-01-02 | ソニー株式会社 | Image processing device and method |
CN117911405A (en) * | 2024-03-19 | 2024-04-19 | 济南科汛智能科技有限公司 | X-ray image processing method for dental pulp and dental body detection |
CN117911405B (en) * | 2024-03-19 | 2024-05-24 | 济南科汛智能科技有限公司 | X-ray image processing method for dental pulp and dental body detection |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP4806230B2 (en) | Deterioration dictionary generation program, method and apparatus | |
US8401333B2 (en) | Image processing method and apparatus for multi-resolution feature based image registration | |
Wenyin et al. | From raster to vectors: extracting visual information from line drawings | |
JP2984633B2 (en) | Reference image creation method and pattern inspection device | |
JP3950777B2 (en) | Image processing method, image processing apparatus, and image processing program | |
JP5854802B2 (en) | Image processing apparatus, image processing method, and computer program | |
JP2001175857A (en) | Reference image generating method, pattern inspecting device, and recording medium with recorded reference image generating program | |
JP2015232869A (en) | Image processor, image processing method and image processing program | |
US11410300B2 (en) | Defect inspection device, defect inspection method, and storage medium | |
JP2006065407A (en) | Image processing device, its method and program | |
JP2009212969A (en) | Image processing apparatus, image processing method, and image processing program | |
JP2008243226A (en) | Object image extraction method | |
JP2009049562A (en) | Image processing device, method, and program | |
JP5600524B2 (en) | Image processing apparatus, image processing method, program, and storage medium | |
US20220270232A1 (en) | Apparatus for adjusting parameter related to defect detection for image processing for image processing, method for information processing, and program | |
WO2013132836A1 (en) | Object detection device, object detection method, and object detection program | |
JP6323179B2 (en) | Object detection system and object detection method | |
JP4150554B2 (en) | Object image extraction method, object image extraction program | |
JP3749726B1 (en) | Low contrast defect inspection method under periodic noise, low contrast defect inspection method under repeated pattern | |
WO2009104325A1 (en) | Line drawing processing device, program, and line drawing processing method | |
US20110064314A1 (en) | Line segment extraction device | |
JP6118295B2 (en) | Marker embedding device, marker detection device, method, and program | |
JP2011176749A (en) | Image processing apparatus and method, and program | |
JP2002133424A (en) | Detecting method of inclination angle and boundary of document | |
JP2005303705A (en) | Image processing device and image processing method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A762 | Written abandonment of application |
Free format text: JAPANESE INTERMEDIATE CODE: A762 Effective date: 20100121 |