JP4300809B2 - Inspection apparatus and inspection method for granular object - Google Patents

Inspection apparatus and inspection method for granular object Download PDF

Info

Publication number
JP4300809B2
JP4300809B2 JP2003019456A JP2003019456A JP4300809B2 JP 4300809 B2 JP4300809 B2 JP 4300809B2 JP 2003019456 A JP2003019456 A JP 2003019456A JP 2003019456 A JP2003019456 A JP 2003019456A JP 4300809 B2 JP4300809 B2 JP 4300809B2
Authority
JP
Japan
Prior art keywords
reference points
region
digital image
point
points
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.)
Expired - Fee Related
Application number
JP2003019456A
Other languages
Japanese (ja)
Other versions
JP2004234132A (en
Inventor
オスカル バネガス
良介 三高
満 白澤
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Panasonic Corp
Panasonic Electric Works Co Ltd
Original Assignee
Panasonic Corp
Matsushita Electric Works Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Panasonic Corp, Matsushita Electric Works Ltd filed Critical Panasonic Corp
Priority to JP2003019456A priority Critical patent/JP4300809B2/en
Publication of JP2004234132A publication Critical patent/JP2004234132A/en
Application granted granted Critical
Publication of JP4300809B2 publication Critical patent/JP4300809B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Image Processing (AREA)
  • Image Analysis (AREA)
  • Length Measuring Devices By Optical Means (AREA)
  • Investigating Materials By The Use Of Optical Means Adapted For Particular Applications (AREA)
  • Medical Preparation Storing Or Oral Administration Devices (AREA)

Description

【0001】
【発明の属する技術分野】
本発明は、固形の薬剤のような粒状物体の外観検査を行う粒状物体の検査装置およびその検査方法に関するものである。
【0002】
【従来の技術】
一般に、医療現場において1回の服用時に複数種類あるいは複数個の薬剤を投与するように処方する場合には、患者が薬剤の種類や個数を間違えることを防止するために、1回分ずつの薬剤を硫酸紙や樹脂フィルムのような包装材により包装して分包として患者に提供するようになってきている。薬剤には用量を間違えたり混用して服用したりすると危険な薬もあるから、薬剤の仕分け作業は人手によって行わねばならないと法律によって定められているが、仕分け作業を誤る場合も考えられるから、薬剤を包装するための分包機には、包装する薬剤の種別および個数を検査する機能が要求される。
【0003】
この種の機能を実現するために画像処理を利用した各種検査装置が提案されている。たとえば、薬剤のような粒状物体の個数を計数する技術としては、薬剤が互いに接触しないよう間隔を開けて配置した状態で薬剤を撮像し、得られた画像二値化した後にラベリング処理を行ってラベリングされた領域の個数を計数する技術が知られている。しかしながら、この技術では、薬剤を互いに接触しないように間隔を開けて配置することを保証しなければならず、薬剤を分離して配置する装置が必要になったり、薬剤を分離して配置する作業が必要になったりするという問題がある。
【0004】
これに対して、二値化した画像の連結成分について輪郭線を追跡する際に輪郭線上の画素のつながり方向を表すチェインコードを記録し、チェインコードの変化によって薬剤同士の重なりによって生じる接点を抽出し、さらにペアとなる接点を作成するとともに、ペアとなる接点間を相互に連結する境界線によって個々の錠剤の画像に分断する技術が提案されている(たとえば、特許文献1参照)。
【0005】
また、包装された薬剤を透過照明を用いて撮像した画像から薬剤の存在部位に対応するマスクを形成し、さらにスリット光を斜め方向照射したときに生じる縞模様のうち薬剤部分のみの画像をマスクによって抽出し、縞模様の不連続点を薬剤の輪郭とみなす技術も提案されている(たとえば、特許文献2参照)。
【0006】
さらに、包装された薬剤にX線のような透過線を照射し、薬剤を透過線に対して相対的に移動させることによって透過線が薬剤を透過する際の透過量を透過線に対する薬剤の位置に対応付け、透過量の変化パターンによって薬剤の個数を計数する技術、透過線の透過量に基づいて薬剤の3次元形状を求め、事前に登録された正しい薬剤の寸法情報と照合することにより薬剤の個数・種別・異物混入・薬剤割れなどを検査する技術も知られている(たとえば、特許文献3参照)。
【0007】
【特許文献1】
特開平7−200770号公報(第4頁、図2)
【特許文献2】
特開平7−204253号公報(第2−3頁、図4−5)
【特許文献3】
特開2000−135268号公報(第7−8頁、第9頁、図10、46)
【0008】
【発明が解決しようとする課題】
上述した各特許文献に記載の技術を用いることによって複数個の薬剤が接触していても互いに別の薬剤と認識して計数することが可能になる。しかしながら、特許文献1に記載の技術では、クローバ型の錠剤や切り込みのある錠剤のように輪郭線にチェインコードの変化が大きい凹み部分が形成されるような薬剤では、1個の薬剤を複数個の薬剤に分割して認識する可能性があり、各薬剤を正しく分離できない場合がある。
【0009】
また、特許文献2に記載の技術では、2個の照明装置が必要であるから比較的高コストになるという問題があり、またスリット光を照射したときの画像が必要であって、半透明の包装材を用いる場合などでは薬剤に対応した正しい縞模様が得られないから包装材の種類に関する制限が多いという問題もある。
【0010】
さらに、特許文献3に記載の技術では、透過線に対して薬剤を相対的に移動させることになるから、比較的高コストになるという問題があり、特に薬剤の3次元形形状を用いる場合には、計測および照合に長い処理時間を要するという問題もある。
【0011】
本発明は上記事由に鑑みて為されたものであり、その目的は、簡単な装置で静止画像を撮像するだけで、複数個の粒状物体が接触した画像から種々形状の各粒状物体を分離することが可能である粒状物体の検査装置およびその検査方法を提供することにある。
【0012】
【課題を解決するための手段】
請求項1ないし請求項22の発明は粒状物体の検査装置に関する。
【0013】
請求項1の発明は、検査対象である粒状物体を含む撮像領域を撮像する撮像装置と、撮像装置により撮像された画像の濃度に関してデジタル化したデジタル画像を記憶するデジタル画像記億手段と、デジタル画像内において複数個の粒状物体に対応する領域が互いに接触しているときに各粒状物体に対応する領域を分割する機能を有した画像解析判定手段とを備え、デジタル画像解析判定手段は、デジタル画像において1個以上の粒状物体に対応する連続した領域である塊領域の輪郭線上または輪郭線の内側の近傍部位に複数個の参照点を分散して配置する機能と、すべての参照点同士を相互に連結した連結線分を生成したときにどの連結線分も塊領域の外を通らない参照点の組合せを1つのグループとしてすべての参照点にグループを対応付けるグループ化の機能と、参照点のグループと前記デジタル画像内における前記粒状物体の画像領域である個別領域とを一対一に対応付けることにより粒状物体に関する検査項目を検査する機能とを備えることを特徴とする。
【0014】
請求項2の発明は、請求項1の発明において、前記デジタル画像が、前記撮像装置により撮像された画像の濃度に関して二値化した二値画像であることを特徴とする。
【0015】
請求項3の発明では、請求項1または請求項2の発明において、前記デジタル画像解析判定手段は、前記個別領域のうち縦または横の幅寸法が最小である個別領域に前記参照点が少なくとも2個設定されるように参照点を配置することを特徴とする。
【0016】
請求項4の発明では、請求項1または請求項2の発明において、前記デジタル画像解析判定手段は、前記塊領域の輪郭線に対して規定した距離だけ内側に前記参照点を設定することを特徴とする。
【0017】
請求項5の発明では、請求項4の発明において、前記個別領域の輪郭線に生じる凹み部分に対して前記連結線分が前記個別領域の内側を通過するように、前記参照点と輪郭線との距離を設定することを特徴とする。
【0018】
請求項6の発明では、請求項1または請求項2の発明において、前記デジタル画像解析判定手段は、前記塊領域の輪郭線に沿って規定した間隔で前記参照点を設定することを特徴とする。
【0019】
請求項7の発明では、請求項1または請求項2の発明において、前記デジタル画像解析判定手段は、前記デジタル画像の画面内に一定間隔の格子点を設定し、前記塊領域の内側に位置する格子点を起点として複数の方向に輪郭線を探索するとともに、各格子点と輪郭線との距離が最短になる方向の線上に参照点を設定することを特徴とする。
【0020】
請求項8の発明では、請求項1または請求項2の発明において、前記デジタル画像解析判定手段は、前記デジタル画像の画面内に一定間隔の格子点を設定し、前記塊領域の内側に位置する格子点を起点として各格子点ごとに定めた1つの方向に輪郭線を探索するとともに、各格子点から輪郭線を探索する方向の線上に参照点を設定することを特徴とする。
【0021】
請求項9の発明では、請求項1または請求項2の発明において、前記デジタル画像解析判定手段は、前記塊領域の輪郭線の曲率が規定値より大きい部位の両側近傍の所定の距離に前記参照点を設定することを特徴とする。
【0022】
請求項10の発明では、請求項1または請求項2の発明において、前記デジタル画像解析判定手段は、前記塊領域の輪郭線の上の点である各輪郭点ごとに前記連結線分の上の点か否かを判定し、当該輪郭点が連結線分の上の点であるときには当該連結線分が塊領域の外側を通過すると判断することを特徴とする。
【0023】
請求項11の発明では、請求項1または請求項2の発明において、前記デジタル画像解析判定手段は、前記塊領域の輪郭線の上の点である各輪郭点の座標が前記連結線分の両端の参照点の間の座標であって、かつ当該輪郭点の座標を当該連結線分の式に代入して等式が成立するときに、当該連結線分が塊領域の外側を通過すると判断することを特徴とする。
【0024】
請求項12の発明では、請求項1または請求項2の発明において、前記デジタル画像解析判定手段は、前記塊領域の輪郭線の上に複数個の区分点を設定するとともに隣接する区分点間を結ぶ区分線分を設定し、前記連結線分と区分線分とが交差しているときに前記連結線分が前記塊領域の外側を通過すると判断することを特徴とする。
【0025】
請求項13の発明では、請求項1または請求項2の発明において、前記デジタル画像解析判定手段は、前記参照点ごとに他の参照点との間の連結線分が前記塊領域の内側のみを通過する本数を計数し、当該本数の少ない参照点から始めて、当該参照点との間の連結線分が塊領域の内側のみを通過する参照点をすべて抽出するとともに抽出したすべての参照点の組合せで連結線分が塊領域の内側のみを通るという条件を満たす参照点を前記グループとする処理を行い、当該処理をすべての参照点がいずれかのグループに属するようになるまで繰り返すことを特徴とする。
【0026】
請求項14の発明では、請求項1または請求項2の発明において、前記デジタル画像解析判定手段は、前記参照点の全組合せを行列要素とする正方行列に対して各参照点間の連結線分が前記塊領域の外側を通過するか否かを行列要素に対応付けて格納し、各参照点ごとに連結線分が塊領域の内側のみを通過している行列要素の個数を求め、当該個数の少ない参照点から始めて、当該参照点との間の連結線分が塊領域の内側のみを通過するすべての参照点の組合せからなる部分行列を前記正方行列から生成し、当該部分行列の行列要素のすべてで連結線分が塊領域の内側のみを通るという条件を満たすときに当該部分行列の要素である参照点を前記グループとし、グループとなった参照点を前記正方行列の行および列から除いた部分行列を生成する処理を行い、当該処理をすべての参照点がいずれかのグループに属するようになるまで繰り返すことを特徴とする。
【0027】
請求項15の発明では、請求項1または請求項2の発明において、前記デジタル画像解析判定手段は、前記塊領域の輪郭線に沿って異なるグループに属する2個の参照点を抽出し、当該2個の参照点の間の輪郭線において曲率が最大である部位を隣接する前記個別領域の境界線上の部位と判断することを特徴とする。
【0028】
請求項16の発明では、請求項2の発明において、前記デジタル画像解析判定手段は、前記塊領域の輪郭線の内側に背景と同じ画素値の領域が存在するときに穴領域として検出し、穴領域の輪郭線が滑らかに連続しているときに当該穴領域を埋めることを特徴とする。
【0029】
請求項17の発明では、請求項1または請求項2の発明において、前記デジタル画像解析判定手段は、前記塊領域における輪郭線の近傍の画素を除去する縮小処理を行った後に前記参照点を設定することを特徴とする。
【0030】
請求項18の発明では、請求項1または請求項2の発明において、前記デジタル画像解析判定手段は、前記個別領域の形状に関する特徴量を用いて粒状物体の種別を判断するとともに、粒状物体の種別ごとの個数の計数と粒状物体の種別の間違いの判断の少なくとも一方を前記検査項目として検査することを特徴とする。
【0031】
請求項19の発明では、請求項1または請求項2の発明において、前記デジタル画像解析判定手段は、検査対象となる粒状物体のテンプレートに前記個別領域をパターンマッチングすることにより粒状物体の種別を判断するとともに、粒状物体の種別ごとの個数の計数と粒状物体の種別の間違いの判断と粒状物体の良否判定との少なくとも1つを前記検査項目として検査することを特徴とする。
【0032】
請求項20の発明は、検査対象である粒状物体を含む撮像領域を撮像する撮像装置と、撮像装置により撮像された画像の濃度に関してデジタル化したデジタル画像を記憶するデジタル画像記億手段と、デジタル画像内において複数個の粒状物体に対応する領域が互いに接触しているときに各粒状物体に対応する領域を分割する機能を有した画像解析判定手段とを備える検査装置により粒状物体に関する検査項目を検査する粒状物体の検査方法であって、デジタル画像解析判定手段では、デジタル画像において1個以上の粒状物体に対応する連続した領域である塊領域の輪郭線上または輪郭線の内側の近傍部位に複数個の参照点を分散して配置した後、すべての参照点同士を相互に連結した連結線分を生成したときにどの連結線分も塊領域の外を通らない参照点の組合せを1つのグループとしてすべての参照点にグループを対応付けるグループ化を行い、次に、参照点のグループと前記デジタル画像内における前記粒状物体の画像領域である個別領域とを一対一に対応付けることにより粒状物体に関する検査項目を検査することを特徴とする。
【0033】
本発明の検査装置は、透過照明または落射照明などの比較的簡単な照明を用いかつ静止画像を撮像するだけであるから、特殊かつ高価な装置を用いることなく、汎用的かつ安価な機器によって構成することが可能になる。しかも、複数個の粒状物体が接触している場合でも各粒状物体に一対一に対応したグループを生成することができるから、粒状物体の個数を計数することは容易であり、さらには粒状物体の分離に際して連結線分が塊領域の外側を通るか否かの判断を用いるから、連結線分の端点となる参照点の位置を適宜に設定すれば、大きさや形状が異なっていたり多少の凹み部分を持っていたりする粒状物体が混在していても、粒状物体を正しく分離して個数の計数が可能になる。また、透過照明を用いることによって粒状物体を包む包装材が透明ではなく半透明であるような場合でも本発明の技術を適用できる。
【0034】
【発明の実施の形態】
以下に説明する各実施形態では、図1に示す装置を用い、撮像装置1により撮像した画像信号の濃淡情報に関する信号値を適宜の閾値で二値化した二値画像により粒状物体2の認識を行う。ただし、画像信号を二値化せずにA/D変換によって多値化することによって濃淡画像を生成してもよい。濃淡画像を用いると微分処理などを適用することが可能であるから、認識精度を向上させることが可能である。また、検査台3に載置した粒状物体2に光を照射するにあたって、検査台3に対して撮像装置1の反対側から光を照射する透過照明用の照明装置4を用いる例を示すが、粒状物体2として白色の粒状物体を黒色の検査台に載せる場合のように粒状物体の色が背景色とは明確に区別できる場合には、検査台3に対して照明装置1と同じ側から光を照射する落射照明用の照明装置を採用することも可能である。さらに、粒状物体2の例として錠剤やカプセルのような固形の薬剤を示すが、他の粒状物体であっても輪郭線の形状の認識に本発明の技術を適用可能である。
【0035】
図1に示す装置は、認識の対象物である粒状物体としての薬剤2を載置する検査台3を備え、検査台3の上方には薬剤2を撮像するためにTVカメラからなる撮像装置1が配置される。検査台3は半透明の合成樹脂板であって拡散透過性を有しており、検査台3の下方には検査台3を全面に亘って輝度むらなく照明することができる照明装置4が配置される。つまり、薬剤2が検査台3に載置されていない状態において検査台3には輝度むらが生じないことが望ましいから、照明装置4において輝度むらを生じない構成を採用するとともに、検査台3に拡散透過性を持たせることによって、輝度むらを抑制している。
【0036】
撮像装置1により撮像される画像は、薬剤2が不透明であれば薬剤2に対応する部位が暗く薬剤2の背景が明るくなるから薬剤2のシルエットを含む画像になり、薬剤2が透明であれば、薬剤2の中央部が厚く、周辺部ほど薄くなっている形状を透過する光の屈折作用により、薬剤2の中央部が明るく周辺部が暗い画像になる。ここに、透明な薬剤2としては、ゼリー状の薬剤2や内部に液体を封じたカプセル状の薬剤2などがある。このように、薬剤2が不透明か透明かにかかわらず、薬剤2の輪郭と背景との間には比較的大きな輝度差が生じるから、撮像装置1から出力される画像信号の濃淡情報に関する信号値を二値化手段11を用いて適宜の閾値で二値化することにより、錠剤2の輪郭と背景とを分離することが可能になる。撮像装置1から出力された画像信号を二値化手段11で二値化することにより得られる二値画像は、画素値が0と1との二値のみからなるデジタル画像であるから、このデジタル画像はRAMからなるデジタル画像記憶手段12に格納される。デジタル画像記憶手段12は、二値画像の記憶だけではなく後述する各種画像処理の際の作業用の記憶領域としても用いられる。デジタル画像記憶手段12に格納された二値画像はマイクロコンピュータからなるデジタル画像解析判定手段13に入力され、以下の各実施形態において説明する処理が施されることによって、薬剤2の形状、寸法、個数の認識が行われる。デジタル画像解析判定手段13には、CRTや液晶ディスプレイからなるモニタ装置14が接続され、モニタ装置14には、撮像装置1で撮像した画像、二値化手段11で二値化した二値画像、デジタル画像解析判定手段13による認識結果などを表示することが可能になっている。
【0037】
なお、以下に説明する実施形態では、組み合わせるべき複数個の薬剤2を検査台3の上に載置し、撮像装置1により撮像される複数個の薬剤2の画像から検査台3の上の薬剤2が正しい組合せか否かを判断するのであって、組み合わせるべき薬剤2は最終的には包装材によって1包みに包装される。ここで、包装材が透明ないし半透明であって薬剤2を撮像装置1により撮像したときに包装材による包装を行っていない場合と同様の画像を得ることが可能である場合には、あらかじめ包装材で包装した薬剤2を検査台3に載置することも可能である。
【0038】
以下では具体例を用いて本発明の実施形態におけるデジタル画像解析判定手段13の動作を説明する。ここでは、図3(a)に示すように、薬剤2として、円形の錠剤T1、楕円形の糖衣錠T2、カプセルT3、クローバ型の錠剤T4、長円形の錠剤T5の5個の薬剤2を検査台3に載置する場合を想定する。なお、薬剤2の各形状は平面形状である。上述したように、透過照明を行うから撮像装置1により撮像された画像内では5個の薬剤2に対応する部位は暗くなり薬剤2の背景は明るくなる。つまり、撮像装置2から出力される画像信号においては薬剤2のシルエットが得られる。
【0039】
二値化手段11では撮像装置2から出力される画像信号の濃淡情報に関する信号値を適宜の閾値で二値化するから、たとえば閾値よりも暗い部位の画素値を0とし、閾値よりも明るい部位の画素値を1とすれば、二値画像では薬剤2に対応する部位の画素値が0、薬剤2に対応しない部位の画素値が1になる。図示例では錠剤T1,T2,T4がいずれもカプセルT3に接触しているから、二値画像では、図3(b)のように、錠剤T1,T2,T4とカプセルT3とに対応する連続した1つの領域(以下では、「塊領域」という)D1が形成され、個々の錠剤T1,T2,T4とカプセルT3とを区別することができなくなる。一方、個々の薬剤2を画像によって認識するには、塊領域D1から個々の薬剤2を分離することが必要である。なお、錠剤T5は単体で1つの塊領域D2を形成する。要するに、塊領域は二値画像において、8近傍(3×3画素の領域の中心の画素に着目したときの残りの画素)のうちのいずれかの画素値が0である画素の集合であって、8近傍のすべての画素値が1である画素によって区分されている領域になる。
【0040】
そこで、複数の薬剤2が接触している場合に二値画像内で形成される塊領域D1から個々の薬剤2を分離して認識するために、本実施形態ではデジタル画像解析判定手段13において以下の処理を行っている。すなわち、二値化手段11において二値化されることにより得られた二値画像について、まず塊領域D1,D2の輪郭線の近傍における適宜の画素を参照点に設定する。参照点は塊領域D1,D2の輪郭線の上の部位、または輪郭線に対して数画素内側の部位に設定される。
【0041】
ここに、図4(a)に示すように、図形I1の輪郭線に凹みがなければ、輪郭線の近傍に設定したすべての参照点P1〜P5について、参照点P1〜P5の間を相互に結ぶ線分である連結線分s(1−2),s(1−3),……,s(4−5)は図形I1の内側に存在するという法則が一般に成立する。なお、連結線分s(m−n)は、参照点Pmと参照点Pnとの間を結ぶ線分を意味する。上述した法則は輪郭線に若干の凹みがあったとしても凹みが大きくなければ多くの場合に成立するが、図4(b)に示すように、図形I2の輪郭線に比較的大きい凹みがあれば、参照点P1〜P6のうちのいずれかについて、連結線分s(1−2),s(1−3),……,s(5−6)が図形I2の外側を通ることになる。以下の説明では、図形の輪郭線の近傍に設定した参照点の間を結ぶ連結線分が図形の内部のみを通る場合に、当該連結線分の端点である2つの参照点は「領域内連結性」を有するといい、参照点の間を結ぶ連結線分が一部でも図形の外側を通る場合には2つの参照点は「領域内連結性」を持たないという。ここにおいて、一般的な薬剤2の輪郭線には大きな凹みはないが、図3(a)に示すクローバ型の錠剤T4や、半分に割って服用可能な切り込みを有する錠剤のように、若干の凹みを有した薬剤2もあるから、この種の薬剤2における凹み部分が領域内連結性の有無の判断に影響しないように、既知の凹み部分の形状や寸法に応じて輪郭線よりも内側に参照点を設定するのである。
【0042】
本実施形態では、上述した領域内連結性の有無を利用することによって、図3(b)に示した二値画像における塊領域D1,D2から個別の薬剤2に対応する領域(以下では、「個別領域」という)E1〜E5を分離する処理を行う。つまり、図5に示すように、各個別領域E1〜E5に複数個ずつの参照点P1〜P13が設定されるような設定方法で参照点P1〜P13を設定し、連結線分s(1−2),s(1−3),……,s(12−13)のうち塊領域D1,D2の内側のみを通る連結線分s(1−3),s(1−5),s(2−6),s(2−8),s(3−5),s(4−9),s(6−8),s(7−10),s(7−11),s(10−11),s(12−13)を抽出する。抽出した連結線分s(m−n)の両端点となる参照点P1〜P13は領域内連結性を有しており、領域内連結性を有する2個の参照点P1〜P13は1つの個別領域E1〜E5に含まれる。ここで、領域内連結性を有する各参照点P1〜P13のうち同じ個別領域E1〜E5に属するもの同士をグループ化すれば、グループG1〜G5の個数が個別領域E1〜E5の個数に一致する。
【0043】
グループ化に際しては、領域内連結性を有する参照点P1〜P13であって他の連結線分s(m−n)と共用される参照点P1〜P13を抽出する。このような参照点P1〜P13を端点に持つ連結線分s(m−n)は1つの個別領域E1〜E5に属することになる。上述の例で言えば、参照点P1,P3,P5は、連結線分s(1−3),s(1−5),s(3−5)のうちの各2本でそれぞれ共用されているのであって、参照点P1,P3,P5は1つのグループG1になり、参照点P1,P3,P5のグループG1に対応する個別領域はE4になる。また、参照点P4,P9は、連結線分s(4−9)のみの端点になっているが、領域内連結性を有しているから1つのグループG2になる。参照点P4,P9のグループG2に対応する個別領域はE1になる。同様にして、参照点P7,P10,P11のグループG3は個別領域E3に対応し、参照点P12,P13のグループG4は個別領域E2に対応し、参照点P2,P6,P8のグループG5は個別領域E5に対応する。このようにして、図5に示す例では、参照点(P1,P3,P5)のグループG1、参照点(P2,P6,P8)のグループG2、参照点(P4,P9)のグループG3、参照点(P7,P10,P11)のグループG4、参照点(P12,P13)のグループG5の5個のグループに分離することが可能になる。つまり、塊領域D1,D2を5個の個別領域E1〜E5に分離することが可能になる。
【0044】
上述した手順における各処理過程についてさらに詳しく説明する。上述したように、二値画像における塊領域から個別領域を分離するには、まず塊領域の輪郭線の近傍である適宜の位置に参照点を設定することが要求される。参照点は基本的には分離しようとする各個別領域ごとに複数個ずつ必要であるが、塊領域のどの部位が個別領域になるかは不明であるから、参照点の位置を決める処理は個別領域の分離において重要な処理になる。
【0045】
参照点を設定する第1の技術としては、塊領域Dの輪郭線Lを抽出する輪郭線追跡を行い、図6に示すように、輪郭線追跡の際に輪郭線Lの上で所定画素の間隔で仮参照点p1〜p13を設定し、さらに各仮参照点p1〜p13を通る輪郭線Lの法線上で輪郭線Lの内側に処理距離だけ離れた部位にそれぞれ参照点P1〜P13を設定する技術がある。輪郭線追跡の技術は周知であるが、簡単に説明すると、まず二値画像内でラスタ走査を行うとともに画素値が背景から塊領域Dに変化する変化点を求める。ここで、二値画像内では隣接する画素値が1から0に変化する点が変化点になるから、輪郭線Lとしては画素値が0である点とする。このようにして最初に得られた画素を追跡開始点とし、追跡開始点から、たとえば時計回りに輪郭線L上の画素を追跡する。輪郭線Lの追跡は周知技術を用いる。輪郭線Lを追跡する技術の一例を示すと、輪郭線Lを時計回りに追跡する場合であれば、輪郭線Lの上で着目する画素の8近傍の画素のうちで追跡済みの画素に対して時計回りに隣接する画素から始めて時計回りに並ぶ各画素の画素値を求め、着目する画素と同じ画素値の画素が出現すれば、当該画素を次に追跡する画素とする。たとえば、着目する画素(画素値は0になる)に対して左隣りの画素が前に追跡した画素であるものとし、着目する画素の8近傍のうち左上および上の画素が着目する画素とは異なる画素値(つまり、画素値は1になる)であるとすれば、次に追跡する画素は右上の画素になる。このような処理を繰り返し、追跡開始点に戻れば、輪郭線Lの追跡が終了する。輪郭線Lを追跡する技術として、上述の技術は一例であって、他の周知技術を用いることができるのは言うまでもない。
【0046】
輪郭線Lを追跡する際には輪郭線Lの上の画素を1画素ずつ辿ることになるから、輪郭線Lの上の画素を規定した画素ごとに仮参照点p1〜p13として設定し、仮参照点p1〜p13を通る輪郭線Lの法線上で規定の画素数分(たとえば、3〜5画素)だけ塊領域Dの内側に参照点P1〜P13を設定する。輪郭線Lの法線の方向は、たとえば仮参照点p1〜p13の8近傍の画素の画素値から求めた微分値を正接とする方向であって塊領域Dの内向き方向として求めることができる。上述のように輪郭線Lよりもやや内側に参照点P1〜P13を設定することによって、輪郭線Lに多少の凹みがあっても参照点P1〜P13を結ぶ連結線分s(m−n)が塊領域Dの外に出る可能性を低減することができる。つまり、個別領域が輪郭線Lに凹みを有する形状であっても個別領域を分離できる可能性が高くなる。したがって、仮参照点p1〜p13と参照点P1〜P13との距離は、分離すべき個別領域の輪郭線Lの形状(つまりは、薬剤2の形状)に応じて適宜に設定される。第1の技術においては、塊領域Dの輪郭線Lの全長は不明であるから、輪郭線Lの上を追跡する際に規定した画素ごとに仮参照点p1〜p13を設定すると、輪郭線Lを1周したときの最後の仮参照点と最初の仮参照点とは他の仮参照点の間隔とは異なる可能性があるが、仮参照点を等間隔に設定しているのは仮参照点を適宜に分散させるためであって、必ずしも等間隔である必要はないから、一部の仮参照点の間隔にずれがあることは動作に影響しない。
【0047】
参照点を輪郭線Lの近傍に設定する第2の技術として、輪郭線Lの上の画素を追跡しない技術を採用することもできる。すなわち、図7に示すように、二値画像において一定の間隔の格子GRを設定し、二値画像内の格子点q1〜q12のうち塊領域D1の内側に存在する格子点q3,q4,q5,q7,q8,q9,q10について、図8に示すように、それぞれ有限個の方向(図示例では8方向)について輪郭線Lとの交点を探索する。このようにして求めた交点のうち各格子点q3,q4,q5,q7,q8,q9,q10にもっとも近い交点を仮参照点とし、各仮参照点の近傍であって塊領域Dの内側にそれぞれ参照点P3,P4,P5,P7,P8,P9,P10を設定する。参照点P3,P4,P5,P7,P8,P9,P10は、仮参照点を探索する方向の線上で仮参照点に対して規定した画素分だけ塊領域Dの内側に設定する。このように格子GRを利用する技術を採用すると、輪郭線Lを追跡する場合に比較すると、塊領域Dの輪郭線Lの上のすべての点を抽出する必要がないから、データの処理量が少なくなり参照点の決定に要する時間を短縮することが可能になる。
【0048】
上述した第2の技術では、各格子点q1〜q12についてそれぞれ8方向について輪郭線Lとの交点を仮参照点として探索しているが、図9のように塊領域Dの内側に存在する格子点q3,q4,q5,q7,q8,q9,q10ごとに決めた1方向についてのみ輪郭線Lとの交点を仮参照点として探索してもよい。この場合、各格子点q3,q4,q5,q7,q8,q9,q10のラスタ走査の順で探索方向を時計回りに90度ずつ回転させるなどすればよい。たとえば、図示例では格子点q3,q4,q5,q7,q8,q9,q10の順に探索方向が上、右、下、左、上、右、下になる。この技術を用いれば、上記の各格子点q1〜q12についてそれぞれ8方向に探索することが不要となり、処理時間の短縮化が図れるとともに各格子点q3,q4,q5,q7,q8,q9,q10に対応する参照点P3,P4,P5,P7,P8,P9,P10を適度に分散させて決定することができる(なお、図中では格子点q5,q10に対応する参照点P5,P10は図外になるので示していない)。
【0049】
本実施形態では、2個ずつの参照点の領域内連結性の有無によって個別領域を分離するから、異なる個別領域に含まれる参照点同士には領域内連結性がないほうが望ましい。つまり、連結線分が個別領域同士の接触部分を通過しないように参照点を配置することが望ましく、このことから個別領域同士の接触部分の近傍に参照点を配置することが望ましいと言える。そこで、塊領域Dの輪郭線Lを抽出し、この輪郭線Lの各部位の曲率を求めるとともに、図10に示すように、輪郭線Lの曲率が規定した閾値を超える部位C1〜C7は個別領域同士が接触している部位の候補であると判断して、当該部位C1〜C7に対して規定の関係となる近傍部位に参照点P1〜P14を設定してもよい。各部位C1〜C7に対しては2個ずつの参照点P1〜P14を設定するのであって、各部位C1〜C7ごとにその両側近傍の所定の距離範囲の輪郭線部分を円弧で近似し、その円弧の略中央から曲率中心方向に向けて法線を立て、この法線上で輪郭線Lから塊領域Dに規定した距離だけ内側の部位に参照点P1〜P14を設定する。このようにして各部位C1〜C7ごとに2個ずつの参照点P1〜P14が設定されるのであって、曲率が大きい部位C1〜C7(図示例では部位C1,C2,C7)では参照点P1〜P14(図示例では参照点P1,P2,P3,P4,P13,P14)を結ぶ連結線分が塊領域Dの外側を通るから、個別領域E1〜E5の分離が容易になる。
【0050】
なお、参照点の個数については、仮に個別領域が独立している場合には各個別領域に1個ずつ参照点を設定すればどの参照点間にも領域内連結性が生じることはなく、あるいはまた、個別領域同士に連続した部分があっても参照点間に領域内連結性が生じないように参照点を設定することができるのであれば各個別領域に1個ずつ参照点を設定するだけでも塊領域を各個別領域に分離することが可能と考えられる。しかしながら、前者の仮定には個別領域に連続部分が生じないことを保証する別途の構成が必要であって、これが保証できるのであれば二値画像から個別領域を分離する理由がないから、個別領域を分離する処理は不要であり、後者の仮定には塊領域の中で個別領域に対応する部位がすでに知られていることが必要であって、個別領域が不明である塊領域から個別領域を分離して抽出するという目的とは矛盾しているから、結局、各個別領域にそれぞれ1個ずつ参照点を設定することはできない。
【0051】
また、異なる個別領域に属する2個の参照点が領域内連結性を有する可能性を完全に排除することは困難であるから、異なる個別領域に設定した任意の2個の参照点について領域内連結性を持たない参照点の組み合わせが必ず含まれるようにしなければ個別領域を正しく分離することができない。言い換えると、参照点の個数が少ない場合には、異なる個別領域に属する参照点のすべての組合せについて領域内連結性を有する組合せになる可能性があり、結果的に2個の個別領域を1個の個別領域と誤認する可能性が生じる。
【0052】
上述のような事情に鑑みれば、各個別領域ごとに十分に多くの参照点を設定することが望ましいと言える。したがって、上述した第1の技術では、輪郭線を探索して設定される仮参照点の間隔を、予測される最小の個別領域の外周長さよりも十分に小さく設定することが望ましい。また、上述した第2の技術では、格子点の間隔を、予測される最小の個別領域の幅よりも十分小さく設定することが望ましい。そして、第1の技術と第2の技術とにおいて、予測される縦または横の幅寸法が最小である個別領域に対して参照点が少なくとも2個設定されるようにすることで誤認識をなくすことができる。
【0053】
上述のようにして参照点が設定された後には、デジタル画像解析判定手段13において、各参照点の組合せにおける領域内連結性の有無を判断する。つまり、すべての参照点の組合せについて領域内連結性の有無を評価する。ここでは、図11のように塊領域D1,D2に対して参照点P1〜P15が設定されているものとする。上述したように各参照点P1〜P15ごとに他の参照点P1〜P15との間に連結線分s(m−n)を設定し、各連結線分s(m−n)が塊領域D1,D2の内側のみを通るか否かを判断する。領域内連結性の有無は二値画像を用いて判断するから、連結線分s(m−n)の上のすべての画素の画素値が塊領域D1,D2の画素値と一致するか否かを判断すればよい。つまり、連結線分s(m−n)の上の画素がすべて0であれば、この連結線分s(m−n)の端点である2個の参照点の組は領域内連結性を有することになる。たとえば、図11において参照点P1に着目すれば、連結線分s(1−n)のうち、2本の連結線分s(1−2),s(1−3)だけが塊領域D1の内側のみを通っている。つまり、参照点P1,P2の組と、参照点P1,P3の組とは領域内連結性を有する。
【0054】
各2個の参照点P1〜P15の組について領域内連結性の有無を判断するにあたっては、上述のように連結線分s(m−n)の上の画素値によって判断する構成のほか、連結線分s(m−n)と輪郭線Lとの交点の有無を判断する構成を採用してもよい。つまり、上述したように、参照点P1〜P15の設定に際して塊領域D1,D2の輪郭線Lを追跡する処理を行った場合には、輪郭線Lの上の画素が抽出されているから、輪郭線Lの上の画素と他の画素とに異なる画素値を与えた輪郭線画像(たとえば、輪郭線Lの上の画素の画素値を1、他の画素の画素値を0に設定する)を生成し、連結線分s(m−n)の上で画素値が1になる画素が存在すれば、連結線分s(m−n)が輪郭線Lと交差したことを意味するから、この連結線分s(m−n)の端点である参照点P1〜P15の組には領域内連結性がないと判断するのである。
【0055】
輪郭線Lと連結線分s(m−n)とが交差するか否かを判断するにあたっては、連結線分s(m−n)の式を求めて連結線分s(m−n)の上の画素の座標を計算によって求めるとともに、当該座標のうち輪郭線画像における輪郭線Lの座標に一致する画素が存在するか否かを判断することが考えられる。しかしながら、輪郭線画像を格納するためにメモリの容量が大きくなるだけではなく、参照点の個数が多くなると連結線分s(m−n)の本数が多くなるから、連結線分s(m−n)の上の画素の座標を求める演算だけでも膨大な処理が必要になる上に、輪郭線画像を格納したメモリにアクセスして求めた各画素の座標を輪郭線Lの上の画素の座標とそれぞれ照合しなければならないから、処理速度が遅くなり、アクセスタイムの速い高価なメモリが必要になる。そこで、輪郭線Lの各画素の座標ごとに、すべての連結線分s(m−n)の式に当て嵌めて輪郭線Lと連結線分s(m−n)との交差を検証する方法を採用するのが望ましい。この方法を採用すれば、連結線分s(m−n)の上の画素の座標を求める必要がなく、既知である輪郭線Lの上の画素の座標を各連結線分s(m−n)の式に代入するだけの演算になるから、演算量が比較的少なくなる上にメモリのアクセス回数が少なくなり、連結線分s(m−n)と輪郭線Lとの交差の有無を判定する処理の高速化が期待できる。
【0056】
連結線分s(m−n)と輪郭線Lとの交差の有無を判断する技術について、図11に基づいてさらに詳しく説明する。ここでは、輪郭線Lの上のすべての画素の座標はすでに求められているものとする。また、輪郭線Lの上の任意の画素である輪郭点Pcの座標を(cx、cy)とする。任意の2個の参照点Pm,Pn(1≦m,n≦15)を結ぶ連結線分s(m−n)が輪郭線Lと交差するか否かの判断、つまり領域内連結性の有無の判断は以下の手順で行う。ここに、参照点Pm,Pnの座標をそれぞれ(xm,ym),(xn,yn)とする。
【0057】
まず、画像のX方向およびY方向の辺を有し、2個の参照点Pm,Pnを対角線の両端とする長方形を仮想し、この長方形に輪郭点Pcが含まれるか否かを判断する。つまり、
MIN(xm、xn)≦cx≦MAX(xm,xn)
MIN(ym,yn)≦cy≦MAX(ym,yn)
がともに成立するか否かを判断する。ただし、MIN(a,b)はaとbとのうちの小さいほう、MAX(a,b)はaとbとのうちの大きいほうを意味する。要するに、上記長方形は連結線分s(m−n)を対角線とするから、輪郭点Pcが上述の長方形になければ連結線分s(m−n)と交差しないことは自明であって、上記長方形に含まれない輪郭点Pcは連結線分s(m−n)とは交差しない点として以下の処理の対象から除外する。言い換えると、連結線分s(m−n)を表す直線の式の適用領域を参照点Pm,Pnの間に限定する条件を設定したことになる。
【0058】
次に、上記長方形内に輪郭点Pcが含まれる場合には、連結線分s(m−n)を表す式に輪郭点Pcの座標(cx,cy)を代入する。ここで等号が成立するときには、この輪郭点Pcは連結線分s(m−n)の上にあることを意味するから、連結線分s(m−n)と輪郭線Lとが交差することになり、参照点Pm,Pnとの組には領域内連結性がないと判断することができる。なお、座標値は離散値であるから、一致・不一致の判断には1画素分の誤差は許容する。すべての連結線分s(m−n)について上述の処理を行った後、輪郭線Lに沿って次の輪郭点Pcに同処理を繰り返し、すべての輪郭点Pcについて同処理を行う。このようにして、連結線分s(m−n)と輪郭線Lとの交差の判断によって、容量が比較的少なくアクセスタイムの比較的遅いメモリを用いながらも比較的短時間で参照点Pm,Pnの間の領域内連結性の有無を判断することができる。
【0059】
ところで、上述した技術をさらに高速化するには、図12に示すように、輪郭線Lの上で輪郭線Lに沿って適宜の区分点ri(1≦i≦18)を設定し、隣接する区分点riの間を結ぶ区分線分S(i,(i+1))と連結線分s(m−n)とが交差するか否かを判断するようにしてもよい。区分点riの間隔を比較的小さく設定すれば、区分線分S(i,(i+1))の集合によって輪郭線Lを多角形近似したことになるから、連結線分s(m−n)と区分線分S(i,(i+1))との交差の有無は、連結線分s(m−n)と輪郭線Lとの交差の有無を判断したことと等価に扱うことが可能になる。つまり、連結線分s(m−n)と区分線分S(i,(i+1))とが交差するときには、連結線分s(m−n)の端点である参照点Pm,Pnには領域内連結性がないと判断する。ここに、区分点riの設定には多角形近似として周知の技術を用いることが可能であるが、本実施形態のように既知の粒状物体(薬剤2)を判別する場合には、輪郭線Lの曲率が大きい部位に区分点riを設け、他の部位には適当な間隔で区分点riを設けるようにしてもよい。この技術では連結線分s(m−n)と区分線分S(i,(i+1))との交差の判定が必要であって、連結線分s(m−n)に輪郭点Pcを代入する技術に比較すると複雑な演算が必要になるが、区分線分S(i,(i+1))の本数は輪郭点Pcの個数に比較して相当に少ないから、直線の式から座標を演算する回数をより少なくして高速な処理が可能になる。
【0060】
なお、連結線分s(m−n)は輪郭線Lと1回でも交差すれば、連結線分s(m−n)の端点である参照点Pm,Pnの間には領域内連結性がないと判断できるので、連結線分s(m−n)に関して領域内連結性がないと判断した時点で、当該連結線分s(m−n)に関して、他の輪郭点Pcとの一致あるいは区分線分S(i,(i+1))との交差の判定を打ち切るようにすれば、一層の高速化が可能になる。たとえば、図12に示す例では区分線分S(1,2)から始めて時計回りに連結線分s(m−n)との交差を順に判定するとすれば、区分線分S(2,3)と連結線分s(1−2),s(2−3)とが交差するから、この時点で連結線分s(1−2),s(2−3)の各端点である参照点P1,P2の組および参照点P2,P3の組にはいすれも領域内連結性がないと判断される。そこで、次の区分線分S(3,4)から以降については連結線分s(1−2),s(2−3)との交差については考慮する必要がなく、連結線分s(1−3)との交差のみを判定すればよく、結果的に処理の大幅な効率化が期待できる。
【0061】
上述のようにして、連結線分s(m−n)の端点である各2個ずつの参照点Pm,Pnの各組について領域内連結性をそれぞれ判断した後には、領域内連結性を有する参照点Pm,Pnの組についてグループ化を行う。要するに、各参照点Pm,Pnが同じ個別領域E1〜E5に含まれるか否かの評価を行う。この評価のために、各参照点Pm,Pnの組について領域内連結性の有無を図13のような対応表にまとめる。図13において縦横に参照点Pm,Pnを配列してあり、参照点Pm,Pnの交点は連結線分s(m−n)に相当する。参照点Pm,Pnが領域内連結性を有する場合は参照点Pm,Pnの交点には○と表記し、領域内連結性を持たない参照点Pm,Pnの交点には×と表記してある。また、各参照点はそれ自身に領域内連結性があるものとする。さらに、図13では各参照点P1〜P15ごとに領域内連結性を有する参照点P1〜P15の個数を領域内連結性の点数として対応表の右端に示している。たとえば、参照点P1については参照点P2,P3との間に領域内連結性があり、また参照点P1自身も領域内連結性があるものとして数えるから、参照点P1について領域内連結性の点数は3点になる。
【0062】
このような対応表は、マイコンからなるデジタル画像解析判定手段13において、通常はRAMで構成されるデジタル画像記憶手段12上に確保した行列領域に設定される。各行列要素(m,n)は連結線分s(m−n)に相当し、各行列要素(m,n)に0と1との値を与えることによって、連結線分s(m−n)の端点である参照点Pm,Pnの間の領域内連結性の有無を表すことができる。たとえば、対象となる塊画像に設定した参照点Piの個数がN個である場合には、N×N個の正方行列を記憶する行列領域を確保し、行列要素(m,n)に対応する連結線分s(m−n)の端点Pm,Pnの組が領域内連結性を有しているときには行列要素(m,n)に1を設定し、領域内連結性を持たないときには行列要素(m,n)に0を設定する。なお、図13において対角成分は、同一の参照点Pm,Pnに対応する領域内連結性の有無を表しているから同一値になる。言い換えると、各参照点Pm,Pnの領域内連結性の有無を判定する際には、各参照点Pm,Pnの組の一方から連結線分s(m,n)を設定して領域内連結性を一度判定すれば、他方から連結線分s(n,m)を設定して領域内連結性を判定する必要はなく、それだけ領域内連結性の有無の判定に要する時間を短縮することが可能になる。たとえば、参照点P1について参照点P2との領域内連結性の有無を判定した後には、参照点P2について参照点P1との領域内連結性の有無を判定する必要がないということである。
【0063】
上述した対応表に基づいて、領域内連結性を有する参照点Pm,Pnのグループ化を行う。つまり、1つのグループに属する参照点には領域内連結性があり、かつ領域内連結性を有する参照点は必ずいずれかのグループに属するように以下の手順でグループ化を行う。まず、対応表において領域内連結性の点数を参照し、どのグループにも属していない参照点のうちで、領域内連結性の点数が最少である参照点を抽出する。図13においては、参照点P1,P5,P6,P12,P13,P14,P15に対する領域内連結性の点数がいずれも3点であるから、これらの参照点P1,P5,P6,P12,P13,P14,P15を参照点群U1とする。このようにして求めた参照点群U1の各参照点P1,P5,P6,P12,P13,P14,P15について、相互に領域内連結性を有する参照点を順に求め、相互に領域内連結性を有する参照点を1つのグループとして扱う。つまり、グループとして扱う参照点は単に領域内連結性を有するだけではなく、相互に領域内連結性を有することが要求される。相互に領域内連結性があるとは、参照点群U1から選択した1つの参照点について対応表から領域内連結性を有する参照点を抽出し、選択した参照点と領域内連結性を有する参照点とのみからなる部分行列を生成したときに、この部分行列の中の行列要素の値がすべて1(表では○で表している)であることを意味する。言い換えると、1つのグループに含まれるすべての参照点は領域内連結性を有しており、任意の2個の参照点間に領域内連結性がなければ、互いに異なるグループに属するとみなされるのである。
【0064】
たとえば、図13においては参照点群U1について参照点P1から始めると、参照点P1に対して領域内連結性を有する参照点はP2,P3になるから、参照点P1,P2,P3のみからなる部分行列を生成すると図14のようになる。図14によれば行列要素のすべての値が1(表では○で表している)であるから、これらの3個の参照点P1,P2,P3は相互に領域内連結性を有することになる。このように相互に領域内連結性を有するときには1つのグループとするのであって、ここでは、参照点P1,P2,P3からなるグループをG1とする。
【0065】
参照点P1,P2,P3は1つのグループG1をなすことがわかったから、次には、図15のように対応表から参照点P1,P2,P3を除いた部分行列を生成する。
【0066】
図15についても図13と同様の処理を行う。つまり、参照点群U1から次の参照点として選択したP5について、領域内連結性を有する参照点であるP6,P7を抽出し、参照点P5,P6,P7からなる図16のような部分行列を生成する。ここで、参照点P5,P6の組および参照点P5,P7の組にはそれぞれ領域内連結性があるが、参照点P6,P7には領域内連結性がないから、図16に示した部分行列の中で各参照点P5,P6,P7について、あらためて領域内連結性の点数を計数し、点数が最少になる参照点P6,P7についてそれぞれ参照点P5との部分行列を生成する。参照点P5,P6のみを含む部分行列は図17のようになり、図17の行列要素の値はすべて1になるから、参照点P5,P6は相互に領域内連結性があると判断して1つのグループG2として扱う。参照点P5,P7からなる部分行列では行列要素の値に0が含まれるから、参照点P5,P7には相互に領域内連結性はないと判断する。
【0067】
上述のようにして参照点P5,P6もグループG2をなすと判定されるから、次には図15から参照点P5,P6も除いた部分行列を生成する。つまり、元の対応表から参照点P1,P2,P3,P5,P6を除いた図18のような部分行列を生成する。
【0068】
参照点群U1において図18に残った参照点P12,P13,P14,P15のうち、次にグループ化の対象となるのは参照点P12であるから、上述した処理と同様にして参照点P12に関する領域内連結性を有する参照点P10,P11を抽出する。参照点P10,P11,P12は相互に領域内連結性を有するから、参照点P10,P11,P12からなるグループG3を生成する。
【0069】
次に、P1,P2,P3,P5,P6,P10,P11,P12を除外し、図19のようにP4,P7,P8,P9,P13,P14,P15からなる部分行列を生成する。参照点群U1について次の参照点はP13であるから、P13について相互に領域内連結性がある参照点P13,P14,P15を抽出しグループG4とする。
【0070】
グループG4を生成すると、図20のように参照点P4,P7,P8,P9が残り、これらの参照点P4,P7,P8,P9では相互に領域内連結性を有しているから、参照点P4,P7,P8,P9をグループG5とする。
【0071】
上述のようにしてすべての参照点P1〜P15がいずれかのグループG1〜G5に属するようになれば、グループ化の処理を終了する。
【0072】
上述した手順によって参照点P1〜P15をグループ化すると、各グループG1〜G5と各参照点P1〜P15との関係は図21のようになる。図から明らかなように、塊領域D1において複数の個別領域E1〜E4が結合しており、異なる個別領域E1〜E4に含まれる参照点P1〜P15の一部は領城内連結性を有しているにもかかわらず(たとえば、個別領域E4の参照点P2は個別領域E3の参照点P7,P8との間に領域内連結性がある)、グループG1〜G5の個数が個別領域E1〜D5の個数に一致しており、しかも各グルーブG1〜G5に属する参照点P1〜P15は各個別領域E1〜E5に属するように正しく分割される。
【0073】
なお、上述したように、各個別領域のそれぞれについて1個ずつの参照点を設定することは不可能であるが、いずれかの個別領域について参照点が1個しか含まれない場合は生じうる。たとえば、各個別領域の輪郭線の長さが既知であるときに(つまり、画像内に含まれる粒状物体が既知であるときに)、個別領域のうちで輪郭線の長さが最小である個別領域に対して、輪郭線に沿って設定する参照点の間隔を小さくすれば、輪郭線の長さが最小である個別領域の中には1個の参照点が設定されることは保証されるものの、2個以上の参照点が設定される保証はない。図11に示す例で言えば、個別領域E2には参照点P6があっても参照点P5が設定されていない可能性もある。上述した例のように、1つのグループG1〜G5には最低でも2個の参照点P1〜P15が含まれるようにするのが望ましいが、1つの個別領域E1〜E5に1個の参照点P1〜P15しか設定されていない場合もあるから、1個の参照点しか含まないグループが生成されることも許容するのが望ましい。ただし、この場合には当該参照点が隣接する個別領域内のどの参照点とも領域内連結性がないという条件を満たさなければ、正しいグループを生成することができないから、たとえば図11で参照点P5がない場合には、参照点P6が他のどのグループにも属さない参照点として最後まで残った場合に参照点P6だけを含む1つのグループを生成する。要するに、グループ化の処理の際に、どのグループにも属さない参照点であって他の参照点とは領域内連結性を持たない単独の参照点が残った場合には、この参照点も1つのグループを構成するものとして扱うのである。
【0074】
なお、上述したグループ化の処理手順において、領域内連結性の点数が最少である参照点から順にグループ化を行っているのは、他の個別領域に属する参照点との間で偶然に領域内連結性を有している場合に、グループの候補となる参照点群に対応する部分行列を生成し、部分行列のすべての行列要素の値が0でなければ、部分行列の範囲内でさらに領域内連結性の点数が最少になる参照点に対応する部分行列を生成するという、再帰的な処理を行うためである(上述の例では図15〜図17を生成する手順に対応する)。
【0075】
この理由をさらに詳しく説明するために、図22に示すように、塊領域Dにおいて異なる個別領域E1,E2に設定された比較的多くの参照点P1〜P7が領域内連結性を有するような場合を想定する。図22に示す例では、領域内連結性に関する対応表が図23のようになる。
【0076】
ここで、領域内連結性の点数が最少である参照点から順にグループ化を行うのではなく、領域内連結性の点数が最大である参照点から順にグループ化を行うと仮定すると、まず参照点P1について領域内連結性を有する参照点P2,P3,P4,P6,P7を抽出し、図24に示す部分行列を生成することになる。この部分行列には行列要素の値が0ではないものが含まれているから、図24の部分行列からさらに部分行列を生成することが必要であるが、図24の部分行列において領域内連結性の点数が最大である参照点はP1であるから、図24からは部分行列を生成することができず、結局、再帰的な処理を継続することができなくなる。
【0077】
これに対して、本実施形態では、領域内連結性の点数が最少である参照点から順にグループ化を行うようにしているから、図23に対しては先ず参照点P3が抽出され、図25のように参照点P1,P2,P3,P4を含む部分行列が生成される。
【0078】
図25では値が0ではない行列要素が含まれているから、領域内連結性の点数が最少である参照点P2に着目し、参照点P1,P2,P3からなる部分行列を生成する。つまり、図26のような部分行列が生成され、すべての行列要素の値が0になる部分行列を得ることができる。要するに、すべての行列要素の値が0になるまで再帰的に処理を繰り返すことによって、領城内連結性のない参照点の組み合わせを排除でき、相互に領域内連結性のある参照点を正しくグループ化することができる。
【0079】
さらに、領域内連結性の点数の少ない参照点は他の個別領域に設定した参照点との間で領域内連結性を有する可能性が低いから、このような参照点を優先してグループ化を行うことによって誤分割の可能性を低減することができる。たとえば、図22に示す例では、領域内連結性の点数のもっとも多い参照点P1については、参照点P1を含む個別領域E1とは異なる個別領域E2に含まれる3個の参照点P4,P6,P7との間に領域内連結性を有しているのに対して、領域内連結性の点数が最少である参照点P3については、参照点P3を含む個別領域E1とは異なる個別領域E2に含まれる1個の参照点P4との間に領域内連結性を有しているのみであり、不要な参照点をグループから除外するのが容易になる。
【0080】
上述のように、薬剤2を撮像してから個別領域をグループ化する処理を図2にまとめて示す。すなわち、撮像装置1により撮像された画像は、まず二値化手段11により二値化され(S1)、デジタル画像記憶手段12に格納される。デジタル画像解析判定手段13は、デジタル画像記憶手段12に格納された二値画像を読み出し、二値画像に含まれる塊領域の輪郭線の近傍に適数個の参照点を設定する(S2)。参照点の設定後には、各2個ずつの参照点の間の領域内連結性を判断し対応表を生成する(S3)。ここで、参照点をグループ化したときにグループごとに付与するグループ番号nと、参照点を領域内連結性の点数ごとに群化する際の参照点群番号jとを初期化する(S4)。
【0081】
対応表が生成された後には、まずどのグループにも属していない参照点の中から領域内連結性の点数が最少である参照点群Ujを生成する(S5)。参照点を区別する参照点番号iを初期化し(S6)、参照点番号iの参照点が参照点群Ujに含まれるか否かを判断する(S7)。着目する参照点が参照点群Ujに含まれていない場合には、参照点番号iをインクリメントして(S8)、次の参照点について参照点群Ujに含まれるか否かを判断する(S7)。参照点が参照点群Ujに含まれるときには、当該参照点がいずれかのグループに属しているか否かを判断し(S9)、どのグループにも属していない場合に、当該参照点について相互に領域内連結性を有する参照点を抽出し、相互に領域内連結性を有する参照点を1つのグループとする(S10)。こうして1つのグループが形成されると、グループに属する参照点を対応表から除去し、グループ番号をインクリメントする(S11)。さらに、残った参照点の個数が参照点番号iよりも大きいときには(S12)、参照点番号iをインクリメントし(S8)、ステップS7からステップS11の処理を繰り返す。なお、ステップS9において着目する参照点がすでに他のグループに属しているときには、参照点番号iをインクリメントしてステップS7に戻る。上述の処理によって、各参照点をグループ化し、グループに属していない参照点の個数が参照点番号iよりも少なくなれば、どのグループにも属していない参照点が残っているか否かを判定し(S13)、参照点が残っている場合には、参照点群番号jをインクリメントして(S14)、残っている参照点のうち領域内連結性の点数が次に大きい参照点群について参照点群Ujを生成し(S5)、再びステップS6からステップS12の処理を行う。以上の処理は、すべての参照点がいずれかのグループに属するようになるまで続けられる。
【0082】
上述した処理手順によって粒状物体である薬剤2の個数はグループの個数に一致するから、薬剤2の個数を計数することが可能になる。ここで、薬剤2の剤形についても判別することができれば、ひとまとめにする複数個の薬剤2を誤って混在させる可能性をより低減できると考えられる。そこで、以下では、剤形が円形錠剤かカプセルかなどの種別を判別するために、各個別領域の輪郭線を分離する技術について説明する。要するに、グループについて境界を正確に求めることにより、個別領域を各別に分離するのである。
【0083】
以下では、図21のようにグループG1〜G5を形成した場合を例として説明する。この場合、塊領域D2に対しては1個のグループG4が存在するだけであるから、塊領域D2は1個の個別領域E5を形成しているものとして、以下の処理から除外する。グループ化の後に個別領域E1〜E4の境界を決定するには、まず輪郭線Lを追跡し、塊領域D1の輪郭線Lの形状を抽出する(参照点の設定の際に輪郭線追跡を行う場合には、参照点P1〜P12の設定時に求めた輪郭線Lの形状を用いてもよい)。次に、図27に示すように、輪郭線Lの上であって参照点P1〜P12にもっとも近い判定点R1〜R12を設定する。次に、輪郭線Lに沿って各判定点R1〜R12がどのグループG1〜G3,G5に属するのかを求める。さらに、輪郭線Lに沿って隣り合う判定点R1〜R12であって、かつ異なるグループG1〜G3,G5に属する判定点R1〜R12のペアを抽出する。たとえば、図27に示す例では、判定点R3,R4のペア、判定点R4,R5のペア、判定点R6,R7のペア、判定点R8,R10のペア、判定点R12,R9のペア、判定点R9,R1のペアの6ペアになる。このようにして求めた判定点R1〜R12のペアの間において輪郭線Lの曲率を求め、曲率が最大になる位置を各グループG1〜G3,G5に対応する個別領域の境界点B1〜B6とする。各境界点B1〜B6のうちで同グループG1〜G3,G5の間である2個ずつの境界点B1〜B6を結ぶ線分を境界線とし、各個別領域E1〜E4を境界線によって分離する。つまり、図示例では境界点B1,B6はグループG1,G5の間にあり、境界点B2,B3はグループG2,G5の間にあり、境界点B4,B5はグループG3,G5の間にあるから、境界点B1,B6の間と、境界点B2,B3の間と、境界点B4,B5の間とにそれぞれ境界線を設定する。このように設定した境界線により塊領域D1を分割すれば、図28に示すように、塊領域D1を各個別領域E1〜E4にほぼ正確に分割することが可能になる。
【0084】
塊領域D1を個別領域E1〜E4に分割した後には、個別領域E1〜E5の形状に関する特徴量(面積、幅、高さ、輪郭線の曲率分布など)に基づいて剤形を判別し、薬剤2の種別ごとの個数を計数したり、種別の間違いや異物の混入の検査が可能になる。
【0085】
さらに精度よく薬剤2の種別を判別するには、検査台3に載置する薬剤2を撮像装置1により撮像した画像をテンプレートとして登録しておき、上述のようにして個別領域E1〜E4を分割した後に、各個別領域E1〜E5をテンプレートとパターンマッチングすることによって薬剤2の種別を判定してもよい。このようなテンプレートを用いると、薬剤2の種別ごとの個数を検査したり、種別の間違いや異物の混入の検査が可能になるだけではなく、薬剤2の割れなどの良否検査も可能になる。
【0086】
上述した処理は粒状物体が一様に不透明であるという仮定で説明したが、実際には透明である薬剤2(ソフトタブレットと称するゼリー状の薬剤2や透明なカプセルに液体を封じた薬剤2など)や、粒状物体の外周に囲まれる部位に孔が存在する薬剤2(服用時に喉に詰まっても窒息することがないように中央部に孔を設けているドーナツ状の薬剤2など)がある。これらの薬剤2についても上述した処理を可能とするためには、二値画像において各薬剤2の内側となる部位の画素値を0に設定しておく前処理が必要である。
【0087】
いま、透明な薬剤2について考察すると、透過照明を行う照明装置4を用いると、光の屈折によって薬剤2の中央部が明るくなり外周部のみが暗くなったドーナツ状のシルエットが形成される。また、上述のように中央部に孔を設けた薬剤2においても同様なシルエットが形成される。この種の薬剤2を撮像装置1で撮像し、二値画像を生成すると、図29に示すように、1個の個別領域Eの内側に背景と同じ値を持つ穴領域Hが形成されることになる。つまり、個別領域Eの輪郭線Lの近傍に参照点P1,P2を設定すると、両参照点P1,P2を結ぶ連結線分s(1−2)が穴領域Hを通過するから、両参照点P1,P2の間には領域内連結性がなく、上述した処理を行うと参照点P1,P2を1つのグループとして扱うことができなくなる。つまり、1つの個別領域Eの中に背景と同じ値の穴領域Hが存在する場合には、上述した処理手順のみでは個別領域Eを正しく抽出することができない。
【0088】
そこで、個別領域Eの中に穴領域Hが生じるような薬剤2が存在することを考慮し、以下のように二値画像から穴領域Hを除去する前処理を行う。ここで、複数個の薬剤2が互いに接触しているような場合には、図30(a)に示すように、複数個(図示例では4個)の個別領域E1〜E4からなる塊領域Dが形成され個別領域E1〜E4に囲まれた穴領域H2が形成されることがあるから、塊領域Dの中の穴領域H1,H2として、1つの個別領域E1の内側の穴領域H1と、個別領域E1〜E4に囲まれた穴領域H2とが生じる。つまり、穴領域H1を除去するには、1つの個別領域E1の内側の穴領域H1であるか、個別領域E1〜E4に囲まれた穴領域H2であるかを識別することが必要である。
【0089】
まず、塊領域Dの中に穴領域H1,H2が存在するか否かを、輪郭線を抽出するとともに輪郭線の内側の画素値を判別することによって識別する。つまり、輪郭線によって囲まれる図形の内側の画素値が1(つまり、背景と同じ画素値)であれば、この輪郭線に囲まれた領域は穴領域H1,H2と判別することができる。図30(a)からわかるように、上述した理由によって個別領域E1の内側に形成される穴領域H1は単純な円形や楕円形になり滑らかに連続しているのに対して、複数個の個別領域E1〜E4に囲まれることによって形成された穴領域H2の輪郭線には輪郭線上を順次追跡したときの曲率の変化が不連続となる複数個の曲率不連続点F1〜F4が形成される。この性質を利用すれば、穴領域H1,H2の輪郭線上を順次追跡し、輪郭線の所定の間隔ごとの曲率を調べ、曲率不連続点F1〜F4の有無を判別することで、穴領域H1,H2の種類を識別することが可能であるから、個別領域E1の内側である穴領域H1については、図30(b)のように輪郭線の内側の画素の値を0(つまり、個別領域E1〜E4の他の部位の値)にし、穴領域H1を除去する。このような前処理を行うことによって、上述した処理手順で個別領域E1〜E4を分離することが可能になる。
【0090】
ところで、薬剤2を包装材により包装した状態で撮像する場合では、包装材の表面反射によって1個の個別領域に複数個の小さな穴領域がノイズとして生じることがあり、また包装材の表面に汚れがあると汚れの部分が個別領域と同じ画素値を持ちノイズになることもある。この種のノイズの影響を除外するために、塊領域とともにその中に含まれる穴領域を検出し、既知である薬剤2の寸法および予測される穴領域の寸法を考慮し、小さな塊領域および穴領域をノイズとみなして除去するのが望ましい。
【0091】
上述した処理手順では、薬剤2の接触部位の長さが短いほど異なる個別領域に跨る連結線分が形成される可能性が低減し、結果的に個別領域の分離が容易になって誤認識の可能性を低減することができる。そこで、図31(a)のように複数個の個別領域E1〜E4が連続した塊領域Dが形成されているときには、あらかじめ縮小処理(つまり、輪郭線Lを所定の画素分だけ塊領域Dの内側にずらす処理)を行うことによって、図31(b)のように個別領域E1〜E4の接触部位の長さを小さくしておくことが望ましい。このような処理を行うことにより、塊領域Dから個別領域E1〜E4を分離する際の信頼性が向上する。
【0092】
【発明の効果】
請求項1、20の発明の構成によれば、複数個の粒状物体に対応する個別領域が接触して塊領域が形成されている場合であっても、塊領域が複数個の個別領域からなるものであるか否かをグループの個数で容易に判別することができる。しかも、透過照明または落射照明などの比較的簡単な照明を用いかつ静止画像を撮像するだけであるから、特殊かつ高価な装置を用いることなく、汎用的かつ安価な機器によって構成することが可能になる。その上、粒状物体の分離に際して、すべての参照点同士を相互に連結した連結線分を生成し、各連結線分が塊領域の外側を通るか否かの判断を用いるから、連結線分の端点となる参照点の位置を適宜に設定すれば、大きさや形状が異なっていたり多少の凹み部分を持っていたりする粒状物体が混在していても、粒状物体を正しく分離して個数の計数が可能になる。さらに、塊領域の輪郭線の形状を細かく解析したり処理時間のかかるパターンマッチング処理を画像の全体に対して行う必要もなく、少数の参照点について連結線分が塊領域の外側を通過するか否かの評価のみで、塊領域が複数個の個別領域からなるものであるか否かを短時間で判断することができる。
【0093】
請求項2の発明は、請求項1の発明において、デジタル画像が、撮像装置により撮像された画像の濃度に関して二値化した二値画像であるから、多値画像を用いる場合に比較して処理が簡単であり、処理時間の一層の短縮を図ることができる。
【0094】
請求項3の発明では、請求項1または請求項2の発明において、デジタル画像解析判定手段は、個別領域のうち縦または横の幅寸法が最小である個別領域に参照点が少なくとも2個設定されるように参照点を配置するから、各個別領域ごとに必要十分な個数の参照点を設定することができ、塊領域を構成する個別領域の個数を誤認識する可能性を低減できる。
【0095】
請求項4の発明では、請求項1または請求項2の発明において、デジタル画像解析判定手段は、塊領域の輪郭線に対して規定した距離だけ内側に参照点を設定するので、輪郭線に凹み部分が存在するような粒状物体が含まれている場合でも各粒状物体を正しく認識することができる。
【0096】
請求項5の発明では、請求項4の発明において、個別領域の輪郭線に生じる凹み部分に対して連結線分が個別領域の内側を通過するように、参照点と輪郭線との距離を設定するから、検査対象である粒状物体の大きさや粒状物体の輪郭線に生じる凹み部分の大きさに応じて参照点の位置を調節することになり、結果的に個別領域の個数を誤認識する可能性を低減することができる。
【0097】
請求項6の発明では、請求項1または請求項2の発明において、デジタル画像解析判定手段は、塊領域の輪郭線に沿って規定した間隔で参照点を設定するので、参照点を適切に配置することができる。
【0098】
請求項7の発明では、請求項1または請求項2の発明において、デジタル画像解析判定手段は、デジタル画像の画面内に一定間隔の格子点を設定し、塊領域の内側に位置する格子点を起点として複数の方向に輪郭線を探索するとともに、各格子点と輪郭線との距離が最短になる方向の線上に参照点を設定するので、輪郭線の追跡が不要であり塊領域の面積が比較的大きい場合でも高速な処理が期待できる。
【0099】
請求項8の発明では、請求項1または請求項2の発明において、デジタル画像解析判定手段は、デジタル画像の画面内に一定間隔の格子点を設定し、塊領域の内側に位置する格子点を起点として各格子点ごとに定めた1つの方向に輪郭線を探索するとともに、各格子点から輪郭線を探索する方向の線上に参照点を設定するので、参照点を設定する処理が単純であって、参照点の個数が比較的少ないときには特に高速な処理が期待できる。
【0100】
請求項9の発明では、請求項1または請求項2の発明において、デジタル画像解析判定手段は、塊領域の輪郭線の曲率が規定値より大きい部位の両側近傍の所定の距離に参照点を設定するので、隣接する個別領域に含まれる参照点との間の連結線分が塊領域内のみを通過する可能性を低減することができ、塊領域から個別領域を分離する際の信頼性を向上することができる。
【0101】
請求項10の発明では、請求項1または請求項2の発明において、デジタル画像解析判定手段は、塊領域の輪郭線の上の点である各輪郭点ごとに連結線分の上の点か否かを判定し、当該輪郭点が連結線分の上の点であるときには当該連結線分が塊領域の外側を通過すると判断するので、参照点を結ぶ連結線分の上の全画素の座標を求める必要がなく、結果的に連結線分が塊領域の外を通過するか否かの判定のための処理に対する負荷が小さくなり高速な処理が期待できる。すなわち、参照点間を結ぶ連結線分が塊領域の内側のみを通過するか否かを判断するために、連結線分上のすべての画素について画素値を判断するとすれば、連結線分の式に基づいて連結線分の上の各画素の座標を求める必要があり、この場合には、(連結線分の本数)×(連結線分の上の画素数)に相当する回数だけ座標演算を行うとともに画素値の判定を行うことが必要であって、多くの時間を費やすことになる。これに対して、請求項10の発明では、輪郭線の上の輪郭点が参照点間を結ぶ連結線分の上に位置するときには、当該連結線分の端点である参照点の組には領城内連結性がないと判定するだけであるから、演算量を大幅に低減することが可能になる。
【0102】
請求項11の発明では、請求項1または請求項2の発明において、デジタル画像解析判定手段は、塊領域の輪郭線の上の点である各輪郭点の座標が連結線分の両端の参照点の間の座標であって、かつ当該輪郭点の座標を当該連結線分の式に代入して等式が成立するときに、当該連結線分が塊領域の外側を通過すると判断するので、連結線分の式に対して輪郭点の座標を代入するだけの単純な演算で連結線分が塊領域の外側を通過するか否かの判断が可能になり、演算量を大幅に低減することができる。
【0103】
請求項12の発明では、請求項1または請求項2の発明において、デジタル画像解析判定手段は、塊領域の輪郭線の上に複数個の区分点を設定するとともに隣接する区分点間を結ぶ区分線分を設定し、連結線分と区分線分とが交差しているときに連結線分が塊領域の外側を通過すると判断するので、塊領域の輪郭線を区分線分からなる多角形で近似したことになり、輪郭線の上の輪郭点について1点ずつ判断する場合に比較すると短時間での判断が可能になる。
【0104】
請求項13の発明では、請求項1または請求項2の発明において、デジタル画像解析判定手段は、参照点ごとに他の参照点との間の連結線分が塊領域の内側のみを通過する本数を計数し、当該本数の少ない参照点から始めて、当該参照点との間の連結線分が塊領域の内側のみを通過する参照点をすべて抽出するとともに抽出したすべての参照点の組合せで連結線分が塊領域の内側のみを通るという条件を満たす参照点をグループとする処理を行い、当該処理をすべての参照点がいずれかのグループに属するようになるまで繰り返すものであり、この処理を行うことによって、仮に異なる個別領域に含まれる参照点の間を結ぶ連結線分が塊領域の外側を通過しない場合であっても、すべての参照点の組合せで連結線分が塊領域の内側のみを通るという条件を満たす参照点をグループとする処理を行うことによって、参照点を正しくグループ化することができる。
【0105】
請求項14の発明では、請求項1または請求項2の発明において、デジタル画像解析判定手段は、参照点の全組合せを行列要素とする正方行列に対して各参照点間の連結線分が塊領域の外側を通過するか否かを行列要素に対応付けて格納し、各参照点ごとに連結線分が塊領域の内側のみを通過している行列要素の個数を求め、当該個数の少ない参照点から始めて、当該参照点との間の連結線分が塊領域の内側のみを通過するすべての参照点の組合せからなる部分行列を正方行列から生成し、当該部分行列の行列要素のすべてで連結線分が塊領域の内側のみを通るという条件を満たすときに当該部分行列の要素である参照点をグループとし、グループとなった参照点を正方行列の行および列から除いた部分行列を生成する処理を行い、当該処理をすべての参照点がいずれかのグループに属するようになるまで繰り返すものであり、仮に異なる個別領域に含まれる参照点の間を結ぶ連結線分が塊領域の外側を通過しない場合であっても、すべての参照点の組合せで連結線分が塊領域の内側のみを通るという条件を満たす参照点をグループとする処理を行うことによって、参照点を正しくグループ化することができる。しかも、連結線分に対応した行列要素を持つ行列を用いるから、グループ化の処理が単純化される。
【0106】
請求項15の発明では、請求項1または請求項2の発明において、デジタル画像解析判定手段は、塊領域の輪郭線に沿って異なるグループに属する2個の参照点を抽出し、当該2個の参照点の間の輪郭線において曲率が最大である部位を隣接する個別領域の境界線上の部位と判断するので、個別領域を分割するための境界線を容易に設定することができ、塊領域を個別領域に分割する処理を正確かつ容易に行うことができる。
【0107】
請求項16の発明では、請求項2の発明において、デジタル画像解析判定手段は、塊領域の輪郭線の内側に背景と同じ画素値の領域が存在するときに穴領域として検出し、穴領域の輪郭線が滑らかに連続しているときに当該穴領域を埋めるので、複数の個別領域に囲まれて形成されているような穴領域と個別領域の内側に形成される穴領域とを区別し、個別領域の内側の穴領域のみを埋めることができるから、粒状物体が透明であったりドーナツ状であったりしても、個別領域を正しく切り出すことが可能になる。
【0108】
請求項17の発明では、請求項1または請求項2の発明において、デジタル画像解析判定手段は、塊領域における輪郭線の近傍の画素を除去する縮小処理を行った後に参照点を設定するので、隣接する個別領域の接続部位の長さを小さくすることになり、異なる個別傾城に含まれる参照点の間で連結線分が塊領域の内側のみを通過する可能性を低減し、結果的に個別領域の分割の信頼性を向上させることができる。
【0109】
請求項18の発明では、請求項1または請求項2の発明において、デジタル画像解析判定手段は、個別領域の形状に関する特徴量を用いて粒状物体の種別を判断するとともに、粒状物体の種別ごとの個数の計数と粒状物体の種別の間違いの判断の少なくとも一方を検査項目として検査するので、参照点を用いて分割した各個別領域に対応する粒状物体に関して個数検査や種別検査を容易に行うことができる。
【0110】
請求項19の発明では、請求項1または請求項2の発明において、デジタル画像解析判定手段は、検査対象となる粒状物体のテンプレートに個別領域をパターンマッチングすることにより粒状物体の種別を判断するとともに、粒状物体の種別ごとの個数の計数と粒状物体の種別の間違いの判断と粒状物体の良否判定との少なくとも1つを検査項目として検査するので、参照点を用いて分割した各個別領域に対応する粒状物体に関して個数検査や種別検査や良否判定を容易に行うことができる。
【図面の簡単な説明】
【図1】本発明の実施形態を示す概略構成図である。
【図2】同上におけるグループ化の技術を説明する流れ図である。
【図3】(a)は撮像装置により撮像した画像を示す図、(b)は二値画像を示す図である。
【図4】本発明の原理説明図である。
【図5】本発明の概念を説明する図である。
【図6】本発明の実施形態における参照点の設定例を示す説明図である。
【図7】同上において格子を用いた参照点の設定方法を示す説明図である。
【図8】同上において格子を用いた参照点の設定例を示す説明図である。
【図9】同上において格子を用いた参照点の他の設定例を示す説明図である。
【図10】同上における参照点の別の設定例を示す説明図である。
【図11】同上における領域内連結性の評価方法を示す説明図である。
【図12】同上における領域内連結性の他の評価方法を示す説明図である。
【図13】同上においてグループ化に用いる対応表を示す図である。
【図14】同上において相互に領域内連結性を有することを確認するための部分行列を示す図である。
【図15】同上においてグループ化の過程で用いる部分行列を示す図である。
【図16】同上においてグループ化の過程で用いる部分行列を示す図である。
【図17】同上において相互に領域内連結性を有することを確認するための部分行列を示す図である。
【図18】同上においてグループ化の過程で用いる部分行列を示す図である。
【図19】同上においてグループ化の過程で用いる部分行列を示す図である。
【図20】同上において相互に領域内連結性を有することを確認するための部分行列を示す図である。
【図21】同上においてグループ化の概念を説明する図である。
【図22】同上に用いる処理手順の正当性を説明する図である。
【図23】図22に示す例での対応表を示す図である。
【図24】比較例で用いる部分行列を示す図である。
【図25】図22に示す例でのグループ化の過程で用いる部分行列を示す図である。
【図26】図22に示す例において相互に領域内連結性を有することを確認するための部分行列を示す図である。
【図27】本発明の実施例において個別領域の分割方法を示す図である。
【図28】同上において個別領域を分割した状態を示す図である。
【図29】同上において穴領域を生じる例を示す図である。
【図30】同上において穴領域を生じる場合の前処理の例を示す説明図である。
【図31】同上において信頼性を向上させるための前処理の例を示す説明図である。
【符号の説明】
1 撮像装置
2 薬剤
3 検査台
4 照明装置
11 二値化手段
12 デジタル画像記憶手段
13 デジタル画像解析判定手段
[0001]
BACKGROUND OF THE INVENTION
The present invention relates to a granular object inspection apparatus for inspecting the appearance of a granular object such as a solid medicine and an inspection method thereof.
[0002]
[Prior art]
In general, when prescribing to administer multiple types or multiple drugs at the time of taking once in a medical field, in order to prevent the patient from making a mistake in the type and number of drugs, one dose of each drug is used. It has come to be packaged with a packaging material such as sulfuric acid paper or resin film and provided to patients as a package. Since some drugs are dangerous if they are taken in the wrong dose or mixed, the law stipulates that the drug sorting work must be done manually, but it is possible that the sorting work may be mistaken, A packaging machine for packaging medicines is required to have a function of inspecting the type and number of medicines to be packaged.
[0003]
In order to realize this type of function, various inspection apparatuses using image processing have been proposed. For example, as a technique for counting the number of granular objects such as drugs, a drug is imaged in a state where the drugs are arranged at intervals so that the drugs do not contact each other, and the obtained image is binarized and then a labeling process is performed. A technique for counting the number of labeled regions is known. However, with this technology, it must be ensured that the drugs are arranged at intervals so as not to contact each other, and a device for separating and arranging the drugs becomes necessary, or the work for separating and arranging the drugs There is a problem that it becomes necessary.
[0004]
On the other hand, when tracing a contour line for a connected component of a binarized image, a chain code indicating the connection direction of pixels on the contour line is recorded, and a contact point caused by overlapping of drugs due to a change in the chain code is extracted. In addition, a technique has been proposed in which a pair of contacts is created, and an image of each tablet is divided by a boundary line interconnecting the pairs of contacts (for example, see Patent Document 1).
[0005]
Moreover, a mask corresponding to the site where the drug is present is formed from an image obtained by imaging the packaged drug using transmitted illumination, and an image of only the drug part in the striped pattern generated when the slit light is irradiated obliquely is masked. A technique is also proposed in which a discontinuous point in a striped pattern is regarded as a contour of a medicine (see, for example, Patent Document 2).
[0006]
Furthermore, by irradiating the packaged medicine with a transmission ray such as X-ray and moving the medicine relative to the transmission line, the amount of transmission when the transmission line penetrates the medicine is determined by the position of the medicine with respect to the transmission line. , A technique for counting the number of medicines according to the permeation amount change pattern, a three-dimensional shape of the medicine based on the transmission amount of the transmission line, and collating with the pre-registered correct medicine dimension information There are also known techniques for inspecting the number, type, foreign matter contamination, drug cracking, and the like (see, for example, Patent Document 3).
[0007]
[Patent Document 1]
Japanese Patent Laid-Open No. 7-200570 (page 4, FIG. 2)
[Patent Document 2]
JP 7-204253 A (page 2-3, FIG. 4-5)
[Patent Document 3]
JP 2000-135268 A (pages 7-8 and 9, pages 10 and 46)
[0008]
[Problems to be solved by the invention]
By using the techniques described in the above-mentioned patent documents, even if a plurality of drugs are in contact with each other, they can be recognized as different drugs and counted. However, in the technique described in Patent Document 1, a drug in which a concave portion with a large change in chain code is formed in the contour line, such as a clover-type tablet or a tablet with a cut, is used for a plurality of one drug. There is a possibility that the medicines are divided and recognized, and each medicine may not be correctly separated.
[0009]
In addition, the technique described in Patent Document 2 has a problem that it requires a relatively high cost because two illumination devices are necessary, and also requires an image when irradiated with slit light. In the case of using a packaging material, there is a problem that there are many restrictions on the type of the packaging material because a correct stripe pattern corresponding to the drug cannot be obtained.
[0010]
Furthermore, in the technique described in Patent Document 3, since the drug is moved relative to the transmission line, there is a problem that the cost is relatively high, particularly when a three-dimensional shape of the drug is used. Has a problem that a long processing time is required for measurement and verification.
[0011]
The present invention has been made in view of the above reasons, and its purpose is to separate each granular object of various shapes from an image in which a plurality of granular objects are in contact with each other by simply capturing a still image with a simple device. It is an object of the present invention to provide a granular object inspection apparatus and inspection method thereof.
[0012]
[Means for Solving the Problems]
The inventions of claims 1 to 22 relate to an inspection apparatus for granular objects.
[0013]
According to a first aspect of the present invention, there is provided an imaging device for imaging an imaging region including a granular object to be inspected, digital image storage means for storing a digital image digitized with respect to the density of the image captured by the imaging device, and digital An image analysis determination unit having a function of dividing an area corresponding to each granular object when areas corresponding to the plurality of granular objects are in contact with each other in the image. In the image One or more Corresponding to granular objects Is a continuous region Contour line outline Above or inside the contour A function to disperse and arrange a plurality of reference points in the vicinity, All Reference points Mutual A grouping function that associates a group of reference points as a group with a combination of reference points that do not pass outside the block region when a connected connection line is generated, and a group of reference points And a function of inspecting inspection items related to granular objects by associating one-to-one correspondence with individual areas which are image areas of the granular objects in the digital image.
[0014]
The invention of claim 2 is characterized in that, in the invention of claim 1, the digital image is a binary image binarized with respect to the density of the image taken by the imaging device.
[0015]
According to a third aspect of the present invention, in the first or second aspect of the present invention, the digital image analysis determination means includes at least two reference points in an individual area having a minimum vertical or horizontal width dimension among the individual areas. Reference points are arranged so as to be individually set.
[0016]
According to a fourth aspect of the present invention, in the first or second aspect of the present invention, the digital image analysis determining means sets the reference point inward by a distance defined with respect to the outline of the mass region. And
[0017]
According to a fifth aspect of the present invention, in the fourth aspect of the invention, the reference point and the contour line are arranged so that the connecting line segment passes through the inside of the individual region with respect to the recessed portion generated in the contour line of the individual region. The distance is set.
[0018]
According to a sixth aspect of the present invention, in the first or second aspect of the present invention, the digital image analysis determining unit sets the reference points at intervals defined along the outline of the mass region. .
[0019]
According to a seventh aspect of the invention, in the first or second aspect of the invention, the digital image analysis determining means sets lattice points at regular intervals in the screen of the digital image and is located inside the lump area. A contour line is searched in a plurality of directions starting from a lattice point, and a reference point is set on a line in a direction in which the distance between each lattice point and the contour line is the shortest.
[0020]
In the invention of claim 8, in the invention of claim 1 or claim 2, the digital image analysis determination means sets grid points at regular intervals in the screen of the digital image and is located inside the lump area. A contour line is searched in one direction determined for each lattice point starting from the lattice point, and a reference point is set on a line in a direction in which the contour line is searched from each lattice point.
[0021]
According to a ninth aspect of the present invention, in the first or second aspect of the present invention, the digital image analysis determining means may perform the reference to a predetermined distance near both sides of a region where the curvature of the outline of the mass region is larger than a specified value. It is characterized by setting a point.
[0022]
According to a tenth aspect of the present invention, in the first or second aspect of the invention, the digital image analysis determining means is arranged on the connecting line segment for each contour point that is a point on the contour line of the block region. It is determined whether or not it is a point, and when the contour point is a point on the connecting line segment, it is determined that the connecting line segment passes outside the block region.
[0023]
According to an eleventh aspect of the present invention, in the first or second aspect of the present invention, the digital image analysis determining means is configured such that the coordinates of each contour point, which is a point on the contour line of the block region, are at both ends of the connecting line segment. And when the equation is established by substituting the coordinates of the contour point into the expression of the connection line segment, it is determined that the connection line segment passes outside the block region. It is characterized by that.
[0024]
According to a twelfth aspect of the present invention, in the first or second aspect of the invention, the digital image analysis determining means sets a plurality of segment points on the outline of the block region and sets the interval between adjacent segment points. A connecting segment line is set, and when the connecting line segment and the segment line segment intersect, it is determined that the connecting line segment passes outside the block region.
[0025]
According to a thirteenth aspect of the present invention, in the first or second aspect of the present invention, the digital image analysis determining means may determine that the connecting line segment between each reference point and another reference point is only inside the mass region. Count the number of passing lines, start with a reference point with a small number, extract all the reference points where the connecting line segment to the reference point passes only inside the block area, and a combination of all the extracted reference points And the reference point satisfying the condition that the connecting line segment passes only inside the block region is set as the group, and the process is repeated until all the reference points belong to any group. To do.
[0026]
According to a fourteenth aspect of the present invention, in the first or second aspect of the present invention, the digital image analysis determining means includes a connecting line segment between each reference point with respect to a square matrix whose matrix elements are all combinations of the reference points. Is stored in association with a matrix element, and the number of matrix elements whose connecting line segment passes only inside the chunk area is determined for each reference point. Starting from a reference point with a small number of points, generating a submatrix from the square matrix consisting of a combination of all reference points where the connecting line segment between the reference point passes only inside the block region, and the matrix elements of the submatrix When the condition that all connected line segments pass only inside the block region is satisfied, the reference points that are elements of the submatrix are set as the group, and the grouped reference points are excluded from the rows and columns of the square matrix. Generated submatrix That processing performed, and repeating until the processing for all the reference points will belong to any group.
[0027]
In the invention of claim 15, in the invention of claim 1 or claim 2, the digital image analysis determination means extracts two reference points belonging to different groups along the outline of the mass region, It is characterized in that a part having the maximum curvature in the contour line between the reference points is determined as a part on the boundary line of the adjacent individual region.
[0028]
In the invention of claim 16, in the invention of claim 2, the digital image analysis determination means detects a hole area when an area having the same pixel value as the background exists inside the outline of the block area, The hole region is filled when the contour line of the region is smoothly continuous.
[0029]
According to a seventeenth aspect of the present invention, in the first or second aspect of the invention, the digital image analysis determining means sets the reference point after performing a reduction process for removing pixels in the vicinity of the contour line in the block region. It is characterized by doing.
[0030]
In the invention of claim 18, in the invention of claim 1 or claim 2, the digital image analysis determination means determines the type of granular object using the feature quantity related to the shape of the individual area, and the type of granular object. It is characterized in that at least one of counting the number of each and judging whether the granular object type is wrong is inspected as the inspection item.
[0031]
According to a nineteenth aspect of the present invention, in the first or second aspect of the invention, the digital image analysis determining means determines the type of the granular object by pattern matching the individual area to a template of the granular object to be inspected. At the same time, at least one of counting the number of granular objects, determining whether the granular object is wrong, and determining whether the granular object is good is inspected as the inspection item.
[0032]
The invention according to claim 20 is an image pickup device for picking up an image pickup region including a granular object to be inspected, a digital image storage means for storing a digital image digitized with respect to the density of the image picked up by the image pickup device, Inspection items relating to granular objects are obtained by an inspection apparatus including an image analysis determination unit having a function of dividing an area corresponding to each granular object when areas corresponding to the plurality of granular objects are in contact with each other in the image. A method for inspecting a granular object to be inspected, wherein the digital image analysis judging means One or more Corresponding to granular objects Is a continuous region Contour line outline Above or inside the contour After distributing a plurality of reference points in the vicinity, All Reference points Mutual When the connected connected line segments are generated, a combination of reference points that do not pass outside the block area is grouped so that all the reference points are associated with each other. Inspection items relating to granular objects are inspected by associating groups with individual areas that are image areas of the granular objects in the digital image on a one-to-one basis.
[0033]
Since the inspection apparatus of the present invention uses relatively simple illumination such as transmitted illumination or epi-illumination and only captures a still image, it is constituted by a general-purpose and inexpensive apparatus without using a special and expensive apparatus. It becomes possible to do. In addition, even when a plurality of granular objects are in contact with each other, a group corresponding to each granular object can be generated in a one-to-one manner. Therefore, it is easy to count the number of granular objects. Since the determination of whether or not the connecting line segment passes outside the block area is used for separation, if the position of the reference point that is the end point of the connecting line segment is set appropriately, the size and shape may be different or some dent Even if there are mixed granular objects that have a particle size, it is possible to correctly separate the granular objects and count the number. Further, the technique of the present invention can be applied even when the packaging material that wraps the granular object is not transparent but translucent by using transmitted illumination.
[0034]
DETAILED DESCRIPTION OF THE INVENTION
In each embodiment described below, the granular object 2 is recognized by a binary image obtained by binarizing the signal value relating to the grayscale information of the image signal captured by the imaging device 1 with an appropriate threshold using the device shown in FIG. Do. However, a grayscale image may be generated by binarizing the image signal by A / D conversion without binarizing the image signal. When a grayscale image is used, differentiation processing or the like can be applied, so that recognition accuracy can be improved. In addition, an example of using the illumination device 4 for transmissive illumination that irradiates light from the opposite side of the imaging device 1 to the inspection table 3 when irradiating the granular object 2 placed on the inspection table 3 is shown. When the color of the granular object can be clearly distinguished from the background color as in the case where a white granular object is placed on the black inspection table as the granular object 2, light from the same side as the illumination device 1 with respect to the inspection table 3 It is also possible to employ an illumination device for epi-illumination that irradiates. Furthermore, solid drugs such as tablets and capsules are shown as examples of the granular object 2, but the technique of the present invention can be applied to recognition of the shape of the contour line even for other granular objects.
[0035]
The apparatus shown in FIG. 1 includes an examination table 3 on which a medicine 2 as a granular object that is a recognition target is placed, and an imaging apparatus 1 including a TV camera for imaging the medicine 2 above the examination table 3. Is placed. The inspection table 3 is a semi-transparent synthetic resin plate and has diffuse permeability, and an illuminating device 4 that can illuminate the entire surface of the inspection table 3 without uneven brightness is disposed below the inspection table 3. Is done. That is, since it is desirable that the unevenness in brightness does not occur in the inspection table 3 in a state where the medicine 2 is not placed on the inspection table 3, a configuration in which the unevenness in brightness does not occur in the illumination device 4 is adopted. By imparting diffuse permeability, uneven brightness is suppressed.
[0036]
If the drug 2 is opaque, the image captured by the imaging device 1 is an image including the silhouette of the drug 2 because the part corresponding to the drug 2 is dark and the background of the drug 2 is bright, and the drug 2 is transparent. The center part of the medicine 2 is bright and the peripheral part is dark because of the refraction action of the light passing through the shape where the center part of the medicine 2 is thicker and the peripheral part is thinner. Examples of the transparent drug 2 include a jelly-shaped drug 2 and a capsule-shaped drug 2 in which a liquid is sealed. As described above, regardless of whether the drug 2 is opaque or transparent, a relatively large luminance difference is generated between the outline of the drug 2 and the background. Therefore, the signal value relating to the grayscale information of the image signal output from the imaging device 1 By binarizing with an appropriate threshold value using the binarizing means 11, it becomes possible to separate the outline of the tablet 2 from the background. Since the binary image obtained by binarizing the image signal output from the imaging device 1 by the binarizing means 11 is a digital image having only binary values of pixel values 0 and 1, this digital image The image is stored in the digital image storage means 12 comprising a RAM. The digital image storage means 12 is used not only as a binary image but also as a working storage area for various image processing described later. The binary image stored in the digital image storage unit 12 is input to the digital image analysis determination unit 13 composed of a microcomputer, and subjected to processing described in the following embodiments, whereby the shape, size, The number is recognized. A monitor device 14 comprising a CRT or a liquid crystal display is connected to the digital image analysis determination means 13, and the monitor device 14 has an image captured by the imaging device 1, a binary image binarized by the binarization means 11, The recognition result by the digital image analysis determination means 13 can be displayed.
[0037]
In the embodiment described below, a plurality of medicines 2 to be combined are placed on the examination table 3, and the medicines on the examination table 3 are obtained from images of the plurality of medicines 2 imaged by the imaging device 1. It is determined whether or not 2 is a correct combination, and the drugs 2 to be combined are finally packaged in one package by a packaging material. Here, if the packaging material is transparent or translucent and the medicine 2 is imaged by the imaging device 1 and an image similar to the case where packaging with the packaging material is not performed can be obtained, the packaging material is packaged in advance. It is also possible to place the medicine 2 packaged with a material on the examination table 3.
[0038]
The operation of the digital image analysis determination unit 13 in the embodiment of the present invention will be described below using a specific example. Here, as shown in FIG. 3 (a), five drugs 2, a round tablet T1, an oval sugar-coated tablet T2, a capsule T3, a clover-shaped tablet T4, and an oval tablet T5, are examined as the drugs 2. The case where it mounts on the stand 3 is assumed. In addition, each shape of the medicine 2 is a planar shape. As described above, since transmission illumination is performed, in the image picked up by the imaging apparatus 1, the parts corresponding to the five medicines 2 become dark and the background of the medicine 2 becomes bright. That is, the silhouette of the medicine 2 is obtained in the image signal output from the imaging device 2.
[0039]
Since the binarizing means 11 binarizes the signal value related to the density information of the image signal output from the imaging device 2 with an appropriate threshold, for example, the pixel value of a part darker than the threshold is set to 0 and the part brighter than the threshold In the binary image, the pixel value of the part corresponding to the medicine 2 is 0, and the pixel value of the part not corresponding to the medicine 2 is 1 in the binary image. In the illustrated example, since the tablets T1, T2, T4 are all in contact with the capsule T3, in the binary image, as shown in FIG. 3B, the tablets T1, T2, T4 and the capsule T3 corresponding to each other are continuous. One region (hereinafter referred to as “bulk region”) D1 is formed, and individual tablets T1, T2, T4 and capsules T3 cannot be distinguished. On the other hand, in order to recognize each medicine 2 by an image, it is necessary to separate each medicine 2 from the mass region D1. Note that the tablet T5 alone forms one lump region D2. In short, a block region is a set of pixels in which any pixel value is 0 in 8 neighborhoods (remaining pixels when focusing on the center pixel of a 3 × 3 pixel region) in a binary image. , 8 is an area partitioned by pixels having pixel values of 1 in the vicinity.
[0040]
Therefore, in order to separate and recognize each medicine 2 from the mass region D1 formed in the binary image when a plurality of medicines 2 are in contact, in this embodiment, the digital image analysis determination unit 13 performs the following. Is being processed. That is, for a binary image obtained by binarization by the binarization means 11, first, appropriate pixels in the vicinity of the contour lines of the mass regions D1 and D2 are set as reference points. The reference point is set at a position on the outline of the mass regions D1 and D2, or a position several pixels inside the outline.
[0041]
Here, as shown in FIG. 4A, if there is no dent in the contour line of the figure I1, all the reference points P1 to P5 set near the contour line are mutually connected between the reference points P1 to P5. The connecting line segments s (1-2), s (1-3),..., S (4-5), which are connected lines, are on the inside The law of existence generally holds. The connecting line segment s (mn) means a line segment connecting the reference point Pm and the reference point Pn. The above-mentioned law is valid in many cases even if there is a slight dent in the contour line, but if the dent is not large, there is a relatively large dent in the contour line of the figure I2 as shown in FIG. For example, for any of the reference points P1 to P6, the connecting line segments s (1-2), s (1-3),..., S (5-6) pass outside the figure I2. . In the following description, when a connecting line segment connecting between reference points set in the vicinity of a contour line of a figure passes only inside the figure, the two reference points that are end points of the connecting line segment are “intra-region connection”. It is said that the two reference points do not have “intra-region connectivity” if even a part of the connecting line segment connecting the reference points passes outside the figure. Here, the outline of the general drug 2 does not have a large dent, but it is slightly different from the clover-shaped tablet T4 shown in FIG. 3 (a) or a tablet having a cut that can be taken in half. Since there is a medicine 2 having a dent, in order to prevent the dent portion in this kind of medicine 2 from affecting the determination of the presence or absence of intra-region connectivity, it is located inside the contour line according to the shape and size of the known dent part. A reference point is set.
[0042]
In the present embodiment, by using the presence or absence of intra-region connectivity described above, regions corresponding to individual drugs 2 from the mass regions D1 and D2 in the binary image shown in FIG. A process of separating E1 to E5 (referred to as “individual areas”) is performed. That is, as shown in FIG. 5, the reference points P1 to P13 are set by a setting method in which a plurality of reference points P1 to P13 are set in each of the individual areas E1 to E5, and the connecting line segment s (1- 2), s (1-3),..., S (12-13), connecting line segments s (1-3), s (1-5), s ( 2-6), s (2-8), s (3-5), s (4-9), s (6-8), s (7-10), s (7-11), s (10 -11) and s (12-13) are extracted. The reference points P1 to P13 which are both end points of the extracted connecting line segment s (mn) have intra-region connectivity, and the two reference points P1 to P13 having intra-region connectivity are one individual. It is included in the areas E1 to E5. Here, if the reference points P1 to P13 having intra-region connectivity belonging to the same individual regions E1 to E5 are grouped, the number of groups G1 to G5 matches the number of individual regions E1 to E5. .
[0043]
In the grouping, reference points P1 to P13 which are reference points P1 to P13 having intra-region connectivity and shared with other connection line segments s (mn) are extracted. The connecting line segment s (mn) having such reference points P1 to P13 as end points belongs to one individual region E1 to E5. In the above example, the reference points P1, P3, and P5 are shared by two of the connecting line segments s (1-3), s (1-5), and s (3-5), respectively. Therefore, the reference points P1, P3, and P5 become one group G1, and the individual area corresponding to the group G1 of the reference points P1, P3, and P5 becomes E4. The reference points P4 and P9 are end points of only the connecting line segment s (4-9), but have the intra-region connectivity and become one group G2. The individual area corresponding to the group G2 of the reference points P4 and P9 is E1. Similarly, the group G3 of the reference points P7, P10, P11 corresponds to the individual area E3, the group G4 of the reference points P12, P13 corresponds to the individual area E2, and the group G5 of the reference points P2, P6, P8 is individual. This corresponds to the region E5. Thus, in the example shown in FIG. 5, the group G1 of the reference points (P1, P3, P5), the group G2 of the reference points (P2, P6, P8), the group G3 of the reference points (P4, P9), the reference It becomes possible to divide into five groups: a group G4 of points (P7, P10, P11) and a group G5 of reference points (P12, P13). That is, the lump areas D1 and D2 can be separated into five individual areas E1 to E5.
[0044]
Each process in the above-described procedure will be described in more detail. As described above, in order to separate an individual area from a mass area in a binary image, it is first required to set a reference point at an appropriate position near the outline of the mass area. Basically, multiple reference points are required for each individual area to be separated, but it is unclear which part of the mass area will be an individual area, so the process of determining the position of the reference point is individual. This is an important process in area separation.
[0045]
As a first technique for setting a reference point, contour tracking for extracting the contour line L of the mass region D is performed, and as shown in FIG. Temporary reference points p1 to p13 are set at intervals, and further, reference points P1 to P13 are set at portions separated by a processing distance inside the contour line L on the normal line of the contour line L passing through the temporary reference points p1 to p13, respectively. There is technology to do. The contour tracking technique is well known, but will be briefly described. First, raster scanning is performed in a binary image, and a change point at which the pixel value changes from the background to the block region D is obtained. Here, since the point at which the adjacent pixel value changes from 1 to 0 in the binary image becomes the changing point, the contour line L is assumed to have a pixel value of 0. The pixel first obtained in this way is set as the tracking start point, and the pixel on the contour line L is tracked, for example, clockwise from the tracking start point. A well-known technique is used for tracking the contour line L. An example of a technique for tracking the contour line L is as follows. If the contour line L is to be tracked clockwise, among the pixels in the vicinity of the pixel of interest on the contour line L, the tracked pixels are compared. Then, the pixel value of each pixel arranged in the clockwise direction is calculated starting from the pixel adjacent in the clockwise direction. If a pixel having the same pixel value as the pixel of interest appears, that pixel is determined as the pixel to be traced next. For example, it is assumed that the pixel adjacent to the left with respect to the pixel of interest (pixel value is 0) is the pixel that was tracked before, and the upper left and upper pixels of the eight neighborhoods of the pixel of interest are the pixels of interest If the pixel values are different (that is, the pixel value is 1), the next pixel to be traced is the upper right pixel. If such processing is repeated to return to the tracking start point, the tracking of the contour line L is completed. As a technique for tracking the contour line L, the above-described technique is an example, and it goes without saying that other well-known techniques can be used.
[0046]
When the contour line L is tracked, the pixels on the contour line L are traced one pixel at a time. Therefore, the pixels on the contour line L are set as provisional reference points p1 to p13 for each of the defined pixels. Reference points P <b> 1 to P <b> 13 are set inside the lump region D by a predetermined number of pixels (for example, 3 to 5 pixels) on the normal line of the contour line L passing through the reference points p <b> 1 to p <b> 13. The direction of the normal line of the contour line L can be obtained, for example, as a tangent to the differential value obtained from the pixel values of the eight neighboring pixels of the temporary reference points p1 to p13 and the inward direction of the lump region D. . By setting the reference points P1 to P13 slightly inside the contour line L as described above, the connecting line segment s (mn) connecting the reference points P1 to P13 even if the contour line L has some dent. Can be reduced from the mass region D. That is, even if the individual area has a shape having a dent in the contour line L, the possibility that the individual area can be separated increases. Therefore, the distance between the temporary reference points p1 to p13 and the reference points P1 to P13 is appropriately set according to the shape of the outline L of the individual region to be separated (that is, the shape of the medicine 2). In the first technique, since the total length of the contour line L of the lump region D is unknown, if the temporary reference points p1 to p13 are set for each pixel defined when tracking on the contour line L, the contour line L The last temporary reference point and the first temporary reference point may be different from the other temporary reference points, but the temporary reference points are set at regular intervals. This is to distribute the points appropriately, and does not necessarily need to be equally spaced. Therefore, a deviation in the intervals of some temporary reference points does not affect the operation.
[0047]
As a second technique for setting the reference point in the vicinity of the contour line L, a technique that does not track pixels on the contour line L may be employed. That is, as shown in FIG. 7, a grid GR having a constant interval is set in the binary image, and grid points q3, q4, q5 existing inside the lump region D1 among the grid points q1 to q12 in the binary image. , Q7, q8, q9, and q10, as shown in FIG. 8, the intersection with the contour line L is searched for each in a finite number of directions (eight directions in the illustrated example). Of the intersections obtained in this way, the intersection closest to each of the lattice points q3, q4, q5, q7, q8, q9, q10 is set as a temporary reference point, and is in the vicinity of each temporary reference point and inside the lump region D. Reference points P3, P4, P5, P7, P8, P9, and P10 are set, respectively. The reference points P3, P4, P5, P7, P8, P9, and P10 are set inside the block region D by the number of pixels defined with respect to the temporary reference point on the line in the direction of searching for the temporary reference point. If the technique using the grid GR is employed in this way, it is not necessary to extract all the points on the contour line L of the mass region D as compared with the case where the contour line L is tracked. As a result, the time required for determining the reference point can be reduced.
[0048]
In the second technique described above, each lattice point q1 to q12 is searched for an intersection with the contour line L in eight directions as a temporary reference point, but the lattice existing inside the lump region D as shown in FIG. You may search an intersection with the outline L as a temporary reference point only about one direction decided for every point q3, q4, q5, q7, q8, q9, q10. In this case, the search direction may be rotated 90 degrees clockwise in the order of raster scanning of each of the lattice points q3, q4, q5, q7, q8, q9, and q10. For example, in the illustrated example, the search directions are in the order of lattice points q3, q4, q5, q7, q8, q9, q10 in the order of up, right, down, left, up, right, down. By using this technique, it is not necessary to search each of the lattice points q1 to q12 in eight directions, the processing time can be shortened, and each of the lattice points q3, q4, q5, q7, q8, q9, q10. Can be determined by appropriately dispersing the reference points P3, P4, P5, P7, P8, P9, and P10 corresponding to (reference points P5 and P10 corresponding to the lattice points q5 and q10 in FIG. Not shown because it will be outside).
[0049]
In the present embodiment, the individual regions are separated depending on the presence or absence of intra-region connectivity between two reference points. Therefore, it is desirable that the reference points included in different individual regions have no intra-region connectivity. That is, it is desirable to arrange the reference points so that the connecting line segments do not pass through the contact portions between the individual regions. From this, it can be said that it is desirable to arrange the reference points in the vicinity of the contact portions between the individual regions. Therefore, the contour line L of the lump region D is extracted, and the curvature of each part of the contour line L is obtained. As shown in FIG. 10, the parts C1 to C7 where the curvature of the contour line L exceeds the specified threshold are individually The reference points P1 to P14 may be set in the vicinity of the region C1 to C7 that are determined to be candidates for the region where the regions are in contact with each other. For each part C1 to C7, two reference points P1 to P14 are set, and for each part C1 to C7, a contour portion of a predetermined distance range near both sides is approximated by an arc, A normal is established from the approximate center of the arc toward the center of curvature, and reference points P1 to P14 are set on the inner side of the normal by a distance defined from the contour L to the mass region D. In this way, two reference points P1 to P14 are set for each of the parts C1 to C7. In the parts C1 to C7 having a large curvature (parts C1, C2, and C7 in the illustrated example), the reference point P1. Since the connecting line segment connecting P14 (reference points P1, P2, P3, P4, P13, P14 in the illustrated example) passes outside the block region D, the individual regions E1 to E5 can be easily separated.
[0050]
As for the number of reference points, if individual regions are independent, if one reference point is set for each individual region, intra-region connectivity will not occur between any reference points, or In addition, even if there is a continuous portion between individual areas, if a reference point can be set so that intra-area connectivity does not occur between reference points, only one reference point is set for each individual area. However, it is considered possible to separate the lump area into individual areas. However, the former assumption requires a separate configuration that guarantees that no continuous portion is generated in the individual area, and if this can be guaranteed, there is no reason to separate the individual area from the binary image. The latter assumption requires that the part corresponding to the individual area is already known in the lump area, and the individual area is determined from the lump area where the individual area is unknown. Since there is a contradiction with the purpose of separating and extracting, after all, one reference point cannot be set for each individual region.
[0051]
In addition, since it is difficult to completely eliminate the possibility that two reference points belonging to different individual areas have intra-area connectivity, intra-area connection is performed for any two reference points set in different individual areas. Individual regions cannot be correctly separated unless a combination of reference points having no property is necessarily included. In other words, when the number of reference points is small, there is a possibility that all combinations of reference points belonging to different individual areas may be combinations having intra-area connectivity, and as a result, two individual areas are combined into one. There is a possibility that it may be mistaken as an individual area.
[0052]
In view of the circumstances as described above, it can be said that it is desirable to set a sufficiently large number of reference points for each individual region. Therefore, in the first technique described above, it is desirable to set the interval between the temporary reference points set by searching for the contour line to be sufficiently smaller than the outer peripheral length of the minimum predicted individual area. In the second technique described above, it is desirable to set the interval between the lattice points to be sufficiently smaller than the width of the smallest predicted individual area. In the first technique and the second technique, at least two reference points are set for each individual region having the smallest predicted vertical or horizontal width dimension, thereby eliminating misrecognition. be able to.
[0053]
After the reference points are set as described above, the digital image analysis determination unit 13 determines whether or not there is intra-region connectivity in each reference point combination. That is, the presence or absence of intra-region connectivity is evaluated for all combinations of reference points. Here, it is assumed that reference points P1 to P15 are set for the mass regions D1 and D2 as shown in FIG. As described above, the connecting line segment s (mn) is set between each of the reference points P1 to P15 and the other reference points P1 to P15, and each connecting line segment s (mn) is the lump area D1. , D2. Since the presence or absence of intra-region connectivity is determined using a binary image, whether or not the pixel values of all the pixels on the connection line segment s (mn) match the pixel values of the cluster regions D1 and D2. Can be judged. That is, if all the pixels on the connecting line segment s (mn) are 0, the set of two reference points that are the end points of the connecting line segment s (mn) has intra-region connectivity. It will be. For example, if attention is paid to the reference point P1 in FIG. 11, only two connecting line segments s (1-2) and s (1-3) out of the connecting line segment s (1-n) are in the lump region D1. It passes only inside. That is, the set of reference points P1 and P2 and the set of reference points P1 and P3 have intra-region connectivity.
[0054]
In determining whether or not there is intra-region connectivity for each set of two reference points P1 to P15, in addition to the configuration in which the determination is based on the pixel values on the connection line segment s (mn), as described above, You may employ | adopt the structure which judges the presence or absence of the intersection of line segment s (mn) and the outline L. FIG. That is, as described above, when the process of tracking the outline L of the lump areas D1 and D2 is performed when setting the reference points P1 to P15, the pixels above the outline L are extracted. An outline image in which different pixel values are given to pixels on the line L and other pixels (for example, the pixel value of the pixel on the outline L is set to 1 and the pixel value of the other pixel is set to 0). If a pixel having a pixel value of 1 is generated on the connecting line segment s (mn), it means that the connecting line segment s (mn) intersects the contour line L. It is determined that the set of reference points P1 to P15 that are end points of the connecting line segment s (mn) has no intra-region connectivity.
[0055]
In determining whether or not the contour line L and the connecting line segment s (mn) intersect, an expression of the connecting line segment s (mn) is obtained to determine the connecting line segment s (mn). It is conceivable to obtain the coordinates of the upper pixel by calculation and determine whether or not there is a pixel that matches the coordinate of the contour line L in the contour image. However, not only the capacity of the memory is increased to store the contour image, but the number of connecting line segments s (mn) increases as the number of reference points increases, so that the connecting line segment s (m− The calculation of the pixel above n) alone requires a huge amount of processing, and the coordinates of each pixel obtained by accessing the memory storing the contour image are represented by the coordinates of the pixel above the contour L. Therefore, the processing speed is slow, and an expensive memory with a fast access time is required. Therefore, a method for verifying the intersection between the contour line L and the connecting line segment s (mn) by fitting to the expression of all the connecting line segments s (mn) for each pixel coordinate of the contour line L. It is desirable to adopt. If this method is adopted, it is not necessary to obtain the coordinates of the pixels on the connecting line segment s (mn), and the coordinates of the pixels on the known contour line L are converted into the connecting line segments s (mn). ), The calculation amount is relatively small and the number of memory accesses is reduced, and the presence or absence of the intersection of the connecting line segment s (mn) and the contour line L is determined. Speeding up the processing.
[0056]
A technique for determining whether or not the connecting line segment s (mn) and the contour line L intersect each other will be described in more detail with reference to FIG. Here, it is assumed that the coordinates of all the pixels on the contour line L have already been obtained. Further, the coordinates of the contour point Pc, which is an arbitrary pixel on the contour line L, are (cx, cy). Determination of whether or not the connecting line segment s (mn) connecting any two reference points Pm and Pn (1 ≦ m, n ≦ 15) intersects the contour line L, that is, whether there is intra-region connectivity The determination is made according to the following procedure. Here, the coordinates of the reference points Pm and Pn are (xm, ym) and (xn, yn), respectively.
[0057]
First, a rectangle having the X and Y sides of the image and having two reference points Pm and Pn as opposite ends of the diagonal line is hypothesized, and it is determined whether or not the rectangle includes a contour point Pc. That means
MIN (xm, xn) ≦ cx ≦ MAX (xm, xn)
MIN (ym, yn) ≦ cy ≦ MAX (ym, yn)
It is determined whether or not both hold. However, MIN (a, b) means the smaller of a and b, and MAX (a, b) means the larger of a and b. In short, since the rectangle has the connecting line segment s (mn) as a diagonal line, it is obvious that the contour point Pc does not intersect the connecting line segment s (mn) unless the contour point Pc is in the above-described rectangle. The contour point Pc not included in the rectangle is excluded from the target of the following processing as a point that does not intersect the connecting line segment s (mn). In other words, a condition for limiting the application area of the straight line expression representing the connecting line segment s (mn) between the reference points Pm and Pn is set.
[0058]
Next, when the contour point Pc is included in the rectangle, the coordinates (cx, cy) of the contour point Pc are substituted into the expression representing the connecting line segment s (mn). Here, when the equal sign is established, it means that the contour point Pc is on the connecting line segment s (mn), and therefore the connecting line segment s (mn) and the contour line L intersect. Therefore, it can be determined that the combination with the reference points Pm and Pn does not have intra-region connectivity. Since the coordinate value is a discrete value, an error for one pixel is allowed for determination of coincidence / non-coincidence. After performing the above-described processing for all the connecting line segments s (mn), the same processing is repeated for the next contour point Pc along the contour line L, and the same processing is performed for all the contour points Pc. In this way, by determining the intersection of the connecting line segment s (mn) and the contour line L, the reference point Pm, can be obtained in a relatively short time while using a memory having a relatively small capacity and a relatively slow access time. The presence or absence of intra-region connectivity between Pn can be determined.
[0059]
By the way, in order to further increase the speed of the technique described above, as shown in FIG. 12, an appropriate segmentation point ri (1 ≦ i ≦ 18) is set on the contour line L along the contour line L and adjacent to it. It may be determined whether or not the segment line segment S (i, (i + 1)) connecting the segment points ri intersects with the connection segment s (mn). If the interval between the segment points ri is set to be relatively small, the contour line L is approximated to a polygon by a set of segment line segments S (i, (i + 1)), so that the connection segment s (mn) and The presence / absence of an intersection with the segment line segment S (i, (i + 1)) can be handled equivalently to the determination of the presence / absence of an intersection between the connecting line segment s (mn) and the contour line L. That is, when the connecting line segment s (mn) and the segment line segment S (i, (i + 1)) intersect, the reference points Pm and Pn that are the end points of the connecting line segment s (mn) are regions. Judged that there is no internal connectivity. Here, it is possible to use a well-known technique for polygonal approximation to set the dividing point ri. However, when a known granular object (drug 2) is discriminated as in this embodiment, the contour line L Alternatively, the dividing points ri may be provided at portions where the curvature is large, and the dividing points ri may be provided at appropriate intervals in other portions. In this technique, it is necessary to determine the intersection of the connecting line segment s (mn) and the segment line segment S (i, (i + 1)), and the contour point Pc is substituted into the connecting line segment s (mn). Compared with the technique to be used, a complicated calculation is required. However, since the number of segment lines S (i, (i + 1)) is considerably smaller than the number of contour points Pc, coordinates are calculated from a straight line expression. It is possible to perform high-speed processing by reducing the number of times.
[0060]
Note that if the connecting line segment s (mn) intersects the contour line L even once, there is intra-region connectivity between the reference points Pm and Pn which are the end points of the connecting line segment s (mn). Since it can be determined that there is no intra-region connectivity with respect to the connection line segment s (mn), the connection line segment s (mn) matches or is divided with another contour point Pc. If the determination of the intersection with the line segment S (i, (i + 1)) is terminated, the speed can be further increased. For example, in the example shown in FIG. 12, if the intersection with the connecting line segment s (mn) is determined in order clockwise starting from the segment line segment S (1, 2), the segment line segment S (2, 3). And the connecting line segments s (1-2) and s (2-3) intersect with each other, and at this point, the reference points P1 that are the end points of the connecting line segments s (1-2) and s (2-3) , P2 and reference points P2 and P3 are determined not to have intra-region connectivity. Therefore, there is no need to consider the intersection with the connecting line segments s (1-2) and s (2-3) from the next segment line S (3, 4), and the connecting line segment s (1 It is sufficient to determine only the intersection with -3), and as a result, significant efficiency improvement of the process can be expected.
[0061]
As described above, after determining intra-region connectivity for each pair of two reference points Pm and Pn that are end points of the connecting line segment s (mn), the intra-region connectivity is obtained. Grouping is performed on a set of reference points Pm and Pn. In short, it is evaluated whether or not each reference point Pm, Pn is included in the same individual area E1 to E5. For this evaluation, the presence or absence of intra-region connectivity for each set of reference points Pm and Pn is summarized in a correspondence table as shown in FIG. In FIG. 13, reference points Pm and Pn are arranged vertically and horizontally, and an intersection of the reference points Pm and Pn corresponds to a connecting line segment s (mn). When the reference points Pm and Pn have intra-region connectivity, the intersection of the reference points Pm and Pn is marked with ◯, and the intersection of the reference points Pm and Pn without intra-region connectivity is marked with ×. . Each reference point itself has intra-region connectivity. Furthermore, in FIG. 13, the number of reference points P1 to P15 having intra-region connectivity for each reference point P1 to P15 is shown as the intra-region connectivity score at the right end of the correspondence table. For example, since the reference point P1 is counted as having intra-region connectivity between the reference points P2 and P3, and the reference point P1 itself is counted as having intra-region connectivity, the intra-region connectivity score for the reference point P1 Becomes 3 points.
[0062]
Such a correspondence table is set in the matrix area secured on the digital image storage means 12 which is usually constituted by a RAM in the digital image analysis determination means 13 comprising a microcomputer. Each matrix element (m, n) corresponds to a connected line segment s (mn), and by giving each matrix element (m, n) a value of 0 and 1, the connected line segment s (mn). ), The presence or absence of intra-region connectivity between the reference points Pm and Pn. For example, when the number of reference points Pi set in the target block image is N, a matrix area for storing N × N square matrices is secured and corresponds to the matrix element (m, n). When the pair of end points Pm and Pn of the connecting line segment s (mn) has intra-region connectivity, 1 is set to the matrix element (m, n), and when there is no intra-region connectivity, the matrix element Set (m, n) to 0. In FIG. 13, the diagonal components have the same value because they indicate the presence or absence of intra-region connectivity corresponding to the same reference points Pm and Pn. In other words, when determining the presence or absence of intra-region connectivity of each reference point Pm, Pn, a connection line segment s (m, n) is set from one of the sets of the respective reference points Pm, Pn to connect within the region. Once the sex is determined, it is not necessary to set the connecting line segment s (n, m) from the other side to determine the intra-area connectivity, and the time required for determining the presence or absence of intra-area connectivity can be reduced accordingly. It becomes possible. For example, after determining the presence or absence of intra-region connectivity with the reference point P2 for the reference point P1, it is not necessary to determine the presence or absence of intra-region connectivity with the reference point P1 for the reference point P2.
[0063]
Based on the correspondence table described above, the reference points Pm and Pn having intra-region connectivity are grouped. That is, the reference points belonging to one group have intra-region connectivity, and the reference points having intra-region connectivity are grouped by the following procedure so that they always belong to any group. First, the intra-region connectivity score is referred to in the correspondence table, and the reference points having the smallest intra-region connectivity score are extracted from the reference points that do not belong to any group. In FIG. 13, since the number of intra-region connectivity points with respect to the reference points P1, P5, P6, P12, P13, P14, and P15 is three, these reference points P1, P5, P6, P12, P13, Let P14 and P15 be the reference point group U1. For each of the reference points P1, P5, P6, P12, P13, P14, and P15 of the reference point group U1 obtained in this way, reference points having intra-region connectivity with each other are obtained in order, and the intra-region connectivity with each other is obtained. The reference points that are included are treated as one group. That is, the reference points treated as a group are required not only to have intra-region connectivity but also to have intra-region connectivity with each other. The intra-region connectivity means that a reference point having intra-region connectivity is extracted from the correspondence table for one reference point selected from the reference point group U1, and the reference having the intra-region connectivity with the selected reference point is extracted. This means that when a submatrix consisting only of points is generated, the values of the matrix elements in this submatrix are all 1 (indicated by a circle in the table). In other words, all the reference points included in one group have intra-region connectivity, and if there is no intra-region connectivity between any two reference points, they are considered to belong to different groups. is there.
[0064]
For example, in FIG. 13, when the reference point group U1 is started from the reference point P1, the reference points having intra-region connectivity with respect to the reference point P1 are P2 and P3, and therefore only the reference points P1, P2 and P3 are included. FIG. 14 shows a partial matrix generated. According to FIG. 14, since all values of the matrix elements are 1 (indicated by a circle in the table), these three reference points P1, P2, P3 have intra-region connectivity with each other. . Thus, when there is intra-region connectivity with each other, a group is formed. Here, a group including reference points P1, P2, and P3 is set to G1.
[0065]
Since it has been found that the reference points P1, P2, and P3 form one group G1, next, a partial matrix is generated by removing the reference points P1, P2, and P3 from the correspondence table as shown in FIG.
[0066]
Also in FIG. 15, the same processing as in FIG. 13 is performed. That is, for P5 selected as the next reference point from the reference point group U1, reference points P6 and P7 having intra-region connectivity are extracted, and the partial matrix as shown in FIG. 16 including the reference points P5, P6, and P7 is obtained. Is generated. Here, the set of reference points P5 and P6 and the set of reference points P5 and P7 have intra-region connectivity, but the reference points P6 and P7 have no intra-region connectivity, so the portion shown in FIG. For each reference point P5, P6, P7 in the matrix, the number of intra-region connectivity points is counted again, and a submatrix with the reference point P5 is generated for each of the reference points P6, P7 having the smallest number of points. The submatrix including only the reference points P5 and P6 is as shown in FIG. 17, and the values of the matrix elements in FIG. 17 are all 1. Therefore, it is determined that the reference points P5 and P6 have intra-region connectivity. Treat as one group G2. In the submatrix composed of the reference points P5 and P7, 0 is included in the value of the matrix element. Therefore, it is determined that the reference points P5 and P7 have no intra-region connectivity.
[0067]
Since it is determined that the reference points P5 and P6 also form the group G2 as described above, a submatrix that excludes the reference points P5 and P6 from FIG. 15 is generated next. That is, a partial matrix as shown in FIG. 18 is generated by removing the reference points P1, P2, P3, P5, and P6 from the original correspondence table.
[0068]
Among the reference points P12, P13, P14, and P15 remaining in FIG. 18 in the reference point group U1, the next grouping target is the reference point P12. Reference points P10 and P11 having intra-region connectivity are extracted. Since the reference points P10, P11, and P12 have intra-region connectivity with each other, a group G3 including the reference points P10, P11, and P12 is generated.
[0069]
Next, P1, P2, P3, P5, P6, P10, P11, and P12 are excluded, and a partial matrix composed of P4, P7, P8, P9, P13, P14, and P15 is generated as shown in FIG. Since the next reference point for the reference point group U1 is P13, reference points P13, P14, and P15 having intra-region connectivity with respect to P13 are extracted and set as a group G4.
[0070]
When the group G4 is generated, reference points P4, P7, P8, and P9 remain as shown in FIG. 20, and these reference points P4, P7, P8, and P9 have intra-region connectivity with each other. Let P4, P7, P8, and P9 be a group G5.
[0071]
If all the reference points P1 to P15 belong to one of the groups G1 to G5 as described above, the grouping process is terminated.
[0072]
When the reference points P1 to P15 are grouped by the above-described procedure, the relationship between the groups G1 to G5 and the reference points P1 to P15 is as shown in FIG. As is clear from the figure, a plurality of individual areas E1 to E4 are connected in the lump area D1, and some of the reference points P1 to P15 included in the different individual areas E1 to E4 have intra-castle connectivity. (For example, the reference point P2 of the individual area E4 has intra-area connectivity between the reference points P7 and P8 of the individual area E3), but the number of groups G1 to G5 is the number of the individual areas E1 to D5. The reference points P1 to P15 that match the number and belong to the grooves G1 to G5 are correctly divided so as to belong to the individual areas E1 to E5.
[0073]
As described above, it is impossible to set one reference point for each individual area, but it may occur when only one reference point is included for any individual area. For example, when the length of the outline of each individual area is known (that is, when the granular object included in the image is known), the individual whose outline length is the smallest among the individual areas If the interval between the reference points set along the contour line is reduced with respect to the region, it is guaranteed that one reference point is set in the individual region having the minimum length of the contour line. However, there is no guarantee that two or more reference points will be set. In the example shown in FIG. 11, there is a possibility that the reference point P5 is not set even if the individual area E2 has the reference point P6. As in the example described above, it is desirable that at least two reference points P1 to P15 are included in one group G1 to G5, but one reference point P1 is included in one individual region E1 to E5. Since only ~ P15 may be set, it is desirable to allow a group including only one reference point to be generated. However, in this case, a correct group cannot be generated unless the condition that the reference point has no intra-area connectivity with any reference point in the adjacent individual area. For example, in FIG. If no reference point P6 exists, one group including only the reference point P6 is generated when the reference point P6 remains as a reference point that does not belong to any other group. In short, when a single reference point that does not belong to any group and does not have intra-region connectivity with other reference points remains during the grouping process, this reference point is also 1 Treat as one group.
[0074]
In the above-described grouping processing procedure, grouping is performed in order starting from the reference point having the smallest intra-region connectivity score. If there is connectivity, a submatrix corresponding to the reference point group that is a candidate for the group is generated, and if the values of all matrix elements of the submatrix are not 0, further regions within the range of the submatrix This is to perform a recursive process of generating a submatrix corresponding to a reference point having the smallest number of inner connectivity (corresponding to the procedure of generating FIGS. 15 to 17 in the above example).
[0075]
In order to explain this reason in more detail, as shown in FIG. 22, a relatively large number of reference points P1 to P7 set in different individual regions E1 and E2 in the cluster region D have intra-region connectivity. Is assumed. In the example shown in FIG. 22, the correspondence table regarding intra-region connectivity is as shown in FIG.
[0076]
Assuming that grouping is performed in order starting from the reference point having the highest intra-region connectivity score, rather than starting from the reference point having the lowest intra-region connectivity score, first the reference point The reference points P2, P3, P4, P6, and P7 having intra-region connectivity for P1 are extracted, and the partial matrix shown in FIG. 24 is generated. Since this submatrix includes a matrix element whose value is not 0, it is necessary to generate a further submatrix from the submatrix of FIG. 24. In the submatrix of FIG. Since the reference point with the maximum number of points is P1, the submatrix cannot be generated from FIG. 24, and eventually the recursive process cannot be continued.
[0077]
On the other hand, in the present embodiment, since the grouping is performed in order from the reference point having the smallest intra-region connectivity score, the reference point P3 is first extracted for FIG. Thus, a submatrix including reference points P1, P2, P3, and P4 is generated.
[0078]
In FIG. 25, since matrix elements whose values are not 0 are included, attention is paid to the reference point P2 having the smallest intra-region connectivity score, and a partial matrix including the reference points P1, P2, and P3 is generated. That is, a partial matrix as shown in FIG. 26 is generated, and a partial matrix in which all matrix element values are 0 can be obtained. In short, by recursively repeating the process until all matrix element values become 0, it is possible to eliminate combinations of reference points that have no intra-region connectivity, and correctly group reference points that have intra-region connectivity with each other. can do.
[0079]
Furthermore, reference points with a small number of intra-region connectivity scores are unlikely to have intra-region connectivity with reference points set in other individual regions. By doing so, the possibility of erroneous division can be reduced. For example, in the example shown in FIG. 22, for the reference point P1 having the highest intra-region connectivity score, three reference points P4, P6 included in the individual region E2 different from the individual region E1 including the reference point P1. For the reference point P3 having the smallest intra-region connectivity score with the intra-region connectivity with P7, the individual region E2 is different from the individual region E1 including the reference point P3. It only has intra-region connectivity with one included reference point P4, and it is easy to exclude unnecessary reference points from the group.
[0080]
As described above, the process of grouping the individual areas after imaging the medicine 2 is collectively shown in FIG. That is, the image captured by the image capturing apparatus 1 is first binarized by the binarizing unit 11 (S1) and stored in the digital image storage unit 12. The digital image analysis determination unit 13 reads the binary image stored in the digital image storage unit 12, and sets an appropriate number of reference points in the vicinity of the outline of the block region included in the binary image (S2). After setting the reference points, intra-region connectivity between each two reference points is determined to generate a correspondence table (S3). Here, a group number n assigned to each group when the reference points are grouped, and a reference point group number j for grouping the reference points for each intra-region connectivity score are initialized (S4). .
[0081]
After the correspondence table is generated, first, a reference point group Uj having the smallest intra-region connectivity score is generated from the reference points that do not belong to any group (S5). A reference point number i for distinguishing reference points is initialized (S6), and it is determined whether or not the reference point with the reference point number i is included in the reference point group Uj (S7). If the reference point of interest is not included in the reference point group Uj, the reference point number i is incremented (S8), and it is determined whether or not the next reference point is included in the reference point group Uj (S7). ). When the reference point is included in the reference point group Uj, it is determined whether or not the reference point belongs to any group (S9). Reference points having inner connectivity are extracted, and reference points having intra-region connectivity with each other are grouped into one group (S10). When one group is thus formed, the reference points belonging to the group are removed from the correspondence table, and the group number is incremented (S11). Further, when the number of remaining reference points is larger than the reference point number i (S12), the reference point number i is incremented (S8), and the processing from step S7 to step S11 is repeated. If the reference point of interest in step S9 already belongs to another group, the reference point number i is incremented and the process returns to step S7. By the above processing, each reference point is grouped, and if the number of reference points that do not belong to the group is smaller than the reference point number i, it is determined whether there are any remaining reference points that do not belong to any group. (S13) If the reference point remains, the reference point group number j is incremented (S14), and the reference point for the reference point group having the next highest intra-region connectivity score among the remaining reference points. A group Uj is generated (S5), and the processing from step S6 to step S12 is performed again. The above processing is continued until all the reference points belong to any group.
[0082]
Since the number of drugs 2 that are granular objects matches the number of groups by the above-described processing procedure, the number of drugs 2 can be counted. Here, if the dosage form of the medicine 2 can also be discriminated, it is considered that the possibility of mistakenly mixing a plurality of medicines 2 collectively can be reduced. Therefore, in the following, a technique for separating the contour lines of the individual regions will be described in order to determine the type such as whether the dosage form is a circular tablet or a capsule. In short, the individual areas are separated from each other by accurately determining the boundaries for the group.
[0083]
Hereinafter, a case where the groups G1 to G5 are formed as shown in FIG. 21 will be described as an example. In this case, since only one group G4 exists for the lump area D2, the lump area D2 is excluded from the following processing on the assumption that it forms one individual area E5. In order to determine the boundaries of the individual regions E1 to E4 after grouping, the contour line L is first tracked, and the shape of the contour line L of the mass region D1 is extracted (contour line tracing is performed when setting the reference points). In this case, the shape of the contour line L obtained when setting the reference points P1 to P12 may be used). Next, as shown in FIG. 27, determination points R1 to R12 that are on the contour line L and are closest to the reference points P1 to P12 are set. Next, the groups G1 to G3 and G5 to which the determination points R1 to R12 belong along the contour line L are obtained. Further, a pair of determination points R1 to R12 that are adjacent to each other along the contour line L and belong to different groups G1 to G3 and G5 are extracted. For example, in the example shown in FIG. 27, a pair of determination points R3 and R4, a pair of determination points R4 and R5, a pair of determination points R6 and R7, a pair of determination points R8 and R10, a pair of determination points R12 and R9, a determination There are six pairs of points R9 and R1. The curvature of the contour line L is obtained between the pair of determination points R1 to R12 thus obtained, and the position where the curvature is maximized is the boundary points B1 to B6 of the individual areas corresponding to the groups G1 to G3 and G5. To do. Among the boundary points B1 to B6, a line segment connecting two boundary points B1 to B6 between the groups G1 to G3 and G5 is defined as a boundary line, and the individual regions E1 to E4 are separated by the boundary line. . That is, in the illustrated example, the boundary points B1 and B6 are between the groups G1 and G5, the boundary points B2 and B3 are between the groups G2 and G5, and the boundary points B4 and B5 are between the groups G3 and G5. , Boundary lines are set between the boundary points B1 and B6, between the boundary points B2 and B3, and between the boundary points B4 and B5, respectively. If the lump area D1 is divided by the boundary line set in this way, it is possible to divide the lump area D1 into the individual areas E1 to E4 almost accurately as shown in FIG.
[0084]
After dividing the lump area D1 into the individual areas E1 to E4, the dosage form is determined based on the feature quantities (area, width, height, contour curvature distribution, etc.) relating to the shapes of the individual areas E1 to E5. It is possible to count the number of each of the two types, or to check for mistakes in the type or contamination of foreign matters.
[0085]
In order to determine the type of the medicine 2 with higher accuracy, an image obtained by imaging the medicine 2 placed on the examination table 3 by the imaging device 1 is registered as a template, and the individual areas E1 to E4 are divided as described above. After that, the type of the medicine 2 may be determined by pattern matching the individual areas E1 to E5 with the template. When such a template is used, it is possible not only to inspect the number of medicines 2 for each type, or to check for mistakes in the type or contamination of foreign substances, but also to perform quality inspections such as cracking of the medicine 2.
[0086]
The above-described process has been described on the assumption that the granular object is uniformly opaque. However, the drug 2 that is actually transparent (a jelly-shaped drug 2 called a soft tablet, a drug 2 in which a liquid is sealed in a transparent capsule, or the like) ), Or a drug 2 having a hole in the part surrounded by the outer periphery of the granular object (such as a donut-shaped drug 2 having a hole in the center so that it does not suffocate even if clogged in the throat when taken) . In order to enable the above-described processing for these medicines 2 as well, a pre-processing for setting the pixel value of the portion inside each medicine 2 in the binary image to 0 is necessary.
[0087]
Considering the transparent medicine 2 now, when the illumination device 4 that performs transmission illumination is used, a donut-shaped silhouette is formed in which the central portion of the medicine 2 becomes bright and only the outer peripheral portion becomes dark due to light refraction. In addition, a similar silhouette is formed in the medicine 2 having a hole in the center as described above. When this type of medicine 2 is imaged by the imaging device 1 and a binary image is generated, a hole region H having the same value as the background is formed inside one individual region E as shown in FIG. become. That is, if the reference points P1 and P2 are set in the vicinity of the contour line L of the individual area E, the connecting line segment s (1-2) connecting both the reference points P1 and P2 passes through the hole area H. There is no intra-region connectivity between P1 and P2, and if the processing described above is performed, the reference points P1 and P2 cannot be handled as one group. That is, when the hole area H having the same value as the background exists in one individual area E, the individual area E cannot be correctly extracted only by the processing procedure described above.
[0088]
Therefore, in consideration of the presence of the medicine 2 that causes the hole region H in the individual region E, preprocessing for removing the hole region H from the binary image is performed as follows. Here, when a plurality of medicines 2 are in contact with each other, as shown in FIG. 30A, a lump region D composed of a plurality (four in the illustrated example) of individual regions E1 to E4. And the hole region H2 surrounded by the individual regions E1 to E4 may be formed, so that the hole regions H1 and H2 in the lump region D are the hole regions H1 inside one individual region E1, A hole region H2 surrounded by the individual regions E1 to E4 is generated. That is, in order to remove the hole area H1, it is necessary to identify whether the hole area H1 is inside the one individual area E1 or the hole area H2 surrounded by the individual areas E1 to E4.
[0089]
First, whether or not the hole regions H1 and H2 exist in the lump region D is identified by extracting a contour line and determining a pixel value inside the contour line. That is, if the pixel value inside the figure surrounded by the contour line is 1 (that is, the same pixel value as the background), the region surrounded by the contour line can be determined as the hole regions H1 and H2. As can be seen from FIG. 30 (a), the hole region H1 formed inside the individual region E1 for the reasons described above is a simple circle or ellipse and is smoothly continuous, whereas a plurality of individual regions The contour line of the hole region H2 formed by being surrounded by the regions E1 to E4 is formed with a plurality of curvature discontinuity points F1 to F4 where the change in curvature becomes discontinuous when sequentially tracking the contour line. . If this property is utilized, the hole regions H1 and H2 are sequentially traced on the contour lines, the curvatures at predetermined intervals of the contour lines are examined, and the presence or absence of the curvature discontinuities F1 to F4 is determined. , H2 can be identified. For the hole region H1 inside the individual region E1, the value of the pixel inside the contour line is set to 0 (that is, the individual region as shown in FIG. 30B). The hole region H1 is removed in accordance with the values of other parts of E1 to E4. By performing such preprocessing, the individual regions E1 to E4 can be separated by the processing procedure described above.
[0090]
By the way, when the medicine 2 is imaged in a state of being wrapped with a packaging material, a plurality of small hole regions may be generated as noise in one individual region due to the surface reflection of the packaging material, and the surface of the packaging material may become dirty. If there is, the dirty portion may have the same pixel value as that of the individual area and may become noise. In order to eliminate the effects of this kind of noise, detect the hole area contained in it as well as the mass area and take into account the known drug 2 dimensions and the predicted hole area dimensions, It is desirable to remove the region as noise.
[0091]
In the above-described processing procedure, the shorter the length of the contact part of the medicine 2, the lower the possibility that a connecting line segment extending over different individual areas will be formed. The possibility can be reduced. Therefore, when a lump area D in which a plurality of individual areas E1 to E4 are continuous is formed as shown in FIG. 31 (a), the reduction process (that is, the outline L of the lump area D by a predetermined number of pixels) is performed in advance. It is desirable to reduce the length of the contact parts of the individual regions E1 to E4 as shown in FIG. By performing such processing, the reliability at the time of separating the individual areas E1 to E4 from the lump area D is improved.
[0092]
【The invention's effect】
Claim According to the configurations of the inventions 1, 20, Even when individual regions corresponding to several granular objects are in contact with each other to form a lump region, whether or not the lump region is composed of a plurality of individual regions can be easily determined by the number of groups. Can be determined. In addition, since relatively simple illumination such as transmitted illumination or epi-illumination is used and only a still image is captured, it can be configured by general-purpose and inexpensive equipment without using a special and expensive device. Become. Moreover, when separating granular objects , Generate a connecting line segment connecting all reference points to each other, Since it is used to determine whether or not the connected line segment passes outside the block area, if the position of the reference point that is the end point of the connected line segment is set appropriately, the size and shape may differ or the structure may have some dents. Even if there are mixed granular objects, it is possible to correctly separate the granular objects and count the number. Furthermore, there is no need to analyze the shape of the outline of the lump area in detail or perform pattern matching processing that takes a long time on the entire image, so that the connected line segments pass outside the lump area for a small number of reference points. It is possible to determine in a short time whether or not the lump area is composed of a plurality of individual areas only by evaluation of whether or not.
[0093]
Since the digital image is a binary image binarized with respect to the density of the image picked up by the image pickup device in the invention of claim 1, the invention of claim 2 is processed in comparison with the case of using a multi-value image. Is simple, and the processing time can be further shortened.
[0094]
According to a third aspect of the present invention, in the first or second aspect of the invention, the digital image analysis determining means sets at least two reference points in the individual region having the smallest vertical or horizontal width dimension among the individual regions. Since the reference points are arranged in such a manner, a necessary and sufficient number of reference points can be set for each individual area, and the possibility of erroneously recognizing the number of individual areas constituting the cluster area can be reduced.
[0095]
In the invention of claim 4, in the invention of claim 1 or claim 2, the digital image analysis determination means sets the reference point on the inner side by a distance defined with respect to the outline of the lump area, so Each granular object can be correctly recognized even when a granular object that includes a portion is included.
[0096]
In the invention of claim 5, in the invention of claim 4, the distance between the reference point and the contour line is set so that the connecting line segment passes through the inside of the individual region with respect to the recessed portion generated in the contour line of the individual region. As a result, the position of the reference point is adjusted according to the size of the granular object to be inspected and the size of the concave portion generated in the outline of the granular object, and as a result, the number of individual areas can be erroneously recognized. Can be reduced.
[0097]
In the invention of claim 6, in the invention of claim 1 or 2, the digital image analysis determination means sets the reference points at intervals defined along the outline of the block region, so that the reference points are appropriately arranged. can do.
[0098]
According to a seventh aspect of the invention, in the first or second aspect of the invention, the digital image analysis determining means sets lattice points at regular intervals in the screen of the digital image, and sets the lattice points located inside the lump area. As a starting point, the contour line is searched in a plurality of directions, and the reference point is set on the line in the direction where the distance between each lattice point and the contour line is the shortest. Even when the size is relatively large, high-speed processing can be expected.
[0099]
In the invention of claim 8, in the invention of claim 1 or claim 2, the digital image analysis judging means sets lattice points at regular intervals in the screen of the digital image, and sets the lattice points located inside the lump area. The contour line is searched in one direction determined for each grid point as a starting point, and the reference point is set on the line in the direction in which the contour line is searched from each grid point. Therefore, the process of setting the reference point is simple. Thus, particularly high-speed processing can be expected when the number of reference points is relatively small.
[0100]
According to a ninth aspect of the invention, in the first or second aspect of the invention, the digital image analysis determining means sets a reference point at a predetermined distance near both sides of a region where the curvature of the outline of the mass region is larger than a specified value. Therefore, it is possible to reduce the possibility that the connecting line segment between the reference points included in the adjacent individual areas passes only within the mass area, and improve the reliability when separating the individual areas from the mass area. can do.
[0101]
According to a tenth aspect of the present invention, in the first or second aspect of the invention, the digital image analysis judging means is a point on the connecting line segment for each contour point that is a point on the contour line of the block region. When the contour point is a point on the connecting line segment, it is determined that the connecting line segment passes outside the block region, so the coordinates of all the pixels on the connecting line segment connecting the reference points are As a result, the load on the process for determining whether or not the connecting line segment passes outside the block region is reduced, and high-speed processing can be expected. That is, in order to determine whether or not the connecting line segment connecting the reference points passes only inside the block region, if the pixel value is determined for all the pixels on the connecting line segment, the expression of the connecting line segment It is necessary to obtain the coordinates of each pixel on the connecting line segment based on the above, and in this case, the coordinate operation is performed the number of times corresponding to (number of connecting line segments) × (number of pixels on the connecting line segment). In addition, it is necessary to determine the pixel value, and it takes a lot of time. On the other hand, in the invention of claim 10, when the contour point on the contour line is located on the connecting line segment connecting the reference points, the reference point set as the end point of the connecting line segment is not included in the set. Since it is only determined that there is no connectivity within the castle, the amount of computation can be greatly reduced.
[0102]
In the invention of claim 11, in the invention of claim 1 or claim 2, the digital image analysis determination means is configured such that the coordinates of each contour point which is a point on the contour line of the block region are the reference points at both ends of the connecting line segment. And when the equation is established by substituting the coordinates of the contour point into the expression of the connection line segment, it is determined that the connection line segment passes outside the block region. It is possible to determine whether or not the connected line segment passes outside the lump area by simply substituting the coordinates of the contour point for the line segment expression, which can greatly reduce the amount of calculation. it can.
[0103]
According to a twelfth aspect of the present invention, in the first or second aspect of the invention, the digital image analysis judging means sets a plurality of division points on the outline of the block region and connects the division points adjacent to each other. When a line segment is set and the connecting line segment and the segment line segment intersect, it is determined that the link segment passes outside the block area, so the outline of the block area is approximated by a polygon consisting of the segment line segment. As a result, it is possible to make a determination in a short time compared to the case of determining each one of the contour points on the contour line.
[0104]
According to a thirteenth aspect of the present invention, in the first or second aspect of the present invention, the digital image analysis determining means is configured such that the connecting line segment between each reference point and another reference point passes only inside the mass region. Starting from the reference points with a small number of lines, all the reference points where the connecting line segment between the reference points passes only inside the lump area and the combination of all the extracted reference points are connected. A process is performed in which the reference points that satisfy the condition that the minute passes only inside the chunk area are grouped, and this process is repeated until all the reference points belong to one of the groups. Therefore, even if the connecting line segment connecting the reference points included in different individual areas does not pass outside the lump area, the connection line segment is limited only to the inside of the lump area by combining all the reference points. Pass By performing the processing of the group satisfies the reference point mentioned, it is possible to correctly grouping reference point.
[0105]
In the invention of claim 14, in the invention of claim 1 or claim 2, the digital image analysis determination means includes a block of connecting line segments between the reference points for a square matrix having all combinations of reference points as matrix elements. Stores whether or not to pass outside the area in association with the matrix element, and obtains the number of matrix elements whose connected line segments pass only inside the block area for each reference point, and references with a small number Starting from a point, a submatrix consisting of a combination of all reference points where the connecting line segment to the reference point passes only inside the block region is generated from a square matrix and connected by all the matrix elements of the submatrix. When the condition that the line segment passes only inside the block region is satisfied, the reference points that are elements of the submatrix are grouped, and the submatrix is generated by excluding the grouped reference points from the rows and columns of the square matrix. Process, the process It is repeated until all reference points belong to one of the groups, even if the connecting line segment connecting the reference points included in different individual areas does not pass outside the mass area, The reference points can be correctly grouped by performing the process of grouping the reference points that satisfy the condition that the connecting line segments pass only inside the block region in all combinations of the reference points. In addition, since a matrix having matrix elements corresponding to the connected line segments is used, the grouping process is simplified.
[0106]
In the invention of claim 15, in the invention of claim 1 or claim 2, the digital image analysis determination means extracts two reference points belonging to different groups along the outline of the lump region, and the two Since the part with the maximum curvature in the contour line between the reference points is determined as the part on the boundary line of the adjacent individual area, the boundary line for dividing the individual area can be easily set, The process of dividing into individual areas can be performed accurately and easily.
[0107]
In the invention of claim 16, in the invention of claim 2, the digital image analysis determination means detects a hole area when the area having the same pixel value as the background exists inside the outline of the block area, and Since the hole region is filled when the contour line is smoothly continuous, a hole region formed by being surrounded by a plurality of individual regions is distinguished from a hole region formed inside the individual region, Since only the hole area inside the individual area can be filled, the individual area can be correctly cut out even if the granular object is transparent or donut-shaped.
[0108]
In the invention of claim 17, in the invention of claim 1 or claim 2, the digital image analysis determination means sets the reference point after performing the reduction process of removing pixels in the vicinity of the contour line in the block region. The length of the connection part of the adjacent individual area will be reduced, reducing the possibility that the connecting line segment will pass only inside the mass area between the reference points included in different individual ramps, resulting in individual The reliability of area division can be improved.
[0109]
In the invention of claim 18, in the invention of claim 1 or claim 2, the digital image analysis determination means determines the type of granular object using the feature quantity related to the shape of the individual area, and for each type of granular object. Since at least one of counting the number and judging whether the granular object is wrong is inspected as an inspection item, it is possible to easily perform the number inspection and the type inspection on the granular object corresponding to each individual area divided using the reference points. it can.
[0110]
In the invention of claim 19, in the invention of claim 1 or 2, the digital image analysis determination means determines the type of the granular object by pattern-matching the individual area to the template of the granular object to be inspected. Since at least one of counting the number of granular object types, determining whether the granular object type is wrong, and determining whether the granular object is good or bad is inspected as an inspection item, it corresponds to each individual area divided using reference points It is possible to easily perform the number inspection, the type inspection, and the quality determination regarding the granular object to be performed.
[Brief description of the drawings]
FIG. 1 is a schematic configuration diagram showing an embodiment of the present invention.
FIG. 2 is a flowchart for explaining the grouping technique in the above.
3A is a diagram illustrating an image captured by an imaging apparatus, and FIG. 3B is a diagram illustrating a binary image.
FIG. 4 is a diagram illustrating the principle of the present invention.
FIG. 5 is a diagram illustrating the concept of the present invention.
FIG. 6 is an explanatory diagram showing an example of setting reference points in the embodiment of the present invention.
FIG. 7 is an explanatory diagram showing a reference point setting method using a grid in the same as above.
FIG. 8 is an explanatory diagram showing an example of setting reference points using a grid in the same as above.
FIG. 9 is an explanatory diagram showing another example of setting reference points using a grid.
FIG. 10 is an explanatory diagram showing another example of setting reference points in the same as above.
FIG. 11 is an explanatory diagram showing a method for evaluating intra-region connectivity in the same as above.
FIG. 12 is an explanatory diagram showing another evaluation method for intra-region connectivity in the same as above.
FIG. 13 is a diagram showing a correspondence table used for grouping in the above.
FIG. 14 is a diagram showing a partial matrix for confirming mutual connectivity within the region in the same as above.
FIG. 15 is a diagram showing a submatrix used in the grouping process in the above.
FIG. 16 is a diagram showing a submatrix used in the grouping process in the above.
FIG. 17 is a diagram showing a submatrix for confirming mutual intra-region connectivity in the above.
FIG. 18 is a diagram showing a submatrix used in the grouping process in the above.
FIG. 19 is a diagram showing a submatrix used in the grouping process in the above.
FIG. 20 is a diagram showing a partial matrix for confirming mutual connectivity within the region in the same as above.
FIG. 21 is a diagram for explaining the concept of grouping in the above.
FIG. 22 is a diagram for explaining the legitimacy of the processing procedure used in the above.
23 is a diagram showing a correspondence table in the example shown in FIG.
FIG. 24 is a diagram showing a submatrix used in a comparative example.
FIG. 25 is a diagram showing a submatrix used in the grouping process in the example shown in FIG.
FIG. 26 is a diagram showing a partial matrix for confirming mutual intra-region connectivity in the example shown in FIG. 22;
FIG. 27 is a diagram showing a method of dividing individual areas in the embodiment of the present invention.
FIG. 28 is a diagram showing a state where the individual areas are divided in the above.
FIG. 29 is a diagram showing an example of generating a hole region in the same as above.
FIG. 30 is an explanatory diagram showing an example of pre-processing when a hole region is generated in the same as above.
FIG. 31 is an explanatory diagram showing an example of pre-processing for improving reliability in the above.
[Explanation of symbols]
1 Imaging device
2 drugs
3 Inspection table
4 Lighting equipment
11 Binarization means
12 Digital image storage means
13 Digital image analysis determination means

