JP4850961B2 - Image processing apparatus and method - Google Patents

Image processing apparatus and method Download PDF

Info

Publication number
JP4850961B2
JP4850961B2 JP2010157308A JP2010157308A JP4850961B2 JP 4850961 B2 JP4850961 B2 JP 4850961B2 JP 2010157308 A JP2010157308 A JP 2010157308A JP 2010157308 A JP2010157308 A JP 2010157308A JP 4850961 B2 JP4850961 B2 JP 4850961B2
Authority
JP
Japan
Prior art keywords
region
area
red
candidate
eye
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
JP2010157308A
Other languages
Japanese (ja)
Other versions
JP2010257482A (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.)
Canon Inc
Original Assignee
Canon Inc
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 Canon Inc filed Critical Canon Inc
Priority to JP2010157308A priority Critical patent/JP4850961B2/en
Publication of JP2010257482A publication Critical patent/JP2010257482A/en
Application granted granted Critical
Publication of JP4850961B2 publication Critical patent/JP4850961B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Image Processing (AREA)
  • Facsimile Image Signal Circuits (AREA)
  • Color Image Communication Systems (AREA)
  • Image Analysis (AREA)

Description

本発明は画像処理装置およびその方法に関し、例えば、目の色調不良を示す画像領域を検出する画像処理に関する。   The present invention relates to an image processing apparatus and a method thereof, and, for example, relates to an image processing for detecting an image region showing a poor color tone of eyes.

カメラのフラッシュに起因する目の色調不良を補正する方法が提案されている。なお、目の色調不良は、赤目現象として一般によく知られている。赤目現象は、照明の少ない環境下で、人間あるいは犬や猫などの動物を、フラッシュを使用して撮影した際、開いた瞳孔部分に入ったフラッシュの光が眼底で反射して、毛細血管が赤く光る現象である。色素が薄い(少ない)人の方が、瞳孔すなわち水晶体の透過率が高いため、赤目現象を生じ易いとされている。   There have been proposed methods for correcting poor eye tone caused by camera flash. Incidentally, poor color tone of eyes is generally well known as a red-eye phenomenon. The red-eye phenomenon occurs when a human or an animal such as a dog or cat is photographed using a flash in a low-light environment, and the light from the flash that enters the open pupil is reflected from the fundus, causing capillaries to appear. It is a phenomenon that shines red. It is said that a person with less (less) pigment is more likely to cause a red-eye phenomenon because the transmittance of the pupil, that is, the lens, is higher.

また、近年普及したディジタルカメラはさらに小型化が進み、レンズの光軸とフラッシュの光源位置が近付く傾向にある。一般に、フラッシュの光源位置がレンズの光軸に近いほど、赤目現象が発生し易いとされ、その対策は重要な課題になっている。   In recent years, digital cameras that have become widespread have been further miniaturized, and the optical axis of the lens tends to approach the light source position of the flash. In general, the closer the light source position of the flash is to the optical axis of the lens, the easier the red-eye phenomenon occurs, and countermeasures are becoming an important issue.

赤目現象を防ぐ一つの手段として、撮影を行う際にプレ発光を行い、被写体の瞳孔が閉じた上で撮影を行う方法が知られている。しかし、この方法は、通常の撮影に比べて電池を消耗させることや、プレ発光によって被写体の表情が崩れる不具合がある。   As one means for preventing the red-eye phenomenon, a method is known in which pre-light emission is performed at the time of photographing, and photographing is performed after the pupil of the subject is closed. However, this method has a problem that the battery is consumed and the facial expression of the subject is destroyed by pre-emission compared to normal shooting.

そこで、近年、ディジタルカメラによる撮影で得られたディジタル画像データを、パーソナルコンピュータなどを使用して補正、加工することで、赤目を修正する方法が数多く提案されている。   Therefore, in recent years, many methods have been proposed for correcting red eyes by correcting and processing digital image data obtained by photographing with a digital camera using a personal computer or the like.

ディジタル画像データ上で赤目を補正する方法は、大別すると手動補正、半自動補正、自動補正に分類することができる。   Methods for correcting red eyes on digital image data can be roughly classified into manual correction, semi-automatic correction, and automatic correction.

手動補正は、ユーザが、マウスやスタイラスとタブレットなどのポインティングデバイスやタッチパネルを使用して、ディスプレイに表示された赤目領域を指定して補正するものである。   In the manual correction, the user specifies and corrects the red-eye area displayed on the display using a pointing device such as a mouse, stylus, and tablet, or a touch panel.

半自動補正は、ユーザが赤目が存在する領域をある程度指定し、その情報から赤目の補正範囲を特定して補正を行うものである。例えば、ユーザは、両目を囲むような領域をポインティングデバイスによって指定したり、目の近辺の一点を指定する。この指定領域または指定点の情報から補正範囲を特定し補正するものである。   In the semi-automatic correction, the user designates a region where red eyes are present to some extent, specifies the correction range of red eyes from the information, and performs correction. For example, the user designates an area surrounding both eyes with a pointing device, or designates a point near the eyes. The correction range is specified and corrected from the information of the designated area or designated point.

自動補正は、ユーザによる特別な操作を必要とせず、自動的にディジタル画像データ中から補正領域を検出し、補正処理を実行するものである。   The automatic correction does not require any special operation by the user, and automatically detects a correction area from the digital image data and executes a correction process.

手動または半自動補正は、ユーザが何らかの操作により、補正個所を指定する必要がある。そのため、ユーザは、画像データの補正すべき領域付近を拡大表示した後、補正領域を指定する煩わしい操作を必要とする。また、大画面の表示装置を備えたパーソナルコンピュータシステムなどであれば、このような操作も比較的容易であるが、ディジタルカメラやプリンタなど、数インチの表示装置しか備えないデバイス上では、画像を拡大し、画像をスクロールして補正領域を指定する操作は、到底、容易とは言えない。   Manual or semi-automatic correction requires the user to specify a correction location by some operation. Therefore, the user needs a cumbersome operation of specifying the correction area after enlarging and displaying the vicinity of the area to be corrected of the image data. Such operations are relatively easy with a personal computer system equipped with a large-screen display device. However, on a device equipped with only a few inches of display device, such as a digital camera or a printer, an image is displayed. The operation of enlarging and scrolling the image to designate the correction area is not easy at all.

近年、ユーザにとって煩わしい操作を不要とし、かつ、大きな表示装置を備えないデバイスに有効な赤目現象の自動補正に関して様々な提案が行われている。   In recent years, various proposals have been made regarding automatic correction of a red-eye phenomenon that is effective for a device that does not require a troublesome operation for a user and does not include a large display device.

例えば、特開平11-136498号公報は、画像から肌色領域を検出し、その領域内で赤目を構成すると思われる画素をサーチして検出した赤目を構成する画素を補正する方法を提案する。また、特開平11-149559号公報は、肌色領域を検出し、その領域中で瞳の輝度の低さに対応する谷領域を検出し、第一の谷と第二の谷との距離を基に目を決定する方法を提案する。また、特開2000-125320公報は、肌色領域を検出し、肌色領域が人間の顔の特徴であるかを判断し、その領域内で赤目欠陥の一組を検出して距離と大きさを評価することで、赤目領域を特定する方法を提案する。また、特開平11-284874号公報は、画像が赤い瞳孔を含むか否かを自動検出し、赤い瞳孔を検出した場合はその位置、大きさを検出して、瞳孔内の赤色画素を自動的に所定の色に変換する方法を提案する。   For example, Japanese Patent Application Laid-Open No. 11-136498 proposes a method of correcting a pixel constituting a red eye detected by detecting a skin color region from an image, searching for a pixel considered to constitute a red eye in the region. Japanese Patent Application Laid-Open No. 11-149559 detects a skin color area, detects a valley area corresponding to the low luminance of the pupil in the area, and based on the distance between the first valley and the second valley. We propose a method to determine Japanese Patent Laid-Open No. 2000-125320 also detects a skin color area, determines whether the skin color area is a feature of a human face, and detects a set of red-eye defects in the area to evaluate the distance and size. Thus, a method for identifying the red-eye region is proposed. Japanese Patent Application Laid-Open No. 11-284874 automatically detects whether or not an image includes a red pupil. If a red pupil is detected, the position and size of the red pupil are detected to automatically detect red pixels in the pupil. A method for converting to a predetermined color is proposed.

しかし、提案されている赤目現象の自動補正方法には以下の問題が存在する。   However, the proposed automatic correction method for red-eye phenomenon has the following problems.

まず、人物の肌色検出またはニューラルネットワークなどを用いた顔検出の結果に基づく赤目領域の検出は、検出結果の信頼性は高いが、画像中のある程度広い範囲を参照する必要があり、大量のメモリや演算量を必要とする。従って、数GHzのクロックで動作する高性能なCPUと、数百MBのメモリを搭載するパーソナルコンピュータによる処理には適しているが、ディジタルカメラやプリンタ内部の組み込みシステムに実装するのは困難である。   First, detection of red-eye areas based on human skin color detection or face detection results using a neural network, etc. is highly reliable, but it is necessary to refer to a certain wide range in the image, and a large amount of memory is required. And computational complexity. Therefore, it is suitable for processing by a personal computer with a high-performance CPU that operates with a clock of several GHz and a memory of several hundred megabytes, but is difficult to implement in an embedded system inside a digital camera or printer. .

また、上記の自動補正例に限らず、これまでに提案されている方法の多くは、赤目領域が周辺領域と比較して彩度が高いという特徴を利用して赤目領域を特定する。しかし、彩度に基づく判定は、色素が濃い(多い)人には必ずしも適合しない問題がある。よく知られているように、画素値がRGB系で与えられた際の彩度Sは式(1)で求めることができる。
S = {max(R, G, B) - min(R, G, B)}/max(R, G, B) …(1)
ここで、max(R, G, B)はRGB成分の最大値
min(R, G, B)はRGB成分の最小値
In addition to the above automatic correction examples, many of the methods proposed so far specify the red-eye region using the feature that the red-eye region has higher saturation than the surrounding region. However, there is a problem that the determination based on the saturation is not always suitable for a person with a dark (large) pigment. As is well known, the saturation S when the pixel value is given in the RGB system can be obtained by Expression (1).
S = {max (R, G, B)-min (R, G, B)} / max (R, G, B)… (1)
Where max (R, G, B) is the maximum RGB component
min (R, G, B) is the minimum value of RGB components

例えば、日本人の肌色領域は色相(0〜359度)で言えば、0〜30度付近に多く分布することが実験の結果明らかになっている。なお、HIS系の色相では0度付近が赤色で、色相角が大きくなるに従ってイエローに近付く。0〜30度付近で、RGB値の大小関係は以下のようになる。
R > G > B …(2)
For example, it has been clarified as a result of experiments that the Japanese skin color region is distributed in the vicinity of 0 to 30 degrees in terms of hue (0 to 359 degrees). In HIS hues, red is near 0 degrees, and approaches yellow as the hue angle increases. In the vicinity of 0 to 30 degrees, the RGB values are as follows.
R>G> B (2)

また、上述したように、色素が薄い(少ない)人に比べて、色素の濃い(多い)人は鮮やかな赤目にはなり難い。   Further, as described above, a person with a thick (large) pigment is less likely to have vivid red eyes than a person with a thin (small) pigment.

これらを考慮して日本人の赤目領域の画素値および目の周辺の肌色領域の画素値を推測すると次のようになる。
赤目領域:(R, G, B)=(109, 58, 65)
肌色領域:(R, G, B)=(226, 183, 128)
Considering these, the pixel value of the Japanese red-eye region and the pixel value of the skin color region around the eyes are estimated as follows.
Red-eye area: (R, G, B) = (109, 58, 65)
Skin color area: (R, G, B) = (226, 183, 128)

上記のような場合、赤目画素の彩度は40、肌領域画素の彩度は43になり、ほぼ同様の彩度値になる。言い換えれば、彩度に着目しても、被写体(人)によっては赤目画素を特定できない場合がある。   In such a case, the saturation of the red-eye pixel is 40, the saturation of the skin region pixel is 43, and the saturation value is almost the same. In other words, even if attention is paid to the saturation, there are cases where the red-eye pixel cannot be specified depending on the subject (person).

特開平11-136498号公報Japanese Patent Laid-Open No. 11-136498 特開平11-149559号公報Japanese Patent Laid-Open No. 11-149559 特開2000-125320公報JP 2000-125320 A 特開平11-284874号公報Japanese Patent Laid-Open No. 11-284874 特開2004-326805公報JP 2004-326805 JP

本発明は、目の色調不良を示す画像領域を高精度に検出することを目的とする。   An object of the present invention is to detect an image region showing a poor color tone of eyes with high accuracy.

本発明は、前記の目的を達成する一手段として、以下の構成を備える。   The present invention has the following configuration as one means for achieving the above object.

本発明にかかる画像処理は、画像の画素ごとに、目の色調の評価量を前記画像のR成分およびG成分のみから算出し、前記算出された評価量に基づき目の色調不良を示す候補画素を抽出し、前記抽出された複数の候補画素から構成される領域を抽出し、該抽出された領域が予め定められた形状であるか判定を行い、該予め定められた形状であると判定された領域を目の色調不良の候補領域として抽出し、前記候補画素の抽出は、前記画像における注目画素の近傍に予め定めたウィンドウ領域を設定し、前記ウィンドウ領域に含まれる画素の評価量から閾値を決定し、前記閾値を用いて前記注目画素の評価量を二値化することで前記候補画素を抽出することを特徴とする。 The image processing according to the present invention calculates, for each pixel of the image, an evaluation value of the eye color tone from only the R component and the G component of the image, and indicates a candidate pixel indicating a poor color tone of the eye based on the calculated evaluation value And extracting a region composed of the plurality of extracted candidate pixels, determining whether the extracted region has a predetermined shape, and determining that the predetermined shape is the predetermined shape. And extracting the candidate pixels by setting a predetermined window area in the vicinity of the target pixel in the image, and calculating a threshold value based on the evaluation amount of the pixels included in the window area. And the candidate pixel is extracted by binarizing the evaluation amount of the pixel of interest using the threshold value .

本発明によれば、目の色調不良を示す画像領域を高精度に検出することができる。従って、色素が薄い、濃い(少ない、多い)という人の特性に関わらず、目の色調不良を示す画像領域(補正すべき画像領域)を適切に検出することができる。   According to the present invention, it is possible to detect an image region showing a poor color tone of eyes with high accuracy. Therefore, it is possible to appropriately detect an image region (image region to be corrected) showing a poor color tone of an eye, regardless of the characteristics of a human being that the pigment is thin or dark (small or large).

実施例1の画像処理を実行するコンピュータ(画像処理装置)の構成例を示すブロック図、FIG. 1 is a block diagram illustrating a configuration example of a computer (image processing apparatus) that executes image processing according to the first embodiment; 実施例1の赤目の自動補正処理の概要を示す機能ブロック図、Functional block diagram showing an outline of red-eye automatic correction processing of Example 1, ディジタルカメラなどの撮像装置により撮像された赤目画像を概念的に示す図、The figure which shows notionally the red-eye image imaged with imaging devices, such as a digital camera, 適応的二値化処理を説明する図、The figure explaining an adaptive binarization process, 適応的二値化の結果例を示す図、The figure which shows the example of the result of adaptive binarization, 平均値Er(ave)を求める際の高速化手法を説明する図、The figure explaining the speed-up method when calculating the average value Er (ave) 境界線追跡法を説明する図、A diagram explaining the boundary tracking method, 境界線追跡法を説明する図、A diagram explaining the boundary tracking method, 追跡方向ヒストグラムの方向を示す図、Figure showing the direction of the tracking direction histogram, 方向ヒストグラムの一例を示す図、A diagram showing an example of a direction histogram, 赤色領域の外接矩形領域を示す図、A diagram showing a circumscribed rectangular area of a red area, 赤丸領域か否かの判定処理の一例を示すフローチャート、The flowchart which shows an example of the determination process of whether it is a red circle area | region, 赤目候補領域の特徴量を算出する際に使用する周辺領域の定義を説明する図、The figure explaining the definition of the peripheral region used when calculating the feature amount of the red-eye candidate region, 赤目候補領域が画像の端部近傍に存在する場合の周辺領域を説明する図、The figure explaining the peripheral region when the red-eye candidate region is present near the edge of the image, ブロックの平均値Er(ave)の算出領域を示す図、Figure showing the calculation area of the block average value Er (ave), 特徴量群の判定手順の一例を示すフローチャート、A flowchart showing an example of a procedure for determining a feature amount group; 周辺領域の設定方法を説明する図、A diagram explaining how to set the surrounding area, 候補領域リストに記載された複数の赤目領域のうちの一つを補正する処理例を示すフローチャート、The flowchart which shows the process example which correct | amends one of the some red eye area | regions described in the candidate area | region list, 補正範囲の決定を説明する図、The figure explaining determination of the correction range, 補正パラメータの設定方法を説明する図、The figure explaining the setting method of the correction parameter, 実施例2の課題を説明する図、The figure explaining the subject of Example 2, 実施例2における適応的二値化処理を説明する図、FIG. 6 is a diagram illustrating adaptive binarization processing in the second embodiment. 実施例2における適応的二値化処理を説明する図、FIG. 6 is a diagram illustrating adaptive binarization processing in the second embodiment. 実施例3の課題を説明する図、The figure explaining the subject of Example 3, 実施例3の赤目の自動補正処理の概要を示す機能ブロック図、Functional block diagram showing an outline of red-eye automatic correction processing of Example 3, 候補領域評価部の処理例を示すフローチャート、The flowchart which shows the process example of a candidate area | region evaluation part, 中心間距離Sizeを説明する図、The figure explaining center distance Size, 中心間距離Sizeと閾値Th_Sizeの関係例を示す図、The figure which shows the example of a relationship between center distance Size and threshold value Th_Size, 実施例4の課題を説明する図、The figure explaining the subject of Example 4, 実施例4の赤目の自動補正処理の概要を示すブロック図、Block diagram showing an overview of the red-eye automatic correction process of Example 4, 候補領域結合部の処理例を示すフローチャート、The flowchart which shows the process example of a candidate area | region combination part, 候補領域リストの一例を示す図、The figure which shows an example of a candidate area | region list, 候補領域結合処理を説明する図、A diagram for explaining candidate area combining processing, 実施例5におけるバンド分割を説明する図、FIG. 5 is a diagram for explaining band division in Example 5. 実施例5における赤目領域の抽出処理の一例を示すフローチャート、Flowchart showing an example of red-eye region extraction processing in Example 5, Nバンド目の赤目領域の抽出処理の詳細を示すフローチャート、A flowchart showing details of red-eye region extraction processing for the N band, N-1、NおよびN+1バンド目において、OverlapArea内に四つの赤丸領域が存在する例を示す図、In the N-1, N and N + 1 bands, a diagram showing an example in which there are four red circle regions in the OverlapArea, 候補領域選択処理を説明する図、The figure explaining candidate area selection processing, 候補領域リストの一例を示す図、The figure which shows an example of a candidate area | region list, 実施例5における補正処理の一例を示すフローチャート、Flowchart showing an example of correction processing in Embodiment 5, 補正ラインと補正対象領域の関係を示す図、A diagram showing the relationship between the correction line and the correction target area, 候補領域リストに格納された赤目領域の位置情報を説明する図である。It is a figure explaining the positional information on the red eye area | region stored in the candidate area | region list.

以下、本発明にかかる一実施例の画像処理を図面を参照して詳細に説明する。なお、以下で説明する画像処理は、主として、プリンタエンジンへ出力すべき画像情報を生成する、コンピュータ内で稼働するプリンタドライバ、および、スキャナなどの光学読取装置を駆動する、コンピュータ内で稼働するスキャナドライバに組み込むことが望ましい。あるいは、複写機、ファクシミリ、プリンタ、スキャナ、ディジタルカメラ、ディジタルビデオカメラなどのハードウェアに内蔵する、または、ソフトウェアとして供給してもよい。   Hereinafter, image processing according to an embodiment of the present invention will be described in detail with reference to the drawings. The image processing described below mainly includes a printer driver that operates in a computer that generates image information to be output to a printer engine, and a scanner that operates in a computer that drives an optical reading device such as a scanner. It is desirable to incorporate it into the driver. Alternatively, it may be built in hardware such as a copier, facsimile, printer, scanner, digital camera, digital video camera, or supplied as software.

[装置の構成]
図1は実施例1の画像処理を実行するコンピュータ(画像処理装置)の構成例を示すブロック図である。
[Device configuration]
FIG. 1 is a block diagram illustrating a configuration example of a computer (image processing apparatus) that executes image processing according to the first embodiment.

