JP2013247597A - Image processing apparatus, imaging apparatus, and image processing program - Google Patents

Image processing apparatus, imaging apparatus, and image processing program Download PDF

Info

Publication number
JP2013247597A
JP2013247597A JP2012121642A JP2012121642A JP2013247597A JP 2013247597 A JP2013247597 A JP 2013247597A JP 2012121642 A JP2012121642 A JP 2012121642A JP 2012121642 A JP2012121642 A JP 2012121642A JP 2013247597 A JP2013247597 A JP 2013247597A
Authority
JP
Japan
Prior art keywords
pixel
value
flare
image
unit
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.)
Pending
Application number
JP2012121642A
Other languages
Japanese (ja)
Inventor
Nobutaka Hirama
宣孝 平間
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.)
Nikon Corp
Original Assignee
Nikon Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nikon Corp filed Critical Nikon Corp
Priority to JP2012121642A priority Critical patent/JP2013247597A/en
Publication of JP2013247597A publication Critical patent/JP2013247597A/en
Pending legal-status Critical Current

Links

Images

Abstract

PROBLEM TO BE SOLVED: To prevent occurrence of color blurring, when suppressing influence of mixed colors caused by a flare.SOLUTION: An image processing apparatus comprises: an image input unit which receives an image; a flare determination unit which determines whether a flare has occurred or not, on the basis of information on the area of a predetermined color component included in the image; a setting unit which, when the occurrence of a flare is determined, sets to a pixel included in the area of the predetermined color component caused by the flare at least, a weight based on a color component value of the pixel; and a smoothing unit which executes a smoothing process on the image on the basis of the weight set by the setting unit.

Description

本発明は、画像処理装置、撮像装置及び画像処理プログラムに関する。   The present invention relates to an image processing device, an imaging device, and an image processing program.

従来、複数の撮像用画素を二次元状に配列した受光面の一部に焦点検出用の複数の画素を配列した撮像素子が知られている(特許文献1)。複数の撮像用画素は、複数の色成分の各々に対応する分光特性を有し、また、焦点検出用の画素(焦点検出用画素)は、複数の撮像用画素とは異なる分光特性を有する。複数の撮像用画素からは、画像を生成するための信号が読み出されて撮像用画素の画素値が決められ、また焦点検出用画素からは焦点検出のための信号が読み出されて焦点検出用画素の画素値が決められる。画素補間処理を行う時には、撮像用画素の画素値のうち欠落する色成分の画素値を補間するとともに、焦点検出用画素の位置に対応する撮像用画素値を補間する。   2. Description of the Related Art Conventionally, there has been known an imaging element in which a plurality of pixels for focus detection are arranged on a part of a light receiving surface in which a plurality of imaging pixels are arranged two-dimensionally (Patent Document 1). The plurality of imaging pixels have spectral characteristics corresponding to each of the plurality of color components, and the focus detection pixels (focus detection pixels) have spectral characteristics different from the plurality of imaging pixels. A signal for generating an image is read from a plurality of imaging pixels to determine a pixel value of the imaging pixel, and a focus detection signal is read from the focus detection pixel to detect a focus. The pixel value of the working pixel is determined. When performing the pixel interpolation process, the pixel value of the missing color component among the pixel values of the imaging pixel is interpolated, and the imaging pixel value corresponding to the position of the focus detection pixel is interpolated.

特許文献1に記載の発明では、焦点検出用画素に対する補間処理を行うために、焦点検出用画素の近傍にある撮像用画素の画素値を用いて焦点検出用画素の補間画素値を生成し、前記近傍の撮像用画素が焦点検出用画素と同じ分光特性を有した場合の画素値である評価画素値を算出し、前記焦点検出用画素の画素値と前記評価画素値とを用いて画像の高周波成分を算出し、前記補間画素値に前記高周波成分を付加して焦点検出用画素の位置に対応する撮像用画素の画素値を算出している。   In the invention described in Patent Document 1, in order to perform the interpolation processing for the focus detection pixel, the interpolation pixel value of the focus detection pixel is generated using the pixel value of the imaging pixel in the vicinity of the focus detection pixel, An evaluation pixel value that is a pixel value when the neighboring imaging pixel has the same spectral characteristics as the focus detection pixel is calculated, and the image value is calculated using the pixel value of the focus detection pixel and the evaluation pixel value. A high frequency component is calculated, and the pixel value of the imaging pixel corresponding to the position of the focus detection pixel is calculated by adding the high frequency component to the interpolated pixel value.

特開2009−303194号公報JP 2009-303194 A

ところで、撮像素子の受光部周辺の画素間で配線領域からの反射光でフレアが生じると、受光部周辺でマイクロレンズ間の入射光が隣接画素へ漏れ込むクロストークにより混色が発生する。このような現象が起きると、焦点検出用画素のみならず、その周辺の画素も影響を受け、前述した画素補間処理により混色を受けた焦点検出用画素、及びその周りの画素が見た目に違和感を与える補間残りとなって現れる。このような混色が発生した画素に対しては、例えば平滑化処理を行うことで混色の影響を低減することが可能である。しかしながら、フレアの影響が強い領域に併せた平滑化処理を行うと、フレアの影響が強い領域においては、フレアの影響が低減されるが、フレアの影響が弱い領域やフレアが影響していない領域に色にじみが発生してしまうという問題がある。   By the way, when flare is generated by the reflected light from the wiring region between pixels around the light receiving portion of the image sensor, color mixing occurs due to crosstalk in which incident light between the microlenses leaks into adjacent pixels around the light receiving portion. When such a phenomenon occurs, not only the focus detection pixels but also the surrounding pixels are affected, and the focus detection pixels that have undergone color mixing by the pixel interpolation process described above and the surrounding pixels feel uncomfortable. Appears as a residual interpolation. For a pixel in which such color mixture has occurred, for example, the effect of color mixture can be reduced by performing a smoothing process. However, if smoothing processing is performed in a region where the flare is strong, the flare is reduced in the region where the flare is strong, but the region where the flare is weak or the region where the flare is not affected There is a problem that color blur occurs.

本発明は、かかる点に鑑みてなされたものであり、フレアに起因する混色の影響を抑制する際に、色にじみの発生を防止することができるようにした画像処理装置、撮像装置及び画像処理プログラムを提供することを目的とする。   The present invention has been made in view of such points, and an image processing apparatus, an imaging apparatus, and an image processing capable of preventing the occurrence of color bleeding when suppressing the influence of color mixing caused by flare. The purpose is to provide a program.

上述した課題を解決するために、本発明の画像処理装置は、画像を受け付ける画像入力部と、前記画像に含まれる所定の色成分の領域に関わる情報に基づいて、フレアが発生しているか否かを判定するフレア判定部と、前記フレアが発生していると判定されたときに、少なくとも前記フレアに起因した前記所定の色成分の領域に含まれる画素に対して、前記画素が有する色成分値に基づいた重みを設定する設定部と、前記設定部により設定された前記重みに基づいて、前記画像に対する平滑化処理を実行する平滑化部と、を備えたことを特徴とする。   In order to solve the above-described problem, an image processing apparatus according to the present invention is configured to determine whether or not flare has occurred based on information related to an image input unit that receives an image and a region of a predetermined color component included in the image. A flare determination unit that determines whether or not the flare has occurred, and at least the color component included in the predetermined color component region caused by the flare when the flare is generated. A setting unit configured to set a weight based on the value; and a smoothing unit configured to perform a smoothing process on the image based on the weight set by the setting unit.

また、前記画像から前記所定の色成分の領域を検出する領域検出部と、前記画像に含まれるエッジを検出するエッジ検出部と、を備え、前記フレア判定部は、前記領域検出部の検出結果及び前記エッジ検出部の検出結果に基づいて、前記フレアが発生しているか否かを判定するものである。   Further, an area detection unit that detects an area of the predetermined color component from the image, and an edge detection unit that detects an edge included in the image, wherein the flare determination unit is a detection result of the area detection unit And based on the detection result of the said edge detection part, it is determined whether the said flare has generate | occur | produced.

また、前記設定部は、色度図における前記所定の色成分が取り得る色域を複数の領域に分割し、前記フレアに起因した前記所定の色成分の領域に含まれる各画素の色成分値が前記複数の領域のいずれかに属するかを判定することで、前記フレアに起因した前記所定の色成分の領域に含まれる各画素に対して、前記重みを設定するものである。   Further, the setting unit divides a color gamut that the predetermined color component in the chromaticity diagram can take into a plurality of regions, and color component values of each pixel included in the region of the predetermined color component due to the flare Is set to one of the plurality of regions, the weight is set for each pixel included in the region of the predetermined color component caused by the flare.

また、前記設定部は、前記画像のうち、前記フレアに起因した前記所定の色成分の領域を除く領域に含まれる画素に対して、前記フレアに起因した前記所定の色成分の領域に含まれる各画素に設定される重みとは異なる重みを設定するものである。   The setting unit is included in the predetermined color component region caused by the flare with respect to pixels included in the region excluding the predetermined color component region caused by the flare in the image. A weight different from the weight set for each pixel is set.

また、前記画像は、撮像用画素と焦点検出用画素とを有し、前記画像入力部により受け付けた画像、又は前記平滑化処理を行った画像に対して補間処理を行うことで、前記焦点検出用画素に対する補間画素値を生成する画素補間部をさらに備えているものである。   Further, the image includes an imaging pixel and a focus detection pixel, and the focus detection is performed by performing an interpolation process on the image received by the image input unit or the image subjected to the smoothing process. And a pixel interpolation unit that generates an interpolation pixel value for the target pixel.

また、本発明の撮像装置は、前記画像を取得する撮像素子と、上述した画像処理装置とを備えることを特徴とする。   Moreover, the imaging device of this invention is provided with the image pick-up element which acquires the said image, and the image processing apparatus mentioned above.

また、本発明の画像処理プログラムは、画像を受け付ける画像入力工程と、前記画像に含まれる所定の色成分の領域に関わる情報に基づいて、フレアが発生しているか否かを判定するフレア判定工程と、前記フレアが発生していると判定されたときに、少なくとも前記フレアに起因した前記所定の色成分の領域に含まれる画素に対して、前記画素が有する色成分値に基づいた重みを設定する設定工程と、前記設定工程により設定された前記重みに基づいて、前記画像に対する平滑化処理を実行する平滑化工程と、をコンピュータに実行させることが可能なものである。   The image processing program of the present invention includes an image input step for receiving an image, and a flare determination step for determining whether or not a flare has occurred based on information relating to a region of a predetermined color component included in the image. When it is determined that the flare has occurred, a weight based on a color component value of the pixel is set for at least a pixel included in the predetermined color component region caused by the flare. And a smoothing step of executing a smoothing process on the image based on the weight set in the setting step.

本発明によれば、フレアに起因する混色の影響を抑制する際に、色にじみの発生を防止することができる。   According to the present invention, it is possible to prevent the occurrence of color blur when suppressing the influence of color mixing caused by flare.

本発明の電子カメラの電気的構成を示すブロック図である。It is a block diagram which shows the electric constitution of the electronic camera of this invention. 撮像用画素及びAF画素の配置例を示す図である。It is a figure which shows the example of arrangement | positioning of the pixel for imaging, and AF pixel. AF画素が配置された領域を中心とした画像データの一部を示す図である。It is a figure which shows a part of image data centering on the area | region where AF pixel is arrange | positioned. フレア判定部を備えたAF画素補間部を示す図である。It is a figure which shows the AF pixel interpolation part provided with the flare determination part. フレア判定部の構成を示す図である。It is a figure which shows the structure of a flare determination part. フレア判定から画素補間までの処理の流れを示すフローチャートである。It is a flowchart which shows the flow of a process from a flare determination to pixel interpolation. 色度図におけるマゼンタ色の色域を3個の領域に分割した例を示すグラフである。It is a graph which shows the example which divided | segmented the magenta color gamut in a chromaticity diagram into three area | regions. 第1画素補間処理の流れを示すフローチャートである。6 is a flowchart showing a flow of first pixel interpolation processing. 本実施形態の効果が発揮される画像構造の一例を表す図である。It is a figure showing an example of the image structure where the effect of this embodiment is exhibited. 第2画素補間処理の流れを示すフローチャートである。It is a flowchart which shows the flow of a 2nd pixel interpolation process. フレア判定部の構成を示す図である。It is a figure which shows the structure of a flare determination part. フレア判定から画素補間までの処理の流れを示すフローチャートである。It is a flowchart which shows the flow of a process from a flare determination to pixel interpolation. (a)画像データから求めたヒストグラム、(b)求めたヒストグラムと高輝度画素を抽出する際に用いる閾値との関係を示す図である。It is a figure which shows the relationship between the threshold value used when (a) the histogram calculated | required from image data, (b) the calculated histogram, and a high-intensity pixel. Yデータに基づくY画像と、矩形抽出される対象領域との関係を示す図である。It is a figure which shows the relationship between Y image based on Y data, and the object area | region from which a rectangle is extracted. 変数aと、Sb/St値との関係を示すグラフである。It is a graph which shows the relationship between the variable a and Sb / St value. (a)色度図上における[数式51]に基づく色成分の範囲、(b)色度図上における[数式51]及び[数式52]に基づく色成分の範囲を示す図である。(A) A range of color components based on [Formula 51] on the chromaticity diagram, and (b) a range of color components based on [Formula 51] and [Formula 52] on the chromaticity diagram.

図1に示すように、本発明を適用した電子カメラ10は、CPU11を備えている。CPU11には、不揮発性メモリ12、及びワークメモリ13が接続されており、不揮発性メモリ12には、CPU11が種々の制御を行う際に参照される制御プログラムなどが格納されている。さらに、不揮発性メモリ12には、詳しくは後述する撮像素子17のAF画素の位置座標を示すデータ、予め求めておいた画像処理プログラムに用いる各種閾値や加重係数等のデータ、及び各種判定用テーブル等を記憶する。   As shown in FIG. 1, an electronic camera 10 to which the present invention is applied includes a CPU 11. A non-volatile memory 12 and a work memory 13 are connected to the CPU 11, and the non-volatile memory 12 stores a control program that is referred to when the CPU 11 performs various controls. Further, in the nonvolatile memory 12, data indicating the position coordinates of AF pixels of the image sensor 17, which will be described later in detail, data such as various threshold values and weighting coefficients used for an image processing program obtained in advance, and various determination tables Memorize etc.

CPU11は、不揮発性メモリ12に格納されている制御プログラムに従い、ワークメモリ13を一時記憶作業領域として利用して各部の制御を行い、電子カメラ10を構成する各部(回路)機能を作動させる。   The CPU 11 controls each part using the work memory 13 as a temporary storage work area according to a control program stored in the non-volatile memory 12 and operates each part (circuit) function constituting the electronic camera 10.

撮影レンズ14から入射する被写体光は、絞り15、シャッタ16を介してCCDやCMOS等の撮像素子17の受光面に結像する。撮像素子駆動回路18は、CPU11からの制御信号に基づいて撮像素子17を駆動させる。撮像素子17は、ベイヤー配列型単板撮像素子になっており、前面には原色透過フィルタ19が取り付けられている。   Subject light incident from the photographic lens 14 forms an image on a light receiving surface of an image sensor 17 such as a CCD or CMOS through a diaphragm 15 and a shutter 16. The image sensor driving circuit 18 drives the image sensor 17 based on a control signal from the CPU 11. The image sensor 17 is a Bayer array type single-plate image sensor, and a primary color transmission filter 19 is attached to the front surface.

原色透過フィルタ19は、撮像素子17の総画素数Nに対して、例えば、G(緑色)の解像度がN/2、R(赤色)及びB(青色)の解像度がN/4となる原色ベイヤー配列になっている。   The primary color transmission filter 19 is, for example, a primary color Bayer in which the resolution of G (green) is N / 2 and the resolution of R (red) and B (blue) is N / 4 with respect to the total number N of pixels of the image sensor 17. It is an array.

撮像素子17の受光面に結像した被写体像は、アナログの画像信号に変換される。画像信号は、AFE(Analog Front End)回路を構成するCDS21、及びAMP22に順に出力し、AFE回路で所定のアナログ処理が施され、その後、A/D(Analog/Digital変換器)23においてデジタルの画像データに変換されて画像処理部25に送られる。   The subject image formed on the light receiving surface of the image sensor 17 is converted into an analog image signal. The image signal is sequentially output to CDS 21 and AMP 22 constituting an AFE (Analog Front End) circuit, subjected to predetermined analog processing by the AFE circuit, and then digitally processed by an A / D (Analog / Digital converter) 23. It is converted into image data and sent to the image processing unit 25.

画像処理部25は、分離回路、ホワイトバランス処理回路、画素補間(デモザイキング)回路、マトリクス処理回路、非線形変換(γ補正)処理回路、及び輪郭強調処理回路等を備え、デジタルの画像データに対して、ホワイトバランス、画素補間、マトリクス、非線形変換(γ補正)、及び輪郭強調等の処理を施す。分離回路は、詳しくは後述する撮像用画素から出力される信号と、焦点検出用画素から出力される信号とを分離する。画素補間回路は、1画素当たり1色のベイヤー配列信号を、1画素当たり3色からなる通常のカラー画像信号に変換する。   The image processing unit 25 includes a separation circuit, a white balance processing circuit, a pixel interpolation (demosaicing) circuit, a matrix processing circuit, a non-linear transformation (γ correction) processing circuit, an edge enhancement processing circuit, and the like. Thus, processing such as white balance, pixel interpolation, matrix, nonlinear conversion (γ correction), and contour enhancement is performed. The separation circuit separates a signal output from an imaging pixel, which will be described in detail later, and a signal output from the focus detection pixel. The pixel interpolation circuit converts a Bayer array signal of one color per pixel into a normal color image signal composed of three colors per pixel.