Claims (20)

検査対象である粒状物体を含む撮像領域を撮像する撮像装置と、撮像装置により撮像された画像の濃度に関してデジタル化したデジタル画像を記憶するデジタル画像記億手段と、デジタル画像内において複数個の粒状物体に対応する領域が互いに接触しているときに各粒状物体に対応する領域を分割する機能を有した画像解析判定手段とを備え、デジタル画像解析判定手段は、デジタル画像において1個以上の粒状物体に対応する連続した領域である塊領域の輪郭線上または輪郭線の内側の近傍部位に複数個の参照点を分散して配置する機能と、すべての参照点同士を相互に連結した連結線分を生成したときにどの連結線分も塊領域の外を通らない参照点の組合せを1つのグループとしてすべての参照点にグループを対応付けるグループ化の機能と、参照点のグループと前記デジタル画像内における前記粒状物体の画像領域である個別領域とを一対一に対応付けることにより粒状物体に関する検査項目を検査する機能とを備えることを特徴とする粒状物体の検査装置。An imaging device that captures an imaging region including a granular object to be inspected, a digital image storage unit that stores a digital image digitized with respect to the density of an image captured by the imaging device, and a plurality of granular images in the digital image An image analysis determination unit having a function of dividing the region corresponding to each granular object when the regions corresponding to the objects are in contact with each other, and the digital image analysis determination unit includes one or more granular items in the digital image. and the ability to place distributed a plurality of reference points on the site near the inner continuous on the contour line of the mass region is a region or contour corresponding to the object, connection lines connecting all the reference points between each other A grouping that associates all reference points as a group with a combination of reference points that do not pass outside the block region when any segment is generated. And a function of inspecting an inspection item related to a granular object by associating a group of reference points and an individual area that is an image area of the granular object in the digital image on a one-to-one basis. Inspection equipment. 前記デジタル画像が、前記撮像装置により撮像された画像の濃度に関して二値化した二値画像であることを特徴とする請求項1記載の粒状物体の検査装置。2. The granular object inspection apparatus according to claim 1, wherein the digital image is a binary image binarized with respect to a density of an image captured by the imaging apparatus. 前記デジタル画像解析判定手段は、前記個別領域のうち縦または横の幅寸法が最小である個別領域に前記参照点が少なくとも2個設定されるように参照点を配置することを特徴とする請求項1または請求項2記載の粒状物体の検査装置。The digital image analysis determination unit arranges reference points so that at least two reference points are set in an individual region having a minimum vertical or horizontal width dimension among the individual regions. The inspection apparatus for granular objects according to claim 1 or 2. 前記デジタル画像解析判定手段は、前記塊領域の輪郭線に対して規定した距離だけ内側に前記参照点を設定することを特徴とする請求項1または請求項2記載の粒状物体の検査装置。3. The granular object inspection apparatus according to claim 1, wherein the digital image analysis determination unit sets the reference point on the inner side by a distance defined with respect to the outline of the lump area. 前記個別領域の輪郭線に生じる凹み部分に対して前記連結線分が前記個別領域の内側を通過するように、前記参照点と輪郭線との距離を設定することを特徴とする請求項4記載の粒状物体の検査装置。The distance between the reference point and the contour line is set so that the connecting line segment passes through the inside of the individual region with respect to a recessed portion generated in the contour line of the individual region. Granular object inspection device. 前記デジタル画像解析判定手段は、前記塊領域の輪郭線に沿って規定した間隔で前記参照点を設定することを特徴とする請求項1または請求項2記載の粒状物体の検査装置。3. The granular object inspection apparatus according to claim 1, wherein the digital image analysis determination unit sets the reference points at intervals defined along the outline of the lump area. 前記デジタル画像解析判定手段は、前記デジタル画像の画面内に一定間隔の格子点を設定し、前記塊領域の内側に位置する格子点を起点として複数の方向に輪郭線を探索するとともに、各格子点と輪郭線との距離が最短になる方向の線上に参照点を設定することを特徴とする請求項1または請求項2記載の粒状物体の検査装置。The digital image analysis determination means sets lattice points at regular intervals in the screen of the digital image, searches for contour lines in a plurality of directions starting from lattice points located inside the block region, and 3. The granular object inspection apparatus according to claim 1, wherein the reference point is set on a line in a direction in which the distance between the point and the contour line is shortest. 前記デジタル画像解析判定手段は、前記デジタル画像の画面内に一定間隔の格子点を設定し、前記塊領域の内側に位置する格子点を起点として各格子点ごとに定めた1つの方向に輪郭線を探索するとともに、各格子点から輪郭線を探索する方向の線上に参照点を設定することを特徴とする請求項1または請求項2記載の粒状物体の検査装置。The digital image analysis determination means sets lattice points at regular intervals in the screen of the digital image, and outlines in one direction determined for each lattice point starting from a lattice point located inside the block region. 3. The granular object inspection apparatus according to claim 1, wherein a reference point is set on a line in a direction in which a contour line is searched from each lattice point. 前記デジタル画像解析判定手段は、前記塊領域の輪郭線の曲率が規定値より大きい部位の両側近傍の所定の距離に前記参照点を設定することを特徴とする請求項1または請求項2記載の粒状物体の検査装置。The said digital image analysis determination means sets the said reference point to the predetermined distance of the both sides of the site | part where the curvature of the outline of the said lump area | region is larger than a regulation value, The said reference point is characterized by the above-mentioned. Inspection device for granular objects. 前記デジタル画像解析判定手段は、前記塊領域の輪郭線の上の点である各輪郭点ごとに前記連結線分の上の点か否かを判定し、当該輪郭点が連結線分の上の点であるときには当該連結線分が塊領域の外側を通過すると判断することを特徴とする請求項1または請求項2記載の粒状物体の検査装置。The digital image analysis determination means determines whether each contour point that is a point on the contour line of the block region is a point on the connecting line segment, and the contour point is on the connecting line segment. 3. The granular object inspection apparatus according to claim 1, wherein when the point is a point, it is determined that the connecting line segment passes outside the lump area. 前記デジタル画像解析判定手段は、前記塊領域の輪郭線の上の点である各輪郭点の座標が前記連結線分の両端の参照点の間の座標であって、かつ当該輪郭点の座標を当該連結線分の式に代入して等式が成立するときに、当該連結線分が塊領域の外側を通過すると判断することを特徴とする請求項1または請求項2記載の粒状物体の検査装置。The digital image analysis determination unit is configured such that the coordinates of each contour point, which is a point on the contour line of the block region, are coordinates between reference points at both ends of the connecting line segment, and the coordinates of the contour point are determined. The granular object inspection according to claim 1 or 2, wherein when the equation is established by substituting into the equation of the connecting line segment, it is determined that the connecting line segment passes outside the lump region. apparatus. 前記デジタル画像解析判定手段は、前記塊領域の輪郭線の上に複数個の区分点を設定するとともに隣接する区分点間を結ぶ区分線分を設定し、前記連結線分と区分線分とが交差しているときに前記連結線分が前記塊領域の外側を通過すると判断することを特徴とする請求項1または請求項2記載の粒状物体の検査装置。The digital image analysis determining means sets a plurality of segment points on the outline of the block region and sets segment line segments connecting adjacent segment points, and the connecting segment segment and segment segment segment are 3. The granular object inspection apparatus according to claim 1, wherein the connecting line segment is determined to pass outside the lump area when intersecting. 前記デジタル画像解析判定手段は、前記参照点ごとに他の参照点との間の連結線分が前記塊領域の内側のみを通過する本数を計数し、当該本数の少ない参照点から始めて、当該参照点との間の連結線分が塊領域の内側のみを通過する参照点をすべて抽出するとともに抽出したすべての参照点の組合せで連結線分が塊領域の内側のみを通るという条件を満たす参照点を前記グループとする処理を行い、当該処理をすべての参照点がいずれかのグループに属するようになるまで繰り返すことを特徴とする請求項1または請求項2記載の粒状物体の検査装置。The digital image analysis determination means counts the number of connecting line segments between each reference point and other reference points only through the inside of the block region, and starts from the reference points with a small number of the reference points. A reference point that satisfies the condition that all the reference points where the connecting line segment between the points passes only inside the lump area and that the connecting line segment passes only inside the lump area by the combination of all the extracted reference points The granular object inspecting apparatus according to claim 1, wherein the process is performed so that all the reference points belong to any group. 前記デジタル画像解析判定手段は、前記参照点の全組合せを行列要素とする正方行列に対して各参照点間の連結線分が前記塊領域の外側を通過するか否かを行列要素に対応付けて格納し、各参照点ごとに連結線分が塊領域の内側のみを通過している行列要素の個数を求め、当該個数の少ない参照点から始めて、当該参照点との間の連結線分が塊領域の内側のみを通過するすべての参照点の組合せからなる部分行列を前記正方行列から生成し、当該部分行列の行列要素のすべてで連結線分が塊領域の内側のみを通るという条件を満たすときに当該部分行列の要素である参照点を前記グループとし、グループとなった参照点を前記正方行列の行および列から除いた部分行列を生成する処理を行い、当該処理をすべての参照点がいずれかのグループに属するようになるまで繰り返すことを特徴とする請求項1または請求項2記載の粒状物体の検査装置。The digital image analysis determination means associates, with a matrix element, whether or not a connecting line segment between each reference point passes outside the block region with respect to a square matrix having all combinations of the reference points as matrix elements. The number of matrix elements for which each connecting point passes only inside the block region is obtained for each reference point, and the connecting line segment between the reference point and the reference point is calculated starting from the reference point having a small number. A submatrix consisting of a combination of all reference points that pass only inside the block region is generated from the square matrix, and all the matrix elements of the submatrix satisfy the condition that the connected line segments pass only inside the block region Sometimes a reference point that is an element of the submatrix is set as the group, a process of generating a submatrix in which the grouped reference points are excluded from the rows and columns of the square matrix, and the process is performed for all the reference points. Any group Inspection device of the granular objects according to claim 1 or claim 2, wherein the repeating until belongs. 前記デジタル画像解析判定手段は、前記塊領域の輪郭線に沿って異なるグループに属する2個の参照点を抽出し、当該2個の参照点の間の輪郭線において曲率が最大である部位を隣接する前記個別領域の境界線上の部位と判断することを特徴とする請求項1または請求項2記載の粒状物体の検査装置。The digital image analysis determination unit extracts two reference points belonging to different groups along the outline of the block region, and adjoins a part having the maximum curvature in the outline between the two reference points The granular object inspection apparatus according to claim 1, wherein the granular object inspection apparatus determines that the part is on a boundary line of the individual area. 前記デジタル画像解析判定手段は、前記塊領域の輪郭線の内側に背景と同じ画素値の領域が存在するときに穴領域として検出し、穴領域の輪郭線が滑らかに連続しているときに当該穴領域を埋めることを特徴とする請求項2記載の粒状物体の検査装置。The digital image analysis determination means detects a hole area when an area having the same pixel value as the background is present inside the outline of the block area, and detects when the outline of the hole area is smoothly continuous 3. The granular object inspection apparatus according to claim 2, wherein the hole region is filled. 前記デジタル画像解析判定手段は、前記塊領域における輪郭線の近傍の画素を除去する縮小処理を行った後に前記参照点を設定することを特徴とする請求項1または請求項2記載の粒状物体の検査装置。3. The granular object according to claim 1, wherein the digital image analysis determination unit sets the reference point after performing a reduction process of removing pixels in the vicinity of the contour line in the block region. Inspection device. 前記デジタル画像解析判定手段は、前記個別領域の形状に関する特徴量を用いて粒状物体の種別を判断するとともに、粒状物体の種別ごとの個数の計数と粒状物体の種別の間違いの判断の少なくとも一方を前記検査項目として検査することを特徴とする請求項1または請求項2記載の粒状物体の検査装置。The digital image analysis determination means determines a granular object type using a feature amount related to the shape of the individual region, and at least one of counting the number of granular object types and determining whether the granular object type is incorrect. 3. The granular object inspection apparatus according to claim 1, wherein the inspection is performed as the inspection item. 前記デジタル画像解析判定手段は、検査対象となる粒状物体のテンプレートに前記個別領域をパターンマッチングすることにより粒状物体の種別を判断するとともに、粒状物体の種別ごとの個数の計数と粒状物体の種別の間違いの判断と粒状物体の良否判定との少なくとも1つを前記検査項目として検査することを特徴とする請求項1または請求項2記載の粒状物体の検査装置。The digital image analysis determination means determines the type of granular object by pattern matching the individual area with a template of the granular object to be inspected, and counts the number of granular objects for each type of granular object. 3. The granular object inspection apparatus according to claim 1, wherein at least one of an error determination and a granular object quality determination is inspected as the inspection item. 検査対象である粒状物体を含む撮像領域を撮像する撮像装置と、撮像装置により撮像された画像の濃度に関してデジタル化したデジタル画像を記憶するデジタル画像記億手段と、デジタル画像内において複数個の粒状物体に対応する領域が互いに接触しているときに各粒状物体に対応する領域を分割する機能を有した画像解析判定手段とを備える検査装置により粒状物体に関する検査項目を検査する粒状物体の検査方法であって、デジタル画像解析判定手段では、デジタル画像において1個以上の粒状物体に対応する連続した領域である塊領域の輪郭線上または輪郭線の内側の近傍部位に複数個の参照点を分散して配置した後、すべての参照点同士を相互に連結した連結線分を生成したときにどの連結線分も塊領域の外を通らない参照点の組合せを1つのグループとしてすべての参照点にグループを対応付けるグループ化を行い、次に、参照点のグループと前記デジタル画像内における前記粒状物体の画像領域である個別領域とを一対一に対応付けることにより粒状物体に関する検査項目を検査することを特徴とする粒状物体の検査方法。An imaging device that captures an imaging region including a granular object to be inspected, a digital image storage unit that stores a digital image digitized with respect to the density of an image captured by the imaging device, and a plurality of granular images in the digital image A granular object inspection method for inspecting an inspection item related to a granular object by an inspection apparatus including an image analysis determination unit having a function of dividing the area corresponding to each granular object when the areas corresponding to the object are in contact with each other a is, in a digital image analysis determination unit, distributing the plurality of reference point near the inside portion of the one or more on the contour line of the mass region is a continuous region corresponding to the particulate matter or contour in a digital image and after placement, the set of all what connected line segments when mutually generated the connecting line coupled to the reference point to each other even not pass through the outer mass region reference point By grouping the reference points as groups into all reference points, and then associating the reference point groups with individual regions that are image regions of the granular objects in the digital image on a one-to-one basis. A method for inspecting a granular object, comprising inspecting an inspection item relating to the granular object.
JP2003019456A 2003-01-28 2003-01-28 Inspection apparatus and inspection method for granular object Expired - Fee Related JP4300809B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2003019456A JP4300809B2 (en) 2003-01-28 2003-01-28 Inspection apparatus and inspection method for granular object

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2003019456A JP4300809B2 (en) 2003-01-28 2003-01-28 Inspection apparatus and inspection method for granular object