コンピュータ100は、CPU101、ROM102、RAM103、モニタ113(タッチパネルを備えてもよい)を接続するビデオカード104、ハードディスクドライブやメモリカードなどの記憶装置105、マウス、スタイラスおよびタブレットなどのポインティングデバイス106、キーボード107などを接続するUSBやIEEE1394などのシリアルバス用のインタフェイス108、ネットワーク114と接続するネットワークインタフェイスカード(NIC)107を備え、これらの構成はシステムバス109で相互に接続されている。また、インタフェイス108には、プリンタ110、スキャナ111、ディジタルカメラ112などを接続可能である。   The computer 100 includes a CPU 101, a ROM 102, a RAM 103, a video card 104 to which a monitor 113 (which may include a touch panel), a storage device 105 such as a hard disk drive or a memory card, a pointing device 106 such as a mouse, a stylus and a tablet, and a keyboard. A serial bus interface 108 such as USB or IEEE1394 for connecting 107 and the like, and a network interface card (NIC) 107 connected to the network 114 are provided. These components are connected to each other via a system bus 109. In addition, a printer 110, a scanner 111, a digital camera 112, and the like can be connected to the interface 108.

CPU101は、ROM103または記憶装置105に格納されたプログラム(以下で説明する画像処理のプログラムを含む)をワークメモリであるRAM103にロードして当該プログラムを実行し、当該プログラムに従いシステムバス109を介して上記の各構成を制御することで、当該プログラムの機能を実現する。   The CPU 101 loads a program (including an image processing program described below) stored in the ROM 103 or the storage device 105 to the RAM 103 as a work memory, executes the program, and executes the program according to the program via the system bus 109. The functions of the program are realized by controlling each of the above components.

なお、図1は、実施例1で説明する画像処理を実施するハードウェアの一般的な構成を示し、その一部の構成を欠いたり、他のデバイスが追加されても、本発明の範疇に含まれる。   Note that FIG. 1 shows a general configuration of hardware that performs image processing described in the first embodiment, and even if a part of the configuration is missing or another device is added, it is within the scope of the present invention. included.

[処理の概要]
図2は実施例1の赤目の自動補正処理の概要を示す機能ブロック図で、CPU101によって実行される処理である。なお、入力画像は、例えば、ディジタルカメラ112やフィルムスキャナ111から入力される一画素あたりRGB各8ビット、合計24ビットのディジタル画像データである。
[Process overview]
FIG. 2 is a functional block diagram illustrating an outline of the red-eye automatic correction process according to the first embodiment, which is a process executed by the CPU 101. The input image is, for example, digital image data of 24 bits in total, 8 bits for each RGB input from the digital camera 112 or the film scanner 111.

図3はディジタルカメラ112などの撮像装置により撮像された赤目画像を概念的に示す図で、目の瞳孔領域302、虹彩領域301、撮影時に使用したフラッシュに起因するハイライト領域304を示す。また、符号303は白目部分を示している。通常、赤目現象により瞳孔領域302が赤くなる。   FIG. 3 is a diagram conceptually showing a red-eye image picked up by an image pickup device such as the digital camera 112, showing a pupil region 302 of the eye, an iris region 301, and a highlight region 304 resulting from a flash used at the time of photographing. Reference numeral 303 indicates a white-eye portion. Usually, the pupil region 302 becomes red due to the red-eye phenomenon.

図2に示す赤領域抽出部202は、入力端子201に入力される画像データから赤色の領域を抽出する。赤色の領域の抽出方法は様々な方法が考えられるが、適応的二値化による赤色領域の抽出法を後述する。なお、赤領域抽出部202は目であるか否かに関わらず赤色領域を抽出するため、抽出される赤色の領域は、赤目、赤色の信号機、衣服の赤色の模様、赤色の照明など様々なものを含む。   A red region extraction unit 202 shown in FIG. 2 extracts a red region from the image data input to the input terminal 201. There are various methods for extracting the red region, and a method for extracting the red region by adaptive binarization will be described later. Note that the red area extraction unit 202 extracts a red area regardless of whether it is an eye or not. Therefore, the extracted red area can be a variety of things such as red eyes, a red traffic light, a red pattern on clothes, and a red illumination. Including things.

赤丸領域抽出部203は、入力画像データと抽出された赤色領域の情報を入力して、赤色の領域の中からその形状が比較的円に近い領域(以下「赤丸領域」と呼ぶ)を特定する。領域形状の判定方法は様々な方法が考えられるが、境界線追跡による赤丸領域の抽出法を後述する。なお、赤丸領域抽出部203は、抽出した赤丸領域の位置情報を候補領域リストに格納する。   The red circle area extraction unit 203 inputs input image data and information on the extracted red area, and identifies an area of which the shape is relatively close to a circle (hereinafter referred to as “red circle area”) from the red area. . Various methods of determining the shape of the region are conceivable. A method of extracting a red circle region by boundary line tracking will be described later. The red circle region extraction unit 203 stores the extracted position information of the red circle region in the candidate region list.

特徴量判定部204は、入力画像データと候補領域リストを入力して、候補領域リストに記録された赤丸領域について、目と特定できるような様々な特徴量の判定処理を行う。目と特定できるような特徴量には、赤丸領域の彩度、赤丸周辺領域の明度、彩度、色相、エッジの分布などがある。これらの特徴量を、予め定められた閾値と比較し、すべての条件を満たす赤丸領域を赤目領域であると特定する。なお、特徴量判定部204は、特定した赤目領域の位置情報を候補領域リストに格納する。   The feature amount determination unit 204 inputs the input image data and the candidate region list, and performs various feature amount determination processes for identifying the red circle regions recorded in the candidate region list as eyes. Features that can be identified as eyes include the saturation of the red circle region, the brightness, the saturation, the hue, and the edge distribution of the region around the red circle. These feature amounts are compared with a predetermined threshold value, and a red circle region that satisfies all the conditions is specified as a red-eye region. Note that the feature amount determination unit 204 stores the position information of the identified red-eye region in the candidate region list.