画像処理部25から出力される3色の画像データは、バス26を通じてSDRAM27に格納される。SDRAM27に格納した画像データは、CPU11の制御により読み出されて表示制御部28に送られる。表示制御部28は、入力された画像データを表示用の所定方式の信号(例えば、NTSC方式のカラー複合映像信号)に変換して表示部29にスルー画像として出力する。   The three-color image data output from the image processing unit 25 is stored in the SDRAM 27 through the bus 26. The image data stored in the SDRAM 27 is read out under the control of the CPU 11 and sent to the display control unit 28. The display control unit 28 converts the input image data into a predetermined display signal (for example, an NTSC color composite video signal) and outputs it as a through image to the display unit 29.

また、シャッタレリーズに応答して取得した画像データは、SDRAM27から読み出した後に圧縮伸長処理部30に送られ、ここで圧縮処理が施されてからメディアコントローラ31を介して記録媒体であるメモリカード32に記録される。CPU11には、レリーズボタン33や電源スイッチ(不図示)が接続されているとともに、撮像素子17の温度を検出する温度検出部34から温度情報が入力される。この情報は、画像処理部25に送られ、例えばノイズを判定する時に利用される。   The image data acquired in response to the shutter release is read from the SDRAM 27 and then sent to the compression / decompression processing unit 30. After the compression processing is performed here, the memory card 32 which is a recording medium via the media controller 31 is sent. To be recorded. A release button 33 and a power switch (not shown) are connected to the CPU 11, and temperature information is input from a temperature detection unit 34 that detects the temperature of the image sensor 17. This information is sent to the image processing unit 25 and used, for example, when determining noise.

AWB/AE/AF検出部35は、焦点検出用画素(AF画素)の信号に基づいて瞳分割型位相差検出方式によりデフォーカス量、及びデフォーカスの方向を検出する。CPU11は、AWB/AE/AF検出部35で得られるデフォーカス量、及びデフォーカスの方向に基づいてドライバ36を制御して合焦モータ37を駆動してフォーカスレンズを光軸方向で進退させて焦点調整を行う。   The AWB / AE / AF detector 35 detects the defocus amount and the defocus direction by the pupil division type phase difference detection method based on the signal of the focus detection pixel (AF pixel). The CPU 11 controls the driver 36 based on the defocus amount and the defocus direction obtained by the AWB / AE / AF detection unit 35 to drive the focusing motor 37 to advance and retract the focus lens in the optical axis direction. Adjust the focus.

また、AWB/AE/AF検出部35は、撮像用画素の信号に基づいて算出される測光輝度値(Bv)と、撮影者がISO感度設定部38で設定したISO感度値(Sv)とから光値(Lv=Sv+Bv)を算出する。そして、AWB/AE/AF検出部35は、露出値(Ev=Av+Tv)が求めた光値Lvになるように、絞り値とシャッタ速度とを決定する。この決定に基づいて、CPU11は、絞り駆動部39を駆動させ、求めた絞り値となるように絞り15の絞り径を調整する。これに併せて、CPU11は、シャッタ駆動部40を駆動させ、求めたシャッタ速度、シャッタ16が開放されるように、シャッタ16の開閉動作を実行する。   Further, the AWB / AE / AF detection unit 35 uses the photometric luminance value (Bv) calculated based on the image pickup pixel signal and the ISO sensitivity value (Sv) set by the photographer using the ISO sensitivity setting unit 38. The light value (Lv = Sv + Bv) is calculated. Then, the AWB / AE / AF detection unit 35 determines the aperture value and the shutter speed so that the exposure value (Ev = Av + Tv) becomes the calculated light value Lv. Based on this determination, the CPU 11 drives the aperture drive unit 39 to adjust the aperture diameter of the aperture 15 so that the obtained aperture value is obtained. At the same time, the CPU 11 drives the shutter driving unit 40 to execute an opening / closing operation of the shutter 16 so that the obtained shutter speed and the shutter 16 are opened.

AWB/AE/AF検出部35は、オートホワイトバランス調整時に、SDRAM27に取り込んだ1画面の画像データから間引き読み出しを行い、例えば24×16のAWB評価用データを生成する。そして、AWB/AE/AF検出部35は、生成したAWB評価用データを用いて光源種判別を行い、判別された光源種に適したホワイトバランス調整値に従って各色チャンネルの信号に補正をかける。   The AWB / AE / AF detection unit 35 performs thinning-out reading from the image data of one screen captured in the SDRAM 27 during auto white balance adjustment, and generates, for example, 24 × 16 AWB evaluation data. Then, the AWB / AE / AF detection unit 35 performs light source type discrimination using the generated AWB evaluation data, and corrects the signal of each color channel according to the white balance adjustment value suitable for the discriminated light source type.

撮像素子17は、その受光面上にある複数の撮像用画素の各々に、R(赤)、G(緑)、B(青)のいずれかの原色透過フィルタ19がベイヤー配列型に設けられ、その上にマイクロレンズアレイが設けられたCCDやCMOSの半導体イメージセンサ等を適宜選択して用いる。さらに、本実施形態の撮像素子17は、受光面上の一部の領域に、水平走査方向に一次元的に配置された複数のAF画素41を有する。それらのAF画素41には、原色透過フィルタ19が設置されていない。また、AF画素41は、撮影レンズ14の光学系の瞳の左側又は右側を通過する光束を受光する2種類存在する。撮像素子17は、撮像用画素群、及びAF画素群からの画素信号を個別に読み出しすることができる。   The imaging element 17 is provided with a primary color transmission filter 19 of any of R (red), G (green), and B (blue) in a Bayer array type in each of a plurality of imaging pixels on the light receiving surface. A CCD or CMOS semiconductor image sensor with a microlens array provided thereon is appropriately selected and used. Furthermore, the image sensor 17 of the present embodiment has a plurality of AF pixels 41 arranged one-dimensionally in the horizontal scanning direction in a partial region on the light receiving surface. Those AF pixels 41 are not provided with the primary color transmission filter 19. In addition, there are two types of AF pixels 41 that receive light beams that pass through the left or right side of the pupil of the optical system of the photographic lens 14. The imaging element 17 can individually read out pixel signals from the imaging pixel group and the AF pixel group.

なお、本実施形態においては、AF画素41に対して原色透過フィルタ19が設置されていない撮像素子について説明しているが、これに限定される必要はなく、AF画素41に対してNDフィルタやG色の原色透過フィルタを配置した撮像素子であってもよい。   In the present embodiment, an image sensor in which the primary color transmission filter 19 is not installed for the AF pixel 41 is described. However, the present invention is not limited to this, and an ND filter or An image sensor in which a G primary color transmission filter is disposed may be used.

図2に示すように、AF画素41は、セル中心(マイクロレンズの中心)から一方に偏ったセンサ開口部41a,41bを持ち、その偏りの方向に沿って1次元状に並べられている。センサ開口部41a,41bは、偏りが互いに逆方向であり、その偏りの距離は同一である。センサ開口部41aを有するAF画素41は、RGB原色ベイヤー配列中のG画素の代わりに置かれ、また、センサ開口部41bを有するAF画素41は、RGB原色ベイヤー配列中のB画素の代わりに置かれている。このようなセンサ開口部41a,41bをもつAF画素41によって瞳分割位相差AF方式を実現する。つまり、射出瞳を通る光束の中で撮影レンズ14の光軸に対して対称な位置にある2つの部分光束を、センサ開口部41aをもつAF画素41とセンサ開口部41bをもつAF画素41でそれぞれ受光すれば、2つの画素41から出力された信号の位相差によりフォーカスずれの方向(フォーカシングレンズの移動方向)と、フォーカスずれの量(フォーカシングレンズの移動量)が分かる。これにより速やかなフォーカス合わせが可能になる。   As shown in FIG. 2, the AF pixel 41 has sensor openings 41a and 41b that are biased to one side from the cell center (the center of the microlens), and are arranged one-dimensionally along the direction of the bias. The sensor openings 41a and 41b are biased in opposite directions, and the bias distance is the same. The AF pixel 41 having the sensor opening 41a is placed in place of the G pixel in the RGB primary color Bayer array, and the AF pixel 41 having the sensor opening 41b is placed in place of the B pixel in the RGB primary color Bayer array. It is. The pupil division phase difference AF method is realized by the AF pixel 41 having such sensor openings 41a and 41b. That is, of the two light fluxes passing through the exit pupil, two partial light fluxes that are symmetrical with respect to the optical axis of the photographic lens 14 are separated by the AF pixel 41 having the sensor opening 41a and the AF pixel 41 having the sensor opening 41b. If each light is received, the direction of focus shift (moving direction of the focusing lens) and the amount of focus shift (moving amount of the focusing lens) are known from the phase difference between the signals output from the two pixels 41. This enables quick focusing.

したがって、本実施形態におけるAF画素41の各々は、白色光の輝度に応じた左側又は右側の瞳分割された検出信号を出力する。図3は、撮像素子17によって撮像された画像データのうち、AF画素41が配置された領域を中心とした画像データの一部を示す。それぞれのセルが1つの画素を表す。各セルの先頭の記号R、G及びBは、各原色透過フィルタ19を有する撮像用画素を示す。一方、記号X及びYは、左側又は右側からの光束に感度を有するAF画素を示し、それらが交互に水平走査方向に一次元的に配列されている。これらの記号に続く2桁の番号は画素の位置を示す。   Therefore, each AF pixel 41 in the present embodiment outputs a detection signal obtained by dividing the left or right pupil according to the luminance of white light. FIG. 3 shows a part of the image data centered on the area where the AF pixel 41 is arranged in the image data captured by the image sensor 17. Each cell represents one pixel. The symbols R, G, and B at the head of each cell indicate imaging pixels having the primary color transmission filters 19. On the other hand, symbols X and Y indicate AF pixels that are sensitive to light beams from the left side or the right side, and they are alternately arranged one-dimensionally in the horizontal scanning direction. The two-digit number following these symbols indicates the pixel position.

画素補間部は、撮像用画素の画素値を用いてAF画素41の画素値を補間するAF画素補間部45と、AF画素の画素値を補間した後に、ベイヤー配列からRGBへの線形補間法による色補間を行う画素補間部とを備える。   The pixel interpolation unit includes an AF pixel interpolating unit 45 that interpolates the pixel value of the AF pixel 41 using the pixel value of the imaging pixel, and a linear interpolation method from the Bayer array to RGB after interpolating the pixel value of the AF pixel. A pixel interpolation unit for performing color interpolation.

図4及び図5に示すように、AF画素補間部45は、フレア判定部46を備え、フレア判定部46による判定に基づいて異なるAF画素補間処理を行う。例えばフレア判定部46にてフレアが発生していないと判定された場合には、AF画素補間部45は、第1画素補間処理を実行する。この第1画素補間処理は、AF画素の画素値(ホワイト(W)成分)から撮像用画素の画素値を元に加重和で予測することで、そのAF画素の画素値を補間する処理である。   As shown in FIGS. 4 and 5, the AF pixel interpolation unit 45 includes a flare determination unit 46, and performs different AF pixel interpolation processing based on the determination by the flare determination unit 46. For example, when the flare determination unit 46 determines that no flare has occurred, the AF pixel interpolation unit 45 executes the first pixel interpolation process. This first pixel interpolation process is a process of interpolating the pixel value of the AF pixel by predicting with a weighted sum based on the pixel value of the imaging pixel from the pixel value (white (W) component) of the AF pixel. .

一方、フレア判定部46にてフレアが発生していると判定された場合には、AF画素補間部45は、第2画素補間処理を実行する。第2画素補間処理は、AF画素の周囲の撮像用画素の画素値を重み計数により補正し、補正した撮像用画素の画素値を平滑化する処理である。   On the other hand, if the flare determination unit 46 determines that flare has occurred, the AF pixel interpolation unit 45 executes a second pixel interpolation process. The second pixel interpolation process is a process of correcting the pixel values of the imaging pixels around the AF pixel by weighting and smoothing the corrected pixel values of the imaging pixels.

フレア判定部46は、色検出部47、エッジ検出部48、評価値判定部49、及び重み設定部50を備えている。色検出部47は、撮像された画像データにマゼンタ色の色情報を有する画素が含まれるか否かを検出する。例えばマゼンタ色の色情報を有する画素が含まれる場合には、色検出部48は、マゼンタ色の色情報を有する画素を抽出する。エッジ検出部47は、撮像された画像データに対してエッジ検出を行う。評価値算出部49は、エッジ検出部48におけるエッジ検出の結果に基づいて、撮像された画像データにフレアが発生しているか否かを判定する。重み設定部50は、画像データの各画素に対して、後述するクリップ量の算出時にて用いる重みのレベルを設定する。なお、フレアの発生に起因した混色の領域と認識されるマゼンタ領域に含まれる画素に対して設定される重みのレベルと、他の領域に含まれる画素に対して設定される重みのレベルとは、異なる重みのレベルが設定される。   The flare determination unit 46 includes a color detection unit 47, an edge detection unit 48, an evaluation value determination unit 49, and a weight setting unit 50. The color detection unit 47 detects whether or not the captured image data includes pixels having magenta color information. For example, when a pixel having magenta color information is included, the color detection unit 48 extracts a pixel having magenta color information. The edge detection unit 47 performs edge detection on the captured image data. The evaluation value calculation unit 49 determines whether or not flare has occurred in the captured image data based on the result of edge detection in the edge detection unit 48. The weight setting unit 50 sets a weight level used for calculating a clip amount, which will be described later, for each pixel of the image data. The weight level set for pixels included in a magenta area recognized as a mixed color area caused by the occurrence of flare and the weight level set for pixels included in another area are: , Different weight levels are set.

次に、AF画素補間部45の作用について図5を参照しながら説明する。なお、本実施形態において、撮像用画素の各々に設置される原色透過フィルタ19がベイヤー配列のパターンであることから、図3に示す記号XのAF画素の位置には緑色(G)の撮像用画素の画素値が補間され、記号YのAF画素の画素位置には青色(B)の撮像用画素の画素値が補間される。以下の説明では、Y44の青色の撮像用画素の画素値とX45の緑色の撮像用画素の画素値とをそれぞれ補間する場合について説明する。他のAF画素における撮像用画素の画素値を補間する手順も同様である。   Next, the operation of the AF pixel interpolation unit 45 will be described with reference to FIG. In the present embodiment, since the primary color transmission filter 19 installed in each of the imaging pixels has a Bayer pattern, green (G) imaging is performed at the position of the AF pixel of symbol X shown in FIG. The pixel value of the pixel is interpolated, and the pixel value of the blue (B) imaging pixel is interpolated at the pixel position of the AF pixel of symbol Y. In the following description, a case will be described in which the pixel value of the blue imaging pixel Y44 and the pixel value of the green imaging pixel X45 are each interpolated. The procedure for interpolating the pixel values of the imaging pixels in the other AF pixels is the same.

以下、フレア判定について、図6のフローチャートに基づいて説明する。   Hereinafter, flare determination will be described based on the flowchart of FIG.

(色検出処理)
AF画素補間部45は、CPU11から出力された画像データに基づいて、色検出処理を実行する(S−1)。例えば撮像された画像データがRGB色空間で示される画像データ(RGBデータ)であれば、AF画素補間部45は、RGBデータをYCrCb色空間で示される画像データ(YCrCbデータ)に変換する。ここで、RGBデータをYCrCbデータに変換する式は、[数1]で示される。撮像された画像データがYCbCrデータであれば、[数1]で示される色空間の変換処理は省略される。
(Color detection processing)
The AF pixel interpolation unit 45 performs color detection processing based on the image data output from the CPU 11 (S-1). For example, if the captured image data is image data (RGB data) indicated in the RGB color space, the AF pixel interpolation unit 45 converts the RGB data into image data (YCrCb data) indicated in the YCrCb color space. Here, an equation for converting RGB data into YCrCb data is expressed by [Equation 1]. If the captured image data is YCbCr data, the color space conversion process represented by [Equation 1] is omitted.

Figure 2013247597

AF画素補間部45は、YCrCbデータのうち、Crデータ及びCbデータを用いて、マゼンタ色の色情報を有する画素が含まれるか否かを判定する。マゼンタ色の色情報を有する画素が含まれると判定された場合、AF画素補間部45は、マゼンタ色の色情報を有する画素の領域(マゼンタ領域)を抽出する。なお、マゼンタ領域に含まれる画素は、1画素であっても、複数の画素であってもよい。
(エッジ検出)
AF画素補間部45は、YCrCbデータのうち、Yデータを用いてエッジ検出処理を実行する(S−2)。AF画素補間部45は、[数2]を用いて隣り合う4方向のY成分の全体差分和SADを求める。
Figure 2013247597

The AF pixel interpolation unit 45 uses the Cr data and the Cb data in the YCrCb data to determine whether or not a pixel having magenta color information is included. When it is determined that a pixel having magenta color information is included, the AF pixel interpolation unit 45 extracts a pixel region (magenta region) having magenta color information. The pixels included in the magenta area may be one pixel or a plurality of pixels.
(Edge detection)
The AF pixel interpolating unit 45 executes edge detection processing using Y data among YCrCb data (S-2). The AF pixel interpolation unit 45 obtains the total difference sum SAD of the Y components in the four adjacent directions using [Expression 2].

Figure 2013247597
Figure 2013247597

AF画素補間部45は、隣り合う4方向のY成分の全体差分和SADが閾値Th1以下であるか否かを判定する。そして、隣り合う4方向のY成分の全体差分和SADが閾値Th1以下となる場合に、その画素を対象画素とする。   The AF pixel interpolation unit 45 determines whether or not the total difference sum SAD of the Y components in the four adjacent directions is equal to or less than the threshold value Th1. Then, when the total difference sum SAD of the Y components in the four adjacent directions is equal to or less than the threshold value Th1, the pixel is set as the target pixel.