Publications (2)

Publication Number Publication Date
JP2004234132A JP2004234132A (en) 2004-08-19
JP4300809B2 true JP4300809B2 (en) 2009-07-22

Family

ID=32949303

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2003019456A Expired - Fee Related JP4300809B2 (en) 2003-01-28 2003-01-28 Inspection apparatus and inspection method for granular object

Country Status (1)

Country Link
JP (1) JP4300809B2 (en)

Families Citing this family (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4639841B2 (en) * 2005-02-23 2011-02-23 パナソニック電工株式会社 Inspection method for granular object and inspection apparatus using the same
JP4639840B2 (en) * 2005-02-23 2011-02-23 パナソニック電工株式会社 Inspection method for granular object and inspection apparatus using the same
CN101175990B (en) * 2005-02-23 2011-04-20 松下电工株式会社 Inspection method of particlate body and inspection device using it
JP4991278B2 (en) * 2006-12-25 2012-08-01 パナソニック株式会社 Image processing device
JP4966110B2 (en) * 2007-06-26 2012-07-04 パナソニック株式会社 Object identification method and object identification device
JP4755714B2 (en) * 2009-11-17 2011-08-24 株式会社湯山製作所 Drug dispensing device
JP5338978B2 (en) 2010-05-10 2013-11-13 富士通株式会社 Image processing apparatus and image processing program
JP5750603B2 (en) * 2011-03-23 2015-07-22 株式会社ブレイン Object identification device
JP5337844B2 (en) * 2011-06-30 2013-11-06 株式会社東芝 Region detection apparatus, region detection method, and program
CN103492862A (en) * 2011-07-13 2014-01-01 松下电器产业株式会社 Tablet inspection device and tablet inspection method
WO2013021543A1 (en) * 2011-08-08 2013-02-14 パナソニック株式会社 Medication package checking system
CN105208995B (en) * 2013-05-22 2020-01-14 普和希控股公司 Tablet inspection device and tablet inspection method
JP6678375B2 (en) * 2013-11-18 2020-04-08 東京エレクトロン株式会社 Information processing apparatus, information processing method, and information processing system
ES2966157T3 (en) * 2016-08-05 2024-04-18 Yuyama Mfg Co Ltd Medication dispensing apparatus

Also Published As

Publication number Publication date
JP2004234132A (en) 2004-08-19

Similar Documents

Publication Publication Date Title
JP4300809B2 (en) Inspection apparatus and inspection method for granular object
US5796868A (en) Object edge point filtering system for machine vision
WO2014092741A1 (en) Pill identification and counterfeit detection method
US6118893A (en) Analysis of an image of a pattern of discrete objects
KR100929475B1 (en) Inspection method of granular object and inspection apparatus performing the method
CN104990926A (en) TR element locating and defect detecting method based on vision
US20070201733A1 (en) Fingerprint collation apparatus, fingerprint pattern area extracting apparatus and quality judging apparatus, and method and program of the same
US7809195B1 (en) Encoding system providing discrimination, classification, and recognition of shapes and patterns
CN111353992B (en) Agricultural product defect detection method and system based on textural features
KR102037560B1 (en) Device for measuring appearance of grains
Duong et al. Vision inspection system for pharmaceuticals
JP4104213B2 (en) Defect detection method
JP4581424B2 (en) Appearance inspection method and image processing apparatus
JPH0224542A (en) Quality evaluating apparatus for cross section of casting piece
KR102390058B1 (en) Data generation device and method for led panel defect detection
CN116710960A (en) Bubble recognition device, bubble recognition method, and foreign matter detection system
JP2006234518A (en) Inspection method of particlate body and inspection device using it
JPH07200820A (en) Image recognition processing method
JP5033077B2 (en) Method and apparatus for inspecting appearance of molded product
Suksawatchon et al. Shape Recognition Using Unconstrained Pill Images Based on Deep Convolution Network
US20030021480A1 (en) Method, program product, and device for detecting branch point of random line pattern
US20170200383A1 (en) Automated review of forms through augmented reality
US20200232967A1 (en) Culture state determination
US7050621B2 (en) Specified pattern detecting apparatus
WO2022264382A1 (en) Object discrimination device

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20050819

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20081014

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20081028

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20090105

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: 20090331

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20120501

Year of fee payment: 3

R151 Written notification of patent or utility model registration

Ref document number: 4300809

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R151

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20090413

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20120501

Year of fee payment: 3

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20120501

Year of fee payment: 3

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20130501

Year of fee payment: 4

LAPS Cancellation because of no payment of annual fees