補正部205は、入力画像データと赤目領域の位置情報が格納された候補領域リストを入力して、画像データの赤目領域に補正処理を施し、補正処理を施した画像データを出力端子206に出力する。補正処理後の画像データは、モニタ113に表示されたり、RAM103あるいは記憶装置105に格納される、あるいは、インタフェイス108に接続されたプリンタ110によってプリントされたり、NIC107を介してネットワーク114(イントラネット、インターネットを含む)に接続された他のコンピュータやサーバに送信される。   The correction unit 205 inputs the candidate area list in which the input image data and the position information of the red-eye area are stored, performs correction processing on the red-eye area of the image data, and outputs the corrected image data to the output terminal 206 To do. The image data after the correction processing is displayed on the monitor 113, stored in the RAM 103 or the storage device 105, or printed by the printer 110 connected to the interface 108, or the network 114 (intranet, Sent to other computers and servers connected to the Internet.

[赤領域抽出部202]
赤領域抽出部202は、入力画像データに適応的二値化処理を適用することで、画像データから赤色領域を抽出する。つまり、入力画像データの各画素に対して赤色度合いを示す赤色評価量を算出し、その評価量と閾値を比較して、評価値>閾値の場合に注目画素を赤色と判定する。この閾値は、注目画素の周辺領域において適応的に決定される閾値である。なお、ここで言う「二値化」とは赤色と判定した画素に‘1’を、そうではない画素に‘0’を割り当てることを言う。
[Red area extraction unit 202]
The red area extraction unit 202 extracts a red area from the image data by applying an adaptive binarization process to the input image data. That is, a red evaluation amount indicating the degree of red is calculated for each pixel of the input image data, and the evaluation amount is compared with a threshold value. When evaluation value> threshold value, the target pixel is determined to be red. This threshold value is an adaptively determined threshold value in the peripheral region of the target pixel. Here, “binarization” refers to assigning “1” to pixels determined to be red and assigning “0” to pixels that are not.

図4は適応的二値化処理を説明する図である。   FIG. 4 is a diagram for explaining the adaptive binarization processing.

図4において、入力画像データ401上の注目画素402は二値化処理の対象画素である。赤領域抽出部202は、注目画素402の赤色度合いを示す評価量Erを式(3)で定義する。
Er = (R - G)/R …(3)
In FIG. 4, a target pixel 402 on the input image data 401 is a target pixel for binarization processing. The red area extraction unit 202 defines an evaluation amount Er indicating the degree of redness of the pixel of interest 402 by Expression (3).
Er = (R-G) / R… (3)

式(3)は、注目画素402の赤色度合いを、一般的なHSI系の彩度ではなく、B成分を除くR、Gの二成分から求めることを意味している。赤色評価量Erを彩度ではなく、式(3)で定義することの利点を以下に説明する。   Equation (3) means that the red degree of the pixel of interest 402 is obtained from the two components R and G excluding the B component instead of the general HSI saturation. The advantage of defining the red evaluation amount Er not by saturation but by equation (3) will be described below.

例えば、色素が濃い(多い)人の場合、瞳孔領域302の水晶体の透過率が低いために、鮮やかな赤目になりにくいという傾向がある。前述したように、日本人の赤目領域の画素値の推測値は(R, G, B)=(109, 58, 65)であり、日本人の肌色は色相で言えば赤(0度)からイエロー(60度)の間に多く分布することが実験の結果明らかになっている。このような領域は、RGB各成分の大小関係がR>G>Bになり、目の周辺の肌色領域の画素値の推測値は(R, G, B)=(226, 183, 128)である。このような場合、赤目画素の彩度は40、目の周辺の肌領域の画素の彩度は43とほぼ同様の彩度値になる。つまり、赤目領域の画素の彩度値は、目の周辺の肌色領域の画素の彩度値に対して特別突出するわけではない。従って、適応的二値化処理の閾値として彩度を用いれば赤目領域の検出が困難になる。   For example, in the case of a person who is dark (many) with a pigment, since the transmittance of the crystalline lens in the pupil region 302 is low, there is a tendency that bright red eyes are not easily generated. As mentioned above, the estimated value of the pixel value of the Japanese red-eye region is (R, G, B) = (109, 58, 65), and the Japanese skin color is from red (0 degrees) in terms of hue. As a result of the experiment, it is clear that there are many distributions between yellow (60 degrees). In such a region, the magnitude relationship of each RGB component is R> G> B, and the estimated value of the pixel value of the skin color region around the eye is (R, G, B) = (226, 183, 128) is there. In such a case, the saturation of red-eye pixels is 40, and the saturation of pixels in the skin region around the eyes is approximately the same as 43. That is, the saturation value of the pixel in the red-eye area does not particularly protrude from the saturation value of the pixel in the skin color area around the eye. Therefore, if the saturation is used as the threshold value for the adaptive binarization process, it is difficult to detect the red-eye region.

一方、赤色評価量Erを式(3)で定義すれば、赤目領域の画素の赤色評価量Erは47、目の周辺の肌色領域の赤色評価量Erは19になり、目の周辺の肌色領域に比べて赤目領域の画素の赤色評価量Erは二倍以上の値をもつことになる。   On the other hand, if the red evaluation amount Er is defined by Equation (3), the red evaluation amount Er of the pixels in the red eye region is 47, the red evaluation amount Er of the skin color region around the eyes is 19, and the skin color region around the eyes In contrast, the red evaluation amount Er of the pixel in the red-eye region has a value that is twice or more.

以上から、色素が濃い(多い)人の赤目を検出する場合、彩度ではなく、式(3)に示すようなB成分を含まない、R、G成分のみの評価量を定義することで、赤目を構成する画素を精度よく抽出することが可能になる。なお、式(3)において、R成分に対する(R-G)の割合を評価量Erとしたが、これに限定されるわけではなく、例えば(R-G)のみやR/Gを評価量Erとしてもよい。   From the above, when detecting the red eye of a person with a dark (much) pigment, by defining the evaluation amount of only the R and G components that do not include the B component as shown in Equation (3), not the saturation, It becomes possible to accurately extract the pixels constituting the red eye. In Formula (3), the ratio of (R−G) to the R component is the evaluation amount Er, but is not limited thereto, and for example, only (R−G) or R / G may be the evaluation amount Er.

図4に戻り、注目画素402を二値化するために、注目画素402と同一ライン上の、注目画素402に対して左方向(主走査方向の前方)に画素数がThWindowSizeになるようなウィンドウ領域403を設定し、当該ウィンドウ内の画素の赤色評価量Erの平均値Er(ave)を求める。ここで、画素数ThWindowSizeは画像の短辺と比較して1〜2%程度の幅とすることが望ましい。なお、評価量Erは以下の条件を満たす場合にのみ算出するため、評価量Erが負になることはない。
R > 0 かつ R > G …(4)
Returning to FIG. 4, in order to binarize the target pixel 402, a window in which the number of pixels becomes ThWindowSize in the left direction (forward in the main scanning direction) with respect to the target pixel 402 on the same line as the target pixel 402. An area 403 is set, and an average value Er (ave) of the red evaluation amount Er of the pixels in the window is obtained. Here, the number of pixels ThWindowSize is preferably about 1 to 2% of the width compared to the short side of the image. Since the evaluation amount Er is calculated only when the following condition is satisfied, the evaluation amount Er does not become negative.
R> 0 and R> G (4)

平均値Er(ave)を用いて注目画素402を二値化するが、この処理を行うには、注目画素402は以下の条件を満たす必要がある。
R > Th_Rmin かつ R > G かつ R > B …(5)
ここで、Th_RminはRの下限値を表す閾値
The pixel of interest 402 is binarized using the average value Er (ave). To perform this processing, the pixel of interest 402 must satisfy the following conditions.
R> Th_Rmin and R> G and R> B (5)
Here, Th_Rmin is a threshold value indicating the lower limit value of R

上記の条件を満たす場合、式(6)による二値化処理を実行する。
Er > Er(ave) + Margin_RGB ならば‘1’
Er ≦ Er(ave) + Margin_RGB ならば‘0’ …(6)
ここで、Margin_RGRはパラメータ
If the above condition is satisfied, binarization processing according to equation (6) is executed.
If Er> Er (ave) + Margin_RGB, '1'
If Er ≤ Er (ave) + Margin_RGB, '0'… (6)
Where Margin_RGR is a parameter

式(6)は、注目画素402の赤色度合いErがウィンドウ領域403の平均値Er(ave)にMargin_RGRを加えた値よりも大きい場合、注目画素402の二値化後の値を‘1’にする。すなわち、その注目画素402を赤色領域として抽出したことを意味する。なお、赤色領域が連続する場合、平均値Er(ave)の値が大きくなり過ぎるため、平均値Er(ave)に上限を設けてもよい。この二値化結果は、RAM103の中の入力画像用のバッファとは別に割り当てられた領域に保存される。   When the red degree Er of the target pixel 402 is larger than the value obtained by adding Margin_RGR to the average value Er (ave) of the window region 403, the value after binarization of the target pixel 402 is set to '1'. To do. That is, it means that the target pixel 402 is extracted as a red region. Note that when the red region is continuous, the average value Er (ave) becomes too large, and therefore an upper limit may be provided for the average value Er (ave). The binarization result is stored in an area allocated separately from the input image buffer in the RAM 103.

以上の処理を、入力画像データのライン単位に、注目画素402を左から右に移動して、すべての画素に施す。   The above processing is performed on all pixels by moving the pixel of interest 402 from left to right in units of lines of input image data.

なお、実施例1においては、二値化するための閾値(平均値Er(ave))を、注目画素402と同一ライン上の左方向に設定したウィンドウ内の画素の評価値Erから算出したが、これに限定されるものではなく、例えば、注目画素402を含むラインの上方(副走査方向行の前方)数ラインの注目画素402の左方向(主走査方向行の前方)数画素を含むような領域や、注目画素402を中心とする所定の矩形領域をウィンドウに設定してもよい。   In the first embodiment, the threshold for binarization (average value Er (ave)) is calculated from the evaluation value Er of the pixels in the window set in the left direction on the same line as the target pixel 402. However, the present invention is not limited to this, and includes, for example, several pixels above the line including the pixel of interest 402 (front of the row in the sub-scanning direction) several pixels left of the pixel of interest 402 (front of the row in the main scanning direction). Or a predetermined rectangular area centered on the pixel of interest 402 may be set in the window.

図5は適応的二値化の結果例を示す図である。図5(a)は入力画像データの赤目周辺の画像を示し、図5(b)は適応的二値化の結果得られる二値画像で、赤目の瞳孔部分の画素のみが抽出されている様子を示す。   FIG. 5 is a diagram showing an example of the result of adaptive binarization. Fig. 5 (a) shows the image around the red eye of the input image data, Fig. 5 (b) is a binary image obtained as a result of adaptive binarization, and only the pixels of the red-eye pupil part are extracted Indicates.

また、主走査方向に設定したウィンドウ内部の評価量の平均値Er(ave)を求める際に、以下のような高速化手法を用いてもよい。   Further, when obtaining the average value Er (ave) of the evaluation amount inside the window set in the main scanning direction, the following speed-up method may be used.

図6は平均値Er(ave)を求める際の高速化手法を説明する図である。   FIG. 6 is a diagram for explaining a speed-up method for obtaining the average value Er (ave).

図6(a)において、注目画素402の左方向に設定したウィンドウ403内の平均値Er(ave)を求める際、ウィンドウ403内の評価量Erの総和をメモリ(例えばRAM103)に格納する。平均値Er(ave)は、総和をウィンドウ403を構成する画素数nで除算することにより、簡単に求めることができる。次に、注目画素402は一画素右へ移動するが、その際はウィンドウ403も一画素分右へ移動する。この時、図6(b)に示すウィンドウ403内の評価量Erの総和は、図6(a)において求めた総和から画素501の評価量Erを減算し、画素502(直前の注目画素402)の評価量Erを加えることで処理の高速化が図れる。つまり、注目画素402およびウィンドウ403の移動後、改めてウィンドウ403内すべての画素の評価量Erを算出する必要はない。   In FIG. 6A, when the average value Er (ave) in the window 403 set in the left direction of the pixel of interest 402 is obtained, the sum of the evaluation amounts Er in the window 403 is stored in a memory (for example, the RAM 103). The average value Er (ave) can be easily obtained by dividing the sum by the number of pixels n constituting the window 403. Next, the target pixel 402 moves to the right by one pixel. At this time, the window 403 also moves to the right by one pixel. At this time, the sum of the evaluation amounts Er in the window 403 shown in FIG. 6B is obtained by subtracting the evaluation amount Er of the pixel 501 from the sum obtained in FIG. 6A to obtain the pixel 502 (the pixel of interest 402 immediately before). By adding the evaluation amount Er, it is possible to speed up the processing. That is, after the pixel of interest 402 and the window 403 are moved, it is not necessary to calculate the evaluation amount Er of all the pixels in the window 403 again.

[赤丸領域抽出部203]
赤丸領域抽出部203は、二値画像処理方法の一つである境界線追跡法を用いて、赤丸領域を抽出する。
[Red circle area extraction unit 203]
The red circle area extraction unit 203 extracts a red circle area using a boundary line tracking method which is one of binary image processing methods.

図7は境界線追跡法を説明する図である。   FIG. 7 is a diagram for explaining the boundary line tracking method.

境界線追跡処理は、適応的二値化処理の結果得られる二値画像に対して、画像を上端から主副走査方向にスキャンして、注目画素(xa, ya)の値が‘1’で、注目画素の左(xa-1, ya)、左斜め上(xa-1, ya-1)、上方(xa, ya-1)、右斜め上(xa+1, ya-1)の四画素の値が‘0’である注目画素を始点にする(図7に符号701で示す画素)。なお、図7は、二値画像の左上を原点とする座標系を設定している。   The boundary line tracking process scans the binary image obtained as a result of the adaptive binarization process from the upper end to the main / sub scanning direction, and the value of the target pixel (xa, ya) is '1'. , Left pixel (xa-1, ya), upper left pixel (xa-1, ya-1), upper pixel (xa, ya-1), upper right pixel (xa + 1, ya-1) The pixel of interest whose value is '0' is set as the starting point (pixel indicated by reference numeral 701 in FIG. 7). In FIG. 7, a coordinate system having the origin at the upper left of the binary image is set.

そして、始点画素701から反時計回りに再び始点701に戻るまで、値が‘1’の画素を追跡する。追跡の途中、画像領域を逸脱したり、始点画素701よりもY座標が小さくなる場合は、追跡を打ち切り、次の始点を探索する。追跡の途中でY座標が始点画素701よりも小さくなった場合に追跡を打ち切るのは、図8に示すような環状領域の内側を誤って追跡することを防ぐためである。環状領域の内側を追跡した場合には、図8において、画素802に到達すると始点画素801よりもY座標が小さくなるので、ここで追跡処理を打ち切る。   Then, the pixel having a value of “1” is traced until it returns from the start point pixel 701 to the start point 701 counterclockwise again. If the image area is deviated or the Y coordinate is smaller than the start point pixel 701 during tracking, the tracking is stopped and the next start point is searched. The reason why the tracking is aborted when the Y coordinate becomes smaller than the start point pixel 701 during the tracking is to prevent the inside of the annular region as shown in FIG. When the inside of the annular region is tracked, the Y coordinate becomes smaller than that of the start pixel 801 when reaching the pixel 802 in FIG. 8, and the tracking process is terminated here.

上記の追跡過程で、追跡対象領域の周辺の長さ、方向ヒストグラム、X座標とY座標の最大値、最小値を得ることができる。ここで、周辺の長は、追跡した画素の数で、例えば図7の例では始点画素701を含めて九画素になる。   In the above tracking process, the length of the periphery of the tracking target area, the direction histogram, the maximum value and the minimum value of the X and Y coordinates can be obtained. Here, the peripheral length is the number of tracked pixels. For example, in the example of FIG. 7, the peripheral length is nine pixels including the start point pixel 701.

方向ヒストグラムは、追跡過程で、ある画素から次の画素へ移動する向きを、図9に示す八方向で累積したヒストグラムである。図7の例では、始点画素701から反時計回りに追跡すると、移動の向きは667812334になり、その方向ヒストグラムは図10に示すようになる。   The direction histogram is a histogram in which the moving direction from one pixel to the next pixel is accumulated in eight directions shown in FIG. 9 in the tracking process. In the example of FIG. 7, when tracking counterclockwise from the start point pixel 701, the direction of movement is 667812334, and the direction histogram is as shown in FIG.

X、Y座標の最大、最小値は、図11に示すように、値が‘1’の画素が存在する領域、すなわち赤色領域の外接矩形領域を示す。   As shown in FIG. 11, the maximum and minimum values of the X and Y coordinates indicate an area where a pixel having a value of “1” exists, that is, a circumscribed rectangular area of a red area.

赤丸領域抽出部203は、各赤色領域を境界線追跡して、上記の値を取得し、赤丸領域か否かを判定する。   The red circle area extraction unit 203 traces each red area with a boundary line, acquires the above value, and determines whether the area is a red circle area.

図12は赤丸領域か否かの判定処理の一例を示すフローチャートである。   FIG. 12 is a flowchart illustrating an example of a determination process for determining whether or not the region is a red circle region.

まず、赤色領域の縦横比が予め設定された閾値Th_BF_VHRatio以上か否かを判定する(S1201)。縦横比ARは式(7)で算出する。
AR = (ymax - ymin)/(xmax - xmin) …(7)
ただし、AR > 1ならばAR = 1/AR
First, it is determined whether or not the aspect ratio of the red region is equal to or greater than a preset threshold value Th_BF_VHRatio (S1201). The aspect ratio AR is calculated by equation (7).
AR = (ymax-ymin) / (xmax-xmin)… (7)
However, if AR> 1, AR = 1 / AR

すなわち、縦横比ARは0.0〜1.0の範囲で表され、AR=1.0のときは縦と横の長さが同じである。ステップS1201は、縦横比ARと閾値Th_BF_VHRatioを比較して、AR<Th_BF_VHRatioの場合は、その赤色領域は赤丸領域ではないと判定して、次の赤色領域の探索に遷移する。   That is, the aspect ratio AR is expressed in the range of 0.0 to 1.0. When AR = 1.0, the vertical and horizontal lengths are the same. In step S1201, the aspect ratio AR is compared with the threshold value Th_BF_VHRatio. If AR <Th_BF_VHRatio, it is determined that the red area is not a red circle area, and the process proceeds to the search for the next red area.

AR≧Th_BF_VHRatioの場合は、赤色領域のサイズが適正か否かを判定する(S1202)。サイズの判定は、(1)実際の画素数の上限、下限、(2)画像の短辺または長辺に対する比の二つの観点から行う。   If AR ≧ Th_BF_VHRatio, it is determined whether or not the size of the red region is appropriate (S1202). The size is determined from two viewpoints: (1) the upper and lower limits of the actual number of pixels, and (2) the ratio of the short side or the long side of the image.

まず、(1)については、赤色領域の横幅X=xmax-xminと縦幅Y=ymax-yminの小さい方と、予め設定された閾値を比較して、縦幅または横幅が上限Th_BF_SizeMaxと下限Th_BF_SizeMinの間にあるか否かを判定する。もし、上限と下限の間に縦幅Yまたは横幅Xがなければ、その赤色領域は赤丸領域ではないと判定して、次の赤色領域の探索に遷移する。   First, for (1), the smaller of the horizontal width X = xmax-xmin and the vertical width Y = ymax-ymin of the red region is compared with a preset threshold, and the vertical width or horizontal width is the upper limit Th_BF_SizeMax and the lower limit Th_BF_SizeMin It is determined whether it is between. If there is no vertical width Y or horizontal width X between the upper limit and the lower limit, it is determined that the red area is not a red circle area, and a transition is made to the search for the next red area.

また、(2)については、式(8)により求める。
Th_BF_RatioMin < min(X, Y)/min(W, H) < Th_BF_RatioMax …(8)
ここで、X = xmax - xmin
Y = ymax - ymin
Wは入力画像の幅
Hは入力画像の高さ
In addition, (2) is obtained from equation (8).
Th_BF_RatioMin <min (X, Y) / min (W, H) <Th_BF_RatioMax… (8)
Where X = xmax-xmin
Y = ymax-ymin
W is the width of the input image
H is the height of the input image

もし、注目赤色領域が式(8)を満さない場合は、赤丸領域ではないと判定して、次の赤色領域の探索に遷移する。なお、式(8)には、短辺同士を比較する例を示したが、長辺同士を比較してもよい。   If the red region of interest does not satisfy Expression (8), it is determined that the region is not a red circle region, and the process proceeds to the search for the next red region. In addition, although the example which compares short sides was shown in Formula (8), you may compare long sides.

ステップS1202とサイズが適正と判定した場合は、周辺の長さを理想的な円周と比較して、抽出した赤領域が円形に近いか否かの判定を行う。赤色領域の幅X、高さYから、理想的な円周Ciを式(9)で近似的に求める。
Ci = (X + Y)×2×2π/8 …(9)
If it is determined in step S1202 that the size is appropriate, the peripheral length is compared with the ideal circumference to determine whether the extracted red region is close to a circle. From the width X and height Y of the red region, an ideal circumference Ci is approximately obtained by Equation (9).
Ci = (X + Y) × 2 × 2π / 8… (9)

式(9)は、抽出した赤色領域が正方形と仮定して、正方形に内接する円の円周を算出するものである。式(9)において、(X+Y)×2は赤色領域を包含する正方形の四辺の長を、2π/8が正方形の四辺の長さと当該正方形に内接する円の円周の比を示す。上記の理想的な円周ciと周辺の長さを式(10)によって比較し、式(10)を満たさない場合は赤丸領域とは判定せずに、次の赤色領域の探索に遷移する。
min(Ci, Cx)/max(Ci, Cx) > Th_BF_CircleRatio …(10)
ここで、Cxは周辺の長さ
Equation (9) is to calculate the circumference of a circle inscribed in the square, assuming that the extracted red region is a square. In the equation (9), (X + Y) × 2 represents the length of the four sides of the square including the red region, and 2π / 8 represents the ratio of the length of the four sides of the square to the circumference of the circle inscribed in the square. The ideal circumference ci and the length of the periphery are compared by Expression (10). When Expression (10) is not satisfied, the red circle area is not determined, and the next red area search is performed.
min (Ci, Cx) / max (Ci, Cx)> Th_BF_CircleRatio… (10)
Where Cx is the perimeter length

周辺の長さが式(10)を満たす場合、方向ヒストグラムの偏りに関する判定を行う(S1204)。既に説明したように、境界線追跡の過程で、図10に示すような方向のヒストグラムを得ることができる。もし、境界線追跡の対象領域が円に近い場合、追跡処理の結果から得られた八方向の方向ヒストグラムは均等な分布になるが、対象領域が細長い場合などは方向ヒストグラムに偏りが生じる。例えば、右上から右下に細長い形状の対象領域であれば、図9に示す方向のうち、方向2および6に度数が集中し、方向4および8の度数が少なくなる。従って、式(11)に示す条件すべてを満たす場合は注目赤色領域を赤丸領域と判定し、何れか一つでも条件を満たさない場合は、注目赤色領域は赤丸領域ではないと判定して、次の赤色領域の探索に遷移する。
sum(f1, f2, f5, f6) < Σf×Th_BF_DirectRatio
sum(f2, f3, f6, f7) < Σf×Th_BF_DirectRatio
sum(f3, f4, f7, f8) < Σf×Th_BF_DirectRatio …(11)
sum(f4, f5, f8, f1) < Σf×Th_BF_DirectRatio
ここで、fnは方向nの度数
sum(fa, fb, fc, fd)は方向a, b, c, dの度数の和
Σfは度数の総和
When the peripheral length satisfies the equation (10), a determination is made regarding the bias of the direction histogram (S1204). As already described, a histogram having a direction as shown in FIG. 10 can be obtained in the process of tracking the boundary line. If the target area of the boundary line tracking is close to a circle, the eight-direction direction histogram obtained from the result of the tracking process has a uniform distribution. However, when the target area is elongated, the direction histogram is biased. For example, in the case of an elongated target region extending from the upper right to the lower right, the frequencies are concentrated in the directions 2 and 6 in the directions shown in FIG. 9, and the frequencies in the directions 4 and 8 are reduced. Therefore, if all of the conditions shown in Equation (11) are satisfied, the red area of interest is determined as a red circle area.If any one of the conditions is not satisfied, it is determined that the red area of interest is not a red circle area. Transition to the search for the red region of.
sum (f1, f2, f5, f6) <Σf × Th_BF_DirectRatio
sum (f2, f3, f6, f7) <Σf × Th_BF_DirectRatio
sum (f3, f4, f7, f8) <Σf × Th_BF_DirectRatio… (11)
sum (f4, f5, f8, f1) <Σf × Th_BF_DirectRatio
Where fn is the frequency in direction n
sum (fa, fb, fc, fd) is the sum of frequencies in directions a, b, c, d
Σf is the sum of frequencies

式(11)により、ある方向について求めた度数の和が所定割合よりも多い場合、すなわち、ある方向に集中があるならば、注目赤色領域は赤丸領域ではないと判定する。また、式(11)による判定は、度数の総和Σfが小さい場合は判定精度が低下する危惧があり、度数の総和Σfが所定値以下の場合、ステップS1204の処理をスキップしてステップS1205に進むようにしてもよい。   If the sum of the frequencies obtained in a certain direction is greater than a predetermined ratio according to Equation (11), that is, if there is a concentration in a certain direction, it is determined that the red region of interest is not a red circle region. In addition, the determination according to the equation (11) may cause a decrease in determination accuracy when the frequency sum Σf is small. If the frequency sum Σf is less than or equal to a predetermined value, the process of step S1204 is skipped and the process proceeds to step S1205. You may make it.

以上のステップS1201〜S1204のすべての判定(ステップS1204をスキップした場合は残るステップS1201〜S1203の判定)を満たす赤色領域について赤丸領域(赤目領域候補)と判定して、RAM103に割り当てた候補領域リストにその座標位置を格納し(S1205)、画像データの右下近傍に達するまでさらに境界線追跡および図12に示す判定を繰り返す。   A candidate area list assigned to the RAM 103 by determining that the red area satisfying all the determinations of the above steps S1201 to S1204 (remaining determinations of steps S1201 to S1203 when step S1204 is skipped) is a red circle area (red-eye area candidate) The coordinate position is stored in (S1205), and the boundary line tracking and the determination shown in FIG. 12 are repeated until reaching the lower right vicinity of the image data.

[特徴量判定部204]
特徴量判定部204は、抽出された赤丸領域(赤目候補領域)について、人の赤目と特定できるような様々な特徴量を算出し、それを予め定められた閾値と比較して、赤目か否かを判定する。
[Feature amount determination unit 204]
The feature amount determination unit 204 calculates various feature amounts that can be identified as human red eyes for the extracted red circle region (red eye candidate region), and compares the calculated feature amount with a predetermined threshold value to determine whether or not it is a red eye. Determine whether.

特徴量判定部204は、前段までの処理によって候補領域リストに記録された赤目候補領域に対して、以下の五つの特徴量群の判定を図16に示す順番で実行する。
特徴量群0:赤丸領域と周辺領域の評価量の平均値Er(ave)の比較(S10)
特徴量群1:赤丸領域内の色相と評価量Er、色成分の変化に関する判定(S11)
特徴量群2:周辺領域の輝度に関する判定(S12)
特徴量群3:周辺領域の彩度、色相に関する判定(S13)
特徴量群4:周辺領域のエッジの強度に関する判定(S14)
The feature amount determination unit 204 performs the following five feature amount group determinations in the order shown in FIG. 16 for the red-eye candidate regions recorded in the candidate region list by the processing up to the previous stage.
Feature value group 0: Comparison of the average value Er (ave) of the evaluation values of the red circle area and the surrounding area (S10)
Feature amount group 1: Hue in the red circle area, evaluation amount Er, and determination regarding change in color component (S11)
Feature group 2: Judgment on luminance of surrounding area (S12)
Feature group 3: Determination of saturation and hue of surrounding area (S13)
Feature value group 4: Judgment on edge strength of surrounding area (S14)

理想的な赤目領域の赤色成分は、その周辺領域に比べて、瞳孔部分にのみ突出して存在する特徴がある。この特徴は、その他の様々な特徴量と比較しても、最も顕著に表れることが実験により判明している。従って、特徴量群0の判定処理(S10)を最初に行い、赤目候補領域を絞ることが効率的である。   The red component of the ideal red-eye region has a characteristic that it protrudes only in the pupil portion as compared with the peripheral region. Experiments have shown that this feature appears most prominently even when compared with other various feature quantities. Therefore, it is efficient to perform the determination process (S10) of the feature amount group 0 first to narrow down the red-eye candidate region.

特徴量群1の判定(S11)は、赤丸候補領域内のみの画素を参照して特徴量判定を行うため、他の特徴量群の判定に比較して演算量は少ない。   In the determination of the feature amount group 1 (S11), since the feature amount determination is performed with reference to the pixels only in the red circle candidate region, the calculation amount is small compared to the determination of other feature amount groups.

特徴量群2と特徴量群3の判定(S12、S13)は、設定した周辺領域に存在する画素に対して、RGB成分を輝度、色差成分に変換したり、RGB成分を明度、彩度、色相成分に変換する処理を必要とするため、特徴量群1の判定に比べて演算量は多くなる。   The determination of the feature amount group 2 and the feature amount group 3 (S12, S13) is performed by converting the RGB component into luminance and color difference components for the pixels existing in the set peripheral region, or converting the RGB component into lightness, saturation, Since a process for conversion to the hue component is required, the amount of calculation is larger than that of the determination of the feature amount group 1.

特徴量群4の判定(S14)は、エッジの強度を求めるためにSobelなどの公知のエッジ検出フィルタを用いる。そのため、他の特徴量群の判定と比較して最も演算量が多い。   In the determination of the feature quantity group 4 (S14), a known edge detection filter such as Sobel is used to obtain the edge strength. Therefore, the amount of calculation is the largest compared with the determination of other feature amount groups.

従って、特徴量判定部204は、演算量の少ない判定、あるいは、赤目領域の特徴を掴み易い判定から順に行い、それによって赤目領域ではないと判定される赤目候補領域について、図16に示すように、以降の判定をスキップすることで、特徴量判定部204の処理量を抑制する。   Therefore, the feature amount determination unit 204 performs the determination with a small amount of calculation or the determination that makes it easy to grasp the feature of the red-eye region, thereby determining the red-eye candidate region that is determined not to be a red-eye region as shown in FIG. By skipping subsequent determinations, the processing amount of the feature amount determination unit 204 is suppressed.

●周辺領域の定義
図13は赤目候補領域の特徴量を算出する際に使用する周辺領域の定義を説明する図である。
Definition of Surrounding Area FIG. 13 is a diagram for explaining the definition of the surrounding area used when calculating the feature amount of the red-eye candidate area.

図13において、中央のブロック1301が前段の処理で抽出された赤目候補領域(赤丸領域)の外接矩形で、周辺領域はブロック1301を中心として、その周辺にブロック1301の縦横のサイズをそれぞれ二倍、三倍、五倍に拡大した領域である。各倍率の周辺領域を図13(a)〜図13(c)に示す。また、以降で「周辺領域全体」と呼ぶ場合は、周辺領域からブロック1301を除いた部分を意味する。また、「周辺領域のブロック」とは、図13に破線で示すように、ブロック1301の辺を延長して周辺領域を八つに区切った各ブロックを意味する。特徴量群のうち、特徴量群1以外は、この周辺領域に対して判定を行う。このような周辺領域の設定は、最大でも赤目候補領域の外接矩形の五倍の領域しか参照しないため、高速な判定処理が可能である。   In FIG. 13, the central block 1301 is a circumscribed rectangle of the red-eye candidate area (red-circle area) extracted in the previous process, and the peripheral area is centered on the block 1301 and the vertical and horizontal sizes of the block 1301 are doubled around it. This is an area that has been magnified three times and five times. The peripheral region for each magnification is shown in FIGS. 13 (a) to 13 (c). In the following, the term “entire peripheral area” means a portion obtained by removing the block 1301 from the peripheral area. Further, the “peripheral block” means each block obtained by extending the side of the block 1301 and dividing the peripheral region into eight, as indicated by a broken line in FIG. Among the feature amount groups, those other than the feature amount group 1 are determined for this peripheral region. Such a setting of the peripheral region refers to only a region five times the circumscribed rectangle of the red-eye candidate region at the maximum, so that high-speed determination processing is possible.

図14は赤目候補領域が画像の端部近傍に存在する場合の周辺領域を説明する図である。   FIG. 14 is a diagram for explaining a peripheral area when a red-eye candidate area exists in the vicinity of the edge of the image.

図14(a)は、赤目候補領域の外接矩形(ブロック1301)が画像の右端近傍に、ややマージンを残して存在する場合を示す。この場合、周辺領域の各ブロック内に一画素でも画素が存在するならば、その画素を用いて特徴量判定を行う。   FIG. 14 (a) shows a case where the circumscribed rectangle (block 1301) of the red-eye candidate region exists in the vicinity of the right end of the image with a slight margin. In this case, if even one pixel is present in each block in the peripheral area, the feature amount is determined using that pixel.

一方、図14(b)は、ブロック1301がマージンなしで画像右端に接する場合を示している。この場合、周辺ブロックのうち、右上(TR)、右(R)、右下(BR)の3ブロックには画素が存在しないため、当該周辺ブロックの特徴量を算出することができない。このような場合、実施例1では、ブロック1301を赤目領域と判定しないことにして、候補領域リストから除外する。   On the other hand, FIG. 14B shows a case where the block 1301 touches the right edge of the image without a margin. In this case, since there are no pixels in the three blocks of the upper right (TR), right (R), and lower right (BR) among the peripheral blocks, it is not possible to calculate the feature amount of the peripheral block. In such a case, in the first embodiment, the block 1301 is not determined as a red-eye area and is excluded from the candidate area list.

●特徴量群0の判定(S10)
特徴量群0の判定は、ブロック1301に対して例えば図13(b)に示す三倍の周辺領域を設定し、ブロック1301を含む各ブロックについて、式(3)を用いて各画素の評価量Erを算出し、それらの平均値Er(ave)を算出する。算出した平均値Er(ave)は、RAM103に割り当てた配列AEvR[8]に格納する。ここでAEvRは0〜8の九つの要素を保持する配列で、要素0は図13に示す左上(TL)ブロック、要素1は上(T)ブロック、要素2は右上(TR)ブロック、…というように、左上ブロックから右下ブロックの順に割り当てる。
● Judgment of feature amount group 0 (S10)
The feature amount group 0 is determined by setting, for example, a three-fold peripheral region shown in FIG. 13 (b) for the block 1301, and for each block including the block 1301, the evaluation amount of each pixel using Equation (3). Er is calculated, and an average value Er (ave) thereof is calculated. The calculated average value Er (ave) is stored in the array AEvR [8] allocated to the RAM 103. Here, AEvR is an array holding nine elements from 0 to 8, where element 0 is the upper left (TL) block shown in FIG. 13, element 1 is the upper (T) block, element 2 is the upper right (TR) block, and so on. In this way, allocation is performed in the order from the upper left block to the lower right block.

次に、要素i=0〜8(ただし、ブロック1301のi=4は除く)について、以下の式を満たすか否かを判定する。
AEvR[i] < AEvR[4]×Th_FJ0_EvR …(12)
Next, it is determined whether or not the following expression is satisfied for the elements i = 0 to 8 (except for i = 4 of the block 1301).
AEvR [i] <AEvR [4] x Th_FJ0_EvR… (12)

式(12)は、ブロック1301の評価量の平均値AEvR[4]に閾値Th_FJ0_EvRを乗じた値が、他の八個の周辺ブロックの評価量の平均値AEvR[i]よりも大きい場合、赤目領域と判定することを意味する。式(12)を満さない場合、注目赤目候補領域は赤目領域ではないとして、以降の特徴量群の判定を行わず、次の赤目候補領域の判定に移る。   Equation (12) is obtained when the average value AEvR [4] of the evaluation amount of the block 1301 is multiplied by the threshold value Th_FJ0_EvR is greater than the average value AEvR [i] of the evaluation amounts of the other eight neighboring blocks. This means that the area is determined. If the expression (12) is not satisfied, it is determined that the target red-eye candidate region is not a red-eye region, and the subsequent feature-value group determination is not performed, and the next red-eye candidate region is determined.

ところで、まず式(12)によって評価量Erを比較する理由は、以降で説明する特徴量の中で、最も顕著に赤目領域の特徴を掴むことができるからである。様々な実験の結果、式(12)による判定が、赤目領域以外の領域を候補領域リストから除外するのに最も効果的であることが判明している。従って、できるだけ特徴を掴みやすい特徴量から順番に判定することで、特徴量判定部204の演算量を最小限に抑えることができる。   By the way, the reason why the evaluation value Er is compared by the equation (12) is that the feature of the red-eye region can be grasped most prominently among the feature values described below. As a result of various experiments, it has been found that the determination according to the equation (12) is most effective for excluding regions other than the red-eye region from the candidate region list. Therefore, the calculation amount of the feature amount determination unit 204 can be minimized by determining in order from the feature amount that makes it easy to grasp the feature as much as possible.

また、各ブロックの平均値Er(ave)を算出する際、ブロック1301については、図15(a)に示すような菱形の算出領域1501の画素についてのみ評価値Erを算出することが望ましい。赤目領域の形状は一般に円もしくは楕円であるから、ブロック1301の四隅には、赤色度合いが小さい画素が存在する。このため、ブロック1301の評価量の平均値Er(ave)を低下させないためにも、ブロック1301の四隅を除く画素を対象として評価量Erを算出すべきである。なお、評価値Erの算出領域は図15(a)に示す菱形以外に、ブロック1306に内接する円(図15(b))や楕円(図15(c))内としても、同等もしくはより良好な算出結果を得ることができる。   Further, when calculating the average value Er (ave) of each block, it is desirable to calculate the evaluation value Er only for the pixels in the rhombic calculation region 1501 as shown in FIG. Since the shape of the red-eye region is generally a circle or an ellipse, pixels with a small red degree are present at the four corners of the block 1301. For this reason, in order not to reduce the average value Er (ave) of the evaluation amount of the block 1301, the evaluation amount Er should be calculated for pixels excluding the four corners of the block 1301. In addition to the rhombus shown in FIG. 15 (a), the calculation area of the evaluation value Er is equal to or better than the circle inscribed in the block 1306 (FIG. 15 (b)) or the ellipse (FIG. 15 (c)). Can be obtained.

●特徴量群1の判定(S11)
特徴量群1の判定は、赤目候補領域(図13に示すブロック1301)内のみの画像データを参照して、赤目領域か否かを判定する処理である。特徴量群1の判定には、例えば以下のような判定処理が含まれる。
Judgment of feature quantity group 1 (S11)
The determination of the feature amount group 1 is processing for determining whether or not it is a red-eye region by referring to image data only in the red-eye candidate region (block 1301 shown in FIG. 13). The determination of the feature quantity group 1 includes, for example, the following determination process.

まず、赤目候補領域において、色相が±30度以内の画素の評価量の平均値Er(ave)が閾値Th_FJ1_EMin以上で、かつ、閾値Th_FJ1_EMax以下かを判定する。この判定を満さない場合は候補領域リストから除外する。なお、色相については、公知の手法により求めることが可能である。   First, in the red-eye candidate region, it is determined whether the average value Er (ave) of the evaluation amounts of pixels whose hue is within ± 30 degrees is equal to or greater than the threshold Th_FJ1_EMin and equal to or less than the threshold Th_FJ1_EMax. If this determination is not satisfied, it is excluded from the candidate area list. The hue can be obtained by a known method.

次に、赤目候補領域において、色相が±30度以内の画素の評価量Erの最大値、最小値を求め、比率R=最小値/最大値を算出する。赤目候補領域では、評価量Erは大きく変化するため、比率Rはある程度小さい値になる。従って、式(13)に示す判定を行い、式(13)を満さない注目赤目候補領域を候補領域リストから除外する。
R < Th_FJ1_EMaxMinRatio …(13)
Next, in the red-eye candidate region, the maximum value and the minimum value of the evaluation amount Er of pixels whose hue is within ± 30 degrees are obtained, and the ratio R = minimum value / maximum value is calculated. In the red-eye candidate region, the evaluation amount Er changes greatly, and the ratio R becomes a small value to some extent. Therefore, the determination shown in Expression (13) is performed, and the target red-eye candidate area that does not satisfy Expression (13) is excluded from the candidate area list.
R <Th_FJ1_EMaxMinRatio (13)

次に、赤目候補領域において、R成分の標準偏差を測定する。赤目領域には鮮やかな赤領域と、瞳孔境界付近の暗い領域が含まれるため、R成分のダイナミックレンジは非常に大きな値になる。従って、赤目領域のR成分の偏差を測定すれば、その値はある程度大きい値になる。従って、赤目候補領域において、既知の方法によりR成分の標準偏差δrを測定し、閾値Th_FJ1_RDivより大きいか否か判定する。
δr > Th_FJ1_RDiv …(14)
Next, the standard deviation of the R component is measured in the red-eye candidate region. Since the red-eye region includes a bright red region and a dark region near the pupil boundary, the dynamic range of the R component has a very large value. Therefore, if the deviation of the R component in the red-eye region is measured, the value becomes a large value to some extent. Therefore, in the red-eye candidate region, the standard deviation Δr of the R component is measured by a known method, and it is determined whether or not it is larger than the threshold value Th_FJ1_RDiv.
δr> Th_FJ1_RDiv (14)

式(14)を満たさない赤目候補領域は候補領域リストから除外する。なお、上ではR成分の標準偏差について言及したが、当然、R成分の分散を用いたとしても、同様の判定を行うことができる。   Red-eye candidate regions that do not satisfy Equation (14) are excluded from the candidate region list. Although the standard deviation of the R component has been mentioned above, it is obvious that the same determination can be made even if the variance of the R component is used.

また、R成分の変化の度合いを判定する別の方法として、赤目候補領域において、近隣画素間のR成分の差分和の平均値SDr(ave)を算出して閾値Th_FJ1_RDiffより大きいか否かを判定することも考えられる(式15)。
SDr(ave) > Th_FJ1_RDiff …(15)
As another method for determining the degree of change of the R component, in the red-eye candidate region, the average value SDr (ave) of the difference sum of R components between neighboring pixels is calculated to determine whether or not it is larger than the threshold Th_FJ1_RDiff. (Equation 15).
SDr (ave)> Th_FJ1_RDiff… (15)

近隣画素の差分和の平均値を算出する方法は様々な方法が考えられる。例えば、注目画素と、隣接する八つの画素との差分和の平均値を算出してもよいし、単純に左隣の画素との差分を求めてもよい。また、上記の判定は、R成分だけでなく、他のG、B成分あるいは輝度や評価量Erに対しても同様に実施することができる。   There are various methods for calculating the average value of the difference sum of neighboring pixels. For example, an average value of the difference sum between the target pixel and eight adjacent pixels may be calculated, or a difference between the pixel on the left side may be simply obtained. Further, the above determination can be similarly performed not only on the R component but also on other G and B components, luminance, and evaluation amount Er.

●特徴量群2の判定(S12)
特徴量群2の判定は、特徴量群1の判定により候補領域リストから除外されずに残った赤目候補領域に対して周辺領域を設定し、周辺領域内の輝度成分に関する判定処理を行う。特徴量群2の判定には、例えば以下の判定処理が含まれる。
● Judgment of feature amount group 2 (S12)
In the determination of the feature amount group 2, a peripheral region is set for the red-eye candidate region remaining without being excluded from the candidate region list by the determination of the feature amount group 1, and a determination process regarding the luminance component in the peripheral region is performed. The determination of the feature quantity group 2 includes, for example, the following determination process.

まず、赤目候補領域に対して周辺領域(例えば図13(c)に示す五倍領域)を設定する。次に、ブロック1301を除く周辺領域の8ブロックの平均輝度値Y(ave)を算出し、平均輝度値Y(ave)が閾値Th_FJ2_YMin以上、閾値Th_FJ2_YMax以下の範囲か否かを判定する。平均輝度値Y(ave)がこの範囲に入らない場合、つまりブロック1301の周辺が極端に明るい、あるいは、暗い場合は、注目赤目候補領域を候補領域リストから除外する。   First, a peripheral region (for example, a fivefold region shown in FIG. 13C) is set for the red-eye candidate region. Next, the average luminance value Y (ave) of eight blocks in the peripheral area excluding the block 1301 is calculated, and it is determined whether or not the average luminance value Y (ave) is in the range of the threshold value Th_FJ2_YMin or more and the threshold value Th_FJ2_YMax or less. When the average luminance value Y (ave) does not fall within this range, that is, when the periphery of the block 1301 is extremely bright or dark, the target red-eye candidate region is excluded from the candidate region list.

上記の輝度に関する判定は、周辺領域の8ブロック全体で行ってもよいし、周辺領域のブロックごとに平均輝度値Y(ave)を求めて、ブロックごとに予め設定した閾値と比較してもよい。   The above determination regarding luminance may be performed for the entire eight blocks in the peripheral region, or an average luminance value Y (ave) may be obtained for each block in the peripheral region, and compared with a preset threshold value for each block. .

次に、赤目候補領域に対して二倍の周辺領域(図13(a))を設定し、ブロック1301を除く周辺領域の8ブロックそれぞれの平均輝度値Y(ave)を算出し、さらに、八つの平均輝度値の最大値Ymaxと最小値Yminを得る。赤目候補領域に対して二倍の周辺領域を設定した場合、周辺領域の明るさが大きく変化している可能性があるため、以下のような判定を行う。
(Ymax - Ymin) > Th_FJ2_MaxMinDiff2 …(16)
Next, a peripheral region twice as large as the red-eye candidate region (FIG. 13 (a)) is set, and the average luminance value Y (ave) of each of the eight blocks in the peripheral region excluding the block 1301 is calculated. A maximum value Ymax and a minimum value Ymin of two average luminance values are obtained. When the peripheral region twice as large as the red-eye candidate region is set, the brightness of the peripheral region may have changed greatly, so the following determination is performed.
(Ymax-Ymin)> Th_FJ2_MaxMinDiff2… (16)

式(16)を満たさない場合、注目赤目候補領域を候補領域リストから除外する。   When Expression (16) is not satisfied, the target red-eye candidate region is excluded from the candidate region list.

また一方で、赤目候補領域に対して五倍の周辺領域(図13(c))を設定し、上述したように、周辺領域の8ブロックそれぞれの平均輝度値Y(ave)を算出し、さらに、八つの平均輝度値の最大値Ymaxと最小値Yinを得る。赤目候補領域に対して比較的広い五倍の周辺領域を設定した場合、周辺領域の多くは肌色領域であり、それら領域で輝度値が大きく変化するとは考えられない。従って、二倍の周辺領域を設定した場合と異なり、以下の判定を行う。
(Ymax - Ymin) < Th_FJ2_MaxMinDiff5 …(17)
On the other hand, a five-fold peripheral region (FIG. 13 (c)) is set for the red-eye candidate region, and as described above, the average luminance value Y (ave) of each of the eight blocks in the peripheral region is calculated. The maximum value Ymax and the minimum value Yin of the eight average luminance values are obtained. When a relatively wide five-fold peripheral region is set for the red-eye candidate region, most of the peripheral regions are skin color regions, and it is not considered that the luminance value greatly changes in these regions. Therefore, unlike the case where the double peripheral region is set, the following determination is performed.
(Ymax-Ymin) <Th_FJ2_MaxMinDiff5… (17)

式(17)を満たさない場合、注目赤目候補領域を候補領域リストから除外する。   When Expression (17) is not satisfied, the target red-eye candidate area is excluded from the candidate area list.

●特徴量群3の判定(S13)
特徴量群3の判定は、特徴量群1および特徴量群2の判定により候補領域リストから除外されずに残った赤目候補領域に対して周辺領域を設定し、該周辺領域内の彩度および色相に関する判定を行う。特徴量群3の判定には、例えば以下の判定処理が含まれる。
● Judgment of feature amount group 3 (S13)
The determination of the feature amount group 3 is performed by setting a peripheral region for the red-eye candidate region remaining without being excluded from the candidate region list by the determination of the feature amount group 1 and the feature amount group 2, and the saturation and Judgment regarding hue is performed. The determination of the feature amount group 3 includes, for example, the following determination process.

まず、赤目候補領域に対して周辺領域を設定し(例えば、図13(c)に示す五倍領域)、ブロック1301を除く周辺領域の8ブロックにおいて、色相が±Th_FJ3_HRangeの画素数の割合Rhを算出する。赤目領域の周辺領域は肌色領域であるから、大部分の画素の色相は上記の範囲に含まれる筈である。従って、算出した割合Rhが閾値Th_FJ3_HRatio以上であれば赤目候補領域とするが、当該閾値未満の場合は注目赤目候補領域を候補領域リストから除外する。なお、割合Rhは式(18)で計算する。
Rh = Nh/ΣN …(18)
ここで、Nhは色相が±Th_FJ3_HRangeの画素数
ΣNは8ブロックの画素数
First, a peripheral region is set for the red-eye candidate region (for example, the five-fold region shown in FIG. 13C), and the ratio Rh of the number of pixels having a hue of ± Th_FJ3_HRange is set in eight blocks in the peripheral region excluding the block 1301. calculate. Since the peripheral region of the red-eye region is a skin color region, the hue of most pixels should be included in the above range. Accordingly, if the calculated ratio Rh is equal to or greater than the threshold value Th_FJ3_HRatio, the red-eye candidate region is selected, but if it is less than the threshold value, the target red-eye candidate region is excluded from the candidate region list. The ratio Rh is calculated by equation (18).
Rh = Nh / ΣN… (18)
Where Nh is the number of pixels with a hue of ± Th_FJ3_HRange
ΣN is the number of pixels in 8 blocks

次に、赤目候補領域に対して周辺領域を設定し(例えば、図13(c)に示すの五倍領域)、周辺領域の8ブロック全体の平均彩度S(ave)を算出する。平均彩度S(ave)が閾値Th_FJ3_SMin以上、閾値Th_FJ3_SMax以下の範囲にあるか否かを判定する。当該範囲を逸脱する場合、注目赤目候補領域を候補領域リストから除外する。   Next, a peripheral region is set for the red-eye candidate region (for example, the five-fold region shown in FIG. 13C), and the average saturation S (ave) of the entire eight blocks in the peripheral region is calculated. It is determined whether or not the average saturation S (ave) is in a range not less than the threshold value Th_FJ3_SMin and not more than the threshold value Th_FJ3_SMax. When deviating from the range, the target red-eye candidate region is excluded from the candidate region list.

また、上記の彩度の判定は、ブロック単位に行うことも考えられる。つまり、周辺領域のブロックごとに平均彩度S(ave)を算出し、予め設定された閾値と比較すればよい。   It is also conceivable to perform the above saturation determination in units of blocks. That is, the average saturation S (ave) may be calculated for each block in the peripheral area and compared with a preset threshold value.

さらに、赤目領域の周辺には所謂白目領域が存在するため、赤目候補領域に対して設定した周辺領域(例えば、図13(b)に示すの三倍領域)において、彩度Sと明度Lの比S/Lが閾値Th_FJ3_WhitePix以下になる、すなわち彩度Sが小さく、明度Lが高い画素が存在するならば赤目候補領域と判定する。もし、上記の判定が否の場合は、注目赤目候補領域を候補領域リストから除外する。   Furthermore, since there is a so-called white-eye region around the red-eye region, saturation S and lightness L of the peripheral region set for the red-eye candidate region (for example, the triple region shown in FIG. 13B). If the ratio S / L is equal to or less than the threshold Th_FJ3_WhitePix, that is, if there is a pixel with low saturation S and high lightness L, it is determined as a red-eye candidate region. If the above determination is negative, the target red-eye candidate region is excluded from the candidate region list.

●特徴量群4の判定(S14)
特徴量群4の判定は、特徴量群1から特徴量群3の判定により候補領域リストから除外されずに残った赤目候補領域に対して周辺領域を設定し、周辺領域内のエッジに関する判定処理を行う。人の目近傍には非常に強いエッジが存在するため、有効な特徴量になり得る。また、以下ではエッジの検出に公知のSobelフィルタを用いる例を説明するが、これに限定されるものではなく、他のエッジ検出フィルタを用いたとしても、同様の判定処理を行うことが可能である。なお、Sobelフィルタについては公知であるため、ここでの詳細な説明は省略する。特徴量群4の判定には、例えば以下のような判定処理が含まれる。
● Judgment of feature amount group 4 (S14)
The determination of the feature amount group 4 is performed by setting a peripheral region for the remaining red-eye candidate region that is not excluded from the candidate region list by the determination of the feature amount group 1 to the feature amount group 3 and determining the edge in the peripheral region I do. Since a very strong edge exists in the vicinity of the human eye, it can be an effective feature amount. In addition, an example in which a known Sobel filter is used for edge detection will be described below. However, the present invention is not limited to this, and the same determination process can be performed even if another edge detection filter is used. is there. Since the Sobel filter is known, a detailed description thereof is omitted here. The determination of the feature amount group 4 includes, for example, the following determination process.

まず、赤目候補領域に対して周辺領域(例えば、図13(a)に示す二倍領域)を設定し、周辺領域内の各画素に対してSobelフィルタを施す。その結果、画素ごとに得られるSobel出力値の平均値So(ave)を算出する。人の目近傍には強いエッジが存在する場合が多いため、平均値So(ave)と閾値Th_FJ4_SobelPowを比較して、So(ave)≦Th_FJ4_SobelPowの場合は注目赤目候補領域を候補領域リストから除外する。   First, a peripheral region (for example, a double region shown in FIG. 13A) is set for the red-eye candidate region, and a Sobel filter is applied to each pixel in the peripheral region. As a result, an average value So (ave) of Sobel output values obtained for each pixel is calculated. Since there is often a strong edge near the human eye, the average value So (ave) is compared with the threshold Th_FJ4_SobelPow, and if So (ave) ≦ Th_FJ4_SobelPow, the target red eye candidate region is excluded from the candidate region list .

また、赤目候補領域に対して周辺領域(例えば、図13(b)に示す三倍領域)を設定し、周辺領域内の各画素に対してSobelフィルタを施す。その結果、画素ごとに得られるSobel出力値の最大値と最小値の差Dsを算出する。人の目近傍には強いエッジが存在する一方で、肌色の平坦な部分も存在することから、差Dsは比較的大きな値になる筈である。従って、差Dsと閾値Th_FJ4_MaxMinDiffを比較して、Ds≦Th_FJ4_MaxMinDiffの場合は注目赤目候補領域を候補領域リストから除外する。   Further, a peripheral region (for example, a triple region shown in FIG. 13B) is set for the red-eye candidate region, and a Sobel filter is applied to each pixel in the peripheral region. As a result, the difference Ds between the maximum value and the minimum value of the Sobel output value obtained for each pixel is calculated. While a strong edge exists in the vicinity of the human eye and a flat portion of the skin color also exists, the difference Ds should be a relatively large value. Therefore, the difference Ds is compared with the threshold value Th_FJ4_MaxMinDiff, and the red-eye candidate region of interest is excluded from the candidate region list when Ds ≦ Th_FJ4_MaxMinDiff.

さらに、赤目候補領域に対して周辺領域(例えば、図13(b)に示すの三倍領域)を設定し、周辺領域内の各画素に対してSobelフィルタを施す。その結果、画素ごとに得られるSobel出力値をエッジ画像としてRAM103の割り当てた配列sobel[y][x]に格納する。次に、エッジ画像の重心位置(Xw, Yx)を算出する。重心位置(Xw, Yx)は、式(19)によって求める。
(Xw, Yw) = (Σx・Sobel[y][x]/Sobel[y][x], Σy・Sobel[y][x]/Sobel[y][x]) …(19)
Further, a peripheral region (for example, a triple region shown in FIG. 13B) is set for the red-eye candidate region, and a Sobel filter is applied to each pixel in the peripheral region. As a result, the Sobel output value obtained for each pixel is stored in the array sobel [y] [x] assigned to the RAM 103 as an edge image. Next, the gravity center position (Xw, Yx) of the edge image is calculated. The barycentric position (Xw, Yx) is obtained by equation (19).
(Xw, Yw) = (Σx ・ Sobel [y] [x] / Sobel [y] [x], Σy ・ Sobel [y] [x] / Sobel [y] [x])… (19)

もし、注目赤目候補領域が人の目であれば、重心位置(Xw, Yx)は、エッジ画像の中央近傍に存在する筈である。従って、重心位置(Xw, Yx)が、例えばブロック1301に含まれるか否かを判定し、含まれていれば赤目候補領域と判定し、含まれない場合は注目赤目候補領域を候補領域リストから除外する。   If the target red-eye candidate region is a human eye, the barycentric position (Xw, Yx) should exist near the center of the edge image. Therefore, it is determined whether or not the barycentric position (Xw, Yx) is included in the block 1301, for example, and if it is included, it is determined as a red eye candidate area, and if not included, the target red eye candidate area is determined from the candidate area list. exclude.

また、赤目候補領域に対して五倍の周辺領域(図13(c))を設定し、周辺領域の各画素に対してSobelフィルタを施す。その結果得られる各画素のSobel出力値をエッジ画像として配列Sobel[y][x]に格納する。配列Sobel[y][x]は五倍の周辺領域の画素数と同じサイズの配列になる。次に、ブロック1301を含む周辺領域全体に対して、図17に示すような二つの領域、すなわち中央領域1601と外部領域1602を定義し、各領域に対して、配列Sobel[y][x]に格納したSobel出力値の平均値を算出する。なお、図17においては、中央領域1601のサイズをブロック1301の2.5倍としたが、これに限定されるものではない。中央領域1601と外部領域1602それぞれのSobel出力値の平均をSPowin、SPowoutとすると、人の目の近辺においては、外部領域1602よりも中央領域1601の方が強いエッジが存在することから、以下の判定を行う。
SPowin/SPowout > Th_FJ4_InOutRatio …(20)
Further, a fivefold peripheral region (FIG. 13 (c)) is set for the red-eye candidate region, and a Sobel filter is applied to each pixel in the peripheral region. The Sobel output value of each pixel obtained as a result is stored as an edge image in the array Sobel [y] [x]. The array Sobel [y] [x] is an array having the same size as the number of pixels in the five times the peripheral area. Next, two regions as shown in FIG. 17, that is, a central region 1601 and an external region 1602 are defined for the entire peripheral region including the block 1301, and an array Sobel [y] [x] is defined for each region. Calculate the average value of Sobel output values stored in. In FIG. 17, the size of the central region 1601 is 2.5 times that of the block 1301, but the present invention is not limited to this. When the average of the Sobel output values of the central region 1601 and the outer region 1602 is SPow in and SPow out , there is a stronger edge in the central region 1601 than the outer region 1602 in the vicinity of the human eye, The following determination is made.
SPow in / SPow out > Th_FJ4_InOutRatio (20)

式(20)を満たす場合、注目赤目候補領域を赤目領域と判定する。もし、式(20)を満たさない注目赤目候補領域は赤目領域ではないと判定し、候補領域リストから除外する。   When Expression (20) is satisfied, the target red-eye candidate region is determined as a red-eye region. If the target red-eye candidate region that does not satisfy Expression (20) is determined not to be a red-eye region, it is excluded from the candidate region list.

また、上記の応用として、SPowin、SPowoutを単独に別の閾値と比較するような判定も考えられる。 Further, as the above-mentioned application, it is also possible to determine such that SPow in and SPow out are independently compared with another threshold value.

特徴量判定部204は、以上の特徴量群0〜4の判定すべて(あるいは一部)を満たす赤目候補領域を赤目領域として確定し、赤目領域を確定した候補領域リストを補正部205に入力する。   The feature amount determination unit 204 determines a red-eye candidate region that satisfies all (or part of) the determination of the above-described feature amount groups 0 to 4 as a red-eye region, and inputs a candidate region list in which the red-eye region is determined to the correction unit 205. .

[補正部205]
補正部205は、RGB成分で構成された入力画像データと、前段までの処理で得られた赤目領域が記載された候補領域リストが入力される。
[Correction unit 205]
The correction unit 205 receives input image data composed of RGB components and a candidate area list in which red-eye areas obtained by the processing up to the previous stage are described.

図18は補正部205が実行する、候補領域リストに記載された複数の赤目領域のうちの一つを補正する処理例を示すフローチャートである。つまり、補正部205は、候補領域リストに記載された赤目領域を一つずつ図18に示す処理で補正する。   FIG. 18 is a flowchart showing an example of processing performed by the correcting unit 205 to correct one of a plurality of red-eye regions described in the candidate region list. That is, the correcting unit 205 corrects the red-eye areas described in the candidate area list one by one by the process shown in FIG.

まず、注目赤目領域に対して補正範囲を決定する(S1701)。図19は補正範囲の決定を説明する図である。   First, a correction range is determined for the red eye region of interest (S1701). FIG. 19 is a diagram illustrating determination of the correction range.

図19において、中央の矩形領域が候補領域リストに記載された赤目領域1901である。赤目領域1901の中心を通る長径、短径がそれぞれLw1、Lh1の楕円の補正領域1902を設定する。なお、Lw1、Lh1は式(21)によって算出する。
Lw1 = Lw0×CPARAM_AREARATIO
Lh1 = Lh0×CPARAM_AREARATIO …(21)
ここで、Lw0、Lh0は赤目領域1901の幅と高さの1/2
CPARAM_AREARATIOは補正範囲を決定するためのパラメータ
In FIG. 19, a central rectangular area is a red-eye area 1901 described in the candidate area list. An ellipse correction region 1902 having a major axis and a minor axis Lw1 and Lh1 passing through the center of the red-eye region 1901 is set. Lw1 and Lh1 are calculated by equation (21).
Lw1 = Lw0 × CPARAM_AREARATIO
Lh1 = Lh0 × CPARAM_AREARATIO… (21)
Here, Lw0 and Lh0 are 1/2 of the width and height of the red-eye area 1901.
CPARAM_AREARATIO is a parameter for determining the correction range

次に、補正領域1902内で補正に必要なパラメータを算出する(S1702)。算出するパラメータは、楕円領域内部での最大輝度値Ymaxおよび式(3)に示す評価量Erの最大値Ermaxである。   Next, parameters necessary for correction are calculated in the correction area 1902 (S1702). The parameters to be calculated are the maximum luminance value Ymax inside the elliptical area and the maximum value Ermax of the evaluation amount Er shown in the equation (3).

次に、注目画素が補正領域1902内に存在するか否かを判定する(S1703)。注目画素が補正領域1902の楕円領域に存在するか否かは、楕円を算出する公式(式(22))によって判定することができる。
(x/Lw1)2 + (y/Lh1)2 ≦ 1 …(22)
ここで、(x, y)は注目画素の座標
ただし、座標原点は注目赤目領域の中心
Next, it is determined whether or not the target pixel exists in the correction area 1902 (S1703). Whether or not the target pixel exists in the elliptical area of the correction area 1902 can be determined by a formula for calculating the ellipse (formula (22)).
(x / Lw1) 2 + (y / Lh1) 2 ≤ 1 (22)
Where (x, y) is the coordinate of the pixel of interest where the coordinate origin is the center of the red eye region of interest

注目画素の座標(x, y)が式(22)を満たす場合、注目画素は補正領域1902内に存在すると判断して、処理をステップS1704に進める。注目画素が補正領域1902内に存在しない場合は、注目画素を次の画素に移動し(S1710)、処理をステップS1703に戻す。   If the coordinate (x, y) of the target pixel satisfies Expression (22), it is determined that the target pixel exists in the correction region 1902 and the process proceeds to step S1704. If the target pixel does not exist in the correction area 1902, the target pixel is moved to the next pixel (S1710), and the process returns to step S1703.

注目画素が補正領域1902に存在する場合、注目画素のRGB成分値を輝度、色差成分のYCC値に変換する(S1704)。変換方法には既知の様々な方法が存在するが、どの方法を用いても構わない。   If the target pixel exists in the correction area 1902, the RGB component value of the target pixel is converted into the YCC value of the luminance and color difference components (S1704). There are various known conversion methods, but any method may be used.

次に、注目画素に対する評価量を算出する(S1705)。この評価量は、後段のステップS1706で補正量を決定するために必要なパラメータで、具体的には以下の三つの値である。
(1) 赤目領域1901の中心から注目画素までの距離rと、
中心から楕円境界までの距離r0の比r/r0
(2) 注目画素の評価量Erと評価量の最大値Ermaxの比Er/Ermax
(3) 注目画素の輝度Yと最大輝度値Ymaxの比Y/Ymax
Next, the evaluation amount for the pixel of interest is calculated (S1705). This evaluation amount is a parameter necessary for determining the correction amount in the subsequent step S1706, and specifically has the following three values.
(1) The distance r from the center of the red-eye area 1901 to the target pixel,
Ratio r / r0 of distance r0 from center to ellipse boundary
(2) Ratio Er / Ermax between the evaluation value Er of the target pixel and the maximum value Ermax of the evaluation value
(3) Ratio Y / Ymax of luminance Y of the target pixel and maximum luminance value Ymax

次に、ステップS1705で求めたパラメータを用いて、注目画素の輝度Yおよび色差成分Cr、Cbそれぞれの補正量Vy、Vcを式(23)によって算出する(S1706)。
Vy = {1 - RrTy1}・{1 - (1 - Re)Ty2}・{1 - RyTy3}
Vc = {1 - RrTc1}・{1 - (1 - Re)Tc2} …(23)
ここで、Rr = r/r0、Re = Er/Ermax、Ry = Y/Ymax
Next, using the parameters obtained in step S1705, the correction amounts Vy and Vc of the luminance Y and the color difference components Cr and Cb of the pixel of interest are calculated by equation (23) (S1706).
Vy = {1-Rr Ty1 } ・ {1-(1-Re) Ty2 } ・ {1-Ry Ty3 }
Vc = {1-Rr Tc1 } ・ {1-(1-Re) Tc2 }… (23)
Where Rr = r / r0, Re = Er / Ermax, Ry = Y / Ymax

Vy、Vcはともに0.0〜1.0の範囲になり、1.0に近いほど補正量が大きいことを意味する。輝度の補正量Vyは、三つのパラメータすべてを用いて決定し、注目画素の位置が補正領域1902の中心から離れるほど補正量が小さくなる。また、注目画素の評価量Erが、最大値Ermaxに比べて小さい場合、補正量Vyは小さくなる。また、注目画素の輝度値Yが、最大値Ymaxに近い場合、補正量Vyは小さくなる。輝度が高い画素の補正量Vyを小さくするのは、目の中のハイライト部(キャッチライト)を保存する効果がある。一方、色差の補正量Ycは、輝度に関するパラメータを除いたものである。   Vy and Vc are both in the range of 0.0 to 1.0, and the closer to 1.0, the larger the correction amount. The luminance correction amount Vy is determined using all three parameters, and the correction amount decreases as the position of the target pixel moves away from the center of the correction region 1902. Further, when the evaluation amount Er of the target pixel is smaller than the maximum value Ermax, the correction amount Vy is small. When the luminance value Y of the target pixel is close to the maximum value Ymax, the correction amount Vy is small. Reducing the correction amount Vy of a pixel with high luminance has an effect of preserving a highlight portion (catch light) in the eye. On the other hand, the color difference correction amount Yc is obtained by excluding the parameters relating to luminance.

式(23)において、Ty1、Ty2、Ty3、Tc1、Tc2もパラメータで、それらの設定によって、各評価量(つまり、式(23)の括弧{ }内の値)を図20に示すように一次(実線)、二次(破線)、三次(一転鎖線)といった直線または曲線で適用することが可能である。   In Equation (23), Ty1, Ty2, Ty3, Tc1, and Tc2 are also parameters, and depending on their setting, each evaluation amount (that is, the value in parentheses {} in Equation (23)) is primary as shown in FIG. (Solid line), secondary (dashed line), tertiary (one-dot chain line), or a straight line or a curve can be applied.

次に、補正量Vy、Vcを用いて式(24)により補正後のYCC値を算出する(S1707)。
Y' = (1.0 - Wy・Vy)・Y
C' = (1.0 - Wc・Vc)・C …(24)
ここで、Y、Cは補正前の値
Y'、C'は補正後の値
Wy、Wcは重み(0.0〜1.0)
Next, the corrected YCC value is calculated using equation (24) using the correction amounts Vy and Vc (S1707).
Y '= (1.0-Wy ・ Vy) ・ Y
C '= (1.0-Wc ・ Vc) ・ C… (24)
Where Y and C are values before correction
Y 'and C' are values after correction
Wy, Wc are weights (0.0-1.0)

重みWy、Wcは、補正強度を指定したい場合に調節する。例えば、補正強度を弱、中、強と三段階とする場合、Wy、Wcをともに0.3、0.7、1.0などに設定することで、同一の処理で、補正強度が異なる結果を得ることができる。   The weights Wy and Wc are adjusted when it is desired to specify the correction strength. For example, when the correction strength is set to three levels of weak, medium, and strong, by setting both Wy and Wc to 0.3, 0.7, 1.0, etc., it is possible to obtain a result with different correction strengths in the same processing.

新しい輝度、色差成分の値が決定したら、YCC値をRGB値へ変換し、補正後の画素値として入力画像用のメモリバッファに上書きする、あるいは、出力用画像を格納するメモリバッファの所定アドレスに格納する(S1708)。   Once the new luminance and chrominance component values are determined, the YCC value is converted to an RGB value and overwritten in the input image memory buffer as the corrected pixel value, or is stored at a predetermined address in the memory buffer that stores the output image. Store (S1708).

ステップS1709の判定により、注目赤目領域に対応する最後の画素に達するまで、ステップS1710で注目画素を移動して(S1710)、上記の処理(S1703〜S1708)を繰り返す。また、注目赤目領域に対応する最後の画素に達した場合、次の赤目領域の補正処理に移行して、公報領域リストに記録されたすべての赤目領域の補正処理を繰り返す。   By the determination in step S1709, the target pixel is moved in step S1710 (S1710) until the last pixel corresponding to the target red-eye region is reached, and the above processing (S1703 to S1708) is repeated. When the last pixel corresponding to the target red-eye area is reached, the process proceeds to the correction process for the next red-eye area, and the correction process for all red-eye areas recorded in the publication area list is repeated.

なお、補正部205に入力される画像がRGB成分で構成され、入力画像を輝度、色差成分に変換して補正した後、再び、RGB成分に戻す方法を説明したが、これに限定されるものではない。例えば、RGB成分を明度、彩度に変換し、同様の方法を用いて明度、彩度を補正した後、再び、RGB成分に戻したとしても、ほぼ同様の出力結果が得られる。   The image input to the correction unit 205 is composed of RGB components, and after correcting the input image by converting it to luminance and chrominance components, the method of returning to the RGB components again has been described. However, the present invention is not limited to this. is not. For example, even if the RGB component is converted into lightness and saturation, the lightness and saturation are corrected using the same method, and then returned to the RGB component again, almost the same output result can be obtained.

さらに、補正量を決定するためのパラメータとして、注目画素の評価量Erと補正領域1902内の評価量の最大値Ermaxの比Er/Ermaxを用いる例を説明したが、同パラメータを単純に彩度に置き換えることも可能である。つまり、注目画素の彩度と、補正領域1902内の最大彩度との比を用いて補正量を決定してもよい。   Furthermore, as an example of determining the correction amount, the example of using the ratio Er / Ermax between the evaluation amount Er of the target pixel and the maximum value Ermax of the evaluation amount in the correction region 1902 has been described. It is also possible to replace with. That is, the correction amount may be determined using the ratio between the saturation of the target pixel and the maximum saturation in the correction area 1902.

このように、赤目を構成する画素か否かを、彩度ではなく、RおよびG成分の関係で求めた評価量Erを用いて判定することで、色素が濃い(多い)人の赤目も高精度に抽出することができる。また、赤目候補画素に対応する二値画像上で、境界線追跡法を適用することにより、二値画像から極めて少ない演算量で高速に赤丸領域を抽出することができる。また、赤丸領域から、赤目であると考えられる様々な特徴量を算出し、それを評価することで、最終的に赤目領域を高精度に特定することができる。また、個々の特徴量判定による効果、および、特徴量算出時の演算量を考慮して、特徴量の判定を適切な順序で行って赤目領域候補を篩にかけ、赤目領域ではない可能性が高い候補領域を早々に除外する。従って、必要最小限の処理量で赤目領域の検出を実現することができる。   In this way, whether or not a pixel is a red-eye pixel is determined by using the evaluation value Er obtained from the relationship between the R and G components, not the saturation, so that the red-eye of a person with a high (high) pigment is also high. It can be extracted with accuracy. Further, by applying the boundary line tracking method on the binary image corresponding to the red-eye candidate pixel, the red circle region can be extracted from the binary image at a high speed with a very small amount of calculation. In addition, by calculating various feature amounts that are considered to be red-eye from the red-circle region and evaluating them, the red-eye region can be finally identified with high accuracy. Also, considering the effect of individual feature amount determination and the amount of computation at the time of calculating the feature amount, it is highly possible that the determination of the feature amount is performed in an appropriate order and the red-eye region candidate is sieved and not a red-eye region The candidate area is excluded early. Therefore, it is possible to detect the red-eye area with the minimum necessary processing amount.

以下、本発明にかかる実施例2の画像処理を説明する。なお、実施例2において、実施例1と略同様の構成については、同一符号を付して、その詳細説明を省略する。   The image processing according to the second embodiment of the present invention will be described below. Note that the same reference numerals in the second embodiment denote the same parts as in the first embodiment, and a detailed description thereof will be omitted.

実施例1において説明した適応的二値化処理は、注目画素の左方向(主走査方向の前方)に所定サイズのウィンドウ403(図4参照)を設定し、同ウィンドウ403内の画素の評価量の平均値Er(ave)を算出し、平均値Er(ave)を閾値として注目画素が赤色領域を構成するか否かによって二値化する。このような方法は、閾値を算出するために参照する画素数が少なく、処理の高速化が図れる。しかし、ウィンドウ403を注目画素の左方向にしか設定しないため、二値化結果は処理方向に依存する。その結果、図5(a)に示すような画像に適応的二値化処理を施した場合、図21(a)に示すように、赤目領域である瞳孔部分のほかに、符号2001で示すアイラインが赤色領域を構成する画素として抽出される場合がある。以下では、この理由を説明する。   In the adaptive binarization processing described in the first embodiment, a window 403 (see FIG. 4) of a predetermined size is set in the left direction of the target pixel (forward in the main scanning direction), and the evaluation amount of the pixels in the window 403 The average value Er (ave) is calculated, and binarization is performed depending on whether or not the pixel of interest forms a red region with the average value Er (ave) as a threshold value. In such a method, the number of pixels referred to for calculating the threshold is small, and the processing speed can be increased. However, since the window 403 is set only in the left direction of the target pixel, the binarization result depends on the processing direction. As a result, when adaptive binarization processing is performed on the image shown in FIG. 5 (a), as shown in FIG. 21 (a), in addition to the pupil portion that is the red-eye region, A line may be extracted as a pixel constituting a red region. Hereinafter, the reason will be described.

実施例1では、注目画素2002を二値化する閾値は、注目画素2002の左方向に設定したウィンドウの画素の評価量の平均値Er(ave)であり、注目画素2002の評価量Erと平均値er(ave)の比較結果から二値化を行う(式(6)参照)。ここで、抽出したい瞳孔に対して、ウィンドウは左方向にあるため、通常、肌色部分にウィンドウが設定される。色素が薄い(少ない)人の肌色部分の画素値は例えば(R, G, B)=(151, 135, 110)になる。式(3)によって評価量Erを算出すると11%であり、比較的小さい値である。一方、目のアイラインを構成する注目画素2002は、例えば(R, G, B)=(77, 50, 29)のように、肌色部分と比べて多少輝度が低く、同様に評価量Erを算出すると35%になる。両者を比較すると、明らかにウィンドウ内に存在する肌色部分の評価量Erよりも、アイライン部分の評価量Erが大きく、実施例1の適応的二値化処理によれば、パラメータMargin_RGRの設定にも依存するが、注目画素2002は赤色領域を構成する画素として抽出され易い。   In the first embodiment, the threshold value for binarizing the target pixel 2002 is the average value Er (ave) of the evaluation values of the pixels of the window set in the left direction of the target pixel 2002. Binarization is performed from the comparison result of the value er (ave) (see equation (6)). Here, since the window is in the left direction with respect to the pupil to be extracted, the window is usually set in the skin color portion. For example, the pixel value of the skin color portion of a person with light (small) pigment is (R, G, B) = (151, 135, 110). When the evaluation amount Er is calculated by the equation (3), it is 11%, which is a relatively small value. On the other hand, the target pixel 2002 constituting the eye line of the eye has a slightly lower luminance than the skin color portion, for example (R, G, B) = (77, 50, 29), and the evaluation amount Er is similarly set. Calculated to be 35%. Comparing the two, the evaluation amount Er of the eyeline part is clearly larger than the evaluation amount Er of the skin color part existing in the window, and according to the adaptive binarization processing of Example 1, the parameter Margin_RGR is set. However, the target pixel 2002 is easily extracted as a pixel constituting the red region.

その結果、図21(a)に示すような、(xmin, ymin)(xmax, ymax)で囲まれた赤色領域が抽出される。この抽出結果を赤丸領域抽出部203に入力すれば、本来の赤色領域よりも広い領域を対象として赤丸領域の抽出が行われ、抽出結果の信頼性低下、抽出時間の増加などが発生する。   As a result, a red region surrounded by (xmin, ymin) (xmax, ymax) as shown in FIG. 21 (a) is extracted. If this extraction result is input to the red circle area extraction unit 203, the red circle area is extracted for an area larger than the original red area, and the reliability of the extraction result is reduced and the extraction time is increased.

もし、注目画素2002に対して同じ大きさのウィンドウを右方向にも設定した場合は、ウィンドウには肌色画素のほかに、アイラインを構成する画素や、場合によっては赤目の瞳孔部分も多く含まれるため、右方向に設定したウィンドウにおける評価量の平均値Er(ave)は増加する。その結果、注目画素2002は、右方向に設定したウィンドウの画素に比べて、突出した評価量Erをもつわけではないから、赤色領域を構成する画素とは判定され難くい。   If a window of the same size is set in the right direction with respect to the pixel of interest 2002, the window contains many pixels that make up the eyeline and, in some cases, the red-eye pupil, in addition to the flesh-colored pixels. Therefore, the average value Er (ave) of the evaluation amount in the window set in the right direction increases. As a result, the pixel of interest 2002 does not have a protruding evaluation amount Er as compared with the pixel of the window set in the right direction, and thus is not easily determined as a pixel constituting the red region.

以下、実施例2として、赤領域抽出部202が実行する適応的二値化処理において、ウィンドウを左右双方向に設定する例を説明する。   Hereinafter, as Example 2, an example in which the window is set to be bilaterally left and right in the adaptive binarization process executed by the red region extraction unit 202 will be described.

実施例2の適応的二値化処理は、図22Aに示すように、まず注目画素402に対して左方向にウィンドウ403を設定し、実施例1と同様の方法によって注目画素402を二値化する。そして、図22Aに矢印で示すように、注目画素402を左から右方向に移動しながら、その二値化結果をRAM103に割り当てた二値画像用のバッファに格納する。   As shown in FIG. 22A, the adaptive binarization process of the second embodiment first sets a window 403 to the left of the target pixel 402, and binarizes the target pixel 402 by the same method as in the first embodiment. To do. Then, as indicated by an arrow in FIG. 22A, the binarization result is stored in the binary image buffer allocated to the RAM 103 while moving the pixel of interest 402 from the left to the right.

注目画素402がラインの右端に達し、注目画素402を左から右へ移動する二値化が終了すると、図22Bに示すように、同じラインにおいて注目画素402を右から左へ移動する二値化処理を行う。この際、二値化の閾値を設定するためのウィンドウ404は、注目画素402の右方向に設定する。   When the pixel-of-interest 402 reaches the right end of the line and the binarization of moving the pixel-of-interest 402 from left to right is finished, as shown in FIG. 22B, binarization of moving the pixel-of-interest 402 from right to left in the same line Process. At this time, the window 404 for setting the binarization threshold is set to the right of the target pixel 402.

上記の双方向の二値化の何れにおいても、その二値化結果が‘1’の画素を、赤色領域を構成する画素として二値画像用のバッファに格納する。   In any of the above-described bidirectional binarization, a pixel whose binarization result is “1” is stored in the binary image buffer as a pixel constituting the red region.

図21(b)は、双方向の適応的二値化処理によって得られる赤色領域を構成する画素の例を示している。片方向の適応的二値化処理の結果(図21(a))に比べて、アイライン部分などの画素が除去され、赤色領域がより適切に抽出される。   FIG. 21 (b) shows an example of pixels constituting a red region obtained by bidirectional adaptive binarization processing. Compared with the result of the one-way adaptive binarization process (FIG. 21 (a)), pixels such as the eyeline portion are removed, and the red region is more appropriately extracted.

このように、適応的二値化処理によって赤色領域を抽出する場合、二値化閾値を算出するウィンドウを、注目画素に対して左右双方向に設定することで、赤色領域を構成する画素を高精度に抽出することができる。   As described above, when a red region is extracted by adaptive binarization processing, by setting the window for calculating the binarization threshold in both the left and right directions with respect to the target pixel, the pixels constituting the red region are increased. It can be extracted with accuracy.

以下、本発明にかかる実施例3の画像処理を説明する。なお、実施例3において、実施例1、2と略同様の構成については、同一符号を付して、その詳細説明を省略する。   Hereinafter, image processing according to the third embodiment of the present invention will be described. Note that the same reference numerals in the third embodiment denote the same parts as in the first and second embodiments, and a detailed description thereof will be omitted.

実施例1、2では、式(3)に示す評価量Erに着目した適応的二値化処理を行い、赤色領域を構成する画素を抽出する方法を説明した。このような方法は、稀に図23に示すような赤目の瞳孔部分2201とは別に、目尻、目頭部分2202の画素を赤色領域を構成する画素として検出することがある。目尻、目頭部分2202を拡大してみると、例えば(R, G, B)=(81, 41, 31)といった「赤黒い」画素が多く存在することがわかる。この画素の評価量Erは49%になり、比較的大きな値である。そのため、実施例1、2の適応的二値化処理においては、ある程度の大きさをもつ画素集合として検出される可能性が高い上、エッジや周辺領域の明度、色相、彩度などが目の特徴を兼ね備えるため、赤丸領域判定部203と特徴量判定部204においてすべての判定を満足し、最終的に赤目領域と誤判定される可能性が高い。実施例3は、この問題を解決するための構成を備える。   In the first and second embodiments, the method of performing the adaptive binarization processing focusing on the evaluation amount Er shown in Expression (3) and extracting the pixels constituting the red region has been described. Such a method rarely detects the pixels of the corners of the eye and the head 2202 as pixels constituting the red region separately from the pupil portion 2201 of the red eye as shown in FIG. By enlarging the corner of the eye and the head 2202, it can be seen that there are many “red and black” pixels such as (R, G, B) = (81, 41, 31). The evaluation amount Er of this pixel is 49%, which is a relatively large value. Therefore, in the adaptive binarization processing of the first and second embodiments, there is a high possibility that the pixel set having a certain size is detected, and the brightness, hue, saturation, and the like of the edge and the surrounding area are the eyes. Since the features are also combined, all the determinations are satisfied in the red circle region determination unit 203 and the feature amount determination unit 204, and there is a high possibility that the determination will eventually be made as a red-eye region. The third embodiment has a configuration for solving this problem.

図24は実施例3の赤目の自動補正処理の概要を示す機能ブロック図で、CPU 101によって実行される処理である。実施例1と比較すると、候補領域評価部207が追加されている。   FIG. 24 is a functional block diagram illustrating an outline of the red-eye automatic correction process according to the third embodiment. Compared to the first embodiment, a candidate area evaluation unit 207 is added.

候補領域評価部207は、前段までの処理で生成された候補領域リストを参照して、赤目候補領域それぞれについて、相対的な位置と面積を評価して、赤目候補領域を整理する。すなわち、評価の結果、赤目領域として適当ではないと判断される赤目候補領域を候補領域リストから除外する。   The candidate area evaluation unit 207 refers to the candidate area list generated by the processing up to the previous stage, evaluates the relative position and area of each red eye candidate area, and arranges the red eye candidate areas. That is, as a result of the evaluation, a red eye candidate area that is determined to be inappropriate as a red eye area is excluded from the candidate area list.

図25は候補領域評価部207の処理例を示すフローチャートである。なお、特徴量判定部204の処理によって、k個(0〜k-1番目)の領域が赤目候補領域として抽出されたと仮定する(総検出数Ne=k)。   FIG. 25 is a flowchart showing a processing example of the candidate area evaluation unit 207. It is assumed that k (0 to (k-1) th) regions have been extracted as red-eye candidate regions by the processing of the feature amount determination unit 204 (total number of detections Ne = k).

まず、カウンタkに総検出数Neを設定し(S2499)、k番目の赤目候補領域(以下「領域k」と呼ぶ)の中心位置とサイズを算出する(S2500)。なお、サイズは矩形領域として抽出される赤目候補領域の短辺の長さとする。次に、カウンタiに零を設定し(S2501)、領域kの面積(以下「面積k」と呼ぶ)を、領域候補リストに格納されている他の赤目候補領域(以下「領域i」と呼ぶ)の面積(以下「面積i」と呼ぶ)と比較する(S2502、S2503)。面積i<面積kの場合はカウンタiをインクリメントし(S2512)、処理をステップS2502に戻す。   First, the total detection number Ne is set in the counter k (S2499), and the center position and size of the kth red-eye candidate region (hereinafter referred to as “region k”) are calculated (S2500). The size is the length of the short side of the red-eye candidate area extracted as a rectangular area. Next, the counter i is set to zero (S2501), and the area of the region k (hereinafter referred to as “area k”) is referred to as another red-eye candidate region (hereinafter referred to as “region i”) stored in the region candidate list. ) (Hereinafter referred to as “area i”) (S2502, S2503). If area i <area k, counter i is incremented (S2512), and the process returns to step S2502.