なお、Yデータ全体を用いてエッジ検出処理を実行しているが、これに限定される必要はなく、色検出処理にて検出されるマゼンタ領域のYデータを用いてエッジ検出処理を行うことも可能である。ここで、エッジ検出処理は、上記の手法に限定される必要はなく、例えばSobel FilterやPrewitt Filterなどのエッジフィルタを用いることも可能である。
(フレアが発生していないか否かの判定)
Although the edge detection process is executed using the entire Y data, the present invention is not limited to this, and the edge detection process may be performed using the Y data of the magenta area detected by the color detection process. Is possible. Here, the edge detection processing need not be limited to the above-described method, and for example, an edge filter such as a Sobel Filter or a Prewitt Filter can be used.
(Determining whether flare has occurred)

AF画素補間部45は、撮像された画像データにフレアが発生していないか否かを判定する(S−3)。AF画素補間部45は、色検出処理における検出結果及びエッジ検出処理における検出結果に基づいて、対象画素の総数が閾値Th2以上となるマゼンタ領域があるか否かを判定する。上述したように、撮影時に撮像素子17の受光部周辺の画素間で配線領域からの反射光でフレアが生じると、受光部周辺でマイクロレンズ間の入射光が隣接画素へ漏れ込むクロストークにより混色が発生する。このような現象が起きると、対象となる画素及びその周辺部の画素も影響を受ける。したがって、フレアが発生した場合には、フレアの発生に起因した混色となる画素が所定数固まって存在する。このため、フレアが発生しているか否かの判定に用いる閾値Th2は、予め実験、統計などから求められる値が用いられる。   The AF pixel interpolation unit 45 determines whether or not flare has occurred in the captured image data (S-3). The AF pixel interpolation unit 45 determines whether or not there is a magenta region in which the total number of target pixels is equal to or greater than the threshold Th2, based on the detection result in the color detection process and the detection result in the edge detection process. As described above, when flare occurs in the reflected light from the wiring area between pixels around the light receiving portion of the image sensor 17 during photographing, color mixing occurs due to crosstalk in which incident light between microlenses leaks into adjacent pixels around the light receiving portion. Will occur. When such a phenomenon occurs, the target pixel and its peripheral pixels are also affected. Therefore, when flare occurs, there are a predetermined number of pixels that are mixed colors due to the occurrence of flare. For this reason, the threshold value Th2 used for determining whether or not flare has occurred is a value obtained in advance from experiments, statistics, and the like.

例えば、対象画素の画素数が閾値以上となるマゼンタ領域がない場合には、AF画素補間部45は、フレアが発生していないと判定する。この場合、AF画素補間部45は、第1画素補間処理を実行する(S−4)。なお、第1画素補間処理については、後述する。一方、対象画素の画素数が閾値以上となるマゼンタ領域があれば、AF画素補間部45は、フレアが発生していると判定する。   For example, if there is no magenta area in which the number of target pixels is equal to or greater than the threshold, the AF pixel interpolation unit 45 determines that no flare has occurred. In this case, the AF pixel interpolation unit 45 performs the first pixel interpolation process (S-4). The first pixel interpolation process will be described later. On the other hand, if there is a magenta region in which the number of target pixels is equal to or greater than the threshold, the AF pixel interpolation unit 45 determines that flare has occurred.

(重み設定)
AF画素補間部45は、フレアの発生に起因したマゼンタ領域に含まれる画素のそれぞれに対して重みのレベルを設定する(S−5)。この重みのレベルは、第2画素補間処理にて実行されるクリップ量の算出時に使用される。図7に示すように、直線L1及び直線L2で囲まれる領域が、マゼンタ色を示す色域である。このマゼンタ色を示す色域において、マゼンタ色が濃ければ濃いほど、フレアの発生に起因する混色の影響が強くなり、強度の強い補間処理を行う必要がある。また、マゼンタ色が薄ければ薄いほど、フレアの発生に起因する混色の影響が弱くなるので、強度の低い補間処理となる。このような理由により、AF画素補間部45は、フレアの発生に起因した混色の領域と認識されるマゼンタ領域に含まれる画素の色成分値(画素値)が、マゼンタ色の色域を濃淡によって区分した複数の領域のいずれかに属しているかによって重みのレベルを設定する。また、AF画素補間部45は、上述した領域以外の画素に対しては、重みのレベルを「0」とする。そして、設定された重みのレベルをまとめた重み情報を生成する。
(Weight setting)
The AF pixel interpolation unit 45 sets a weight level for each of the pixels included in the magenta area caused by the occurrence of flare (S-5). This weight level is used when calculating the clip amount executed in the second pixel interpolation process. As shown in FIG. 7, the area surrounded by the straight line L1 and the straight line L2 is a color gamut indicating a magenta color. In the color gamut indicating the magenta color, the darker the magenta color, the stronger the influence of color mixing due to the occurrence of flare, and it is necessary to perform a strong interpolation process. Further, the lighter the magenta color, the weaker the influence of the color mixture caused by the occurrence of flare, so that the interpolation process has a lower intensity. For this reason, the AF pixel interpolating unit 45 determines that the color component value (pixel value) of a pixel included in a magenta area recognized as a mixed color area caused by the occurrence of flare is a magenta color gamut based on shading. The weight level is set depending on whether it belongs to one of a plurality of divided areas. The AF pixel interpolation unit 45 sets the weight level to “0” for pixels other than the above-described region. Then, weight information in which the set weight levels are collected is generated.

なお、図7においては、マゼンタ色の色域を3個の領域に区分し、区分された領域のうち、領域55に対しては重みのレベルを「小」、領域56に対しては重みのレベルを「中」、領域57に対しては重みのレベルを「大」をそれぞれ設定した場合について説明している。この重みのレベルを設定した後、AF画素補間部45は、第2画素補間処理を実行する(S−6)。なお、マゼンタ色の色域を3個の領域に分割し、それぞれの領域に対して重みのレベルを設けているが、これに限定される必要はなく、2以上の領域に分割し、それぞれの領域に重みのレベルを設けることも可能である。   In FIG. 7, the magenta color gamut is divided into three areas, and among the divided areas, the weight level is “small” for the area 55 and the weight is set for the area 56. The case where the level is set to “medium” and the weight level is set to “large” for the region 57 is described. After setting the weight level, the AF pixel interpolation unit 45 executes a second pixel interpolation process (S-6). The magenta color gamut is divided into three areas and weight levels are provided for the respective areas. However, the present invention is not limited to this, and the magenta color gamut is divided into two or more areas. It is also possible to provide a level of weight in the region.

[第1画素補間処理]
AF画素補間部45は、フレアが発生してないと判定した場合、第2画素補間処理を選択して実行する。この第1画素補間処理は、AF画素の周辺の撮像用画素の画素値を用いて、画素値の変化率である変動値が最小となる方向を求める。そして、変動の最も小さい方向にある撮像用画素の画素値を用いてAF画素の画素値を補間する。以下、第1画素補間処理の流れを図8のフローチャートに基づいて説明する。
[First pixel interpolation processing]
When it is determined that no flare has occurred, the AF pixel interpolation unit 45 selects and executes the second pixel interpolation process. In the first pixel interpolation process, the pixel value of the imaging pixels around the AF pixel is used to determine the direction in which the variation value, which is the change rate of the pixel value, is minimized. Then, the pixel value of the AF pixel is interpolated using the pixel value of the imaging pixel in the direction of the smallest fluctuation. Hereinafter, the flow of the first pixel interpolation processing will be described based on the flowchart of FIG.

(最小となる変動値の方向を算出)
AF画素補間部45は、X45及びY44のAF画素に対する補間を行うために、X45及びY44の周辺の撮像用画素の画素値を用いて4方向の画素値の変化率である方向変動H1〜H4の値を[数3]〜[数6]を用いてそれぞれ求める(S−21)。なお、本実施形態における4方向とは、水平走査方向、垂直走査方向、水平走査方向に対して45度及び135度方向である。
(Calculate the direction of the minimum fluctuation value)
The AF pixel interpolating unit 45 uses the pixel values of the imaging pixels around X45 and Y44 to interpolate the AF pixels X45 and Y44, and direction variations H1 to H4 that are pixel value change rates in four directions. Are obtained using [Equation 3] to [Equation 6], respectively (S-21). In this embodiment, the four directions are 45 degrees and 135 degrees with respect to the horizontal scanning direction, the vertical scanning direction, and the horizontal scanning direction.

[数3]
水平走査方向の方向変動H1=
2×(|G34−G36|+|G54−G56|)+|R33−R35|+|R53−R55|+|B24−B26|+|B64−B66|
[Equation 3]
Direction variation H1 in the horizontal scanning direction =
2 × (| G34-G36 | + | G54-G56 |) + | R33-R35 | + | R53-R55 | + | B24-B26 | + | B64-B66 |

[数4]
垂直走査方向の方向変動H2=
2×(|G34−G54|+|G36−G56|)+|R33−R53|+|R35−R55|+|B24−B64|+|B26−B66|
[Equation 4]
Direction variation H2 in the vertical scanning direction =
2 × (| G34-G54 | + | G36-G56 |) + | R33-R53 | + | R35-R55 | + | B24-B64 | + | B26-B66 |

[数5]
水平走査方向に対して45度の方向変動H3=
2×(|G27−G36|+|G54−G63|)+|R35−R53|+|R37−R55|+|B26−B62|+|B28−B64|
[Equation 5]
Directional variation H3 = 45 degrees with respect to the horizontal scanning direction =
2 × (| G27-G36 | + | G54-G63 |) + | R35-R53 | + | R37-R55 | + | B26-B62 | + | B28-B64 |

[数6]
水平走査方向に対して135度の方向変動H4=
2×(|G23−G34|+|G56−G67|)+|R33−R55|+|R35−R57|+|B22−B66|+|B24−B68|
[Equation 6]
Directional change H4 = 135 degrees with respect to the horizontal scanning direction =
2 × (| G23-G34 | + | G56-G67 |) + | R33-R55 | + | R35-R57 | + | B22-B66 | + | B24-B68 |

(最小変動値の方向に応じた周辺の撮像用画素の画素値を用いてAF画素の画素値を補間)
AF画素補間部45は、ステップ(S−21)で求めた方向変動H1〜H4のうち最も小さい値の方向変動の方向を選択し、その方向にある撮像用画素の画素値を用いて、AF画素X45の位置でのGの撮像用画素の画素値GX45及びAF画素Y44の位置でのBの撮像用画素の画素値BY44を[数7]〜[数10]のうちの選択した方向に対応する式を用いて求める(S−22)。これにより、変動の小さい方向にある撮像用画素の画素値を用いることにより、より正確にX45及びY44等のAF画素に対する補間を行うことが可能となる。
(Interpolate the pixel value of the AF pixel using the pixel value of the surrounding imaging pixels according to the direction of the minimum variation value)
The AF pixel interpolation unit 45 selects the direction of the smallest direction variation among the direction variations H1 to H4 obtained in step (S-21), and uses the pixel value of the imaging pixel in that direction to perform AF. selected direction among the pixel values B Y44 imaging pixels of B at the position of the pixel values G X45 and AF pixel Y44 of imaging pixels of G at the position of the pixel X45 [Expression 7] - [number 10] (S-22). As a result, by using the pixel values of the imaging pixels in the direction of small fluctuation, it becomes possible to more accurately perform interpolation for AF pixels such as X45 and Y44.

[数7]
方向変動H1が最小の場合
Y44=(B24+B64)/2
X45=(G34+G36+G54+G56)/4
[Equation 7]
When the direction change H1 is the minimum, B Y44 = (B24 + B64) / 2
G X45 = (G34 + G36 + G54 + G56) / 4

[数8]
方向変動H2が最小の場合
Y44=(B24+B64)/2
X45=(G25+G65)/2
[Equation 8]
When the direction change H2 is the minimum B Y44 = (B24 + B64) / 2
G X45 = (G25 + G65) / 2

[数9]
方向変動H3が最小の場合
Y44=(B26+B62)/2
X45=(G36+G54)/2
[Equation 9]
When direction change H3 is the minimum, B Y44 = (B26 + B62) / 2
G X45 = (G36 + G54) / 2

[数10]
方向変動H4が最小の場合
Y44=(B22+B66)/2
X45=(G34+G56)/2
[Equation 10]
When the direction change H4 is the minimum, B Y44 = (B22 + B66) / 2
G X45 = (G34 + G56) / 2

AF画素補間部45は、AF画素の配列方向である水平走査方向において、AF画素の画素値の方向変動H5を、例えば、AF画素のY44及びX45の白色光の画素値W44及びW45と、[数11]とを用いて算出する。   The AF pixel interpolating unit 45 changes the direction variation H5 of the pixel value of the AF pixel in the horizontal scanning direction that is the arrangement direction of the AF pixels, for example, pixel values W44 and W45 of white light of Y44 and X45 of the AF pixel, and [ It is calculated using [Formula 11].

[数11]
H5=|W44−W45|
[Equation 11]
H5 = | W44-W45 |

AF画素補間部45は、その方向変動H5の値が閾値Th3を越えるか否かを判定する(S−23)。方向変動H5が閾値Th3を超える値の場合(YES側)、AF画素補間部45は、ステップ(S−22)で求めたBY44及びGX45の補間した値をY44及びX45における撮像用画素の画素値とし、画像データを更新する。画像処理部25は、更新した画像データに対して3色の画素補間を施して3色の画像データを生成し、3色の画像データを、バス13を介してSDRAM27に格納する(S−24)。 The AF pixel interpolation unit 45 determines whether or not the value of the direction variation H5 exceeds the threshold Th3 (S-23). If the directional fluctuation H5 is a value that exceeds the threshold Th3 (YES side), AF pixel interpolation unit 45, the step (S-22) at the determined B of Y44 and G X45 interpolated value of the imaging pixel in the Y44 and X45 Image data is updated using pixel values. The image processing unit 25 performs three-color pixel interpolation on the updated image data to generate three-color image data, and stores the three-color image data in the SDRAM 27 via the bus 13 (S-24). ).

一方、方向変動H5が閾値Th3以下となる場合(NO側)、画像処理部25は、(S−25)へ移行する。なお、閾値Th3は、例えば、12ビット画像を処理する場合、512程度の値にすれば良い。   On the other hand, when the direction variation H5 is equal to or less than the threshold Th3 (NO side), the image processing unit 25 proceeds to (S-25). Note that the threshold value Th3 may be a value of about 512 when processing a 12-bit image, for example.

AF画素補間部45は、ステップ(S−21)で求めた方向変動H2が閾値Th4を越えるか否かを判定する(S−25)。方向変動H2が閾値Th4を超える値の場合(YES側)、AF画素補間部45は、ステップ(S−22)で求めたBY44及びGX45の補間した値をY44及びX45における撮像用画素の画素値とし、画像データを更新する。画像処理部25は、更新した画像データに対して3色の画素補間を施して3色の画像データを生成し、3色の画像データを、バス13を介してSDRAM27に格納する(S−24)。 The AF pixel interpolation unit 45 determines whether or not the direction variation H2 obtained in step (S-21) exceeds the threshold Th4 (S-25). If the values directional fluctuation H2 is greater than the threshold value Th4 (YES side), AF pixel interpolation unit 45, the step (S-22) at the determined B of Y44 and G X45 interpolated value of the imaging pixel in the Y44 and X45 Image data is updated using pixel values. The image processing unit 25 performs three-color pixel interpolation on the updated image data to generate three-color image data, and stores the three-color image data in the SDRAM 27 via the bus 13 (S-24). ).

一方、方向変動H2が閾値Th4以下となる場合(NO側)、画像処理部25は、(S−26)へ移行する。なお、閾値Th4は、例えば、12ビット画像を処理する場合、64程度の値にすれば良い。   On the other hand, when the direction variation H2 is equal to or less than the threshold Th4 (NO side), the image processing unit 25 proceeds to (S-26). Note that the threshold Th4 may be a value of about 64 when processing a 12-bit image, for example.

その後、AF画素補間部45は、右側からの光束に感度を有するY44等のAF画素における白色光の平均画素値<W44>等を、近傍にある色成分R、G及びBの撮像用画素の画素値を用いて算出する(S−26)。具体的には、ステップ(S−21)において、例えば、画像処理部25が方向変動H2を最小であると判定した場合、Bの撮像用画素の画素値は[数8]に記載の式にあるB24とB64とを用いる。一方、R及びGの画素値については、Bの撮像用画素B24とB64との位置におけるR及びGの画素値を、[数12]に記載の4つの式を用いて補間計算する。   Thereafter, the AF pixel interpolating unit 45 calculates the average pixel value <W44> of white light in the AF pixel such as Y44 having sensitivity to the light flux from the right side, and the like for the imaging pixels of the color components R, G, and B in the vicinity. Calculation is performed using the pixel value (S-26). Specifically, in step (S-21), for example, when the image processing unit 25 determines that the direction variation H2 is the minimum, the pixel value of the B imaging pixel is expressed by the equation described in [Equation 8]. Some B24 and B64 are used. On the other hand, for the R and G pixel values, the R and G pixel values at the positions of the B imaging pixels B24 and B64 are interpolated using the four equations described in [Equation 12].

[数12]
(1)RB24=(R13+R15+R33+R35)/4
(2)GB24=(G14+G23+G25+G34)/4
(3)RB64=(R53+R55+R73+R75)/4
(4)GB64=(G54+G63+G65+G74)/4
[Equation 12]
(1) R B24 = (R13 + R15 + R33 + R35) / 4
(2) G B24 = (G14 + G23 + G25 + G34) / 4
(3) R B64 = (R53 + R55 + R73 + R75) / 4
(4) G B64 = (G54 + G63 + G65 + G74) / 4

そして、AF画素補間部45は、撮像用画素B24及びB64の位置における白色光の画素値W24及びW64を、CPU11から転送されてきたR、G及びBの加重係数WR、WG及びWBを用いて、[数13]に記載の式の加重和によって算出する。なお、加重係数WR、WG及びWBの求め方については後述する。   Then, the AF pixel interpolating unit 45 uses the white light pixel values W24 and W64 at the positions of the imaging pixels B24 and B64 by using the R, G, and B weighting factors WR, WG, and WB transferred from the CPU 11. , [Equation 13]. Note that how to obtain the weighting factors WR, WG and WB will be described later.

[数13]
W24=WR×RB24+WG×GB24+WB×B24
W64=WR×RB64+WG×GB64+WB×B64
そして、画像処理部25は、Y44における白色光の平均画素値<W44>=(W24+W64)/2を算出する。
[Equation 13]
W24 = WR × R B24 + WG × G B24 + WB × B24
W64 = WR × R B64 + WG × G B64 + WB × B64
Then, the image processing unit 25 calculates the average pixel value <W44> = (W24 + W64) / 2 of white light in Y44.

AF画素補間部45は、左側からの光束に感度を有するX45等のAF画素における白色光の平均画素値<W45>等を、ステップ(S−26)の場合と同様に、近傍にある色成分R、G及びBの撮像用画素の画素値を用いて算出する(S−27)。ステップ(S−21)において、画像処理部25が方向変動H2を最小であると判定した場合、Gの撮像用画素の画素値は、[数8]に記載の式にあるG25とG65とを用いる。一方、R及びBの画素値については、Gの撮像用画素G25とG65との位置におけるR及びBの画素値を[数14]に記載の4つの式を用いて補間計算する。   The AF pixel interpolating unit 45 calculates the average pixel value <W45> of white light in the AF pixel such as X45 having sensitivity to the light beam from the left side, as in the case of step (S-26), and the adjacent color components. Calculation is performed using the pixel values of the R, G, and B imaging pixels (S-27). In step (S-21), when the image processing unit 25 determines that the direction variation H2 is the minimum, the pixel value of the G imaging pixel is expressed by G25 and G65 in the equation described in [Equation 8]. Use. On the other hand, for the R and B pixel values, the R and B pixel values at the positions of the G imaging pixels G25 and G65 are interpolated using the four equations described in [Equation 14].

[数14]
(1)RG25=(R15+R35)/2
(2)BG25=(B24+B26)/2
(3)RG65=(R55+R75)/2
(4)BG65=(B64+G66)/2
[Formula 14]
(1) R G25 = (R15 + R35) / 2
(2) B G25 = (B24 + B26) / 2
(3) R G65 = (R55 + R75) / 2
(4) B G65 = (B64 + G66) / 2

そして、AF画素補間部45は、撮像用画素G25及びG65の位置における白色光の画素値W25及びW65を、[数15]に記載の式の加重和によって算出する。   Then, the AF pixel interpolation unit 45 calculates the pixel values W25 and W65 of white light at the positions of the imaging pixels G25 and G65 by using the weighted sum of the formula described in [Equation 15].

[数15]
W25=WR×RG25+WG×G25+WB×BG25
W65=WR×RG64+WG×G25+WB×BG65
そして、画像処理部25は、X45における白色光の平均画素値<W45>=(W25+W65)/2を算出する。
[Equation 15]
W25 = WR × R G25 + WG × G25 + WB × B G25
W65 = WR × R G64 + WG × G25 + WB × B G65
Then, the image processing unit 25 calculates the average pixel value <W45> = (W25 + W65) / 2 of white light at X45.

AF画素補間部45は、撮像素子17の各AF画素における白色光の画素値の高周波成分を、(S−26)及び(S−27)において求めた白色光の平均画素値を用いて求める(S−28)。AF画素補間部45は、撮像素子17の各AF画素の画素値から、各AF画素の画素位置における白色光の平均画素値を最初に求める。つまり、各AF画素の画素値は、左側又は右側からの光束を瞳分割した値である。したがって、各AF画素の位置における白色光の画素値を得るためには、左側及び右側からの光束の画素値を互いに加算する必要がある。そこで、本実施形態のAF画素補間部45は、各AF画素の画素値及び隣接するAF画素の画素値を用いて、例えば、AF画素Y44やX45の位置における白色光の平均画素値を[数16]に記載の式を用いて算出する。   The AF pixel interpolation unit 45 obtains the high-frequency component of the pixel value of white light in each AF pixel of the image sensor 17 using the average pixel value of white light obtained in (S-26) and (S-27) ( S-28). The AF pixel interpolation unit 45 first obtains an average pixel value of white light at the pixel position of each AF pixel from the pixel value of each AF pixel of the image sensor 17. That is, the pixel value of each AF pixel is a value obtained by dividing the light flux from the left side or the right side into pupils. Therefore, in order to obtain the pixel value of the white light at the position of each AF pixel, it is necessary to add the pixel values of the light beams from the left side and the right side to each other. Therefore, the AF pixel interpolation unit 45 of the present embodiment uses the pixel value of each AF pixel and the pixel value of the adjacent AF pixel, for example, to calculate the average pixel value of white light at the position of the AF pixel Y44 or X45 [several 16].

[数16]
<W44>’=W44+(W43+W45)/2
<W45>’=W45+(W44+W46)/2
[Equation 16]
<W44>'= W44 + (W43 + W45) / 2
<W45>'= W45 + (W44 + W46) / 2

なお、ステップ(S−27)で説明した[数16]において、AF画素の配列方向に隣接するAF画素の画素値を用いて、各AF画素の位置における白色光の画素値を算出するので、配列方向に強い変動がある場合には、高周波成分の計算が不正確になり、白色光の画素値の配列方向の解像力が失われるおそれがある。そこで、前述したステップ(S−23)では、配列方向に強い変動がある場合に、高周波成分の付加を中止するようにしている。   In [Expression 16] described in step (S-27), the pixel value of the white light at the position of each AF pixel is calculated using the pixel value of the AF pixel adjacent in the AF pixel arrangement direction. When there is a strong variation in the arrangement direction, the calculation of the high frequency component becomes inaccurate, and the resolution of the white light pixel values in the arrangement direction may be lost. Therefore, in the above-described step (S-23), when there is a strong variation in the arrangement direction, the addition of the high frequency component is stopped.

その後、AF画素補間部45は、[数17]に記載の式から、Y44及びX45の位置における白色光の高周波成分HFY44及びHFX45を求める。 Thereafter, the AF pixel interpolation unit 45 obtains high-frequency components HF Y44 and HF X45 of white light at the positions of Y44 and X45 from the equation described in [Equation 17].

[数17]
HFY44=<W44>’−<W44>
HFX45=<W45>’−<W45>
[Equation 17]
HF Y44 = <W44>'-<W44>
HF X45 = <W45>'-<W45>

AF画素補間部45は、ステップ(S−28)で求めた各AF画素の位置における白色光の画素値の高周波成分HFがその白色光の画素値に占める割合が、閾値Th5(本実施形態では、例えば、10%程度)より小さいか否かを判定する(S−29)。閾値Th5より高周波成分HFが小さい場合(YES側)、AF画素補間部45は、ステップS26で求めたBY44及びGX45の補間した値をY44及びX45における撮像用画素の画素値とし、画像データを更新する。画像処理部25は、更新した画像データに対して3色の画素補間を施して3色の画像データを生成し、3色の画像データを、バス13介してSDRAM27に格納する(S−24)。 The AF pixel interpolating unit 45 determines that the ratio of the high-frequency component HF of the white light pixel value at the position of each AF pixel obtained in step (S-28) to the white light pixel value is the threshold Th5 (in this embodiment). For example, about 10%) is determined (S-29). If the threshold Th5 high-frequency component HF is smaller (YES side), AF pixel interpolation unit 45 the interpolated values of B Y44 and G X45 calculated in step S26 as the pixel values of the image pickup pixels in the Y44 and X45, the image data Update. The image processing unit 25 performs three-color pixel interpolation on the updated image data to generate three-color image data, and stores the three-color image data in the SDRAM 27 via the bus 13 (S-24). .

一方、高周波成分HFが閾値Th5を超過する場合(NO側)、AF画素補間部45は、ステップ(S−30)へ移行する。なお、閾値Th5の値についての説明は、後の加重係数WR、WG及びWBの説明とともに行う。   On the other hand, when the high frequency component HF exceeds the threshold Th5 (NO side), the AF pixel interpolating unit 45 proceeds to step (S-30). Note that the value of the threshold Th5 will be described together with the description of the weighting factors WR, WG, and WB later.

AF画素補間部45は、Y44やX45の近傍における各色成分R、G又はBの撮像用画素の画素値の色変動VR、VGr、VB及びVGbを算出する(S−30)。ここで、色変動VGr及びVGbは、R又はBの撮像用画素の位置におけるGの色変動を示す。AF画素補間部45は、[数18]に記載の2つの式に基づいて、色変動VRとVGrとを求める。   The AF pixel interpolation unit 45 calculates the color variations VR, VGr, VB, and VGb of the pixel values of the image pickup pixels of the respective color components R, G, or B in the vicinity of Y44 and X45 (S-30). Here, the color variations VGr and VGb indicate the G color variation at the position of the R or B imaging pixel. The AF pixel interpolation unit 45 obtains the color fluctuations VR and VGr based on the two equations described in [Equation 18].

[数18]
(1)VR=|R33−R53|+|R35−R55|+|R37−R57|
(2)VGr=|(G32+G34)/2−(G52+G54)/2|+|(G34+G36)/2−(G54+G56)/2|+|(G36+G38)/2−(G56+G58)/2|
[Equation 18]
(1) VR = | R33-R53 | + | R35-R55 | + | R37-R57 |
(2) VGr = | (G32 + G34) / 2− (G52 + G54) / 2 | + | (G34 + G36) / 2− (G54 + G56) / 2 | + | (G36 + G38) / 2− (G56 + G58) / 2 |

なお、本実施形態のAF画素補間部45は、Rの撮像用画素の位置R33、R35、R37、R53、R55及びR57におけるGの画素値の平均値を求めてからVGrの値を計算する。   Note that the AF pixel interpolation unit 45 of the present embodiment calculates the value of VGr after obtaining the average value of the G pixel values at the R imaging pixel positions R33, R35, R37, R53, R55, and R57.

一方、AF画素補間部45は、[数19]に記載の2つの式に基づいて、色変動VBとVGbとを求める。   On the other hand, the AF pixel interpolation unit 45 obtains the color fluctuations VB and VGb based on the two equations described in [Equation 19].

[数19]
(1)VB=|B22−B62|+|B24−B64|+|B26−B66|
(2)VGb=|(G21+G23)/2−(G61+G63)/2|+|(G23+G25)/2−(G63+G65)/2|+|(G25+G27)/2−(G65+G67)/2|
[Equation 19]
(1) VB = | B22−B62 | + | B24−B64 | + | B26−B66 |
(2) VGb = | (G21 + G23) / 2− (G61 + G63) / 2 | + | (G23 + G25) / 2− (G63 + G65) / 2 | + | (G25 + G27) / 2− (G65 + G67) / 2 |

なお、本実施形態のAF画素補間部45は、Bの撮像用画素の位置B22、B24、B26、B62、B64及びB66におけるGの画素値の平均値を求めてからVGbの値を計算する。   Note that the AF pixel interpolation unit 45 of the present embodiment calculates the value of VGb after obtaining the average value of the G pixel values at the positions B22, B24, B26, B62, B64, and B66 of the B imaging pixels.

AF画素補間部45は、ステップ(S−30)で算出した色変動VR、VGr、VB及びVGbを用いて、色成分G及びBの白色光に対する色変動率KWG及びKWBを算出する(S−31)。まず、AF画素補間部45は、色変動VR、VGr、VB及びVGbから[数20]に記載の3つの式から色変動VR2、VG2及びVB2を求める。   The AF pixel interpolation unit 45 calculates the color variation rates KWG and KWB for the white light of the color components G and B using the color variations VR, VGr, VB, and VGb calculated in step (S-30) (S- 31). First, the AF pixel interpolation unit 45 obtains the color variations VR2, VG2, and VB2 from the three formulas described in [Equation 20] from the color variations VR, VGr, VB, and VGb.

[数20]
(1)VR2=(VR+α)×(VGb+α)
(2)VB2=(VB+α)×(VGr+α)
(3)VG2=(VGb+α)×(VGr+α)
[Equation 20]
(1) VR2 = (VR + α) × (VGb + α)
(2) VB2 = (VB + α) × (VGr + α)
(3) VG2 = (VGb + α) × (VGr + α)

ここで、αは、色変動率の値を安定させるための適当な定数であり、例えば、12ビット画像を処理する場合には、α=256程度の値にすれば良い。   Here, α is an appropriate constant for stabilizing the value of the color variation rate. For example, when processing a 12-bit image, α may be set to about 256.

そして、画像処理部25は、色変動VR2、VG2及びVB2を用いて、[数21]に記載の式により白色光における色変動VWを算出する。   Then, the image processing unit 25 calculates the color variation VW in white light using the color variations VR2, VG2, and VB2 according to the equation described in [Equation 21].

[数21]
VW=VR2+VG2+VB2
よって、AF画素補間部45は、色変動率KWG及びKWBを[数22]から算出する。
[Equation 21]
VW = VR2 + VG2 + VB2
Therefore, the AF pixel interpolation unit 45 calculates the color variation rates K WG and K WB from [Equation 22].

[数22]
WB=VG2/VW
WB=VB2/VW
[Equation 22]
K WB = VG2 / VW
K WB = VB2 / VW

AF画素補間部45は、ステップ(S−28)において求めた各AF画素の位置における白色光の画素値の高周波成分HFと、ステップ(S−31)で算出した色変動率KWG及びKWBとを用いて、各AF画素の位置における色成分G及びBの画素値の高周波成分を[数23]に記載の式から算出する(S−32)。 The AF pixel interpolation unit 45 uses the high-frequency component HF of the white light pixel value at the position of each AF pixel obtained in step (S-28), and the color variation rates K WG and K WB calculated in step (S-31). Are used to calculate the high-frequency components of the pixel values of the color components G and B at the position of each AF pixel from the equation described in [Equation 23] (S-32).

[数23]
HFBY44=HFY44×KWB
HFGX45=HFX45×KWG
[Equation 23]
HFB Y44 = HF Y44 × K WB
HFG X45 = HF X45 × K WG

AF画素補間部45は、ステップ(S−32)で求めた各AF画素における各色成分の高周波成分を、ステップ(S−22)で補間して求めた撮像用画素の画素値に付加する(S−18)。CPU11は、例えば、[数24]に記載の式に基づいて、Y44及びX45の撮像用画素値B’及びG’をそれぞれ算出する。   The AF pixel interpolation unit 45 adds the high-frequency component of each color component in each AF pixel obtained in step (S-32) to the pixel value of the imaging pixel obtained by interpolation in step (S-22) (S -18). For example, the CPU 11 calculates the imaging pixel values B ′ and G ′ for Y44 and X45 based on the equation described in [Equation 24], respectively.

[数24]
B’Y44=BY44+HFBY44
G’X45=GX45+HFGX45
[Equation 24]
B ′ Y44 = B Y44 + HFB Y44
G ′ X45 = G X45 + HFG X45

AF画素補間部45は、Y44やX45等のAF画素の位置において補間して求めたB’Y44及びG’X45等の画素値を、それぞれの位置における撮像用画素の画素値として、画像データを更新する。画像処理部25は、更新した画像データに対して1画素当たり3色の画像データに変換してSDRAM27に格納する(S−24)。 The AF pixel interpolating unit 45 uses the pixel values such as B ′ Y44 and G ′ X45 obtained by interpolation at the positions of AF pixels such as Y44 and X45 as the pixel values of the imaging pixels at the respective positions. Update. The image processing unit 25 converts the updated image data into image data of three colors per pixel and stores it in the SDRAM 27 (S-24).

なお、AF画素の配列方向に変動はなくても、各色成分の撮像用画素の分光特性の加重和とAF画素の分光特性とのズレ等に起因して、白色光の画素値の高周波成分が若干の誤差を持つ。垂直走査方向(AF画素の配列方向に交わる方向)に画像の大きな変動がない場合には、高周波成分を付加しなくても補間値の精度は充分であり、高周波成分を付加することによってかえって誤差に起因する偽構造が生じる恐れがある。そこで、ステップ(S−25)では、そのような場合、高周波成分の付加を抑制する。また、算出された高周波成分が充分小さい場合には、それを付加しなくても補間値の精度は充分であり、高周波成分を付加することによってかえって誤差に起因する偽構造が生じるおそれがある。このため、(S−25)では、そのような場合に高周波成分の付加を抑制するようにしている。   Even if there is no change in the arrangement direction of the AF pixels, the high-frequency component of the pixel value of the white light is caused by the deviation between the weighted sum of the spectral characteristics of the imaging pixels of each color component and the spectral characteristics of the AF pixels. Has a slight error. When there is no large fluctuation of the image in the vertical scanning direction (direction intersecting the AF pixel arrangement direction), the accuracy of the interpolation value is sufficient without adding a high-frequency component. There is a risk that a false structure resulting from Therefore, in step (S-25), in such a case, addition of a high frequency component is suppressed. In addition, when the calculated high frequency component is sufficiently small, the accuracy of the interpolation value is sufficient even if it is not added, and there is a possibility that a false structure due to an error may be caused by adding the high frequency component. For this reason, in (S-25), addition of a high frequency component is suppressed in such a case.