面積i≧面積k(領域kよりも面積が大きい赤目候補領域が存在する)場合は、図26に示すような両領域の中心間距離Sizeを算出し(S2504)、中心間距離Sizeから大きさの評価、判定を行うための閾値Th_Sizeを算出する(S2505)。   When area i ≧ area k (there is a red-eye candidate region having a larger area than region k), a center-to-center distance Size between both regions as shown in FIG. 26 is calculated (S2504), and the size is determined from the center-to-center distance Size. A threshold Th_Size for performing evaluation and determination is calculated (S2505).

図27は中心間距離Sizeと閾値Th_Sizeの関係例を示す図で、横軸は中心間距離、縦軸は閾値Th_Sizeである。また、Sa、Sb、La、Lbはパラメータであり、例えば、La=3.0、Lb=5.0、Sa=1.0、Sb=2.0といった値を設定する。このパラメータを設定した場合、中心間距離Sizeが領域kのサイズ(短辺の長さ)の三倍以下であれば閾値Th_Sizeは1.0になる。また、中心間距離sizeが領域kのサイズの三倍から五倍であれば、図27に示す直線上の値として閾値Th_Sizeが決定される。また、中心間距離sizeが五倍を超える場合は判定処理を行わない。   FIG. 27 is a diagram illustrating an example of the relationship between the center-to-center distance Size and the threshold Th_Size, where the horizontal axis represents the center-to-center distance and the vertical axis represents the threshold Th_Size. Sa, Sb, La, and Lb are parameters. For example, values such as La = 3.0, Lb = 5.0, Sa = 1.0, and Sb = 2.0 are set. When this parameter is set, the threshold Th_Size is 1.0 if the center-to-center distance Size is not more than three times the size (short side length) of the region k. If the center-to-center distance size is three to five times the size of the region k, the threshold value Th_Size is determined as a value on the straight line shown in FIG. Also, if the center-to-center distance size exceeds five times, the determination process is not performed.

次に、面積iと面積k×Th_Sizeを比較して、面積i≧面積k×Th_Size、すなわち、領域kの近傍に領域kよりも大きい赤目候補領域が存在する場合は、領域kは赤目領域ではないと判定し、領域kを候補領域リストから除外し(S2507)、総検出数Neをデクリメントし(S2508)、処理をステップS2501に戻す。   Next, comparing the area i and the area k × Th_Size, if the area i ≧ area k × Th_Size, that is, if there is a red-eye candidate region larger than the region k in the vicinity of the region k, the region k is a red-eye region. It is determined that the region k is not present, the region k is excluded from the candidate region list (S2507), the total detection number Ne is decremented (S2508), and the process returns to step S2501.

一方、面積i<面積k×Th_Sizeの場合は、ステップS2509の判定により、i<k-1であればカウンタiをインクリメントし(S2512)、処理をステップS2502に戻す。また、i=k-1であればカウンタkをデクリメントし(S2510)、ステップS2511の判定により、k>0であれば処理をステップS2500に戻し、k=0であれば処理を終了する。   On the other hand, if area i <area k × Th_Size, it is determined in step S2509 that if i <k−1, counter i is incremented (S2512), and the process returns to step S2502. If i = k−1, the counter k is decremented (S2510). If it is determined in step S2511 that k> 0, the process returns to step S2500, and if k = 0, the process ends.