次に、加重係数WR、WG及びWBの求め方について、閾値Th5とともに説明する。そうした加重係数や閾値を求めるにあたり、製品に組み込まれる撮像素子17又はその撮像素子2と同じ性能を持つ撮像素子を用意する。その撮像素子17にほぼ一様な照度の照明を、波長帯域を様々に変えて照射し、それぞれの波長帯域についての撮像画像データを取得する。そして、各波長帯域の撮像画像データnについて、[数16]に記載の式のように瞳分割の異なるAF画素の画素値を加算することにより白色光の画素値Wnを算出する。同時に、AF画素の近傍にある各色成分の撮像用画素の画素値Rn、Gn、Bnについても抽出する。   Next, how to obtain the weighting factors WR, WG and WB will be described together with the threshold value Th5. In obtaining such weighting factors and threshold values, an image sensor 17 having the same performance as the image sensor 17 incorporated in the product or the image sensor 2 is prepared. The imaging element 17 is irradiated with illumination with substantially uniform illuminance while changing the wavelength band in various ways, and captured image data for each wavelength band is acquired. Then, for the captured image data n in each wavelength band, the pixel value Wn of white light is calculated by adding the pixel values of AF pixels with different pupil divisions as in the equation described in [Equation 16]. At the same time, the pixel values Rn, Gn, and Bn of the image pickup pixels of the respective color components in the vicinity of the AF pixel are also extracted.

そして、未知の加重係数WR、WG及びWBの関数として二乗誤差Eを[数25]のように定義する。   Then, a square error E is defined as a function of unknown weighting factors WR, WG and WB as shown in [Equation 25].

[数25]
E=Σn(WR×Rn+WG×Gn+WB×Bn−Wn)
[Equation 25]
E = Σn (WR × Rn + WG × Gn + WB × Bn−Wn) 2

そして、Eを最小とする加重係数WR、WG及びWBを求める(EをWR、WG又はWBでそれぞれ偏微分した値を0にする加重係数WR、WG及びWBを求める)。このようにして、加重係数WR、WG及びWBを求めることにより、AF画素の分光特性を各色成分R、G及びBの撮像用画素の分光特性の加重和によって表される加重係数が求められる。このように求めた加重係数WR、WG及びWBを電子カメラ10の不揮発性メモリに記録する。   Then, weighting coefficients WR, WG, and WB that minimize E are obtained (weighting coefficients WR, WG, and WB that obtain a value obtained by partially differentiating E from WR, WG, or WB are set to 0). In this way, by obtaining the weighting factors WR, WG, and WB, a weighting factor that represents the spectral characteristic of the AF pixel by the weighted sum of the spectral characteristics of the imaging pixels of the respective color components R, G, and B is obtained. The weighting factors WR, WG and WB thus obtained are recorded in the nonvolatile memory of the electronic camera 10.

さらに、求めた加重係数WR、WG及びWBにもとづいて各撮像画像データnについて誤差率Knを[数26]に記載の式で求める。   Further, an error rate Kn is obtained for each captured image data n based on the obtained weighting factors WR, WG, and WB by the equation described in [Equation 26].

[数26]
Kn=|WR×Rn+WG×Gn+WB×Bn−Wn|/Wn
[Equation 26]
Kn = | WR × Rn + WG × Gn + WB × Bn−Wn | / Wn

そして、Knの最大値を求め、閾値Th5として不揮発性メモリ12に記録する。   Then, the maximum value of Kn is obtained and recorded in the nonvolatile memory 12 as the threshold Th5.

図9は、本実施形態の効果が発揮される画像構造の一例を表す。図13は凸構造(明るい線あるいは点)を含む縦5画素の画像構造を縦断した図であり、横軸は垂直走査方向(y座標)であり縦軸は光量または画素値である。そして、凸構造がちょうど水平走査方向に配列されたAF画素列上にある。   FIG. 9 shows an example of an image structure in which the effect of this embodiment is exhibited. FIG. 13 is a diagram in which an image structure of five vertical pixels including a convex structure (bright lines or dots) is vertically cut, the horizontal axis is the vertical scanning direction (y coordinate), and the vertical axis is the light quantity or the pixel value. The convex structure is just on the AF pixel row arranged in the horizontal scanning direction.

図9の○印は、Gの撮像用画素で撮像された画素値である。ただし、AF画素の位置にはGの撮像用画素が存在しないので、その位置でのGの画素値は得られない。従って、丁度AF画素の位置に凸構造がある場合には、AF画素の近傍のGの撮像用画素の画素値からだけでは、図13の凸構造を再現できない。実際、(S−22)において、AF画素の近傍のGの撮像用画素の画素値を用いてAF画素の位置で補間して求めたGの画素値(図9の●印)は、凸構造を再現していない。   The circles in FIG. 9 are pixel values captured by the G imaging pixels. However, since there is no G imaging pixel at the position of the AF pixel, the G pixel value at that position cannot be obtained. Therefore, when there is a convex structure at the position of the AF pixel, the convex structure in FIG. 13 cannot be reproduced only from the pixel values of the G imaging pixels in the vicinity of the AF pixel. In fact, in (S-22), the G pixel value (marked with ● in FIG. 9) obtained by interpolation at the position of the AF pixel using the pixel value of the G imaging pixel in the vicinity of the AF pixel is a convex structure. Is not reproduced.

一方、AF画素の位置では、白色光の画素値が得られる。ただし、通常の画素は瞳の全領域を通過する光を受光するのに対し、AF画素は瞳の右側あるいは左側を通過する光のみを受光するので、瞳分割の異なる隣接するAF画素を加算することにより通常の(瞳の全領域を通過した光の)白色光の画素値が算出される([数16])。   On the other hand, the pixel value of white light is obtained at the position of the AF pixel. However, normal pixels receive light that passes through the entire pupil region, whereas AF pixels receive only light that passes through the right or left side of the pupil, so adjacent AF pixels with different pupil divisions are added. Thus, the pixel value of the normal white light (of the light that has passed through the entire area of the pupil) is calculated ([Equation 16]).

また、AF画素の近傍のGの撮像用画素の位置に、他の色成分R及びBを補間生成して、色成分R、G及びBの加重和を求めることにより、多くの場合には充分な精度で白色光の画素値を求めることができる([数13]及び[数15])。   In addition, it is sufficient in many cases by interpolating and generating other color components R and B at the position of the G imaging pixel in the vicinity of the AF pixel to obtain a weighted sum of the color components R, G and B. The pixel value of white light can be obtained with high accuracy ([Equation 13] and [Equation 15]).

図9の□印は、そのようにして求めた白色光の画素値の分布である。多くの場合、白色光の画素値の高周波成分と、色成分Gの画素値の高周波成分とは比例するので、白色光の画素値から算出した高周波成分は、Gの画素値の凸構造成分の情報を持つ。よって、白色光の画素値の高周波成分に基づいてGの画素値の高周波成分を求め、その値を●印のデータに加えることにより、☆印のGの画素値が得られ、凸構造を再現する([数23])。   The squares in FIG. 9 are the distribution of pixel values of white light determined in this way. In many cases, since the high-frequency component of the white light pixel value is proportional to the high-frequency component of the color component G pixel value, the high-frequency component calculated from the white light pixel value is the convex structure component of the G pixel value. Have information. Therefore, the high-frequency component of the G pixel value is obtained based on the high-frequency component of the white light pixel value, and the value is added to the data of the ● mark to obtain the G pixel value of the ☆ mark and reproduce the convex structure ([Equation 23]).

[第2画素補間処理]
AF画素補間部45は、フレアが発生していると判定される場合、第2画素補間処理を選択して実行する。第2画素補間処理は、AF画素の周囲の撮像用画素の画素値を重み係数により補正し、補正した撮像用画素の画素値を平滑化する処理を行った後、上述した第1画素補間処理を実行する処理である。以下、図3のAF画素X43及びAF画素Y44の2列に対する第2画素補間処理について説明する。以下、第1画素補間処理の流れを図10のフローチャートに基づいて説明する。
[Second pixel interpolation processing]
When it is determined that the flare has occurred, the AF pixel interpolation unit 45 selects and executes the second pixel interpolation process. In the second pixel interpolation process, the pixel value of the imaging pixels around the AF pixel is corrected by the weighting coefficient, and the pixel value of the corrected imaging pixel is smoothed, and then the first pixel interpolation process described above is performed. Is a process of executing. Hereinafter, the second pixel interpolation process for the two columns of the AF pixel X43 and the AF pixel Y44 in FIG. 3 will be described. Hereinafter, the flow of the first pixel interpolation process will be described based on the flowchart of FIG.

(AF画素列の周囲の撮像用画素の画素値を重み係数により補正)
AF画素補間部45は、AF画素列の周囲に配置された撮像用画素の画素値が、閾値MAX_RAW以上となるか否かを判定し、その判定結果に基づいて、設定された重み係数を用いて補正する(S−41)。ここで、閾値MAX_RAWは、画素値が飽和しているか否かを判定するための閾値である。
(The pixel values of the imaging pixels around the AF pixel row are corrected by the weighting coefficient)
The AF pixel interpolation unit 45 determines whether or not the pixel value of the imaging pixels arranged around the AF pixel row is equal to or greater than the threshold value MAX_RAW, and uses the set weight coefficient based on the determination result. (S-41). Here, the threshold value MAX_RAW is a threshold value for determining whether or not the pixel value is saturated.

AF画素補間部45は、撮像用画素の画素値が閾値MAX_RAW以上となる場合には、撮像用画素の画素値に対して補正は行わない。一方、AF画素補間部45は、撮像用画素の画素値が、閾値MAX_RAW未満となる場合には、重み係数を用いた加重和の値を元の画素値から減算することで撮像用画素の画素値を補正する。   The AF pixel interpolation unit 45 does not correct the pixel value of the imaging pixel when the pixel value of the imaging pixel is equal to or greater than the threshold value MAX_RAW. On the other hand, when the pixel value of the imaging pixel is less than the threshold value MAX_RAW, the AF pixel interpolating unit 45 subtracts the weighted sum value using the weighting coefficient from the original pixel value to obtain the pixel of the imaging pixel. Correct the value.

AF画素補間部45は、R色成分の撮像用画素の画素値を[数27]〜[数30]を用いて補正する。   The AF pixel interpolating unit 45 corrects the pixel value of the R color component imaging pixel using [Equation 27] to [Equation 30].

[数27]
R13’=R13−(R3U_0×R33+R3U_1×G34+R3U_2×B24)
[Equation 27]
R13 ′ = R13− (R3U — 0 × R33 + R3U — 1 × G34 + R3U — 2 × B24)

[数28]
R33’=R33−(R1U_0×R33+R1U_1×G34+R1U_2×B24)
[Equation 28]
R33 ′ = R33− (R1U — 0 × R33 + R1U_1 × G34 + R1U_2 × B24)

[数29]
R53’=R53−(R1S_0×R53+R1S_1×G54+R1S_2×B64)
[Equation 29]
R53 ′ = R53− (R1S_0 × R53 + R1S_1 × G54 + R1S_2 × B64)

[数30]
R73’=R73−(R3S_0×R53+R3S_1×G54+R3S_2×B64)
[Equation 30]
R73 ′ = R73− (R3S — 0 × R53 + R3S — 1 × G54 + R3S — 2 × B64)

ここで、R1U_0,R1U_1,R1U_2,R1S_0,R1S_1,R1S_2,R3U_0,R3U_1,R3U_2,R3S_0,R3S_1,R3S_2は、重み係数である。なお、重み係数中、文字Sは、AF画素よりも上方に位置することを示し、文字Uは、AF画素よりも下方に位置することを示している。   Here, R1U_0, R1U_1, R1U_2, R1S_0, R1S_1, R1S_2, R3U_0, R3U_1, R3U_2, R3S_0, R3S_1, and R3S_2 are weighting coefficients. In the weighting factor, the character S indicates that it is positioned above the AF pixel, and the character U indicates that it is positioned below the AF pixel.

AF画素補間部45は、G色成分の撮像用画素の画素値を[数31]〜[数36]を用いて補正する。   The AF pixel interpolating unit 45 corrects the pixel values of the G color component imaging pixels using [Equation 31] to [Equation 36].

[数31]
G14’=G14−(G3U_0×R33+G3U_1×G34+G3U_2×B24)
[Equation 31]
G14 ′ = G14− (G3U_0 × R33 + G3U_1 × G34 + G3U_2 × B24)

[数32]
G23’=G23−(G2U_0×R33+G2U_1×G34+G2U_2×B24)
[Formula 32]
G23 ′ = G23− (G2U — 0 × R33 + G2U_1 × G34 + G2U_2 × B24)

[数33]
G34’=G34−(G1U_0×R33+G1U_1×G34+G1U_2×B24)
[Equation 33]
G34 ′ = G34− (G1U — 0 × R33 + G1U_1 × G34 + G1U_2 × B24)

[数34]
G54’=G54−(G1S_0×R53+G1S_1×G54+G1S_2×B64)
[Formula 34]
G54 ′ = G54− (G1S_0 × R53 + G1S_1 × G54 + G1S_2 × B64)

[数35]
G63’=G63−(G2S_0×R53+G2S_1×G54+G2S_2×B64)
[Equation 35]
G63 ′ = G63− (G2S — 0 × R53 + G2S_1 × G54 + G2S_2 × B64)

[数36]
G74’=G74−(G3S_0×R53+G3S_1×G54+G3S_2×B64)
[Equation 36]
G74 ′ = G74− (G3S_0 × R53 + G3S_1 × G54 + G3S_2 × B64)

ここで、G1U_0,G1U_1,G1U_2,G1S_0,G1S_1,G1S_2,G2U_0,G2U_1,G2U_2,G2S_0,G2S_1,G2S_2,G3U_0,G3U_1,G3U_2,G3S_0,G3S_1,G3S_2は、重み係数である。   Here, G1U_0, G1U_1, G1U_2, G1S_0, G1S_1, G1S_2, G2U_0, G2U_1, G2U_2, G2S_0, G2S_1, G2S_2, G3U_0, G3U_1, G3U_2, G3S_1, G3S_1, G3S_1, and G3S_1 are weights.

また、AF画素補間部45は、B色成分の撮像用画素の画素値を、[数37],[数38]を用いて補正する。   Further, the AF pixel interpolation unit 45 corrects the pixel value of the image pickup pixel of the B color component using [Equation 37] and [Equation 38].

[数37]
B24’=B24−(B2U_0×R33+B2U_1×G34+B2U_2×B24)
[Equation 37]
B24 ′ = B24− (B2U — 0 × R33 + B2U_1 × G34 + B2U_2 × B24)

[数38]
B64’=B64−(B2S_0×R53+B2S_1×G54+B2S_2×B64)
[Equation 38]
B64 ′ = B64− (B2S_0 × R53 + B2S_1 × G54 + B2S_2 × B64)

ここで、B2U_0,B2U_1,B2U_2,B2S_0,B2S_1,B2S_2は重み係数である。   Here, B2U_0, B2U_1, B2U_2, B2S_0, B2S_1, and B2S_2 are weighting coefficients.

(隣接するAF画素の画素値を用いたクリップ量の算出)
AF画素補間部45は、隣接するAF画素の画素値X43,Y44を読み出し、[数39]を用いてクリップ量Th_LPFを求める(S−42)。
(Calculation of clip amount using pixel values of adjacent AF pixels)
The AF pixel interpolation unit 45 reads the pixel values X43 and Y44 of the adjacent AF pixels, and obtains the clip amount Th_LPF using [Equation 39] (S-42).

[数39]
Th_LPF=(X43+Y44)×K_Th_LPF
[Equation 39]
Th_LPF = (X43 + Y44) × K_Th_LPF

ここで、K_Th_LPFは係数である。この係数K_Th_LPFは、その値が大きいほど平滑化処理の効果が高く、つまり、平滑化処理の強度が強くなる。   Here, K_Th_LPF is a coefficient. As the coefficient K_Th_LPF is larger, the effect of the smoothing process is higher, that is, the strength of the smoothing process is increased.

上述したフレア判定において、フレアが発生していると判定された場合には、重み情報が生成されている。AF画素補間部45は、重み情報に基づいて、係数K_Th_LPFの値を設定する。例えば重みのレベルが「0」となる場合には、AF画素補間部45は、係数K_Th_LPF=5に設定する。また、重みのレベルが「小」となる場合には、AF画素補間部45は、係数K_Th_LPF=20に設定する。また、重みのレベルが「中」となる場合には、AF画素補間部45は、係数K_Th_LPF=70に設定する。重みのレベルが「大」となる場合には、AF画素補間部45は、係数K_Th_LPF=128に設定する。このように、係数K_Th_LPFの値を重みのレベルに応じて変化させることで平滑化処理の効果を変更している。   In the flare determination described above, when it is determined that a flare has occurred, weight information is generated. The AF pixel interpolation unit 45 sets the value of the coefficient K_Th_LPF based on the weight information. For example, when the weight level is “0”, the AF pixel interpolation unit 45 sets the coefficient K_Th_LPF = 5. When the weight level is “small”, the AF pixel interpolating unit 45 sets the coefficient K_Th_LPF = 20. When the weight level is “medium”, the AF pixel interpolation unit 45 sets the coefficient K_Th_LPF = 70. When the weight level is “large”, the AF pixel interpolating unit 45 sets the coefficient K_Th_LPF = 128. As described above, the effect of the smoothing process is changed by changing the value of the coefficient K_Th_LPF in accordance with the weight level.