このような判定処理により、候補領域リストに記録された赤目候補領域から不要な候補領域を除去することができる。   By such determination processing, unnecessary candidate areas can be removed from the red-eye candidate areas recorded in the candidate area list.

このように、ある赤目候補領域の近傍に、その赤目候補領域よりも小さい赤目候補領域が存在する場合、小さい赤目候補領域を候補領域リストから除外することで、上記の問題を解決することができる。   Thus, when a red eye candidate area smaller than the red eye candidate area exists in the vicinity of a certain red eye candidate area, the above problem can be solved by excluding the small red eye candidate area from the candidate area list. .

以下、本発明にかかる実施例4の画像処理を説明する。なお、実施例3において、実施例1〜3と略同様の構成については、同一符号を付して、その詳細説明を省略する。   Hereinafter, image processing according to the fourth embodiment of the present invention will be described. Note that the same reference numerals in the third embodiment denote the same parts as in the first to third embodiments, and a detailed description thereof will be omitted.

実施例1の適応的二値処理を用いると、赤目の中に存在するハイライトによって赤目領域が分断される場合がある。図28(a)は赤目の拡大図を示し、符号2701は虹彩領域を、符号2702は赤い瞳孔領域を、符号2703はフラッシュによって発生したハイライト(白)領域をそれぞれ示している。よく知られているように、赤目現象はフラッシュによって引き起こされる現象であるから、撮影された画像データの瞳孔領域2702には、高い確率でフラッシュの光が反射したハイライト領域が存在する。これはキャッチライトとも呼ばれる。 With adaptive binarization process in Example 1, there are cases where the red eye area is divided by the highlight present in the red-eye. FIG. 28 (a) shows an enlarged view of the red eye. Reference numeral 2701 indicates an iris area, reference numeral 2702 indicates a red pupil area, and reference numeral 2703 indicates a highlight (white) area generated by the flash. As is well known, since the red-eye phenomenon is a phenomenon caused by a flash, there is a highlight area where the flash light is reflected with high probability in the pupil area 2702 of the captured image data. This is also called catch light.

通常、ハイライト領域は瞳孔内の微小な点として存在するため、赤目検出処理には影響しない。しかし、撮影条件によっては、ハイライト領域が瞳孔領域の大部分を占めるほど大きくなったり、図28(a)に示すハイライト領域2703のように、細長い領域になったりする。このような画像データに実施例1の適応的二値化処理を適用すると、ハイライト領域2703の評価量Erは極めて小さい値になり、赤色領域としては認識されず、二値画像において、図28(b)に示すように、瞳孔領域が二つ領域2704、2705に分断される場合がある。このような二つの領域に後段の処理を適用すれば、瞳孔領域2702が赤目領域と判定される確率は極めて低下する。実施例4は、近隣に存在する赤丸領域を結合する処理によって、この問題を解決する。 Usually, since the highlight region exists as a minute point in the pupil, the red-eye detection process is not affected. However, depending on the imaging conditions, the highlight region becomes so large that it occupies most of the pupil region, or becomes a long and narrow region like a highlight region 2703 shown in FIG. When the adaptive binarization processing according to the first embodiment is applied to such image data, the evaluation amount Er of the highlight area 2703 becomes an extremely small value and is not recognized as a red area. (b), the sometimes pupil region is divided into two regions 2704,2705. If the subsequent processing is applied to such two regions, the probability that the pupil region 2702 is determined as the red-eye region is extremely reduced. The fourth embodiment solves this problem by the process of combining the red circle regions existing in the neighborhood.

図29は実施例4の赤目の自動補正処理の概要を示す機能ブロック図で、CPU101によって実行される処理である。実施例3と比較すると、候補領域結合部208が追加されている。   FIG. 29 is a functional block diagram illustrating an outline of the red-eye automatic correction process according to the fourth embodiment, which is a process executed by the CPU 101. Compared to the third embodiment, a candidate region combining unit 208 is added.

候補領域結合処理部208は、赤丸領域抽出部203が抽出した赤丸領域の左上、右下座標が格納された候補領域リストを参照して、当該赤丸領域の近傍に存在する赤丸領域を結合すべきか否か判断する。図31は候補領域リストの一例を示す図である。図31には四つの赤丸領域が記録された例を示すが、実際には、赤丸領域の数は数十から、場合によっては数千になる。   The candidate area combination processing unit 208 refers to the candidate area list storing the upper left and lower right coordinates of the red circle area extracted by the red circle area extraction unit 203, and should the red circle area existing in the vicinity of the red circle area be combined? Judge whether or not. FIG. 31 is a diagram showing an example of the candidate area list. FIG. 31 shows an example in which four red circle areas are recorded. Actually, the number of red circle areas is from several tens to several thousand in some cases.

図30は候補領域結合部208の処理例を示すフローチャートである。   FIG. 30 is a flowchart illustrating a processing example of the candidate area combining unit 208.

まず、カウンタi=0、カウンタj=iに初期化し(S2901、S2902)、候補領域リストのi番目とj番目に記録された赤丸領域(以下「領域i」「領域j」と呼ぶ)を結合すべきか否かを判定する(S2903)。具体的には、図32(a)に示すように、幅がWi、高さがHi(単位は画素数)の領域iと、幅がWj、高さがHjの領域jを包含する矩形領域を設定し、その幅Wijと高さHijを算出する。次に、式(25)によって、領域i、領域jが近隣に存在し、かつ、その大きさも同程度であるか否かを判定する。
(Wi・Hi + Wj・Hj)/(Wij・Hij) > Th_J …(25)
ここで、0<閾値Th_J≦1.0
First, counter i = 0 and counter j = i are initialized (S2901, S2902), and the i-th and j-th recorded red circle areas (hereinafter referred to as “area i” and “area j”) in the candidate area list are combined. It is determined whether or not to be performed (S2903). Specifically, as shown in FIG. 32 (a), a rectangular region including a region i having a width Wi and a height Hi (unit is the number of pixels) and a region j having a width Wj and a height Hj. And the width Wij and the height Hij are calculated. Next, it is determined by Expression (25) whether the area i and the area j are present in the vicinity and the sizes thereof are similar.
(Wi ・ Hi + Wj ・ Hj) / (Wij ・ Hij)> Th_J… (25)
Where 0 <threshold Th_J ≦ 1.0

式(25)は、領域iの面積と領域jの面積の和と、両者を包含する矩形領域の面積の比を算出し、比が閾値Th_Jよりも大きい場合、両領域は近隣に存在し、かつ、大きさも同程度であると判断できることを意味する。もし、領域i、領域jが図32(b)に示すような位置関係あれば、式(25)で算出する比は小さくなり、結合すべきではないと判断される。 Equation (25) calculates the ratio of the area of the region i and the area of the region j and the area of the rectangular region including both, and when the ratio is larger than the threshold Th_J, both regions exist in the neighborhood, And it means that it can be judged that the size is also comparable. If region i, area j is if the positional relationship shown in FIG. 32 (b), decreases the ratio calculated by formula (25), it is determined not to be bound.

ステップS2903の判定の結果、結合すべきではないと判定した場合は、カウンタjをインクリメントして(S2908)、処理をステップS2903に戻す。また、結合すべきと判定した場合は、結合後の領域が、結合前と比較して正方形に近付いたか否かを判定する(S2904)。具体的には、式(26)を用いて判定する。
min(Wij, Hij)/max(Wij, Hij) > max{min(Wi, Hi)/max(Wi, Hi), min(Wj, Hj)/max(Wj, Hj)}
…(26)
As a result of the determination in step S2903, if it is determined that they should not be combined, the counter j is incremented (S2908), and the process returns to step S2903. If it is determined that the regions should be combined, it is determined whether or not the region after combining is closer to a square than before combining (S2904). Specifically, the determination is made using Expression (26).
min (Wij, Hij) / max (Wij, Hij)> max {min (Wi, Hi) / max (Wi, Hi), min (Wj, Hj) / max (Wj, Hj)}
… (26)

式(26)は、領域i、領域jを包含する矩形領域の縦横比(1.0以下)と、領域iおよび領域jの縦横比のうちの大きい値とを比較した場合に左辺が大きい、すなわち、正方形に近いことを意味する。式(26)を満たせば、結合後の矩形領域はより正方形に近付くことになり、その結果、赤丸領域も円形に近付くことになる。   Equation (26) is obtained by comparing the aspect ratio (1.0 or less) of the rectangular area including the area i and the area j with a large value of the aspect ratio of the area i and the area j, that is, the left side is large. Means close to a square. If Expression (26) is satisfied, the combined rectangular area will be closer to a square, and as a result, the red circle area will also be closer to a circle.