(色成分毎の予測誤差を算出)
AF画素補間部45は、[数40]、[数41]を用いて、同一列に配置された同一の色成分となる撮像用画素のうち、AF画素41から遠い位置にある撮像用画素(遠位撮像用画素)の画素値と、AF画素41から近い位置にある撮像用画素(近位撮像用画素)の画素値との差分を予測誤差として算出する(S−43)。
(Calculate prediction error for each color component)
The AF pixel interpolation unit 45 uses [Equation 40] and [Equation 41], and among the imaging pixels having the same color component arranged in the same column, the imaging pixels (far from the AF pixel 41 ( The difference between the pixel value of the distal imaging pixel) and the pixel value of the imaging pixel (proximal imaging pixel) located near the AF pixel 41 is calculated as a prediction error (S-43).

[数40]
deltaRU=R13’−R33’
deltaRS=R73’−R53’
[Equation 40]
deltaRU = R13′−R33 ′
deltaRS = R73′−R53 ′

[数41]
deltaGU=G14’−G34’
deltaGS=G74’−R54’
[Equation 41]
deltaGU = G14'-G34 '
deltaGS = G74'-R54 '

(予測誤差がクリップ範囲から越えているか否かを判定)
AF画素補間部45は、[数40]、[数41]により求めた予測誤差deltaRU,deltaRS、deltaGU及びdeltaGSの各値が、[数39]にて求めたクリップ量に基づいたクリップ範囲(−Th_LPF〜Th_LPF)に含まれている否かを判定する(S−44)。
(Determines whether the prediction error exceeds the clip range)
The AF pixel interpolating unit 45 calculates the clip range (−) based on the clip amount obtained by [Equation 39] in which each value of the prediction error deltaRU, deltaRS, deltaGU, and deltaGS obtained by [Equation 40] and [Equation 41]. It is determined whether or not included in (Th_LPF to Th_LPF) (S-44).

(クリップ処理)
AF画素補間部45は、予測誤差deltaRU,deltaRS、deltaGU及びdeltaGSのうち、クリップ範囲から外れている予測誤差に対して、クリップ処理を行う(S−45)。ここで、クリップ処理とは、クリップ範囲から外れている予測誤差の値をクリップ範囲に含まれるようにクリッピングすることである。
(Clip processing)
The AF pixel interpolation unit 45 performs a clipping process on a prediction error out of the clip range among the prediction errors deltaRU, deltaRS, deltaGU, and deltaGS (S-45). Here, the clipping process is to perform clipping so that a prediction error value outside the clip range is included in the clip range.

(近位撮像用画素の画素値に予測誤差を加算)
AF画素補間部45は、[数42]により、予測誤差を各列の近位撮像用画素の画素値に加算する(S−46)。ここで、予測誤差は、[数40],[数41]により求めた値、又は、クリッピングされた値である。
(Add prediction error to pixel value of proximal imaging pixel)
The AF pixel interpolation unit 45 adds the prediction error to the pixel value of the proximal imaging pixel in each column by [Equation 42] (S-46). Here, the prediction error is a value obtained by [Equation 40] and [Equation 41] or a clipped value.

[数42]
R33”=R33’+deltaRU
R53”=R53’+deltaRS
G34”=G34’+deltaGU
G54”=G54’+deltaGS
[Formula 42]
R33 "= R33 '+ deltaRU
R53 "= R53 '+ deltaRS
G34 "= G34 '+ deltaGU
G54 "= G54 '+ deltaGS

これにより、AF画素列の周囲の撮像用画素の画素値である、遠位撮像用画素の画素値及び近位撮像用画素の画素値がそれぞれ補正され、さらに、予測誤差を用いた平滑化処理により近位撮像用画素の画素値が補正される。   Thereby, the pixel value of the distal imaging pixel and the pixel value of the proximal imaging pixel, which are the pixel values of the imaging pixels around the AF pixel row, are respectively corrected, and further, a smoothing process using a prediction error Thus, the pixel value of the proximal imaging pixel is corrected.

(補正した撮像用画素の画素値をSDRAMに記憶)
AF画素補間部45は、重み係数により補正された遠位撮像用画素の画素値と、予測誤差により補正された近位撮像用画素の画素値とを、SDRAM27に記憶する(S−47)。
(The corrected pixel value of the imaging pixel is stored in the SDRAM)
The AF pixel interpolation unit 45 stores the pixel value of the distal imaging pixel corrected by the weighting factor and the pixel value of the proximal imaging pixel corrected by the prediction error in the SDRAM 27 (S-47).

上述した処理(S−41からS−47の処理)が完了すると、第1画素補間処理が実行される。   When the above-described processing (the processing from S-41 to S-47) is completed, the first pixel interpolation processing is executed.

(第1画素補間処理)
AF画素補間部45は、SDRAM27に記憶した撮像用画素の画素値を用いて、上述した第2画素補間処理を実行する(S−48)。これにより、AF画素に対応する撮像用画素の画素値が算出される。つまり、AF画素の画素値が補間される。
(First pixel interpolation processing)
The AF pixel interpolation unit 45 executes the second pixel interpolation process described above using the pixel values of the imaging pixels stored in the SDRAM 27 (S-48). Thereby, the pixel value of the imaging pixel corresponding to the AF pixel is calculated. That is, the pixel value of the AF pixel is interpolated.

(補間したAF画素の画素値をSDRAMに記憶)
AF画素補間部45は、第1画素補間処理(S−49)により補間したAF画素の画素値をSDRAM27に記憶する。
(The interpolated AF pixel value is stored in SDRAM)
The AF pixel interpolation unit 45 stores the pixel value of the AF pixel interpolated by the first pixel interpolation process (S-49) in the SDRAM 27.

この第2画素補間処理においては、補正処理において、マゼンタ色の濃淡によって設定される重みのレベルに基づいた平滑化処理を実行している。この平滑化処理を行うことで、AF画素に隣接する撮像用画素に対して、発生するフレアによる混色の影響を低減することができるとともに、フレアが発生していない領域における色にじみの発生を抑制することができる。また、混色の影響や色にじみの影響を低減した撮像用画素の画素値を用いてAF画素に対する補間処理を行うので、AF画素においても、発生するフレアによる混色の影響が低減した画素値が得られる。つまり、フレアの影響を低減した画像を得ることができる。   In the second pixel interpolation process, a smoothing process based on the weight level set by the density of magenta is performed in the correction process. By performing this smoothing process, it is possible to reduce the influence of color mixing due to the flare that occurs on the imaging pixels adjacent to the AF pixel, and to suppress the occurrence of color blur in areas where no flare occurs can do. In addition, since the interpolation processing for the AF pixel is performed using the pixel value of the imaging pixel in which the influence of the color mixture or the color blur is reduced, the pixel value in which the influence of the color mixture due to the generated flare is reduced can be obtained also in the AF pixel. It is done. That is, an image with reduced flare effects can be obtained.

以上説明したように、実施形態によれば、フレアが生じている場合、フレア判定した画像を構成する画素のうちの焦点検出用画素の周囲の撮像用画素の画素値を重み係数により補正し、補正した撮像用画素の画素値を、フレアに起因する混色(マゼンタ色)の濃淡に基づいた閾値を用いて平滑化する処理を行うため、焦点検出用画素の周囲の撮像用画素に対して混色の影響を低減する際に生じる色にじみの発生を抑制することができる。これにより、その後に行う焦点検出用画素の補間画素値の生成でも混色の影響や色にじみの影響を抑制することができる。   As described above, according to the embodiment, when flare occurs, the pixel value of the imaging pixels around the focus detection pixel among the pixels constituting the flare-determined image is corrected by the weighting factor, Since the pixel value of the corrected imaging pixel is smoothed using a threshold value based on the density of the mixed color (magenta color) caused by flare, color mixing is performed on the imaging pixels around the focus detection pixel. It is possible to suppress the occurrence of color bleeding that occurs when the influence of the above is reduced. Thereby, it is possible to suppress the influence of color mixing and the effect of color blurring even in the subsequent generation of the interpolation pixel value of the focus detection pixel.

なお、上記実施形態では、AF画素の配列方向を水平走査方向としたが、本発明はこれに限定されず、AF画素は垂直走査方向又はその他の方向に配列されていても良い。   In the above embodiment, the arrangement direction of the AF pixels is the horizontal scanning direction. However, the present invention is not limited to this, and the AF pixels may be arranged in the vertical scanning direction or other directions.

また、上記各実施形態では、AF画素の各々は左側又は右側からの光束を瞳分割する焦点検出画素としたが、本発明はこれに限定されず、AF画素の各々は左側及び右側からの光束を瞳分割する画素を有する焦点検出画素でも良い。   In each of the above embodiments, each AF pixel is a focus detection pixel that divides the light beam from the left or right side into pupils, but the present invention is not limited to this, and each AF pixel has a light beam from the left and right sides. Focus detection pixels having pixels that divide the pupil may be used.

本実施形態では、色検出部47、エッジ検出部48、評価値判定部49及び重み設定部50を備えたフレア判定部46の例を取り上げているが、これに限定する必要はなく、図11に示すフレア判定部60であってもよい。   In the present embodiment, an example of the flare determination unit 46 including the color detection unit 47, the edge detection unit 48, the evaluation value determination unit 49, and the weight setting unit 50 is taken up. However, the present invention is not limited to this, and FIG. The flare determination unit 60 shown in FIG.

以下、図11に示すフレア判定部60の構成について説明する。フレア判定部60は、ヒストグラム生成部61、閾値算出部62、対象領域抽出部63、マトリクス決定部64、マゼンタ領域検出部65、評価値判定部66及び重み設定部67を備えている。このフレア判定部47は、画像データ(YRGBデータ)の他、ホワイトバランス用のゲイン値をCPU11から取得する。   Hereinafter, the configuration of the flare determination unit 60 shown in FIG. 11 will be described. The flare determination unit 60 includes a histogram generation unit 61, a threshold calculation unit 62, a target region extraction unit 63, a matrix determination unit 64, a magenta region detection unit 65, an evaluation value determination unit 66, and a weight setting unit 67. The flare determination unit 47 acquires a gain value for white balance from the CPU 11 in addition to image data (YRGB data).

ヒストグラム生成部61は、画像データのYデータを用いて、ヒストグラムを生成する。閾値算出部62は、ヒストグラム生成部61によって生成されたヒストグラムから、高輝度となる領域(高輝度領域)を抽出する際に用いる閾値(高輝度判定用閾値)を算出する。対象領域抽出部63は、Yデータと高輝度判定用閾値とを用いて、高輝度となる矩形の領域を対象領域として抽出する。マトリクス決定部64は、画像データのRGBデータをCrCbデータに変換する際に用いるマトリクスを決定する。マゼンタ領域検出部65は、対象領域抽出部63により抽出された対象領域に含まれるマゼンタ色が存在する領域(マゼンタ領域)を検出する。この検出の際に、マゼンタ領域検出部65は、マゼンタ領域の総面積、Y成分の総エッジ量などを算出する。評価値判定部66は、マゼンタ領域の総面積、分散値/マゼンタ領域の総面積、Y成分の平均エッジ量を求め、求めた値を各々閾値判定してフレアが発生しているか否かを判定する。重み設定部67は、フレアに起因する混色の領域と認識されるマゼンタ領域に含まれる各画素の色成分(Cr値及びCb値)に基づいて、重みのレベルを設定する。   The histogram generation unit 61 generates a histogram using the Y data of the image data. The threshold calculation unit 62 calculates a threshold (high luminance determination threshold) used when extracting a region with high luminance (high luminance region) from the histogram generated by the histogram generation unit 61. The target area extraction unit 63 uses the Y data and the high luminance determination threshold value to extract a rectangular area having high luminance as the target area. The matrix determination unit 64 determines a matrix used when converting RGB data of image data into CrCb data. The magenta region detection unit 65 detects a region (magenta region) in which the magenta color included in the target region extracted by the target region extraction unit 63 exists. In this detection, the magenta area detection unit 65 calculates the total area of the magenta area, the total edge amount of the Y component, and the like. The evaluation value determination unit 66 obtains the total area of the magenta region, the dispersion value / the total area of the magenta region, and the average edge amount of the Y component, and determines whether or not flare has occurred by determining each of the obtained values as a threshold value. To do. The weight setting unit 67 sets the weight level based on the color components (Cr value and Cb value) of each pixel included in the magenta area recognized as a mixed color area caused by flare.

以下、図11に示す構成のフレア判定部60を備えたAF画素補間部においてフレア判定を行う場合について、図12に示すフローチャートに基づいて説明する。なお、AF画素補間部については、本実施形態と同一の符号(符号45)を付して説明する。   Hereinafter, the case where the flare determination is performed in the AF pixel interpolation unit including the flare determination unit 60 having the configuration illustrated in FIG. 11 will be described based on the flowchart illustrated in FIG. 12. The AF pixel interpolation unit will be described with the same reference numeral (symbol 45) as in the present embodiment.

(ヒストグラムの生成)
AF画素補間部45は、画像データのYデータを用いて、ヒストグラムを生成する(S−61)。ここで、Yデータが16ビットデータである場合には、AF画素補間部45は、Yデータを16ビットデータから8ビットデータに変換し、ヒストグラムを生成する。図13(a)は、Yデータを用いたヒストグラムの一例である。
(Generate histogram)
The AF pixel interpolation unit 45 generates a histogram using the Y data of the image data (S-61). If the Y data is 16-bit data, the AF pixel interpolation unit 45 converts the Y data from 16-bit data to 8-bit data, and generates a histogram. FIG. 13A is an example of a histogram using Y data.

(ヒストグラムを用いて高輝度判定用閾値を算出)
AF画素補間部45は、生成されたヒストグラムを用いて、後述するマゼンタ領域を検出する際に使用する領域(対象領域)を抽出する際に用いる閾値(高輝度判定用閾値)Th_highを算出する(S−62)。AF画素補間部45は、図13(b)に示すように、Yデータを用いて、画素値が飽和しているかを判定する閾値(飽和判定用閾値)Th11を用いて、飽和していない画素値を特定する。この飽和判定用閾値Th11は、ヒストグラムが8ビットデータを用いて生成されていることから、8ビットデータにて設けられることが好ましいが、16ビットデータの場合には8ビットデータに変換した値を用いればよい。
(Calculate threshold for high brightness determination using histogram)
The AF pixel interpolation unit 45 uses the generated histogram to calculate a threshold (high brightness determination threshold) Th_high used when extracting a region (target region) used when detecting a magenta region, which will be described later ( S-62). As shown in FIG. 13B, the AF pixel interpolating unit 45 uses Y data and uses a threshold value (saturation determination threshold value) Th <b> 11 to determine whether the pixel value is saturated. Identify the value. The saturation determination threshold Th11 is preferably provided as 8-bit data because the histogram is generated using 8-bit data. However, in the case of 16-bit data, a value converted to 8-bit data is used. Use it.

この特定の後、AF画素補間部45は、ヒストグラムのうち、閾値Th11以下の画素値及び画素数を乗算した値を、画素値の高い方から順に加算していく。そして、加算して行く過程で、[数43]を満足したときの画素値を高輝度判定用閾値Th_highとする。   After this specification, the AF pixel interpolation unit 45 sequentially adds values obtained by multiplying the histogram by a pixel value equal to or less than the threshold value Th11 and the number of pixels from the highest pixel value. Then, in the process of adding, the pixel value when [Equation 43] is satisfied is set as a high-luminance determination threshold Th_high.

[数43]
ヒストグラムの加算値(画素値×画素数)>(256−Th12)×全画素数
[Equation 43]
Histogram addition value (pixel value × number of pixels)> (256-Th12) × total number of pixels

なお、Th12は、高輝度成分となる割合を示す閾値である。また、全画素数は、24×16画素のYデータを用いていることから、24×16(=384)画素となる。   Note that Th12 is a threshold value indicating the ratio of the high luminance component. The total number of pixels is 24 × 16 (= 384) pixels because Y data of 24 × 16 pixels is used.

AF画素補間部45は、求めた高輝度判定用閾値Th_highを8ビットデータから16ビットデータに変換する。   The AF pixel interpolation unit 45 converts the obtained high-luminance determination threshold Th_high from 8-bit data to 16-bit data.

(高輝度判定用閾値を用いてマゼンタ領域を検出する際に用いる領域(対象領域)を矩形抽出)
AF画素補間部45は、16ビットに変換された高輝度判定用閾値Th_highと、AWB評価用のYデータを用いて、対象領域を矩形抽出する(S−63)。AF画素補間部45は、図14に示すように、Yデータに基づく画像(Y画像)70の各画素のうち、水平走査方向に1画素ずつ画素をずらしていき、目的の画素の画素値と、目的の画素の1つ前の画素の画素値との双方が高輝度判定用閾値Th_high以上の画素値となる画素を検出する。AF画素補間部45は、水平走査方向の1ラインに対する処理が終わると、垂直走査方向に1画素ずらし、同様の処理を実行する。これにより、AF画素補間部45は、Yデータの全ての画素に対して、目的の画素の画素値と、目的の画素の1つ前の画素の画素値との双方が高輝度判定用閾値Th_high以上の画素値となる画素を検出する。
(Rectangle extraction of the area (target area) used when detecting the magenta area using the threshold for high brightness determination)
The AF pixel interpolation unit 45 uses the high-luminance determination threshold Th_high converted to 16 bits and the Y data for AWB evaluation to extract a rectangle of the target area (S-63). As shown in FIG. 14, the AF pixel interpolating unit 45 shifts pixels one by one in the horizontal scanning direction among the pixels of the image (Y image) 70 based on the Y data, and determines the pixel value of the target pixel. Then, a pixel in which both the pixel value of the pixel immediately before the target pixel is equal to or higher than the high luminance determination threshold Th_high is detected. When the processing for one line in the horizontal scanning direction is completed, the AF pixel interpolation unit 45 shifts one pixel in the vertical scanning direction and executes the same processing. As a result, the AF pixel interpolation unit 45 determines that the pixel value of the target pixel and the pixel value of the pixel immediately before the target pixel are both high-luminance determination threshold Th_high for all pixels of Y data. Pixels having the above pixel values are detected.

図13においては、符号71に示す領域が検出される画素の領域となる。AF画素補間部45は、検出された領域(符号71)のうち、1画素分小さい矩形の領域(符号72)を対象領域として抽出する。これは、検出された画素の領域を、そのまま対象領域として抽出すると、後述する隣り合う4方向のY成分のエッジ量の全体差分和を求める際に、低輝度画素の画素値が使用されてしまうことを防止している。AF画素補間部45は、抽出した対象領域の四隅に位置する画素の位置データを矩形抽出される対象領域の位置情報として生成する。   In FIG. 13, the area indicated by reference numeral 71 is the area of the detected pixel. The AF pixel interpolation unit 45 extracts a rectangular area (reference numeral 72) smaller by one pixel from the detected area (reference numeral 71) as a target area. This is because if the detected pixel area is extracted as a target area as it is, the pixel value of the low-brightness pixel will be used when obtaining the total difference sum of the edge amounts of Y components in the four adjacent directions described later. To prevent that. The AF pixel interpolation unit 45 generates the position data of the pixels located at the four corners of the extracted target area as the position information of the target area to be extracted as a rectangle.

ここで、AF画素補間部45は、Yデータの全ての画素に対して上述した処理を行っているが、これに限定される必要はなく、上述した飽和判定用閾値Th11未満の輝度値となる画素に対して上述した処理を実行することも可能である。   Here, the AF pixel interpolating unit 45 performs the above-described processing on all the pixels of the Y data. However, the present invention is not limited to this, and the luminance value is less than the above-described saturation determination threshold Th11. It is also possible to perform the above-described processing on the pixel.

(マトリクスの算出)
AF画素補間部45は、画像データのRGBデータをCrCbデータに変換する際のマトリクスを算出する(S−64)。
(Matrix calculation)
The AF pixel interpolation unit 45 calculates a matrix used when converting the RGB data of the image data into CrCb data (S-64).

撮影時に発生するフレアに起因する混色は、画像中にマゼンタ色として現れることが知られている。このマゼンタ色になる原因としては、ホワイトバランス処理に用いられるR,G,Bゲイン値を、各画素の各色成分の画素値にそれぞれに乗算したときに、R色成分及びB色成分の値がG色成分の値よりも大きくなってしまうことが挙げられる。   It is known that a color mixture caused by flare occurring at the time of photographing appears as a magenta color in an image. The reason for this magenta color is that when the R, G, and B gain values used for white balance processing are multiplied by the pixel values of the respective color components of the respective pixels, the values of the R color component and the B color component are changed. For example, it becomes larger than the value of the G color component.

ここで、光源の種類を変えて同一被写体を撮影した場合、ホワイトバランス処理にて用いるR,G,Bゲイン値は、光源の種類に対応した値を使用している。このため、同一色の被写体を撮影した場合であっても、光源の種類によって、その出力値が大きく変動する。この出力値の変動により、フレアを確実に検出することが難しくなる。   Here, when the same subject is photographed by changing the type of the light source, the R, G, and B gain values used in the white balance process use values corresponding to the type of the light source. For this reason, even when a subject of the same color is photographed, the output value varies greatly depending on the type of light source. Due to the fluctuation of the output value, it is difficult to reliably detect the flare.

そのため、本発明においては、RGBデータをCrCbデータに変換する際に用いる色空間変換用マトリクスに対して、ホワイトバランス処理で用いるゲイン値を利用して求まる補正係数のマトリクスを乗算して、新たな色空間変換用マトリクスを算出する。そして、新たに求めた色空間用マトリクスを用いて、RGBデータをCrCbデータに変換する。   Therefore, in the present invention, a color space conversion matrix used when converting RGB data to CrCb data is multiplied by a correction coefficient matrix obtained by using a gain value used in white balance processing, and a new matrix is obtained. A color space conversion matrix is calculated. Then, the RGB data is converted into CrCb data using the newly obtained color space matrix.

ここで、R色成分に対する新たなゲイン値を、ホワイトバランス用のRゲイン値と基準値(512×2)とを重み係数を用いた加重和によって設定する場合を[数44]にて表す。   Here, a new gain value for the R color component is represented by [Equation 44] when a white balance R gain value and a reference value (512 × 2) are set by a weighted sum using a weighting coefficient.

[数44]
α=a×Rgain+(1−a)×512×2
[Equation 44]
α R = a × Rgain + (1−a) × 512 × 2

ここで、基準値(512×2)は、光源の種類が変化しても、Rgainの値がGgainのおよそ2倍であるということを考慮して設定される値である。   Here, the reference value (512 × 2) is a value set in consideration of the fact that the value of Rgain is approximately twice that of Ggain even if the type of the light source changes.

ここで、晴天下での撮影と室内撮影とのそれぞれにおいて、aの値を変化させたときに得られるSb/St値について考慮する。Sbはクラス(晴天下での撮影及び室内撮影)間の分散であり、Stは全てのサンプルにおける分散である。なお、このSb/St値はその値が小さいほど、クラス間(晴天下での撮影及び室内撮影間)の距離が小さく、異なる光源間の出力値の変動が小さいことを示す。ここで、図15に示すように、aの値を変動させると、a=0.5の場合が最もSb/St値が小さくなることがわかる。   Here, the Sb / St value obtained when the value of a is changed in each of shooting under clear sky and indoor shooting is considered. Sb is the variance between classes (shooting under clear sky and indoor shooting), and St is the variance in all samples. Note that the smaller the Sb / St value, the smaller the distance between classes (between shooting under clear sky and indoor shooting), and the smaller the variation in output value between different light sources. Here, as shown in FIG. 15, when the value of a is varied, it can be seen that the Sb / St value is the smallest when a = 0.5.

これを考慮すると、R色成分、G色成分、B色成分の信号値がそれぞれLSB=512となる場合、補正したRゲイン値α、Gゲイン値α、Bゲイン値αは、それぞれ[数45]で表される。なお、Rgain,Ggain,Bgainは、それぞれ、ホワイトバランス処理用の各色成分のゲイン値である。 Considering this, when the signal values of the R color component, the G color component, and the B color component are LSB = 512, the corrected R gain value α R , G gain value α G , and B gain value α B are respectively [Expression 45] Rgain, Ggain, and Bgain are gain values of the respective color components for white balance processing.

[数45]
α=0.5×Rgain+512
α=Ggain=512
α=0.5×Bgain+512
[Equation 45]
α R = 0.5 × Rgain + 512
α G = Ggain = 512
α B = 0.5 × Bgain + 512

また、R色成分、B色成分の信号値がLSB=256、G色成分の信号値がLSB=512となる場合、補正したRゲイン値α、Gゲイン値α、Bゲイン値αは、それぞれ[数46]となる。 Further, when the signal values of the R color component and the B color component are LSB = 256 and the signal value of the G color component is LSB = 512, the corrected R gain value α R , G gain value α G , and B gain value α B Is [Equation 46].

[数46]
α=Rgain+512
α=Ggain=512
α=Bgain+512
[Equation 46]
α R = Rgain + 512
α G = Ggain = 512
α B = Bgain + 512

このα,α,αを用いて、RGBデータをCrCbデータに変換する。ここで、一般的なRGB→YCrCb変換は、[数47]で表される。 Using these α R , α G , and α B , RGB data is converted into CrCb data. Here, general RGB → YCrCb conversion is expressed by [Equation 47].

Figure 2013247597
Figure 2013247597

上述したように、本発明においては、色空間の変換時において補正したRゲイン値α、Gゲイン値α、Bゲイン値αを乗算する。そこで、RGBからCrCbへの色空間の変換時に用いる式は、[数48]となる。 As described above, in the present invention, the R gain value α R , the G gain value α G , and the B gain value α B corrected at the time of color space conversion are multiplied. Therefore, the equation used when converting the color space from RGB to CrCb is [Equation 48].

Figure 2013247597
Figure 2013247597

つまり、RGBデータからCrCbデータを求める際に用いるマトリクスCは、[数47]及び[数48]から、[数49]となる。   That is, the matrix C used when obtaining the CrCb data from the RGB data is represented by [Equation 49] from [Equation 47] and [Equation 48].

Figure 2013247597

なお、マトリクスの各値は、[数50]のように、整数化した値を用いてもよい。
Figure 2013247597

As each value of the matrix, an integerized value such as [Equation 50] may be used.

[数50]
00=(50×α)/100
01=(−42×α)/100
02=(―8×α)/100
10=(−17×α)/100
11=(−33×α)/100
12=(50×α)/100
[Equation 50]
C 00 = (50 × α R ) / 100
C 01 = (− 42 × α G ) / 100
C 02 = (− 8 × α B ) / 100
C 10 = (− 17 × α R ) / 100
C 11 = (− 33 × α G ) / 100
C 12 = (50 × α B ) / 100

(RGBデータをCrCbデータへと変換)
AF画素補間部45は、求めたマトリクスを用いて、抽出された対象領域に含まれる画素のRGBデータをCrCbデータに変換する(S−65)。AF画素補間部45は、対象領域の位置情報を参照して、対象領域に含まれる画素のRGBデータを[数6]及び[数7]を用いてCrCbデータにマトリクス変換する。
(Convert RGB data to CrCb data)
The AF pixel interpolation unit 45 converts the RGB data of the pixels included in the extracted target area into CrCb data using the obtained matrix (S-65). The AF pixel interpolation unit 45 refers to the position information of the target area, and performs matrix conversion of RGB data of the pixels included in the target area into CrCb data using [Formula 6] and [Formula 7].

なお、AWB評価用データがYRGBデータではなく、YCrCbデータの場合には、上述した色空間の変換処理は実行する必要はない。この場合、Cr値、Cb値に対して、ホワイトバランス処理で使用される各色ゲイン値を補正した値を用いて、Cr値、Cb値を補正すればよい。   When the AWB evaluation data is not YRGB data but YCrCb data, it is not necessary to perform the color space conversion process described above. In this case, the Cr value and the Cb value may be corrected using a value obtained by correcting each color gain value used in the white balance process with respect to the Cr value and the Cb value.

また、抽出された対象領域に含まれる画素のRGBデータをCrCbデータに変換する場合について説明しているが、RGBデータ全体をCrCbデータに変換することも可能である。   Moreover, although the case where the RGB data of the pixels included in the extracted target area is converted into CrCb data has been described, it is also possible to convert the entire RGB data into CrCb data.

(対象領域に含まれるマゼンタ領域の検出)
AF画素補間部45は、CrCbデータに変換された各画素の画素値が、[数51]〜[数53]を満足するか否かを判定する(S−66)。
(Detection of magenta area included in target area)
The AF pixel interpolation unit 45 determines whether or not the pixel value of each pixel converted into CrCb data satisfies [Equation 51] to [Equation 53] (S-66).

[数51]
Cr<Th13×Cb and Cr>(Th14/256)×Cb
[Formula 51]
Cr <Th13 × Cb and Cr> (Th14 / 256) × Cb

[数52]
Cb>Th15 or Cr>Th15
[Formula 52]
Cb> Th15 or Cr> Th15

[数53]
R<Th11 and G<Th11 and B<Th11
[Formula 53]
R <Th11 and G <Th11 and B <Th11

ここで、[数9]は、対象領域に含まれる画素の画素値(Cr,Cb)が、マゼンタ色の色域となるか否かを判定するための条件式である。図16(a)に示すように、色度図において、斜線で示す範囲が、[数51]で示される範囲である。また、[数52]は、画素の画素値(Cr,Cb)が、所定の強度の値を有しているか否かを判定するための条件式である。ここで、Cr値、Cb値のそれぞれが「0」、又は0に近い値をとる場合には、マゼンタ色の強度が弱い。そこで、Cr値、Cb値のいずれかの値が所定値(ここでは、閾値Th5)を越える値となる場合について考慮すればよい。そこで、[数52]及び[数53]から求められる範囲(図16(b)中ハッチングで示す範囲)をマゼンタ色の色域とし、この色域に、高輝度領域に含まれる画素の画素値が含まれるか否かを判定する。   Here, [Equation 9] is a conditional expression for determining whether or not the pixel value (Cr, Cb) of the pixel included in the target region falls within the magenta color gamut. As shown in FIG. 16A, in the chromaticity diagram, the range indicated by diagonal lines is the range indicated by [Equation 51]. [Formula 52] is a conditional expression for determining whether or not the pixel value (Cr, Cb) of the pixel has a predetermined intensity value. Here, when each of the Cr value and the Cb value is “0” or a value close to 0, the intensity of the magenta color is weak. Therefore, a case where any one of the Cr value and the Cb value exceeds a predetermined value (here, the threshold Th5) may be considered. Therefore, the range obtained from [Equation 52] and [Equation 53] (the range indicated by hatching in FIG. 16B) is the magenta color gamut, and the pixel values of the pixels included in the high luminance region are included in this color gamut. Whether or not is included is determined.

さらに、[数53]は、対象領域に含まれる画素のR,G,B色成分の画素値が、飽和しているか否かを判定するための条件式である。   Furthermore, [Equation 53] is a conditional expression for determining whether or not the pixel values of the R, G, and B color components of the pixels included in the target region are saturated.

AF画素補間部45は、対象領域に含まれる画素のうち、上述した[数51]〜[数53]を満足する画素を抽出する。この際に、AF画素補間部45は、隣り合う4方向のY成分のエッジ量の絶対差分和SADを[数54]を用いて求める。   The AF pixel interpolation unit 45 extracts pixels satisfying the above-described [Equation 51] to [Equation 53] from the pixels included in the target region. At this time, the AF pixel interpolation unit 45 obtains the absolute difference sum SAD of the edge amounts of the Y components in the four adjacent directions by using [Expression 54].

Figure 2013247597
Figure 2013247597

AF画素補間部45は、[数54]で求めたY成分のエッジ量の絶対差分和SADを該エッジ量のノーマライズファクタ値(=4)で除算することでY成分のエッジ量の平均値を求める。AF画素補間部45は、Y成分のエッジ量の平均値が閾値Th16以下であるか判定する。ここで、AF画素補間部45は、Y成分のエッジ量の平均値を算出した後、閾値Th16と比較しているが、これに限定される必要はなく、Y成分のエッジ量と閾値とを比較してもよい。   The AF pixel interpolation unit 45 divides the absolute difference sum SAD of the edge amounts of the Y component obtained by [Equation 54] by the normalization factor value (= 4) of the edge amount to obtain the average value of the edge amounts of the Y component. Ask. The AF pixel interpolation unit 45 determines whether the average value of the Y component edge amounts is equal to or less than the threshold Th16. Here, the AF pixel interpolation unit 45 calculates the average value of the edge amount of the Y component and then compares it with the threshold Th16. However, the present invention is not limited to this, and the edge amount of the Y component and the threshold are calculated. You may compare.

AF画素補間部45は、[数51]〜[数53]を満足し、且つY成分のエッジ量の平均値が閾値Th16以下となる画素が特定される毎に、特定された画素の数を加算する。また、AF画素補間部45は、求めたY成分のエッジ量の絶対差分和SADを加算することで総エッジ量edge_sumを算出し、また、Y方向のエッジ量の平均値を求める際に使用したノーマライズファクタ値edge_countを加算する。   The AF pixel interpolation unit 45 calculates the number of specified pixels every time a pixel that satisfies [Equation 51] to [Equation 53] and the average value of the edge amount of the Y component is equal to or less than the threshold Th16 is specified. to add. Further, the AF pixel interpolating unit 45 calculates the total edge amount edge_sum by adding the absolute difference sum SAD of the obtained Y component edge amounts, and used to obtain the average value of the edge amounts in the Y direction. The normalization factor value edge_count is added.

さらに、AF画素補間部45は、特定された画素のx座標、x座標を二乗した値(x座標の二乗値)、y座標、及びy座標を二乗した値(y座標の二乗値)をそれぞれ加算する。以下、x座標を加算した値をx座標加算値ave_x、x座標の二乗値を加算した値をx座標二乗加算値sqr_x、y座標を加算した値をy座標加算値ave_y、y座標の二乗値を加算した値をy座標二乗加算値sqr_yと称して説明する。   Further, the AF pixel interpolation unit 45 obtains the x coordinate of the specified pixel, the value obtained by squaring the x coordinate (square value of the x coordinate), the y coordinate, and the value obtained by squaring the y coordinate (square value of the y coordinate), respectively. to add. Hereinafter, the value obtained by adding the x coordinate is the x coordinate added value ave_x, the value obtained by adding the square value of the x coordinate is the x coordinate square added value sqr_x, the value obtained by adding the y coordinate is the y coordinate added value ave_y, and the square value of the y coordinate. A value obtained by adding is described as a y-coordinate square addition value sqr_y.

(評価値判定)
AF画素補間部45は、以下に説明する第1から第3評価値を求め、これら評価値を判定する(S−67)。AF画素補間部45は、これら評価値を各々判定することで、フレアが発生しているか否かが判定される。
(Evaluation value judgment)
The AF pixel interpolation unit 45 obtains first to third evaluation values described below and determines these evaluation values (S-67). The AF pixel interpolating unit 45 determines whether or not flare has occurred by determining each of these evaluation values.

第1評価値は[マゼンタ領域の総面積]であり、これはマゼンタ領域として特定された画素の総数が対応する。AF画素補間部45は、第1の評価値が閾値Th17を超過するか(第1評価値>閾値Th17であるか)を判定する。   The first evaluation value is [total area of the magenta area], which corresponds to the total number of pixels specified as the magenta area. The AF pixel interpolation unit 45 determines whether the first evaluation value exceeds the threshold Th17 (whether the first evaluation value> the threshold Th17).

第2評価値は、[分散値/マゼンタ領域の総面積]である。一般に、分散値は、[数55]により求められる。   The second evaluation value is [dispersion value / total area of magenta region]. In general, the variance value is obtained by [Equation 55].

Figure 2013247597
Figure 2013247597

[数55]にて表される分散値を、空間分散値(空間モーメント)に対応する式として置き換えると、[数56]となる。   When the dispersion value represented by [Expression 55] is replaced with an expression corresponding to the spatial dispersion value (spatial moment), [Expression 56] is obtained.

Figure 2013247597
Figure 2013247597

この式を用いて、AF画素補間部45は、分散値/マゼンタ領域の総面積を[数57]を用いて算出する。   Using this equation, the AF pixel interpolation unit 45 calculates the total area of the dispersion value / magenta region using [Equation 57].

Figure 2013247597
Figure 2013247597

AF画素補間部45は、[数57]にて求めた[分散値/マゼンタ領域の総面積]を第2評価値とし、この第2評価値が閾値Th18未満となるか(第2評価値<閾値Th18であるか)を判定する。なお、第2評価値<閾値Th18としているが、これに限定する必要はなく、第2評価値<閾値Th18/32としてもよい。この場合、32は第2評価値に対して割り振られるノーマライズファクタ値である。   The AF pixel interpolation unit 45 sets [dispersion value / total area of magenta area] obtained in [Equation 57] as the second evaluation value, and whether the second evaluation value is less than the threshold Th18 (second evaluation value < Whether the threshold value is Th18). Although the second evaluation value <threshold Th18 is set, the present invention is not limited to this, and the second evaluation value <threshold Th18 / 32 may be used. In this case, 32 is a normalization factor value assigned to the second evaluation value.

第3の評価値は、[Y成分のエッジ量の平均値]である。AF画素補間部45は、Y成分のエッジ量の平均値を[数58]を用いて算出する。   The third evaluation value is [average value of edge amounts of Y component]. The AF pixel interpolation unit 45 calculates the average value of the edge amounts of the Y component using [Equation 58].

[数58]
Yedge=edge_sum/edge_count
[Formula 58]
Yedge = edge_sum / edge_count

AF画素補間部45は、[数58]にて求めた[Y成分のエッジ量の平均値]を第3評価値とし、この第3評価値が閾値TH19未満となるか(第3評価値<閾値Th19であるか)を判定する。なお、評価値判定において、[マゼンタ領域の総面積]を第1評価値、[分散値/マゼンタ領域の総面積]を第2評価値、[Y成分のエッジ量の平均値]を第3評価値とし、それぞれの評価値を用いた評価値判定をしているが、これに限定される必要はなく、[マゼンタ領域の総面積]、[分散値/マゼンタ領域の総面積]、[Y成分のエッジ量の平均値]の少なくとも2つを評価値として、評価値判定を行うことも可能である。   The AF pixel interpolating unit 45 sets the [average value of the edge amount of the Y component] obtained in [Equation 58] as the third evaluation value, and whether the third evaluation value is less than the threshold value TH19 (third evaluation value < Whether the threshold value is Th19). In the evaluation value determination, [total area of magenta area] is the first evaluation value, [dispersion value / total area of magenta area] is the second evaluation value, and [average value of edge amount of Y component] is the third evaluation value. However, the present invention is not limited to this, and [total area of magenta area], [dispersion value / total area of magenta area], [Y component] It is also possible to perform the evaluation value determination using at least two of the average values of the edge amounts] as evaluation values.