式(26)を満たさない場合は、カウンタjをインクリメントして(S2908)、処理をステップS2903に戻す。また、式(26)を満たす場合は、候補領域リストのi番目の座標情報を、領域i、領域jを包含する矩形領域の座標に更新し、j番目の位置情報を候補領域リストから削除する(S2905)。   If the expression (26) is not satisfied, the counter j is incremented (S2908), and the process returns to step S2903. Also, when Expression (26) is satisfied, the i th coordinate information of the candidate area list is updated to the coordinates of the rectangular area including the area i and the area j, and the j th position information is deleted from the candidate area list. (S2905).

次に、ステップS2906の判定により、カウンタjの値が最大値(リストの終わり)に達していない場合はカウンタjをインクリメントして(S2908)、処理をステップS2903に戻す。また、カウンタjの値が最大値に達した場合は、ステップS2907の判定により、カウンタiの値が最大値(リストの終わり)に達していない場合はカウンタiをインクリメントして(S2909)、処理をステップS2902に戻す。また、カウンタiの値が最大値に達した場合は処理を終了する。   Next, if it is determined in step S2906 that the value of counter j has not reached the maximum value (end of list), counter j is incremented (S2908), and the process returns to step S2903. If the value of the counter j has reached the maximum value, the determination in step S2907 results in the counter i being incremented if the value of the counter i has not reached the maximum value (end of list) (S2909). Is returned to step S2902. If the value of the counter i reaches the maximum value, the process ends.

このような判定処理により、候補領域リストに記録された、ハイライト領域によって分断された赤丸領域を結合することができる。   By such a determination process, the red circle regions recorded in the candidate region list and separated by the highlight region can be combined.

このように、ある赤丸候補の近隣に、当該赤丸領域に類似する赤丸領域が存在する場合、両者を結合すると赤目領域の条件(外接矩形が正方形に近い)に近づくか否かを判定することで、瞳孔内に存在するハイライト領域によって分断された、赤目領域に相当する赤丸領域を適切に結合することができる。   In this way, when there is a red circle region similar to the red circle region in the vicinity of a certain red circle candidate, it is determined whether or not the condition of the red-eye region (the circumscribed rectangle is close to a square) is approximated when both are combined. The red circle region corresponding to the red-eye region divided by the highlight region existing in the pupil can be appropriately combined.

以下、本発明にかかる実施例5の画像処理を説明する。なお、実施例5において、実施例1〜4と略同様の構成については、同一符号を付して、その詳細説明を省略する。   Hereinafter, image processing according to the fifth embodiment of the present invention will be described. Note that the same reference numerals in the fifth embodiment denote the same parts as in the first to fourth embodiments, and a detailed description thereof will be omitted.

実施例5では、実施例1〜4で説明した画像処理を、CPUの処理能力や使用可能なメモリ(RAMなど)の記憶容量が制限された環境下において実施する方法を説明する。このような環境は、複写機、プリンタ、ディジタルカメラ、スキャナ、複合機などの画像入出力デバイスに実装される画像処理部を想定したものである。   In the fifth embodiment, a method will be described in which the image processing described in the first to fourth embodiments is performed in an environment where the processing capacity of the CPU and the storage capacity of a usable memory (RAM or the like) are limited. Such an environment assumes an image processing unit mounted on an image input / output device such as a copying machine, a printer, a digital camera, a scanner, or a multifunction peripheral.

上記の環境では、使用可能なワークメモリは多くても数百KB〜数MB程度である。一方、ディジタルカメラの高解像度化が進み、1000万画素を超える撮像能力をもつかカメラも登場している。このような高精細な画像から赤目領域を検出する処理を、限られたワークメモリを用いて行うには、入力画像の解像度を低下することが有効である。例えば、800万画素の入力画像を、水平垂直方向に一画素間隔でサブサンプルすれば1/4の解像度、すなわち200万画素の画像に縮小することが可能である。この場合、画像を記憶するために必要なワークメモリの容量も1/4になる。しかし、たとえ200万画素に縮小したとしても、縮小後の画像全体を同時に保持するには、RGB24ビットの場合、約6MBのワークメモリが必要になる。大容量のRAMを備えるパーソナルコンピュータやワークステーションでは問題とならない記憶容量だが、限られた環境下においては、ワークメモリの使用量を削減するために、さらなる工夫が必要になる。   In the above environment, usable work memory is about several hundred KB to several MB at most. On the other hand, digital cameras have become higher in resolution, and cameras with an imaging capability exceeding 10 million pixels have also appeared. In order to perform such processing for detecting a red-eye area from a high-definition image using a limited work memory, it is effective to reduce the resolution of the input image. For example, if an input image of 8 million pixels is subsampled at intervals of 1 pixel in the horizontal and vertical directions, it can be reduced to 1/4 resolution, that is, an image of 2 million pixels. In this case, the capacity of the work memory necessary for storing the image is also reduced to 1/4. However, even if the image is reduced to 2 million pixels, about 6 MB of work memory is required in the case of RGB 24-bit in order to simultaneously hold the entire reduced image. Although it is a storage capacity that does not pose a problem for personal computers and workstations with a large amount of RAM, further efforts are required to reduce the amount of work memory used in limited environments.

実施例5においては、入力画像を縮小し、縮小画像をさらにバンドに分割し、各バンド単位に、順次、赤目領域を抽出する方法を説明する。また、バンド分割においては、バンド境界に存在する赤目の検出を可能にするために、図33に示すように、オーバラップ領域を有する。図33において、符号3201は入力画像を縮小して得られる縮小画像を示し、BandHeightは1バンドを構成するライン数を示す。つまり、赤目領域の抽出処理は、Width×BandHeight(単位は画素数)の画像に対して行うことになる。また、実施例5におけるバンド分割は、OverlapAreaで示すライン数だけ、前のバンドと重複する。これによって、符号3202で示すような、バンド境界に存在する赤目領域についても抽出が可能になる。   In the fifth embodiment, a method will be described in which an input image is reduced, the reduced image is further divided into bands, and red-eye regions are sequentially extracted for each band. Further, the band division has an overlap area as shown in FIG. 33 in order to enable detection of red-eye existing at the band boundary. In FIG. 33, reference numeral 3201 indicates a reduced image obtained by reducing the input image, and BandHeight indicates the number of lines constituting one band. That is, the red-eye region extraction process is performed on an image of Width × BandHeight (unit: number of pixels). In addition, the band division in the fifth embodiment overlaps with the previous band by the number of lines indicated by OverlapArea. As a result, the red-eye region existing at the band boundary as indicated by reference numeral 3202 can also be extracted.

図34は実施例5における赤目領域の抽出処理の一例を示すフローチャートで、画像入出力デバイスに搭載されたCPUが実行する処理である。   FIG. 34 is a flowchart illustrating an example of a red-eye area extraction process according to the fifth embodiment, which is a process executed by the CPU mounted on the image input / output device.

まず、カウンタNを零に初期化し(S3301)、Nバンド目の縮小画像を生成する(S3302)。   First, the counter N is initialized to zero (S3301), and a reduced image of the Nth band is generated (S3302).

縮小画像の生成方法は、簡単のために、単純間引きによって縮小画像を生成する方法を説明する。例えば、800万画素の画像が画像入出力デバイスのメモリ(例えばデバイスに装備されたフラッシュメモリやハードディスク、あるいは、外部から装着されたメモリカード)に格納されているものとする。   As a method for generating a reduced image, a method for generating a reduced image by simple thinning will be described for the sake of simplicity. For example, it is assumed that an image of 8 million pixels is stored in a memory of an image input / output device (for example, a flash memory or a hard disk installed in the device, or a memory card mounted from the outside).

ステップS3302において、メモリの画像データにアクセスし、画像データがJPEG形式で保存されていれば、最初のMCU(最小符号化単位)ブロックのデコードしてワークメモリの所定領域に格納する。このMCUブロックのサイズは、例えば16×8画素である。次に、デコード後の画像データから例えば一画素間隔でサブサンプリングして、8×4画素の画像データを生成し、ワークメモリの赤目領域抽出用の画像格納領域に格納する。この処理をBandHeightライン数分の赤目領域抽出用の画像格納領域が満たされるまで繰り返す。この処理によって、800万画素の画像を200万画素に縮小する場合のバンド画像を得ることができる。   In step S3302, the image data in the memory is accessed, and if the image data is stored in JPEG format, the first MCU (minimum coding unit) block is decoded and stored in a predetermined area of the work memory. The size of this MCU block is, for example, 16 × 8 pixels. Next, sub-sampling is performed from the decoded image data, for example, at an interval of one pixel to generate 8 × 4 pixel image data, which is stored in the image storage area for red-eye area extraction in the work memory. This process is repeated until the image storage areas for red-eye area extraction corresponding to the number of BandHeight lines are filled. By this processing, it is possible to obtain a band image when an 8 million pixel image is reduced to 2 million pixels.

勿論、画像の縮小方法は、単純間引き以外にも、最近隣補間や線形縮小を用いる方法など、様々な方法を利用することができ、それらのどれを使用しても構わない。   Of course, various image reduction methods other than simple decimation, such as a method using nearest neighbor interpolation or linear reduction, can be used, and any of them may be used.

上記の処理によって、縮小画像のバンド画像が得られると、Nバンド目の赤目領域の抽出処理を行う(S3303)。   When the band image of the reduced image is obtained by the above processing, the red-eye region extraction processing for the Nth band is performed (S3303).

図35はNバンド目の赤目領域の抽出処理(S3303)の詳細を示すフローチャートである。   FIG. 35 is a flowchart showing details of the N-band red-eye region extraction processing (S3303).

まず、縮小画像データに上記実施例で説明した適応的二値化処理を施す(S3401)。処理結果(赤色領域の二値画像)は、縮小画像の格納領域とは別に割り当てた領域に保存する。この際、縮小画像のOverlapArea領域は重複領域であるから、当該領域の処理は、N-1バンド目で実施済みである。従って、N>0であれば、OverlapArea領域の処理をスキップし、N-1バンド目の処理結果を再利用するようにしてもよい。このようにすることで、処理の高速化を図ることができる。   First, the adaptive binarization processing described in the above embodiment is performed on the reduced image data (S3401). The processing result (the binary image in the red area) is stored in an area allocated separately from the storage area for the reduced image. At this time, since the overlap area of the reduced image is an overlapping area, the processing of the area has already been performed in the (N-1) th band. Accordingly, if N> 0, the processing of the overlap area may be skipped and the processing result of the (N−1) th band may be reused. By doing so, the processing speed can be increased.

次に、二値化の結果(赤色領域)に対して、上記の実施例で説明した境界線追跡を施し、バンド画像から赤丸領域を抽出する(S3402)。   Next, the boundary line tracking described in the above embodiment is performed on the binarization result (red region), and a red circle region is extracted from the band image (S3402).

次に、抽出した赤丸領域に対して特徴量判定処理を施す前に、複数の赤丸領域のうち、特徴量判定処理を施す赤丸領域を選択する候補領域選択処理を行う(S3403)。   Next, before performing the feature amount determination process on the extracted red circle region, a candidate region selection process is performed to select a red circle region to be subjected to the feature amount determination process from among a plurality of red circle regions (S3403).

図36は、N-1、NおよびN+1バンド目において、OverlapArea内に四つの赤丸領域が存在する例を示している。例えば、赤丸領域3603に注目すると、当該領域はNバンド目とN+1バンド目の双方に存在し両者について特徴量判定を行えば、OverlapArea領域に存在する赤丸領域は常に二回の処理することになり、効率的ではない。   FIG. 36 shows an example in which four red circle regions exist in the Overlap Area in the N-1, N, and N + 1 bands. For example, paying attention to the red circle area 3603, the area exists in both the N band and the N + 1 band, and if the feature amount determination is performed for both, the red circle area existing in the OverlapArea area is always processed twice. And is not efficient.

そこで、赤丸領域3603の場合、NまたはN+1バンド目のどちらで特徴量判定を行うべきかを考える。N+1バンド目では、赤丸領域3601に対して設定する周辺領域の上部が欠けるのに対して、Nバンド目では、周辺領域を参照することが可能である。従って、赤丸領域3603については、Nバンド目の判定結果の方が信頼性が高いと言える。さらに一般化すれば、OverlapArea領域に存在する赤丸領域の特徴量判定は、周辺領域をより広く参照できるバンドにおいて処理すべきである。   Therefore, in the case of the red circle region 3603, it is considered whether the feature amount determination should be performed in the N or N + 1 band. In the (N + 1) th band, the upper part of the peripheral region set for the red circle region 3601 is missing, whereas in the Nth band, it is possible to refer to the peripheral region. Therefore, for the red circle region 3603, it can be said that the determination result of the Nth band is more reliable. To further generalize, the feature amount determination of the red circle area existing in the Overlap Area area should be processed in a band where the surrounding area can be referred to more widely.

従って、実施例5の候補領域選択処理(S3403)は、OverlapArea領域に存在する赤丸領域について、図37に示すように、赤丸領域の上端からN+1バンド目の上端までの距離UPLenを予測(N+1バンド目は未処理であるから、N+1バンド目における赤丸領域の位置を予測する)し、赤丸領域の下端からNバンド目の下端までの距離BTLenを算出し、当該赤丸領域の特徴量判定を、UPLen<BTLenならばNバンド目で行い、UPLen≧BTLenならばNバンド目では行わない(言い換えればN+1バンド目で行う)と判定する。なお、Nバンド目で特徴量判定を行わない場合は、当該赤丸領域を当該バンドの候補領域リストから除外する。   Accordingly, the candidate area selection process (S3403) of the fifth embodiment predicts the distance UPLen from the upper end of the red circle area to the upper end of the (N + 1) band, as shown in FIG. 37, for the red circle area existing in the Overlap Area area ( Since the N + 1 band is unprocessed, the position of the red circle area in the N + 1 band is predicted), and the distance BTLen from the lower end of the red circle area to the lower end of the N band is calculated, and the characteristics of the red circle area are calculated. If UPLen <BTLen, the amount determination is performed in the Nth band, and if UPLen ≧ BTLen, it is determined not to be performed in the Nth band (in other words, in the N + 1th band). Note that when the feature amount determination is not performed in the Nth band, the red circle area is excluded from the candidate area list of the band.

同様に、図36に示す赤丸領域3604について距離UPLen、BTLenを算出すると、その関係はUPLen>BTLenになるため、赤丸領域3604はN+1バンド目で特徴量判定を行うことになる。また、上記の関係を赤丸領域3601、3602に適用すると、それぞれN-1バンド目、Nバンド目で特徴量判定を行うことになる。   Similarly, when the distances UPLen and BTLen are calculated for the red circle region 3604 shown in FIG. 36, the relationship is UPLen> BTLen, and therefore the red circle region 3604 performs feature amount determination at the N + 1 band. Further, when the above relationship is applied to the red circle regions 3601 and 3602, the feature amount determination is performed in the N−1 band and the N band, respectively.

このように、候補領域選択処理(S3403)では、OverlapArea領域に存在する赤丸領域の上部および下部とバンド端の距離(マージン)を算出し、その関係に応じて、どちらのバンドで特徴量判定を行うか否かを判断する。これによって、OverlapArea領域内の赤丸領域の重複する特徴量判定を防ぐことができる。   In this way, in the candidate area selection process (S3403), the distance (margin) between the upper and lower parts of the red circle area and the band edge in the OverlapArea area is calculated, and the feature amount determination is performed in which band according to the relationship. Determine whether to do it. As a result, it is possible to prevent the determination of the feature amount overlapping the red circle area in the OverlapArea area.

図35に戻り、候補領域選択処理(S3403)で選択された赤丸領域に対して、上記の実施例で説明した特徴量判定処理を施す(S3404)。その結果、赤目領域と判断した領域の補正処理に必要なパラメータを算出し(S3405)、赤目領域の情報とパラメータの組み合わせを、図38に示すように、候補領域リストに追加する(S3406)。なお、パラメータは、補正量Vy、Vcの計算(式(23))に必要な補正領域の最大輝度値Ymaxと評価量の最大値Ermaxである。   Returning to FIG. 35, the feature amount determination process described in the above embodiment is performed on the red circle area selected in the candidate area selection process (S3403) (S3404). As a result, parameters necessary for correction processing of the area determined to be a red-eye area are calculated (S3405), and the combination of information and parameters of the red-eye area is added to the candidate area list as shown in FIG. 38 (S3406). The parameters are the maximum luminance value Ymax of the correction area and the maximum value Ermax of the evaluation amount necessary for calculating the correction amounts Vy and Vc (formula (23)).

図34に戻り、図35に示すNバンド目の赤目領域の抽出処理(S3303)が終了すると、最終バンドの処理が完了したか否かを判定し(S3304)、完了であれば処理を終了し、未了であればカウンタNをインクリメントして(S3405)、処理をステップS3302に戻す。   Returning to FIG. 34, when the red-eye region extraction processing (S3303) for the Nth band shown in FIG. 35 is completed, it is determined whether or not the final band processing is complete (S3304). If not completed, the counter N is incremented (S3405), and the process returns to step S3302.

図39は実施例5における補正処理の一例を示すフローチャートである。   FIG. 39 is a flowchart illustrating an example of correction processing according to the fifth embodiment.

まず、赤目領域の位置情報を変換する(S3801)。実施例5では、赤目領域の抽出、補正処理を画像入出力デバイスの組み込み処理として実行することを想定するため、上述したように、赤目領域の抽出処理は縮小画像で行う。しかし、補正対象の画像は縮小前の高解像度の画像であり、プリンタなどの画像出力デバイスであれば、縮小前の画像をさらに印刷(出力)解像度に拡大したり、回転した画像の可能性がある。従って、縮小画像上で抽出した赤目領域の位置情報を縮小率や拡大率(変倍率)、回転に応じて変換する必要がある。   First, the position information of the red-eye area is converted (S3801). In the fifth embodiment, since it is assumed that the red-eye area extraction and correction process is executed as an image input / output device incorporation process, the red-eye area extraction process is performed on a reduced image as described above. However, the image to be corrected is a high-resolution image before reduction, and if it is an image output device such as a printer, there is a possibility that the image before reduction is further enlarged to the print (output) resolution or rotated. is there. Therefore, it is necessary to convert the position information of the red-eye area extracted on the reduced image according to the reduction ratio, enlargement ratio (magnification), and rotation.

候補領域リストに格納された位置情報が、図41に示すように、赤目領域の左上座標(xt0, yt0)と右下座標(xb0, yb0)で表現され、かつ、縮小画像の縦横の画素数がW0、H0、補正対象画像の縦横の画素数がW1、H1の場合、補正対象画像における赤目領域の座標を式(27)で算出する。
(xt1, yt1) = {int(xt0・k), int(yt0・k)}
(xb1, yb1) = {int(xb0・k), int(yb0・k)} …(27)
ここで、k = W1/W0
int( )は自身を超えない最大の整数
(xt1, yt1)は補正対象画像上の赤目領域の左上座標
(xb1, yb1)は補正対象画像上の赤目領域の右下座標
As shown in FIG. 41, the position information stored in the candidate area list is represented by the upper left coordinates (x t0 , y t0 ) and lower right coordinates (x b0 , y b0 ) of the red-eye area, and the reduced image When the vertical and horizontal pixel numbers are W0 and H0, and the vertical and horizontal pixel numbers of the correction target image are W1 and H1, the coordinates of the red-eye area in the correction target image are calculated by Expression (27).
(x t1 , y t1 ) = {int (x t0・ k), int (y t0・ k)}
(x b1 , y b1 ) = {int (x b0・ k), int (y b0・ k)}… (27)
Where k = W1 / W0
int () is the largest integer not exceeding itself
(x t1 , y t1 ) is the upper left coordinates of the red-eye area on the image to be corrected
(x b1 , y b1 ) is the lower right coordinates of the red-eye area on the image to be corrected

ステップSS3801において、補正対象画像上の赤目領域の座標が決定すると、実施例1と同様に、赤目領域周辺に楕円領域を設定し、楕円領域に含まれる画素を補正対象画素として以下の処理を行う。   When the coordinates of the red-eye area on the correction target image are determined in step SS3801, an elliptical area is set around the red-eye area, and the following processing is performed using the pixels included in the elliptical area as correction target pixels, as in the first embodiment. .