(フレアが発生していないか否かの判定)
上述した評価値判定処理を行うことで、撮像された画像データにフレアが発生しているか否かが判定される(S−68)。AF画素補間部45は、上述した評価値判定において、[第1評価値>閾値Th17]、[第2評価値<閾値Th18]、[第3評価値<閾値Th19]の条件の少なくともいずれか1つの条件を満足していない場合には、フレアが発生していないと判定する。この場合、AF画素補間部45は、第1画素補間処理を実行する(S−69)。一方、AF画素補間部45は、これら条件が全て満足している場合には、フレアが発生していると判定する。
(Determining whether flare has occurred)
By performing the evaluation value determination process described above, it is determined whether or not flare has occurred in the captured image data (S-68). In the evaluation value determination described above, the AF pixel interpolation unit 45 at least one of the conditions of [first evaluation value> threshold Th17], [second evaluation value <threshold Th18], and [third evaluation value <threshold Th19]. When one condition is not satisfied, it is determined that no flare has occurred. In this case, the AF pixel interpolation unit 45 executes the first pixel interpolation process (S-69). On the other hand, if all these conditions are satisfied, the AF pixel interpolation unit 45 determines that flare has occurred.

(重みのレベルの設定)
AF画素補間部45は、フレアに起因する混色であると認識されたマゼンタ領域に含まれる画素に対して重みのレベルを設定する(S−68)。重みのレベルの設定については、本実施形態と同一の処理であることから、ここでは説明を省略する。
(Weight level setting)
The AF pixel interpolating unit 45 sets the weight level for the pixels included in the magenta area recognized as a color mixture caused by flare (S-68). The setting of the weight level is the same as that in the present embodiment, and thus the description thereof is omitted here.