まず、カウンタRを零に初期化し(S3802)、補正対象画像のRライン目の画像データを取得する(S3803)。実施例5では、補正対象画像をライン単位に補正する処理を説明するが、これに限定されるわけではなく、所定ライン数のバンド単位に補正しても構わない。補正対象画像の画像データの取得は、例えば図1に示す記憶装置105やメモリカードなどに、JPEGなどの圧縮形式で保存された画像データを所定のライン数分伸長し、そのうちの1(または複数)ラインを取得することで実現する。   First, the counter R is initialized to zero (S3802), and image data for the R-th line of the correction target image is acquired (S3803). In the fifth embodiment, a process of correcting the correction target image in units of lines will be described. However, the present invention is not limited to this, and the correction may be performed in units of bands of a predetermined number of lines. Acquisition of the image data of the correction target image is performed by, for example, expanding the image data stored in a compression format such as JPEG in the storage device 105 or the memory card shown in FIG. ) Realize by acquiring the line.

次に、Rライン目が補正対象画素を含むか否かを判定する(S3804)。実施例5の補正処理は、赤目領域(矩形領域)の周辺に設定した楕円領域を補正対象領域にする。そのため、Rライン目が補正対象領域の上端から下端の間に位置するか否かを、候補領域リストに格納されたすべての赤目領域について判定する。Rライン目が補正対象画素を含まない場合は、カウンタRをインクリメントして(S3807)、処理をステップS3803に戻す。   Next, it is determined whether or not the R-th line includes a correction target pixel (S3804). In the correction processing of the fifth embodiment, an elliptical area set around the red-eye area (rectangular area) is set as a correction target area. Therefore, whether or not the R-th line is located between the upper end and the lower end of the correction target area is determined for all red-eye areas stored in the candidate area list. If the R-th line does not include the correction target pixel, the counter R is incremented (S3807), and the process returns to step S3803.

例えば、図40に示すような場合、Rライン目は、ある赤目領域4003周辺に設定した補正対象領域4002に含まれる。従って、Rライン目の補正対象領域4002に含まれる画素について、実施例1で説明した補正処理を施す(S3805)。この補正処理に必要な最大輝度値Ymaxと評価量の最大値Ermaxは、上述したステップS3405において求めて候補領域リストに格納された値を使用する。   For example, in the case shown in FIG. 40, the R-th line is included in the correction target region 4002 set around a certain red-eye region 4003. Therefore, the correction process described in the first embodiment is performed on the pixels included in the correction target area 4002 of the R-th line (S3805). As the maximum luminance value Ymax and the maximum evaluation value Ermax necessary for this correction processing, the values obtained in step S3405 and stored in the candidate area list are used.

以上の処理を、ステップS3806の判定により、Rライン目が最終ラインになるまで繰り返すことで、入力画像全体に補正処理を施すことができる。   By repeating the above processing until the R-th line becomes the final line according to the determination in step S3806, the entire input image can be corrected.

補正処理が終了した画像データは、例えば、記憶装置105に格納されたり、あるいは、色変換、疑似階調処理を施した後、例えばプリンタ110により記録紙に印刷されることになる。   The image data that has been subjected to the correction processing is stored in, for example, the storage device 105, or is subjected to color conversion and pseudo gradation processing and then printed on recording paper by the printer 110, for example.

このように、入力画像を縮小し、かつ、バンドに分割してバンド単位に赤目領域の抽出処理を行うことで、実施例1〜4で説明したような赤目領域の抽出および補正を、メモリリソースが極めて少ない環境下で実行することが可能になる。また、隣接するバンドとの間に重複領域が存在するようにバンド分割することで、バンド境界に存在する赤目領域の抽出が可能になる。   In this way, by reducing the input image and dividing the input image into bands and performing red-eye region extraction processing in units of bands, the red-eye region extraction and correction described in the first to fourth embodiments can be performed using memory resources. It is possible to execute in an environment where there is very little. Further, by dividing the band so that there is an overlapping region between adjacent bands, it is possible to extract a red-eye region existing at the band boundary.

なお、赤目領域の抽出部を撮像装置などの画像入力デバイスに搭載し、赤目領域の補正部を印刷装置などの画像出力デバイスに搭載しても構わない。   The red-eye area extraction unit may be mounted on an image input device such as an imaging apparatus, and the red-eye area correction unit may be mounted on an image output device such as a printing apparatus.

[変形例]
上記の各実施例においては、画素ごとの評価量ErとしてRGB成分値のうち、Bを使用しない評価量Erを定義した。しかし、これに限定するものではなく、例えば、式(28)によって評価量Erを定義し、係数kを0または係数i、jよりも小さい値に設定しても同様の効果を得ることができる。ここで、係数i、j、kは負の数になり得る重みである。
Er = (i・R + j・G + k・B)/R …(28)
[Modification]
In each of the above-described embodiments, the evaluation amount Er that does not use B among the RGB component values is defined as the evaluation amount Er for each pixel. However, the present invention is not limited to this. For example, the same effect can be obtained even if the evaluation amount Er is defined by Equation (28) and the coefficient k is set to 0 or a value smaller than the coefficients i and j. . Here, the coefficients i, j, and k are weights that can be negative numbers.
Er = (i ・ R + j ・ G + k ・ B) / R… (28)

また、画素値をLabやYCbCrなどの別の色空間に変換した後、青色成分を考慮に入れない、あるいは、青色成分の重みを小さくして評価量Erを定義してもよい。   Alternatively, after the pixel value is converted into another color space such as Lab or YCbCr, the blue component may not be taken into consideration, or the evaluation amount Er may be defined by reducing the blue component weight.

[他の実施例]
なお、本発明は、複数の機器(例えばホストコンピュータ、インタフェイス機器、リーダ、プリンタなど)から構成されるシステムに適用しても、一つの機器からなる装置(例えば、複写機、ファクシミリ装置など)に適用してもよい。
[Other embodiments]
Note that the present invention can be applied to a system including a plurality of devices (for example, a host computer, an interface device, a reader, and a printer), and a device (for example, a copying machine and a facsimile device) including a single device. You may apply to.

また、本発明の目的は、前述した実施例の機能を実現するソフトウェアのプログラムコードを記録した記憶媒体(または記録媒体)を、システムあるいは装置に供給し、そのシステムあるいは装置のコンピュータ(またはCPUやMPU)が記憶媒体に格納されたプログラムコードを読み出し実行することによっても、達成されることは言うまでもない。この場合、記憶媒体から読み出されたプログラムコード自体が前述した実施例の機能を実現することになり、そのプログラムコードを記憶した記憶媒体は本発明を構成することになる。また、コンピュータが読み出したプログラムコードを実行することにより、前述した実施例の機能が実現されるだけでなく、そのプログラムコードの指示に基づき、コンピュータ上で稼働しているオペレーティングシステム(OS)などが実際の処理の一部または全部を行い、その処理によって前述した実施例の機能が実現される場合も含まれることは言うまでもない。   Also, an object of the present invention is to supply a storage medium (or recording medium) on which a program code of software that realizes the functions of the above-described embodiments is recorded to a system or apparatus, and the computer (or CPU or CPU) of the system or apparatus. Needless to say, this can also be achieved by the MPU) reading and executing the program code stored in the storage medium. In this case, the program code itself read from the storage medium realizes the functions of the above-described embodiments, and the storage medium storing the program code constitutes the present invention. Further, by executing the program code read by the computer, not only the functions of the above-described embodiments are realized, but also an operating system (OS) running on the computer based on the instruction of the program code. It goes without saying that a case where the function of the above-described embodiment is realized by performing part or all of the actual processing and the processing is included.

さらに、記憶媒体から読み出されたプログラムコードが、コンピュータに挿入された機能拡張カードやコンピュータに接続された機能拡張ユニットに備わるメモリに書込まれた後、そのプログラムコードの指示に基づき、その機能拡張カードや機能拡張ユニットに備わるCPUなどが実際の処理の一部または全部を行い、その処理によって前述した実施例の機能が実現される場合も含まれることは言うまでもない。   Furthermore, after the program code read from the storage medium is written into a memory provided in a function expansion card inserted into the computer or a function expansion unit connected to the computer, the function is determined based on the instruction of the program code. Needless to say, the CPU of the expansion card or the function expansion unit performs part or all of the actual processing and the functions of the above-described embodiments are realized by the processing.

本発明を上記記憶媒体に適用する場合、その記憶媒体には、先に説明したフローチャートに対応するプログラムコードが格納されることになる。   When the present invention is applied to the storage medium, the storage medium stores program codes corresponding to the flowcharts described above.

Claims (15)

画像の画素ごとに、目の色調の評価量を前記画像のR成分およびG成分のみから算出する算出手段と、
前記算出手段によって算出された評価量に基づき目の色調不良を示す候補画素を抽出する抽出手段と、
前記抽出手段によって抽出された複数の候補画素から構成される領域を抽出し、該抽出された領域が予め定められた形状であるか判定を行い、該予め定められた形状であると判定された領域を目の色調不良の候補領域として抽出する領域抽出手段とを有し、
前記抽出手段は、前記画像における注目画素の近傍に予め定めたウィンドウ領域を設定し、前記ウィンドウ領域に含まれる画素の評価量から閾値を決定し、前記閾値を用いて前記注目画素の評価量を二値化することで前記候補画素を抽出することを特徴とする画像処理装置。
For each pixel of the image, calculation means for calculating the evaluation amount of the tone of the eye from only the R component and the G component of the image,
Extracting means for extracting candidate pixels indicating poor color tone of eyes based on the evaluation amount calculated by the calculating means;
An area composed of a plurality of candidate pixels extracted by the extraction means is extracted, and it is determined whether the extracted area has a predetermined shape, and is determined to have the predetermined shape. possess a region extracting means for extracting a region as a candidate region of poor color tone of eyes,
The extraction unit sets a predetermined window region in the vicinity of the target pixel in the image, determines a threshold value from the evaluation amount of the pixels included in the window region, and uses the threshold value to determine the evaluation amount of the target pixel. An image processing apparatus that extracts the candidate pixels by binarization .
前記抽出手段は、前記画像における前記注目画素と同一ライン上に複数の画素の分の前記ウィンドウ領域を設定することを特徴とする請求項1に記載された画像処理装置。 2. The image processing apparatus according to claim 1 , wherein the extraction unit sets the window area for a plurality of pixels on the same line as the target pixel in the image. 前記抽出手段は、前記注目画素を前記同一ラインの方向に走査して候補画素の抽出を行った後、前記ライン上で該走査した方向と逆の方向に前記注目画素を走査して候補画素の抽出を行い、前記二回の走査でともに抽出した画素を前記候補画素とすることを特徴とする請求項2に記載された画像処理装置。 The extraction unit scans the target pixel in the direction of the same line and extracts candidate pixels, and then scans the target pixel in a direction opposite to the scanned direction on the line. 3. The image processing apparatus according to claim 2 , wherein extraction is performed, and pixels extracted together in the two scans are set as the candidate pixels. 前記予め定められた形状の領域は、円または楕円に近い形状の領域であることを特徴とする請求項1に記載された画像処理装置。   2. The image processing apparatus according to claim 1, wherein the region having the predetermined shape is a region having a shape close to a circle or an ellipse. さらに、前記領域抽出手段によって抽出された候補領域から算出した目の特徴量に基づき、前記候補領域を補正領域にするか否かを決定する決定手段と、
前記決定手段において前記候補領域を補正領域にすると決定された場合、前記補正領域に色調不良を補正する処理を施す補正手段とを有することを特徴とする請求項1または請求項4に記載された画像処理装置。
And determining means for determining whether or not the candidate area is to be a correction area based on the eye feature amount calculated from the candidate area extracted by the area extracting means;
If the candidate area is determined to the correction region in the determination unit, according to claim 1 or claim 4, characterized in that it has a correction means for performing a process of correcting the poor color tone in the correction area Image processing device.
前記決定手段は、前記候補領域から複数の前記目の特徴量を算出し、前記候補領域が前記特徴量のすべて、または、前記特徴量のうち予め定めた特徴量に対して予め定めた基準を満たす場合、前記候補領域を前記補正領域と判定することを特徴とする請求項5に記載された画像処理装置。 The determining unit calculates a plurality of feature amounts of the eyes from the candidate region, and the candidate region uses a predetermined reference for all of the feature amounts or a predetermined feature amount of the feature amounts. 6. The image processing apparatus according to claim 5 , wherein if the condition is satisfied, the candidate area is determined as the correction area. 前記補正手段は、前記補正領域の画素と前記補正領域の中心の間の距離に応じて第一の重みを算出する手段、前記画像における注目画素の前記評価量と前記補正領域の画素の評価量の最大値の比に応じて第二の重みを算出する手段、前記注目画素の輝度値と前記補正領域の画素の輝度値の最大値の比に応じて第三の重みを算出する手段、前記第一から第三の重みを用いて輝度および色差成分の補正量を決定する手段、並びに、前記補正量を用いて、前記注目画素の輝度および色差成分を補正する手段を有することを特徴とする請求項6に記載された画像処理装置。 The correction means calculates a first weight according to a distance between a pixel in the correction area and a center of the correction area, the evaluation amount of the target pixel in the image, and an evaluation amount of the pixel in the correction area Means for calculating a second weight in accordance with a ratio of the maximum values of, a means for calculating a third weight in accordance with a ratio of the luminance value of the target pixel and the luminance value of the pixel in the correction area, It has means for determining the correction amount of the luminance and chrominance component using the first to third weights, and means for correcting the luminance and chrominance component of the pixel of interest using the correction amount. 7. The image processing device according to claim 6 . 前記補正量を決定する手段は、前記第一から第三の重みを用いて前記輝度成分の補正量を決定し、前記第一および第二の重みを用いて前記色差成分の補正量を決定することを特徴とする請求項7に記載された画像処理装置。 The means for determining the correction amount determines the correction amount of the luminance component using the first to third weights, and determines the correction amount of the color difference component using the first and second weights. 8. The image processing apparatus according to claim 7 , wherein: さらに、前記候補領域の近傍に、前記候補領域より小さい候補領域が存在する場合、前記小さい候補領域を除外する領域の除外手段を有することを特徴とする請求項1に記載された画像処理装置。   2. The image processing apparatus according to claim 1, further comprising an area excluding unit that excludes the small candidate area when a candidate area smaller than the candidate area exists in the vicinity of the candidate area. さらに、前記領域抽出手段によって抽出された複数の候補領域の間の距離を判定する閾値を用いて前記複数の候補領域の間の距離を判定し、さらに、前記複数の候補領域に外接する領域の縦横比を用いて前記外接する領域の形状を判定し、前記複数の候補領域の間の距離と前記外接する領域の形状の判定結果に応じて、前記複数の候補領域を結合する領域結合手段を有することを特徴とする請求項1に記載された画像処理装置。   Further, a distance between the plurality of candidate areas is determined using a threshold value for determining a distance between the plurality of candidate areas extracted by the area extracting unit, and further, a region circumscribing the plurality of candidate areas is determined. A region combining unit that determines the shape of the circumscribed region using an aspect ratio, and combines the plurality of candidate regions according to the determination result of the distance between the plurality of candidate regions and the shape of the circumscribed region. 2. The image processing apparatus according to claim 1, further comprising: 前記領域結合手段は、前記複数の候補領域の面積の和を、前記複数の候補領域に外接する領域の面積で除算した値が所定の閾値よりも大きく、かつ、前記外接する領域の形状が、前記複数の候補領域の何れよりも正方形に近い場合に、前記複数の候補領域を結合することを特徴とする請求項10に記載された画像処理装置。 The region combining means is a value obtained by dividing the sum of the areas of the plurality of candidate regions by the area of the region circumscribing the plurality of candidate regions is larger than a predetermined threshold, and the shape of the circumscribed region is 11. The image processing apparatus according to claim 10 , wherein the plurality of candidate areas are combined when they are closer to a square than any of the plurality of candidate areas. 前記領域結合手段は、前記複数の候補領域の面積の和を、前記複数の候補領域に外接する領域の面積で除算した値が所定の閾値よりも大きく、かつ、前記外接する領域の縦横比が前記複数の候補領域の何れの縦横比よりも大きい場合に、前記複数の候補領域を結合することを特徴とする請求項10に記載された画像処理装置。 The region combining means has a value obtained by dividing the sum of the areas of the plurality of candidate regions by the area of the region circumscribing the plurality of candidate regions is greater than a predetermined threshold, and an aspect ratio of the circumscribed region is 11. The image processing apparatus according to claim 10 , wherein the plurality of candidate areas are combined when the aspect ratio is larger than any aspect ratio of the plurality of candidate areas. 画像の画素ごとに、目の色調の評価量を前記画像のR成分およびG成分のみから算出する算出ステップと、
前記算出ステップによって算出された評価量に基づき目の色調不良を示す候補画素を抽出する抽出ステップと、
前記抽出ステップによって抽出された複数の候補画素から構成される領域を抽出し、該抽出された領域が予め定められた形状であるか判定を行い、該予め定められた形状であると判定された領域を目の色調不良の候補領域として抽出する領域抽出ステップとを有し、
前記抽出ステップは、前記画像における注目画素の近傍に予め定めたウィンドウ領域を設定し、前記ウィンドウ領域に含まれる画素の評価量から閾値を決定し、前記閾値を用いて前記注目画素の評価量を二値化することで前記候補画素を抽出することを特徴とする画像処理方法。
For each pixel of the image, a calculation step for calculating an evaluation amount of the tone of the eye from only the R component and the G component of the image;
An extraction step of extracting candidate pixels indicating poor color tone of eyes based on the evaluation amount calculated by the calculation step;
An area composed of a plurality of candidate pixels extracted by the extraction step is extracted, and it is determined whether or not the extracted area has a predetermined shape, and is determined to have the predetermined shape possess a region extraction step of extracting a region as a candidate region of poor color tone of eyes,
The extraction step sets a predetermined window region in the vicinity of the target pixel in the image, determines a threshold value from the evaluation amount of the pixels included in the window region, and uses the threshold value to calculate the evaluation amount of the target pixel. An image processing method , wherein the candidate pixels are extracted by binarization .
コンピュータを請求項1から請求項12の何れか一項に記載された画像処理装置の各手段として機能させるためのプログラム。 Program for causing to function as each means of the image processing apparatus according to computer claims 1 to any one of claims 12. 請求項14に記載されたプログラムが記録されたことを特徴とするコンピュータが読み取り可能な記録媒体。 15. A computer-readable recording medium on which the program according to claim 14 is recorded.
JP2010157308A 2010-07-09 2010-07-09 Image processing apparatus and method Expired - Fee Related JP4850961B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2010157308A JP4850961B2 (en) 2010-07-09 2010-07-09 Image processing apparatus and method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2010157308A JP4850961B2 (en) 2010-07-09 2010-07-09 Image processing apparatus and method

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
JP2009231002A Division JP4580029B2 (en) 2009-10-02 2009-10-02 Image processing apparatus and method

Publications (2)

Publication Number Publication Date
JP2010257482A JP2010257482A (en) 2010-11-11
JP4850961B2 true JP4850961B2 (en) 2012-01-11

Family

ID=43318245

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2010157308A Expired - Fee Related JP4850961B2 (en) 2010-07-09 2010-07-09 Image processing apparatus and method

Country Status (1)

Country Link
JP (1) JP4850961B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP6188453B2 (en) 2013-06-28 2017-08-30 キヤノン株式会社 Image processing apparatus, image processing method, and program

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3358033B2 (en) * 1993-06-25 2002-12-16 オリンパス光学工業株式会社 Image correction device and image correction method
JP3961734B2 (en) * 1999-12-24 2007-08-22 富士フイルム株式会社 Image processing method, apparatus, and recording medium
JP4148903B2 (en) * 2004-01-06 2008-09-10 株式会社東芝 Image processing apparatus, image processing method, and digital camera
JP4405942B2 (en) * 2005-06-14 2010-01-27 キヤノン株式会社 Image processing apparatus and method

Also Published As

Publication number Publication date
JP2010257482A (en) 2010-11-11

Similar Documents

Publication Publication Date Title
JP4405942B2 (en) Image processing apparatus and method
JP4498224B2 (en) Image processing apparatus and method
JP4420459B2 (en) Image processing apparatus and method
US7171044B2 (en) Red-eye detection based on red region detection with eye confirmation
US7454040B2 (en) Systems and methods of detecting and correcting redeye in an image suitable for embedded applications
US8175341B2 (en) Image processing method and apparatus thereof
US8498496B2 (en) Method and apparatus for filtering red and/or golden eye artifacts
JP4850961B2 (en) Image processing apparatus and method
JP4580029B2 (en) Image processing apparatus and method
JP2007004455A (en) Image processing apparatus, image processing method, and storage medium recording program
EP2143069A1 (en) Method for red eye detection in a digital image
JP6188453B2 (en) Image processing apparatus, image processing method, and program
JP2005202841A (en) Image processing method and apparatus

Legal Events

Date Code Title Description
A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20110715

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20110913

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

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

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20111019

R151 Written notification of patent or utility model registration

Ref document number: 4850961

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R151

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

Free format text: PAYMENT UNTIL: 20141028

Year of fee payment: 3

LAPS Cancellation because of no payment of annual fees