この場合も、本実施形態と同様の効果を得ることができる。   In this case, the same effect as that of the present embodiment can be obtained.

本実施形態では、第2画素補間処理においてフレアを抑制する処理(S−41からS−47の処理)を行った後、第1画素補間処理を行うようにしているが、これに限定される必要はなく、フレアを抑制するための平滑化処理(S−41からS−47の処理)を複数回行った後、第1画素補間処理を実行することも可能である。フレアを抑制する平滑化処理を複数回行う場合、クリップ量を算出する際に用いる係数K_Th_LPFの値は、1回目の算出時に用いる値と、2回目以降の算出時に用いる値とで異なる値としてもよいし、同一の値を用いることも可能である。   In the present embodiment, the first pixel interpolation process is performed after the process of suppressing flare (the process from S-41 to S-47) in the second pixel interpolation process, but this is not limitative. It is not necessary, and it is also possible to execute the first pixel interpolation process after performing a smoothing process (S-41 to S-47) for suppressing flare a plurality of times. When the smoothing process for suppressing flare is performed a plurality of times, the value of the coefficient K_Th_LPF used when calculating the clip amount may be different between the value used for the first calculation and the value used for the second and subsequent calculations. It is also possible to use the same value.

本実施形態では、フレア判定処理を行うAF画素補間部45について説明しているが、これに限定される必要はなく、フレア判定処理の他にノイズ判定処理を行うAF画素補間部であってもよい。この場合、画像データに対してノイズ判定処理を行う。このノイズ判定処理において、ノイズが少ないと判定された場合に、本実施形態におけるフレア判定処理を実行すればよい。この場合のノイズ判定としては、例えば撮影時の撮像素子の温度、ISO感度、及びシャッタ速度の情報に基づいたノイズ判定を行うことが挙げられる。   In the present embodiment, the AF pixel interpolation unit 45 that performs the flare determination process is described. However, the present invention is not limited to this, and the AF pixel interpolation unit that performs the noise determination process in addition to the flare determination process may be used. Good. In this case, noise determination processing is performed on the image data. In this noise determination process, when it is determined that there is little noise, the flare determination process in the present embodiment may be executed. As noise determination in this case, for example, noise determination based on information on the temperature, ISO sensitivity, and shutter speed of the image sensor at the time of shooting may be performed.

本実施形態では、撮像用画素と、AF画素とを有する画像に対してフレア判定を行う場合について説明しているが、これに限定される必要はなく、撮像用画素のみからなる画像に対しても、本発明を用いることが可能である。   In this embodiment, the case where flare determination is performed on an image having imaging pixels and AF pixels is described. However, the present invention is not limited to this, and an image including only imaging pixels is described. Also, the present invention can be used.

本実施形態では、電子カメラ10を例に挙げて説明しているが、カメラ付き携帯電話機やスマートフォン等の携帯端末機などに本発明を用いることも可能である。   In the present embodiment, the electronic camera 10 is described as an example, but the present invention can also be used for a portable terminal such as a camera-equipped mobile phone or a smartphone.

この他に、図4及び図5の機能や、図6、図8及び図10のフローチャートにおける処理をコンピュータで実現するための画像処理プログラム、又は、図11の機能や、図12のフローチャートをコンピュータで実現するための画像処理プログラムのいずれかの画像処理プログラムに対しても適用することが可能である。この画像処理プログラムは、メモリカード、光学ディスク、磁気ディスクなどのコンピュータにて読み取ることが可能な記憶媒体に記憶されていることが好ましい。   In addition to this, the functions of FIGS. 4 and 5 and the image processing program for realizing the processing in the flowcharts of FIGS. 6, 8 and 10 by a computer, the functions of FIG. 11, and the flowchart of FIG. The present invention can also be applied to any one of the image processing programs for realizing the above. The image processing program is preferably stored in a computer-readable storage medium such as a memory card, an optical disk, or a magnetic disk.

さらに、AF画素値を補間していないRAWデータ等の画像データを取り込んでフレアを判定してAF画素補間を行う画像処理プログラム、及びこれを記憶した記憶媒体の発明としてもよい。   Further, the present invention may be an invention of an image processing program for capturing image data such as RAW data in which AF pixel values are not interpolated and determining flare and performing AF pixel interpolation, and a storage medium storing the image processing program.

10…電子カメラ、17…撮像素子、25…画像処理部、27…SDRAM、41…AF画素、45…AF画素補間部、46,60…フレア判定部、47…色検出部、48…エッジ検出部、49…評価値判定部、50,67…重み設定部、61…ヒストグラム生成部、62…閾値算出部、63…対象領域抽出部、64…マトリクス決定部、65…マゼンタ領域検出部、66…評価値判定部   DESCRIPTION OF SYMBOLS 10 ... Electronic camera, 17 ... Imaging device, 25 ... Image processing part, 27 ... SDRAM, 41 ... AF pixel, 45 ... AF pixel interpolation part, 46, 60 ... Flare determination part, 47 ... Color detection part, 48 ... Edge detection 49, evaluation value determination unit, 50, 67 ... weight setting unit, 61 ... histogram generation unit, 62 ... threshold calculation unit, 63 ... target region extraction unit, 64 ... matrix determination unit, 65 ... magenta region detection unit, 66 ... Evaluation value judgment unit

Claims (7)

画像を受け付ける画像入力部と、
前記画像に含まれる所定の色成分の領域に関わる情報に基づいて、フレアが発生しているか否かを判定するフレア判定部と、
前記フレアが発生していると判定されたときに、少なくとも前記フレアに起因した前記所定の色成分の領域に含まれる画素に対して、前記画素が有する色成分値に基づいた重みを設定する設定部と、
前記設定部により設定された前記重みに基づいて、前記画像に対する平滑化処理を実行する平滑化部と、
を備えたことを特徴とする画像処理装置。
An image input unit for receiving images;
A flare determination unit that determines whether or not flare has occurred based on information related to a region of a predetermined color component included in the image;
Setting that sets a weight based on a color component value of the pixel at least for a pixel included in the predetermined color component region caused by the flare when it is determined that the flare has occurred And
A smoothing unit that performs a smoothing process on the image based on the weight set by the setting unit;
An image processing apparatus comprising:
請求項1に記載の画像処理装置において、
前記画像から前記所定の色成分の領域を検出する領域検出部と、
前記画像に含まれるエッジを検出するエッジ検出部と、
を備え、
前記フレア判定部は、前記領域検出部の検出結果及び前記エッジ検出部の検出結果に基づいて、前記フレアが発生しているか否かを判定することを特徴とする画像処理装置。
The image processing apparatus according to claim 1.
An area detector for detecting an area of the predetermined color component from the image;
An edge detection unit for detecting an edge included in the image;
With
The flare determination unit determines whether or not the flare is generated based on a detection result of the region detection unit and a detection result of the edge detection unit.
請求項1に記載の画像処理装置において、
前記設定部は、色度図における前記所定の色成分が取り得る色域を複数の領域に分割し、前記フレアに起因した前記所定の色成分の領域に含まれる各画素の色成分値が前記複数の領域のいずれかに属するかを判定することで、前記フレアに起因した前記所定の色成分の領域に含まれる各画素に対して、前記重みを設定することを特徴とする画像処理装置。
The image processing apparatus according to claim 1.
The setting unit divides a color gamut that the predetermined color component in the chromaticity diagram can take into a plurality of regions, and a color component value of each pixel included in the region of the predetermined color component caused by the flare is An image processing apparatus, wherein the weight is set for each pixel included in the region of the predetermined color component caused by the flare by determining which of the plurality of regions belongs.
請求項3に記載の画像処理装置において、
前記設定部は、前記画像のうち、前記フレアに起因した前記所定の色成分の領域を除く領域に含まれる画素に対して、前記フレアに起因した前記所定の色成分の領域に含まれる各画素に設定される重みとは異なる重みを設定することを特徴とする画像処理装置。
The image processing apparatus according to claim 3.
The setting unit includes pixels that are included in a region of the predetermined color component caused by the flare and pixels included in a region excluding the region of the predetermined color component caused by the flare in the image. An image processing apparatus characterized in that a weight different from the weight set in the above is set.
請求項1に記載の画像処理装置において、
前記画像は、撮像用画素と焦点検出用画素とを有し、
前記画像入力部により受け付けた画像、又は前記平滑化処理を行った画像に対して補間処理を行うことで、前記焦点検出用画素に対する補間画素値を生成する画素補間部をさらに備えていることを特徴とする画像処理装置。
The image processing apparatus according to claim 1.
The image has imaging pixels and focus detection pixels,
The image processing apparatus further includes a pixel interpolation unit that generates an interpolation pixel value for the focus detection pixel by performing an interpolation process on the image received by the image input unit or the image subjected to the smoothing process. A featured image processing apparatus.
前記画像を取得する撮像素子と、
請求項1から請求項5のいずれか1項に記載の画像処理装置と、
を備えたことを特徴とする撮像装置。
An image sensor for acquiring the image;
The image processing apparatus according to any one of claims 1 to 5,
An imaging apparatus comprising:
画像を受け付ける画像入力工程と、
前記画像に含まれる所定の色成分の領域に関わる情報に基づいて、フレアが発生しているか否かを判定するフレア判定工程と、
前記フレアが発生していると判定されたときに、少なくとも前記フレアに起因した前記所定の色成分の領域に含まれる画素に対して、前記画素が有する色成分値に基づいた重みを設定する設定工程と、
前記設定工程により設定された前記重みに基づいて、前記画像に対する平滑化処理を実行する平滑化工程と、
をコンピュータに実行させることが可能な画像処理プログラム。
An image input process for receiving images;
A flare determination step for determining whether or not flare has occurred based on information relating to a region of a predetermined color component included in the image;
Setting that sets a weight based on a color component value of the pixel at least for a pixel included in the predetermined color component region caused by the flare when it is determined that the flare has occurred Process,
A smoothing step of executing a smoothing process on the image based on the weight set in the setting step;
An image processing program capable of causing a computer to execute.
JP2012121642A 2012-05-29 2012-05-29 Image processing apparatus, imaging apparatus, and image processing program Pending JP2013247597A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2012121642A JP2013247597A (en) 2012-05-29 2012-05-29 Image processing apparatus, imaging apparatus, and image processing program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2012121642A JP2013247597A (en) 2012-05-29 2012-05-29 Image processing apparatus, imaging apparatus, and image processing program

Publications (1)

Publication Number Publication Date
JP2013247597A true JP2013247597A (en) 2013-12-09

Family

ID=49847040

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2012121642A Pending JP2013247597A (en) 2012-05-29 2012-05-29 Image processing apparatus, imaging apparatus, and image processing program

Country Status (1)

Country Link
JP (1) JP2013247597A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9936105B2 (en) 2014-12-26 2018-04-03 Canon Kabushiki Kaisha Image processing apparatus and image processing method
CN112519527A (en) * 2019-11-09 2021-03-19 解益新 Integrated bus control system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9936105B2 (en) 2014-12-26 2018-04-03 Canon Kabushiki Kaisha Image processing apparatus and image processing method
CN112519527A (en) * 2019-11-09 2021-03-19 解益新 Integrated bus control system

Similar Documents

Publication Publication Date Title
JP5994778B2 (en) Flare determination device, imaging device, and flare determination program
JP6040594B2 (en) Imaging apparatus, image processing apparatus, and image processing program
KR101263888B1 (en) Image processing apparatus and image processing method as well as computer program
CN105049680B (en) Carry out image processing equipment and image processing method that image restores processing
US8692909B2 (en) Image processing device and image pickup device using the same
US8243158B2 (en) Image processing device, imaging device, and medium storing image processing program for interpolating at an af pixel position
US8199229B2 (en) Color filter, image processing apparatus, image processing method, image-capture apparatus, image-capture method, program and recording medium
JP3892648B2 (en) Image input device, white balance adjustment method, and computer-readable recording medium storing program for executing the method
US10630920B2 (en) Image processing apparatus
US8970745B2 (en) Image processing device, image processing method and storage medium to suppress shading of images in which pixel addition processing is performed
US9699387B2 (en) Image processing device for processing pupil-divided images obtained through different pupil regions of an imaging optical system, control method thereof, and program
CN106162132A (en) Image processing equipment and control method thereof
US8284278B2 (en) Image processing apparatus, imaging apparatus, method of correction coefficient calculation, and storage medium storing image processing program
US9398207B2 (en) Imaging apparatus and image correction method, and image processing apparatus and image processing method
JP5834542B2 (en) Imaging apparatus, image processing apparatus, program, and recording medium
JP2014036262A (en) Imaging device
JP2013247597A (en) Image processing apparatus, imaging apparatus, and image processing program
JP2010068465A (en) Image processing apparatus, image capturing apparatus, and image processing method
JP2013125046A (en) Imaging device and camera system
JP2009022044A (en) Image processing apparatus and image processing program
JP2009065691A (en) Image processing apparatus, recording medium and image processing program
JP2013013006A (en) Imaging apparatus, manufacturing method of the same, image processor, program and recording medium
KR20110047540A (en) Digital camera and controlling method thereof
JP2014164236A (en) Imaging device
JP2001238128A (en) Image processing apparatus