JP2017152866A - Image processing system and image processing method - Google Patents

Image processing system and image processing method Download PDF

Info

Publication number
JP2017152866A
JP2017152866A JP2016032424A JP2016032424A JP2017152866A JP 2017152866 A JP2017152866 A JP 2017152866A JP 2016032424 A JP2016032424 A JP 2016032424A JP 2016032424 A JP2016032424 A JP 2016032424A JP 2017152866 A JP2017152866 A JP 2017152866A
Authority
JP
Japan
Prior art keywords
subject
target
shadow
state
light source
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.)
Granted
Application number
JP2016032424A
Other languages
Japanese (ja)
Other versions
JP6718253B2 (en
JP2017152866A5 (en
Inventor
哲也 秦
Tetsuya Hata
哲也 秦
平井 信也
Shinya Hirai
信也 平井
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Canon Inc
Original Assignee
Canon Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Canon Inc filed Critical Canon Inc
Priority to JP2016032424A priority Critical patent/JP6718253B2/en
Publication of JP2017152866A publication Critical patent/JP2017152866A/en
Publication of JP2017152866A5 publication Critical patent/JP2017152866A5/ja
Application granted granted Critical
Publication of JP6718253B2 publication Critical patent/JP6718253B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

PROBLEM TO BE SOLVED: To provide a natural correction result by adequately determining a state of shade to be used as a correction target, when a rewriting correction is made to an image including a plurality of subjects.SOLUTION: A subject in an input image is detected, the contrast value of each subject is detected, and a subject the detected contrast value of which is largest and a subject the detected contrast value of which is smallest are selected as subjects to be corrected. A target contrast value is set so that the subject the selected contrast value of which is largest is decreased in contrast value and the subject the contrast value of which is smallest is increased in contrast value. A virtual light-source is set so that the contrast value of a subject to be corrected is equal to the target contrast value. Using the virtual light-source, the brightness of the subject to be corrected is corrected.SELECTED DRAWING: Figure 2

Description

本発明は、画像処理装置に関し、特に、入力された画像の明るさを補正する画像処理装置及び方法に関するものである。   The present invention relates to an image processing apparatus, and more particularly to an image processing apparatus and method for correcting the brightness of an input image.

従来、撮影後の画像中の被写体に対して、仮想的な光源(仮想光源)からの光を照射し、リライティングを行う技術が知られている。これにより、環境光によって生じる被写体の陰影を、撮影後に補正することができる。
例えば、特許文献1では、撮影画像に対して疑似的なライティング処理を行うリライティング処理手段について開示されている。具体的には、仮想光源の位置を決定する方法に関して、被写体に対して環境光と仮想光源とを逆方向に配置することにより、被写体の影を低減させるよう補正する技術が開示されている。
2. Description of the Related Art Conventionally, a technique for performing relighting by irradiating light from a virtual light source (virtual light source) to a subject in an image after shooting is known. Thereby, the shadow of the subject caused by the ambient light can be corrected after shooting.
For example, Patent Document 1 discloses a relighting processing unit that performs pseudo lighting processing on a captured image. Specifically, with respect to a method for determining the position of a virtual light source, a technique for correcting the subject to reduce the shadow of the subject by disposing the ambient light and the virtual light source in opposite directions is disclosed.

特開2010−135996号公報JP 2010-135996 A

リライティング補正を行うことで、被写体の陰影の状態を目標とする陰影の状態へ近づけるよう補正する事ができる。リライティング補正の目標とする陰影の状態は、画像中の被写体が一つのみである場合には、見た目に好ましい所定の陰影の状態を定めれば良い。   By performing the relighting correction, it is possible to correct the shadow state of the subject so as to approach the target shadow state. As the shadow state targeted for relighting correction, when there is only one subject in the image, a predetermined shade state that is desirable to the eye may be determined.

一方、画像中の被写体が複数存在する場合には、単に見た目に好ましい陰影の状態を定めるのではなく、被写体間での陰影の状態の違いも考慮して目標とする陰影の状態を定める必要がある。例えば、コントラストの大小関係など、被写体間での陰影の状態の違いは、それぞれの被写体への撮影時の環境光の当たり方の違いを反映したものである。このため、リライティング補正の前後で、被写体間の陰影の状態の関係が逆転してしまうと、撮影時の環境光の当たり方と矛盾する不自然な画像になる場合があると考えられるからである。   On the other hand, when there are a plurality of subjects in the image, it is necessary to determine the target shade state in consideration of the difference in the shade state between the subjects, instead of simply determining the preferred shade state to the eye. is there. For example, the difference in the state of shadow between subjects such as the magnitude relationship of the contrast reflects the difference in how ambient light strikes each subject when shooting. For this reason, if the relationship of the shadow state between the subjects is reversed before and after the relighting correction, it is considered that there may be an unnatural image that contradicts the way the ambient light hits at the time of shooting. .

しかしながら、特許文献1で挙げた従来の技術においては、画像中に被写体が複数含まれる場合に、目標とする陰影の状態を設定する方法が開示されておらず、複数の被写体に対するリライティング補正を適切に制御できない場合があった。   However, the conventional technique described in Patent Document 1 does not disclose a method for setting a target shadow state when an image includes a plurality of subjects, and appropriate relighting correction for a plurality of subjects is performed. There was a case that could not be controlled.

そこで、本発明の目的は、複数の被写体が存在する画像に対して、仮想光源を用いてリライティング処理を行う場合に、リライティング補正の目標とする陰影の状態を適切に決定することにより、自然なリライティング結果を得ることが可能となる画像処理装置及び方法を提供することである。   Accordingly, an object of the present invention is to determine a natural shadow state as a target for relighting correction when performing relighting processing using a virtual light source on an image having a plurality of subjects. It is an object to provide an image processing apparatus and method capable of obtaining a relighting result.

上記目的を達成するために、本発明は以下の構成を有する。   In order to achieve the above object, the present invention has the following configuration.

着目画像中の被写体を検出する被写体検出手段と、
前記被写体ごとの陰影の程度を示す陰影状態を検出する状態検出手段と、
検出された前記陰影状態に基づいて、前記被写体の補正の前の陰影の程度と補正の後の陰影の程度の序列が入れ替わらないように、前記着目画像中の対象となる被写体ごとに、目標となる陰影の状態である目標陰影状態を設定する目標設定手段と、
前記着目画像に対して、前記状態検出手段により検出された陰影状態と前記目標陰影状態とに基づいて、前記対象となる被写体ごとに仮想光源の設定を決定する光源設定手段と、
前記仮想光源を用いて前記着目画像中の前記対象となる被写体の明るさを補正する補正手段とを備えることを特徴とする画像処理装置。
Subject detection means for detecting a subject in the image of interest;
State detecting means for detecting a shadow state indicating a degree of shadow for each subject;
Based on the detected shadow state, a target for each target subject in the image of interest is arranged so that the order of the degree of shadow before correction of the subject and the order of shadow after correction are not interchanged. Target setting means for setting a target shadow state that is a shadow state to become,
A light source setting unit that determines a setting of a virtual light source for each target subject based on the shadow state detected by the state detection unit and the target shadow state for the target image;
An image processing apparatus comprising: a correction unit that corrects the brightness of the subject subject in the image of interest using the virtual light source.

本発明によれば、複数の被写体が存在する画像に対するリライティング処理を行う際に、それぞれの被写体に対するリライティング補正の目標とする陰影の状態を適切に設定することで、自然なリライティング結果を得ることが可能となる。   According to the present invention, when performing relighting processing on an image in which a plurality of subjects exist, a natural relighting result can be obtained by appropriately setting a shadow state targeted for relighting correction for each subject. It becomes possible.

デジタルカメラの構成を示すブロック図である。It is a block diagram which shows the structure of a digital camera. 画像処理部の構成を示すブロック図である。It is a block diagram which shows the structure of an image process part. 本発明の第1の実施例におけるリライティング処理全体の流れを示すフローチャートである。It is a flowchart which shows the flow of the whole relighting process in 1st Example of this invention. 本発明の第1の実施例における被写体の例を示す図である。It is a figure which shows the example of the to-be-photographed object in 1st Example of this invention. 本発明の第1の実施例における目標陰影状態の設定方法を説明する図である。It is a figure explaining the setting method of the target shadow state in 1st Example of this invention. 本発明の第一の実施例における仮想光源の位置を決定する方法の例を示す図である。It is a figure which shows the example of the method of determining the position of the virtual light source in the 1st Example of this invention. 本発明の第1の実施例における仮想光源と被写体の位置関係の例を示す図である。It is a figure which shows the example of the positional relationship of a virtual light source and a to-be-photographed object in 1st Example of this invention. 本発明の第2の実施例における目標陰影状態の設定処理の流れを示すフローチャートである。It is a flowchart which shows the flow of the setting process of the target shadow state in 2nd Example of this invention.

以下に、本発明の好ましい実施の形態を、添付の図面に基づいて詳細に説明する。本実施例では、画像処理装置としてデジタルカメラに適用した例について説明する。   Hereinafter, preferred embodiments of the present invention will be described in detail with reference to the accompanying drawings. In this embodiment, an example in which the image processing apparatus is applied to a digital camera will be described.

以下、図1〜7を参照して、本発明の第1の実施例おける、デジタルカメラについて説明する。
<デジタルカメラの構成>
図1は、本発明の実施形態によるデジタルカメラ100の構成例を示すブロック図である。本発明は撮影された画像に適用する画像処理、より具体的にはリライティング(re-lighting)処理の方法に特徴を有する。従って、撮影や記録に関する構成は必須では無い。
A digital camera according to the first embodiment of the present invention will be described below with reference to FIGS.
<Configuration of digital camera>
FIG. 1 is a block diagram illustrating a configuration example of a digital camera 100 according to an embodiment of the present invention. The present invention is characterized by an image processing applied to a captured image, more specifically, a relighting processing method. Therefore, a configuration relating to shooting and recording is not essential.

図1において、レンズ群101は、フォーカスレンズを含むズームレンズである。絞り機能を備えるシャッター102が、レンズ群101と撮像部103との間に設けられている。撮像部103は、レンズ群101によって撮像面に形成される光学像を画素単位の電気信号に変換するCCD/CMOSイメージセンサを代表とする撮像素子を有する。A/D変換器104は、撮像部103が出力するアナログ信号をデジタル信号(画像データ)に変換する。   In FIG. 1, a lens group 101 is a zoom lens including a focus lens. A shutter 102 having a diaphragm function is provided between the lens group 101 and the imaging unit 103. The imaging unit 103 includes an imaging element represented by a CCD / CMOS image sensor that converts an optical image formed on the imaging surface by the lens group 101 into an electrical signal in pixel units. The A / D converter 104 converts the analog signal output from the imaging unit 103 into a digital signal (image data).

画像処理部105は、A/D変換器104から出力される画像データに対し、色補間(デモザイク)、ホワイトバランス調整、γ補正などの各種画像処理を行う。画像処理部105はまた、撮影された画像に対するリライティング処理を行う。画像メモリ106は画像データを一時的に記憶する。メモリ制御部107は、画像メモリ106の読み書きを制御する。D/A変換器108は、画像データをアナログ信号に変換する。表示部109はLCDや有機ELディスプレイ等の表示装置を有し、各種GUIやライブビュー画像、記録媒体112から読み出して再生した画像などを表示する。コーデック部110は、画像メモリ106に記憶されている画像データを記録媒体に記録するために予め定められた方法で符号化したり、画像ファイルに含まれる符号化画像データを例えば表示のために復号したりする。   The image processing unit 105 performs various image processing such as color interpolation (demosaic), white balance adjustment, and γ correction on the image data output from the A / D converter 104. The image processing unit 105 also performs relighting processing on the captured image. The image memory 106 temporarily stores image data. A memory control unit 107 controls reading and writing of the image memory 106. The D / A converter 108 converts the image data into an analog signal. The display unit 109 includes a display device such as an LCD or an organic EL display, and displays various GUIs, live view images, images read out from the recording medium 112 and reproduced. The codec unit 110 encodes the image data stored in the image memory 106 by a predetermined method for recording on the recording medium, or decodes the encoded image data included in the image file for display, for example. Or

インタフェース(I/F)111は、例えば半導体メモリカードやカード型ハードディスクなどの着脱可能な記録媒体112を、デジタルカメラ100と機械的および電気的に接続する。システム制御部50は例えばCPUやMPUなどのプログラマブルなプロセッサであってよい。システム制御部50は、不揮発性メモリ121等に記録されたプログラムを実行して必要なブロックや回路を制御することにより、デジタルカメラ100の機能を実現する。   The interface (I / F) 111 mechanically and electrically connects a detachable recording medium 112 such as a semiconductor memory card or a card type hard disk to the digital camera 100. The system control unit 50 may be a programmable processor such as a CPU or MPU. The system control unit 50 implements the functions of the digital camera 100 by executing a program recorded in the nonvolatile memory 121 and controlling necessary blocks and circuits.

顔検出部113は、撮影された画像に含まれる顔領域を検出し、検出された顔領域のそれぞれについて、位置、大きさ、信頼度などの顔情報を求める。なお、顔検出部113はニューラルネットワークに代表される学習を用いた手法、目、鼻、口などの特徴部位を、画像領域からテンプレートマッチングを用い探し出し類似度が高ければ顔とみなす手法など、任意の方法を用いて顔領域を検出することができる。   The face detection unit 113 detects a face area included in the photographed image, and obtains face information such as a position, a size, and reliability for each of the detected face areas. Note that the face detection unit 113 uses a technique such as learning represented by a neural network, a feature part such as an eye, nose, or mouth is searched from an image area using template matching, and is considered as a face if the similarity is high. The face area can be detected by using the method.

操作部120は、ユーザがデジタルカメラ100に各種の指示を入力するためのボタンやスイッチなどの入力デバイスをまとめて記載したものである。表示部109がタッチディスプレイである場合、タッチパネルは操作部120に含まれる。また、音声入力や視線入力など、非接触で指示を入力するタイプの入力デバイスが操作部120に含まれてもよい。   The operation unit 120 collectively describes input devices such as buttons and switches for the user to input various instructions to the digital camera 100. When the display unit 109 is a touch display, the touch panel is included in the operation unit 120. Further, the operation unit 120 may include an input device of a type that inputs an instruction in a non-contact manner such as voice input or line-of-sight input.

不揮発性メモリ121は電気的に消去・記録可能な、例えばEEPROM等であってよい。不揮発性メモリ121は、各種の設定値、GUIデータをはじめ、システム制御部50がMPUやCPUである場合には、システム制御部50が実行するためのプログラムが記録される。システムメモリ122は、システム制御部50の動作用の定数、変数、不揮発性メモリ121から読みだしたプログラム等を展開するために用いる。   The nonvolatile memory 121 may be an electrically erasable / recordable, for example, an EEPROM. The nonvolatile memory 121 stores various setting values and GUI data, and programs to be executed by the system control unit 50 when the system control unit 50 is an MPU or CPU. The system memory 122 is used to develop constants and variables for operation of the system control unit 50, programs read from the nonvolatile memory 121, and the like.

<デジタルカメラの基本動作>
次に、上記のように構成されたデジタルカメラ100における被写体撮影時の基本動作について説明する。撮像部103は、シャッター102が開いている際にレンズ群101が撮像面に形成する被写体像を撮像素子によって光電変換し、アナログ画像信号としてA/D変換器104へ出力する。A/D変換器104は撮像部103から出力されるアナログ画像信号をデジタル画像信号(画像データ)に変換し画像処理部105に出力する。
画像処理部105は、A/D変換器104からの画像データ、又は、メモリ制御部107からの画像データに対し、同時化処理(デモザイク処理)、γ補正、リライティング処理などの各種画像処理を行う。また、画像処理部105では、撮影で得られた画像データを用いて輝度やコントラストなどに関する所定の演算処理を行い、得られた演算結果に基づいてシステム制御部50が焦点調節や露光制御を行う。焦点検出や露出制御に顔検出部113の検出結果を考慮してもよい。このように、本実施形態のデジタルカメラ100では、TTL(スルー・ザ・レンズ)方式のAF(オートフォーカス)処理、AE(自動露出)処理を行う。画像処理部105ではさらに、撮影で得られた画像データを用いたオートホワイトバランス(AWB)調整も行う。
<Basic operation of digital camera>
Next, a basic operation at the time of photographing an object in the digital camera 100 configured as described above will be described. The imaging unit 103 photoelectrically converts the subject image formed on the imaging surface by the lens group 101 when the shutter 102 is opened, and outputs the subject image to the A / D converter 104 as an analog image signal. The A / D converter 104 converts the analog image signal output from the imaging unit 103 into a digital image signal (image data) and outputs the digital image signal to the image processing unit 105.
The image processing unit 105 performs various image processing such as synchronization processing (demosaic processing), γ correction, and relighting processing on the image data from the A / D converter 104 or the image data from the memory control unit 107. . Further, the image processing unit 105 performs predetermined calculation processing relating to brightness, contrast, and the like using image data obtained by photographing, and the system control unit 50 performs focus adjustment and exposure control based on the obtained calculation result. . You may consider the detection result of the face detection part 113 for focus detection or exposure control. As described above, the digital camera 100 according to the present embodiment performs TTL (through the lens) AF (autofocus) processing and AE (automatic exposure) processing. The image processing unit 105 further performs auto white balance (AWB) adjustment using image data obtained by shooting.

画像処理部105から出力された画像データは、メモリ制御部107を介して画像メモリ106に書き込まれる。画像メモリ106は、撮像部103から出力された画像データや、表示部109に表示するための画像データを格納する。
また、D/A変換器108は、画像メモリ106に格納されている画像表示用のデータをアナログ信号に変換して表示部109に供給する。表示部109は、LCD等の表示装置に、D/A変換器108からのアナログ信号に応じた表示を行う。
コーデック部110は、画像メモリ106に記録された画像データをJPEGやMPEGなどの規格に基づき符号化する。システム制御部50は符号化した画像データに対して予め定められたヘッダなどを付与して画像ファイルを形成し、インタフェース111を介して記録媒体112に記録する。
The image data output from the image processing unit 105 is written into the image memory 106 via the memory control unit 107. The image memory 106 stores image data output from the imaging unit 103 and image data to be displayed on the display unit 109.
The D / A converter 108 converts the image display data stored in the image memory 106 into an analog signal and supplies the analog signal to the display unit 109. The display unit 109 performs display in accordance with an analog signal from the D / A converter 108 on a display device such as an LCD.
The codec unit 110 encodes the image data recorded in the image memory 106 based on a standard such as JPEG or MPEG. The system control unit 50 assigns a predetermined header or the like to the encoded image data, forms an image file, and records the image file on the recording medium 112 via the interface 111.

なお、現在のデジタルカメラでは、撮影スタンバイ状態においては動画撮影を行い、撮影された動画を表示部109に表示し続けることにより表示部109を電子ビューファインダ(EVF)として機能させるのが一般的である。この場合、シャッター102は開いた状態とし、撮像部103のいわゆる電子シャッターを用いて例えば30フレーム/秒の撮影を行う。   Note that with current digital cameras, it is common to perform moving image shooting in the shooting standby state, and keep the captured moving image displayed on the display unit 109 so that the display unit 109 functions as an electronic viewfinder (EVF). is there. In this case, the shutter 102 is opened and a so-called electronic shutter of the imaging unit 103 is used to capture an image at, for example, 30 frames / second.

そして、操作部120に含まれるシャッターボタンが半押しされると上述のAF,AE制御が行われ、全押しされると本撮影により記録用の静止画撮影が実行され、記録媒体112に記録される。また、動画撮影ボタンなどにより動画撮影が指示された場合は、記録媒体112への動画記録を開始する。   When the shutter button included in the operation unit 120 is half-pressed, the above-described AF and AE control is performed. When the shutter button is fully pressed, the still image shooting for recording is performed by the main shooting and is recorded on the recording medium 112. The Also, when moving image shooting is instructed by a moving image shooting button or the like, moving image recording on the recording medium 112 is started.

<リライティング処理に関する機能構成例>
図2は、画像処理部105の、リライティング処理に関係する機能構成例を示すブロック図である。なお、図2に示す機能ブロックの1つ以上は、マイクロプロセッサとソフトウェアの組み合わせよって実現されてもよいし、ASIC(Application Specific Integrated Circuit)やPLD(Programmable Logic Device)のようなハードウェアによって実現されてもよい。PLDにはFPGA(Field-Programmable Gate Array)、PLA(Programmable Logic Array)などが含まれる。なお、リライティング処理は、リライティング処理の実行が指定された状態で撮影された画像や、メニュー画面等からリライティング処理の実施が指示された、例えば記録媒体112に記録済の画像に対して実施することができる。なお、リライティング処理において撮影時の情報が必要な場合、不揮発性メモリ121またはシステムメモリ122から読み出したり、画像ファイルのヘッダなどから取得したりするものとする。図2において、画像処理部105は、画像信号生成部201、WB増幅部202、被写体領域抽出部203、陰影状態検出部204、目標陰影状態設定部205、仮想光源設定部206、仮想光源信号付加部207、ガンマ処理部208を含む。
<Example of functional configuration related to relighting>
FIG. 2 is a block diagram illustrating a functional configuration example of the image processing unit 105 related to the relighting process. Note that one or more of the functional blocks shown in FIG. 2 may be realized by a combination of a microprocessor and software, or may be realized by hardware such as an ASIC (Application Specific Integrated Circuit) or a PLD (Programmable Logic Device). May be. PLD includes FPGA (Field-Programmable Gate Array), PLA (Programmable Logic Array), and the like. Note that the relighting process is performed on an image captured in a state where execution of the relighting process is specified, or an image recorded on the recording medium 112, for example, on which execution of the relighting process is instructed from a menu screen or the like. Can do. When information at the time of shooting is necessary in the relighting process, the information is read from the nonvolatile memory 121 or the system memory 122 or acquired from the header of the image file. In FIG. 2, the image processing unit 105 includes an image signal generation unit 201, a WB amplification unit 202, a subject area extraction unit 203, a shadow state detection unit 204, a target shadow state setting unit 205, a virtual light source setting unit 206, and a virtual light source signal addition. A unit 207 and a gamma processing unit 208.

<リライティング処理>
次に、画像処理部105における処理の流れを説明する。図3に示したのは、画像処理部105の各部が実行するリライティング処理全体の流れを示したフローチャートである。
ステップS301では、被写体領域抽出部203が、WB増幅部202から入力された画像信号のうち、被写体領域に対応する画像信号のみを抽出する。すなわち被写体検出を行う。なお入力された画像信号を入力画像または着目画像と呼ぶ。例えば、リライティング処理の対象となる被写体領域が、人物の顔領域である場合、顔検出部113で検出した被写体人物の顔領域に対応する画像信号を抽出する。被写体が複数存在する場合は、複数の被写体領域をそれぞれ抽出する。
ステップS302では、被写体領域抽出部203が、抽出した被写体領域が着目画像中に複数存在するか否かを判定する。被写体領域が複数存在していると判定した場合は、ステップS303へ進み、被写体領域が単一である場合は、ステップS307へ進む。
<Relighting process>
Next, the flow of processing in the image processing unit 105 will be described. FIG. 3 is a flowchart showing the overall flow of relighting processing executed by each unit of the image processing unit 105.
In step S <b> 301, the subject region extraction unit 203 extracts only the image signal corresponding to the subject region from the image signals input from the WB amplification unit 202. That is, subject detection is performed. The input image signal is referred to as an input image or a target image. For example, when the subject area to be rewritten is a human face area, an image signal corresponding to the face area of the subject person detected by the face detection unit 113 is extracted. When there are a plurality of subjects, a plurality of subject regions are extracted.
In step S302, the subject area extraction unit 203 determines whether a plurality of extracted subject areas exist in the image of interest. If it is determined that there are a plurality of subject areas, the process proceeds to step S303, and if the subject area is single, the process proceeds to step S307.

ステップS303では、陰影状態検出部204が、抽出された被写体領域のそれぞれに対して、被写体の陰影の状態を検出する。陰影状態検出部204は、検出した被写体の陰影の状態を表す情報を、目標陰影状態設定部205へ出力する。陰影の状態とは、例えば被写体領域中の明るさの分布と、被写体領域中のコントラストを表す情報と、被写体領域中で陰影が生じている領域の輪郭の特性と、被写体領域中で陰影が生じている領域の面積を表す情報のうちの少なくとも一つの情報を含む。本実施例では主にコントラスト値を陰影状態を示す評価値として用いる。
ステップS304では、目標陰影状態設定部205が、入力された被写体それぞれの陰影の状態を表す情報を比較した結果に基づき、リライティング補正の対象とする被写体を決定する。
ステップS305では、目標陰影状態設定部205が、ステップS304で選択された被写体のそれぞれに対して、入力された被写体の陰影の状態を表す情報を比較した結果に基づき目標設定する。すなわち、リライティング補正の目標とする陰影の状態である目標陰影状態を決定する。目標陰影状態設定部205は、決定した目標陰影状態を表す情報を、仮想光源設定部206へ出力する。
ステップS306では、仮想光源設定部206が、入力された目標陰影状態を表す情報と、陰影状態検出部204が検出した被写体の陰影の状態を表す情報に基づき、ステップS304で選択された被写体のそれぞれに対して、仮想光源の設定値を決定する。仮想光源設定部206は、決定した仮想光源の設定値を、仮想光源信号付加部207へ出力する。
In step S303, the shadow state detection unit 204 detects the shadow state of the subject for each of the extracted subject regions. The shadow state detection unit 204 outputs information representing the detected shadow state of the subject to the target shadow state setting unit 205. For example, the state of shading refers to the distribution of brightness in the subject area, information indicating the contrast in the subject area, the characteristics of the contour of the shaded area in the subject area, and the shadow in the subject area. Including at least one piece of information representing the area of the area. In this embodiment, the contrast value is mainly used as an evaluation value indicating the shadow state.
In step S <b> 304, the target shadow state setting unit 205 determines a subject for relighting correction based on the comparison result of the information representing the shadow state of each input subject.
In step S305, the target shadow state setting unit 205 sets a target based on the result of comparing the information representing the input shadow state of the subject for each of the subjects selected in step S304. That is, the target shadow state, which is the target shadow state for relighting correction, is determined. The target shadow state setting unit 205 outputs information representing the determined target shadow state to the virtual light source setting unit 206.
In step S306, the virtual light source setting unit 206 determines each of the subjects selected in step S304 based on the input information indicating the target shadow state and the information indicating the shadow state of the subject detected by the shadow state detection unit 204. On the other hand, the set value of the virtual light source is determined. The virtual light source setting unit 206 outputs the determined virtual light source setting value to the virtual light source signal adding unit 207.

ステップS307では、陰影状態検出部204が、抽出された被写体領域に対して、被写体の陰影の状態を検出する。陰影状態検出部204は、検出した被写体の陰影の状態を表す情報を、目標陰影状態設定部205へ出力する。
ステップS308では、目標陰影状態設定部205が、入力された被写体の陰影の状態を表す情報に基づき、リライティング補正の目標とする陰影の状態である目標陰影状態を決定する。ただし、ステップS308へ進む場合は、補正の対象となる被写体が一つのみ検出されている場合であり、被写体間で陰影の状態を比較して目標陰影状態を定める必要がない。このため、ここでは、予め定められた所定の陰影の状態を目標陰影状態として決定する。目標陰影状態検出部205は、決定した目標陰影状態を表す情報を、仮想光源設定部206へ出力する。
ステップS309では、仮想光源設定部206が、入力された被写体の陰影の状態を表す情報と、目標陰影状態を表す情報とに基づいて、仮想光源の設定値を決定する。仮想光源設定部206は、決定した仮想光源の設定値を、仮想光源信号付加部207へ出力する。ここで仮想光源の設定値を決定する方法は、ステップS306で用いる方法と同様である。
In step S307, the shadow state detection unit 204 detects the shadow state of the subject with respect to the extracted subject region. The shadow state detection unit 204 outputs information representing the detected shadow state of the subject to the target shadow state setting unit 205.
In step S308, the target shadow state setting unit 205 determines a target shadow state, which is a target shadow state for relighting correction, based on the input information indicating the shadow state of the subject. However, when the process proceeds to step S308, only one subject to be corrected is detected, and it is not necessary to determine the target shadow state by comparing the shadow states between the subjects. For this reason, here, a predetermined shadow state determined in advance is determined as the target shadow state. The target shadow state detection unit 205 outputs information representing the determined target shadow state to the virtual light source setting unit 206.
In step S309, the virtual light source setting unit 206 determines a setting value of the virtual light source based on the input information indicating the shadow state of the subject and the information indicating the target shadow state. The virtual light source setting unit 206 outputs the determined virtual light source setting value to the virtual light source signal adding unit 207. Here, the method for determining the setting value of the virtual light source is the same as the method used in step S306.

ステップS310では、仮想光源信号付加部207が、入力された仮想光源の設定値に基づいて、仮想光源に対応する信号を生成し、WB増幅部202から入力された画像信号に対して付加する。なお、リライティング対象となる被写体が複数選択されている場合は、それぞれの被写体に対してステップS306で決定された仮想光源の設定値に基づいて、仮想光源に対応する信号を生成する。
以上が、本実施例におけるリライティング処理の全体の流れである。以下、各ステップにおける処理の詳細について、順に説明する。
In step S <b> 310, the virtual light source signal adding unit 207 generates a signal corresponding to the virtual light source based on the input setting value of the virtual light source, and adds the signal to the image signal input from the WB amplification unit 202. If a plurality of subjects to be relighted are selected, a signal corresponding to the virtual light source is generated based on the setting value of the virtual light source determined in step S306 for each subject.
The above is the overall flow of the relighting process in the present embodiment. Hereinafter, details of processing in each step will be described in order.

<被写体の陰影状態の検出処理>
図4を用いて、陰影状態検出部204が、環境光によって生じる被写体の陰影の状態を検出する処理の詳細について説明する。この処理は図3のステップS303、S307に相当する。陰影状態検出部204は、被写体領域抽出部203から入力された被写体領域の画像信号に基づいて、被写体の明るさ情報を算出する。具体的には、図4に示したように、被写体領域を複数の部分(例えば、8×8=64個のブロック)に分割して、分割したブロック毎に輝度平均値を算出する。次に、陰影状態検出部204は、算出した輝度平均値に基づいて、被写体のコントラスト値を算出する。具体的には、分割した複数のブロックのうち、最も平均輝度の高いブロック(402)と最も平均輝度の低いブロック(403)を選び、その平均輝度の比を算出して、コントラスト値として用いる事とする。ただし、輝度信号に加えて、色相や彩度などの色信号をブロック毎に算出して、被写体色が近いブロック間でコントラスト値を算出するようにする。被写体色が近いとは、たとえば色相や彩度などの色信号の値の差が所定値以内であることなどにより判定される。被写体色が近いブロック間でコントラスト値を算出する場合、たとえば、被写体のブロックを被写体色が近いグループに分類し、各グループ内でコントラスト値を算出する。そしてグループ間で最も大きいコントラスト値を最終的なコントラスト値とする。陰影状態検出部204は、算出したコントラスト値を、被写体陰影情報として、目標陰影状態設定部205へ出力する。
<Detection process of shadow state of subject>
Details of processing in which the shadow state detection unit 204 detects the shadow state of the subject caused by ambient light will be described with reference to FIG. This process corresponds to steps S303 and S307 in FIG. The shadow state detection unit 204 calculates the brightness information of the subject based on the image signal of the subject area input from the subject region extraction unit 203. Specifically, as shown in FIG. 4, the subject area is divided into a plurality of parts (for example, 8 × 8 = 64 blocks), and an average luminance value is calculated for each of the divided blocks. Next, the shadow state detection unit 204 calculates the contrast value of the subject based on the calculated luminance average value. Specifically, the block having the highest average luminance (402) and the block having the lowest average luminance (403) are selected from the plurality of divided blocks, and the ratio of the average luminance is calculated and used as the contrast value. And However, in addition to the luminance signal, a color signal such as hue and saturation is calculated for each block, and a contrast value is calculated between blocks having close subject colors. Whether the subject colors are close is determined by, for example, the difference between the values of color signals such as hue and saturation being within a predetermined value. When calculating the contrast value between blocks with close subject colors, for example, the blocks of the subject are classified into groups with close subject colors, and the contrast value is calculated within each group. The largest contrast value between the groups is set as the final contrast value. The shadow state detection unit 204 outputs the calculated contrast value to the target shadow state setting unit 205 as subject shadow information.

また、陰影状態検出部204は、環境光の位置の推定を行う。環境光の位置の推定は、公知の種々の方法を用いる事ができる。例えば、被写体の中で最も明るい領域を検出して、その領域の法線ベクトルを算出し、その方向を環境光が位置する方向として定めても良い。また、人物の顔領域であれば、鼻などの器官を検出し、その陰の位置を検出することにより、環境光の方向を推定するようにしてもよい。陰影状態検出部204は、推定した環境光の位置情報を、仮想光源設定部206へ出力する。   The shadow state detection unit 204 estimates the position of the ambient light. Various known methods can be used to estimate the position of the ambient light. For example, the brightest area in the subject may be detected, the normal vector of the area may be calculated, and the direction may be determined as the direction in which the ambient light is located. Further, in the case of a human face region, the direction of the ambient light may be estimated by detecting an organ such as the nose and detecting the shadow position. The shadow state detection unit 204 outputs the estimated position information of the ambient light to the virtual light source setting unit 206.

<リライティング対象の決定処理>
次に、目標陰影状態設定部205が、被写体陰影情報に基づいて、リライティング対象とする被写体を決定する処理について、詳細を説明する。この処理は図3のステップS304に相当する。
図5に示したのは、画像中に複数の被写体が含まれる場合に、それぞれの被写体のコントラスト値を算出した結果の例を示したものである。図の横軸は、被写体の区別を表し、縦軸はコントラスト値を表す。図中のCa〜Cdはそれぞれ、被写体a〜dのコントラスト値を表す。図に示した通り、Ca<Cb<Cc<Cdの関係がある。
<Relighting target decision process>
Next, the process in which the target shadow state setting unit 205 determines a subject to be rewritten based on the subject shadow information will be described in detail. This process corresponds to step S304 in FIG.
FIG. 5 shows an example of the result of calculating the contrast value of each subject when the image includes a plurality of subjects. In the figure, the horizontal axis represents subject distinction, and the vertical axis represents the contrast value. Ca to Cd in the figure represent the contrast values of the subjects a to d, respectively. As shown in the figure, there is a relationship of Ca <Cb <Cc <Cd.

目標陰影状態設定部205は、コントラスト値が最も低い被写体と、最も高い被写体とを、リライティング補正の対象として選択する。図5に示した場合であれば、被写体aと被写体dとがリライティング補正の対象となり、被写体b、cはリライティング補正の対象としない。このようにすることで、リライティング補正によって陰影の状態を補正する必要が高いと考えられる被写体のみをリライティング補正の対象とする事ができる。一方、それ以外の被写体はリライティング補正を行わないため、撮影時の環境光による陰影の状態を残した画像を生成することができる。   The target shadow state setting unit 205 selects the subject with the lowest contrast value and the subject with the highest contrast value as the relighting correction target. In the case shown in FIG. 5, subjects a and d are subject to relighting correction, and subjects b and c are not subject to relighting correction. In this way, it is possible to set only the subject that is considered highly necessary to correct the shadow state by the relighting correction as the target of the relighting correction. On the other hand, since relighting correction is not performed on other subjects, it is possible to generate an image that retains the shaded state due to ambient light at the time of shooting.

<被写体の目標陰影状態の決定処理>
次に、目標陰影状態設定部205が、リライティング補正の対象として選択した被写体に対する目標陰影状態を決定する処理について、詳細を説明する。この処理は図3のステップS305、S308に相当する。ここでは、被写体のコントラスト値が基準となるコントラストの値に近づくよう目標陰影状態を定める。更に、本実施例での特徴的な処理として、リライティング補正の前後において、被写体のコントラスト値の大小関係が逆転しないよう、それぞれの被写体に対する目標陰影状態を定める。すなわち、補正の前の陰影状態で表される各被写体の陰影の程度と、補正の後の各被写体の陰影の程度の序列が入れ替わらないように、リライティングの対象となる被写体ごとに、目標となる陰影の状態である目標陰影状態を設定する。このようにすることで、見た目に好ましい陰影の状態に近づけるよう補正し、かつ、元の環境光による影響を残した自然な見た目となるよう、リライティング補正を制御することができる。
<Determination processing of target shadow state of subject>
Next, the details of the process in which the target shadow state setting unit 205 determines the target shadow state for the subject selected as the relighting correction target will be described. This process corresponds to steps S305 and S308 in FIG. Here, the target shadow state is determined so that the contrast value of the subject approaches the reference contrast value. Further, as a characteristic process in the present embodiment, the target shadow state for each subject is determined so that the magnitude relationship of the contrast value of the subject does not reverse before and after the relighting correction. In other words, for each subject to be relighted, the target and the target are rewritten so that the order of the shade of each subject represented by the shadow state before the correction and the order of the shade of each subject after the correction are not interchanged. The target shadow state that is the state of the shadow to be set is set. By doing so, it is possible to control relighting correction so as to make it appear close to the appearance of a shade that is desirable to the eye and to achieve a natural appearance that leaves the influence of the original ambient light.

具体的には、以下のように処理を行う。まず、目標陰影状態設定部205は、基準となるコントラスト値として、被写体コントラスト値の平均値を算出する。算出した平均値の例を図5のCaveに示した。目標陰影状態設定部205は、被写体のコントラスト値がCaveより低ければ(高ければ)、被写体コントラスト値が高く(低く)なるように目標とするコントラスト値を定める。例えば、被写体aの場合であれば、Ca<Caveであるから、被写体コントラスト値が高くなるよう目標陰影状態を設定する。ただし、補正後の被写体aのコントラスト値が、被写体bのコントラスト値Cbより高くならないよう、被写体bのコントラスト値Cbより所定の値ΔCだけ低い値であるCa'=Cb−ΔCを目標陰影状態として決定する。ここで、ΔCは、正の値を持つ定数であり、Cb−Ca≧ΔC>0(条件1)である。あるいはΔCを目標陰影状態としても良い。この場合には目標陰影状態はコントラストの補正量となる。   Specifically, processing is performed as follows. First, the target shadow state setting unit 205 calculates an average value of subject contrast values as a reference contrast value. An example of the calculated average value is shown in Cave in FIG. The target shadow state setting unit 205 determines a target contrast value so that the subject contrast value is higher (lower) if the subject contrast value is lower (higher) than Cave. For example, in the case of the subject a, since Ca <Cave, the target shadow state is set so that the subject contrast value becomes high. However, Ca ′ = Cb−ΔC, which is a value lower than the contrast value Cb of the subject b by a predetermined value ΔC, is set as the target shadow state so that the corrected contrast value of the subject a does not become higher than the contrast value Cb of the subject b. decide. Here, ΔC is a constant having a positive value, and Cb−Ca ≧ ΔC> 0 (condition 1). Alternatively, ΔC may be set as the target shadow state. In this case, the target shadow state is the amount of contrast correction.

同様に、被写体dの場合であれば、Cave<Cdであるから、被写体コントラスト値が低くなるよう目標陰影状態を設定する。ただし、補正後の被写体dのコントラスト値が、被写体cのコントラスト値Ccより低くならないよう、Cd'=Cc+ΔCを目標陰影状態として決定する。すなわち、Cd−Cc≧ΔC>0(条件2)となる。条件1と条件2のいずれをも満たす値がΔCとして選ばれる。目標陰影状態設定部205は、上記の方法により、それぞれの被写体に対して目標とするコントラスト値を決定し、その結果を目標陰影状態として、仮想光源設定部206へ出力する。   Similarly, in the case of the subject d, since Cave <Cd, the target shadow state is set so that the subject contrast value becomes low. However, Cd ′ = Cc + ΔC is determined as the target shadow state so that the corrected contrast value of the subject d does not become lower than the contrast value Cc of the subject c. That is, Cd−Cc ≧ ΔC> 0 (condition 2). A value satisfying both condition 1 and condition 2 is selected as ΔC. The target shadow state setting unit 205 determines a target contrast value for each subject by the above method, and outputs the result as a target shadow state to the virtual light source setting unit 206.

<仮想光源の設定値の決定処理>
次に、仮想光源設定部206が、それぞれの被写体の被写体陰影情報と、目標陰影状態とに基づいて、仮想光源の設定値を算出する処理について、詳細を説明する。この処理は図3のステップS306、S309に相当する。図6に示したのは、仮想光源設定部206が行う処理の流れを示したフローチャートである。図6はひとつの被写体に対する処理手順であり、被写体が複数ある場合には各被写体に順次着目して着目被写体に対して図6の処理手順が遂行される。また、図7に示したのは、被写体、環境光、仮想光源の位置関係を表した図である。ここでは、補正対象領域を図4に示したような人物の顔とした場合で説明する。
<Virtual light source setting value determination process>
Next, the details of the process in which the virtual light source setting unit 206 calculates the setting value of the virtual light source based on the subject shadow information and the target shadow state of each subject will be described. This process corresponds to steps S306 and S309 in FIG. FIG. 6 is a flowchart showing a flow of processing performed by the virtual light source setting unit 206. FIG. 6 shows a processing procedure for one subject. When there are a plurality of subjects, the processing procedure of FIG. 6 is performed on the subject of interest while paying attention to each subject sequentially. FIG. 7 shows the positional relationship among the subject, the ambient light, and the virtual light source. Here, a case where the correction target area is a human face as shown in FIG. 4 will be described.

図7は被写体上方から俯瞰した状態を表しており、被写体領域701の斜線部はたとえば人物の顔の領域を表したものであり、簡単のため、表面は平面で表している。また、法線ベクトル702は、被写体領域701の向きを表す代表的な法線ベクトルである。代表的な法線ベクトルの算出方法は、公知の様々な方法を用いる事が出来る。例えば、不図示の測距手段により被写体までの距離を測定した結果から、被写体の立体形状を推定し、法線ベクトルを算出する事ができる。また、人物の顔の場合であれば、顔検出部113により、顔、及び、目や鼻などの器官を検出して顔の向きを推定した結果に基づき、法線ベクトルを推定する事もできる。また、被写体の法線ベクトルの代表的な方向は、算出した法線ベクトルを被写体領域全体について平均化することで算出する事ができる。または、リライティングの対象とする被写体領域の中心位置での法線ベクトルを代表的な法線ベクトルとして用いても良い。   FIG. 7 shows a state seen from above the subject. The shaded portion of the subject region 701 represents, for example, a human face region, and the surface is represented by a plane for simplicity. A normal vector 702 is a typical normal vector representing the direction of the subject area 701. Various known methods can be used as representative normal vector calculation methods. For example, the normal vector can be calculated by estimating the three-dimensional shape of the subject from the result of measuring the distance to the subject by a distance measuring unit (not shown). In the case of a human face, the normal vector can be estimated based on the result of estimating the face direction by detecting the face and organs such as eyes and nose by the face detection unit 113. . The representative direction of the normal vector of the subject can be calculated by averaging the calculated normal vector over the entire subject area. Alternatively, a normal vector at the center position of the subject area to be relighted may be used as a representative normal vector.

環境光703が、代表的な法線ベクトル702と顔領域701とが交わる座標(画素)710を、陰影状態検出部204が推定した方向から照射している。仮想光704a、704bは、それぞれの位置から座標710を照射する仮想光のイメージである。ここで、法線ベクトル702と仮想光704a,704bの照射方向とが成す角を角α、法線ベクトル702と環境光703の照射方向とが成す角を角βで表す。なお、角αは、仮想光源704a,704bの座標と法線ベクトル702の始点(すなわち法線ベクトル702と被写体領域701との交点710)とを結ぶ直線と、法線ベクトル702とがなす角とも言える。同様に、角βは、環境光源の座標と法線ベクトル702の始点(法線ベクトル702と被写体領域701との交点)とを結ぶ直線と、法線ベクトル702とがなす角とも言える。また、法線ベクトル702と仮想光源704a、704b、環境光703の照射方向とがなす角度は、反時計回りに正の符号、時計回りに負の符号を取るものとする。したがって例えば座標710を原点として法線ベクトル702の角度を基準(すなわち0)とすれば、法線ベクトル702と環境光704bの照射方向とが成す角は−αと表せる。また法線ベクトル702と環境光704aの照射方向とが成す角は+αと表せる。   The ambient light 703 irradiates the coordinates (pixels) 710 where the representative normal vector 702 and the face region 701 intersect from the direction estimated by the shadow state detection unit 204. Virtual lights 704a and 704b are images of virtual light that irradiates coordinates 710 from respective positions. Here, an angle formed by the normal vector 702 and the irradiation direction of the virtual lights 704a and 704b is expressed by an angle α, and an angle formed by the normal vector 702 and the irradiation direction of the ambient light 703 is expressed by an angle β. The angle α is also the angle formed by the normal vector 702 and the straight line connecting the coordinates of the virtual light sources 704a and 704b and the start point of the normal vector 702 (that is, the intersection 710 of the normal vector 702 and the subject area 701). I can say that. Similarly, the angle β can also be said to be an angle formed by the normal vector 702 and a straight line connecting the coordinates of the environment light source and the starting point of the normal vector 702 (intersection of the normal vector 702 and the subject area 701). In addition, the angle formed by the normal vector 702 and the irradiation directions of the virtual light sources 704a and 704b and the ambient light 703 takes a positive sign counterclockwise and a negative sign clockwise. Therefore, for example, if the angle of the normal vector 702 is set as the reference (that is, 0) with the coordinate 710 as the origin, the angle formed by the normal vector 702 and the irradiation direction of the ambient light 704b can be expressed as -α. Further, the angle formed by the normal vector 702 and the irradiation direction of the ambient light 704a can be expressed as + α.

なお、ここで説明する光源の方向とは図7に例示したように平面上における方向であるが、この方向を、たとえば被写体を平面としてとらえた場合に、その被写体面に直交し、かつ互いに直交する2つの平面内で定めれば、三次元空間における光源の方向を定めることができる。たとえば三次元直交座標系において、交点710を原点、被写体面をY−Z平面とした場合、X−Y平面とZ−X平面それぞれの上で光源の方向を決めることで、三次元空間における光源の方向を定めることができる。   Note that the direction of the light source described here is a direction on a plane as illustrated in FIG. 7, but this direction is orthogonal to the subject plane and orthogonal to each other when the subject is considered as a plane, for example. If determined in two planes, the direction of the light source in the three-dimensional space can be determined. For example, in the three-dimensional orthogonal coordinate system, when the intersection 710 is the origin and the subject plane is the YZ plane, the direction of the light source is determined on each of the XY plane and the ZX plane, thereby providing a light source in the three-dimensional space. The direction can be determined.

<仮想光源の設定値の決定処理手順>
図6のフローチャートを用いて、処理の流れを説明する。ここでは、仮想光源設定部206が、仮想光源の設定値として、仮想光源の位置(光を照射する方向)を算出する場合で説明する。したがって図6の各ステップの実行主体は仮想光源設定部206である。
ステップS601では、ステップS305で決定した目標コントラスト値の情報を、目標陰影状態設定部205より取得する。
ステップS602では、ステップS303で検出した、環境光によって生じた被写体コントラスト値を、陰影状態検出部204から取得する。またステップS303では環境光の位置も陰影状態検出部204により検出されており、被写体コントラスト値と共に当該被写体に対する環境光の位置情報も併せて取得する。
ステップS603では、目標コントラスト値と被写体コントラスト値とを比較し、被写体コントラスト値が目標コントラスト値より高いか否かを判定する。被写体コントラスト値が目標コントラスト値より高いと判定した場合はステップS604へ進み、そうでない場合はステップS605へ進む。
ステップS604へ進む場合は、環境光によって被写体領域に暗い陰影が生じ、目標とするコントラスト値よりも被写体コントラスト値が高くなっている場合に対応する。このため、ステップS604で仮想光源設定部206は、被写体に対して、仮想光源と環境光とが異なる側から照射されるよう、仮想光源の位置(方向)を算出する。環境光と異なる側とは、たとえば被写体の法線を挟んで環境光源とは反対側を指す。具体的には、角αの符号が角βの符号とは逆となり、角αの絶対値が45°となるよう、仮想光の照射方向を決定する。
<Virtual light source setting value determination processing procedure>
The flow of processing will be described using the flowchart of FIG. Here, a case where the virtual light source setting unit 206 calculates the position of the virtual light source (light irradiation direction) as the setting value of the virtual light source will be described. Therefore, the execution subject of each step in FIG. 6 is the virtual light source setting unit 206.
In step S <b> 601, the target contrast value information determined in step S <b> 305 is acquired from the target shadow state setting unit 205.
In step S <b> 602, the subject contrast value generated by the ambient light detected in step S <b> 303 is acquired from the shadow state detection unit 204. In step S303, the position of the ambient light is also detected by the shadow state detection unit 204, and the position information of the ambient light with respect to the subject is acquired together with the subject contrast value.
In step S603, the target contrast value is compared with the subject contrast value to determine whether the subject contrast value is higher than the target contrast value. If it is determined that the subject contrast value is higher than the target contrast value, the process proceeds to step S604; otherwise, the process proceeds to step S605.
The case where the process proceeds to step S604 corresponds to a case where a dark shadow is generated in the subject area due to the ambient light and the subject contrast value is higher than the target contrast value. For this reason, in step S604, the virtual light source setting unit 206 calculates the position (direction) of the virtual light source so that the subject is irradiated from different sides of the virtual light source and the ambient light. The side different from the ambient light indicates, for example, the side opposite to the ambient light source across the normal of the subject. Specifically, the irradiation direction of the virtual light is determined so that the sign of the angle α is opposite to the sign of the angle β and the absolute value of the angle α is 45 °.

ここで、角αの絶対値を45°としたのは、一般的な被写体に対して、法線ベクトル602に対して45°の角度から照射すると適切なコントラストとなる場合が多いことによる。ただし、これは単なる例であり、被写体の陰の部分を仮想光によって明るく補正し、被写体領域のコントラストを下げることができれば、これに限定されない。図7の例であれば、ステップS604では仮想光704bが設定される。ここで仮想光704bの照射方向を、法線ベクトル702を対称軸として環境光703と対称となる方向(−β)としても良い。なおここでは法線ベクトル702の角度を0としている。また、他の例として、45°±10°、好ましくは45°±5°の範囲で設定しても良い。リライティング処理後の被写体コントラスト値を算出して、その値が最も目標コントラスト値に近づくよう照射方向を決定するようにしても良い。仮想光の照射方向を算出すると、仮想光源設定部206は処理をS608へ進める。   Here, the reason why the absolute value of the angle α is set to 45 ° is that an appropriate contrast is often obtained when a normal subject is irradiated from an angle of 45 ° with respect to the normal vector 602. However, this is merely an example, and the present invention is not limited to this as long as the shadow portion of the subject can be brightly corrected with virtual light to reduce the contrast of the subject region. In the example of FIG. 7, the virtual light 704b is set in step S604. Here, the irradiation direction of the virtual light 704b may be a direction (−β) that is symmetric with the ambient light 703 with the normal vector 702 as an axis of symmetry. Here, the angle of the normal vector 702 is set to zero. As another example, it may be set within a range of 45 ° ± 10 °, preferably 45 ° ± 5 °. The subject contrast value after the relighting process may be calculated, and the irradiation direction may be determined so that the value is closest to the target contrast value. When the irradiation direction of the virtual light is calculated, the virtual light source setting unit 206 advances the process to S608.

一方ステップS605では、被写体コントラスト値が所定の閾値以下であるか否かを判定する。所定の閾値以下であると判定した場合はステップS606へ進み、そうでない場合はステップS607へ進む。
ステップS606へ進む場合は、被写体コントラスト値が目標とするコントラスト値より低く、さらに、環境光が被写体に対してほぼ一様に照射されており、環境光による陰影がほとんど生じていない場合に対応する。この場合、仮想光源設定部206は、ステップS606で仮想光の照射方向が法線ベクトル702となす角αの絶対値が45°となるように、仮想光の照射方向を決定する。角αの符号は正負何れでも構わないので、角αは、45°と−45°の2通りの値となる。ただし、角αの絶対値を45°としたのは、好ましい値の一例であり、被写体領域の一部を仮想光源によって明るく補正し、被写体領域のコントラストを上げる事ができれば、これに限定されない。例えば、リライティング処理後の被写体コントラスト値を算出して、その値が最も目標コントラスト値に近づくよう照射方向を決定するようにしても良い。仮想光の照射方向を算出すると、仮想光源設定部206は処理をS608へ進める。
On the other hand, in step S605, it is determined whether the subject contrast value is equal to or less than a predetermined threshold value. When it determines with it being below a predetermined threshold value, it progresses to step S606, and when that is not right, it progresses to step S607.
The case where the process proceeds to step S606 corresponds to a case where the subject contrast value is lower than the target contrast value, and the ambient light is irradiated almost uniformly on the subject, and there is almost no shadow due to the ambient light. . In this case, the virtual light source setting unit 206 determines the irradiation direction of the virtual light so that the absolute value of the angle α formed by the irradiation direction of the virtual light with the normal vector 702 is 45 ° in step S606. Since the sign of the angle α may be positive or negative, the angle α has two values of 45 ° and −45 °. However, setting the absolute value of the angle α to 45 ° is an example of a preferable value, and is not limited to this as long as a part of the subject area can be brightly corrected by the virtual light source and the contrast of the subject area can be increased. For example, the subject contrast value after the relighting process may be calculated, and the irradiation direction may be determined so that the value is closest to the target contrast value. When the irradiation direction of the virtual light is calculated, the virtual light source setting unit 206 advances the process to S608.

S607へ進む場合は、環境光によってある程度被写体に陰影が生じているが、目標のコントラストは得られていない場合である。従って、仮想光源設定部206は、ステップS607で、仮想光の照射方向が法線ベクトル702となす角αの符号が、環境光の照射方向が法線ベクトル702となす角βと同一符号で、角αの絶対値が45°となるように、仮想光の照射方向を決定する。ただし、角αの絶対値を45°としたのは、好ましい値の一例であり、被写体領域の一部を仮想光源によって明るく補正し、被写体領域のコントラストを上げる事ができれば、これに限定されない。例えば、角αの絶対値を角βの絶対値を基準として算出しても良い。具体的には、角αの絶対値を、|β|±15°、好ましくは|β|±10°、さらに好ましくは|β|±5°としても良い。ここで±は範囲を示していてもよい。あるいは、α=β、すなわち、環境光と同じ照射方向を仮想光の照射方向として決定してもよい。又は、リライティング処理後の被写体コントラスト値を算出して、その値が最も目標コントラスト値に近づくよう照射方向を決定するようにしても良い。仮想光の照射方向を決定すると、仮想光源設定部206は処理をS608へ進める。   The process proceeds to S607 when the subject is shaded to some extent by the ambient light, but the target contrast is not obtained. Therefore, in step S607, the virtual light source setting unit 206 has the same sign as the angle β that the illumination direction of the virtual light makes with the normal vector 702 and the angle β that makes the illumination direction of the ambient light the normal vector 702, The irradiation direction of the virtual light is determined so that the absolute value of the angle α is 45 °. However, setting the absolute value of the angle α to 45 ° is an example of a preferable value, and is not limited to this as long as a part of the subject area can be brightly corrected by the virtual light source and the contrast of the subject area can be increased. For example, the absolute value of the angle α may be calculated based on the absolute value of the angle β. Specifically, the absolute value of the angle α may be | β | ± 15 °, preferably | β | ± 10 °, more preferably | β | ± 5 °. Here, ± may indicate a range. Alternatively, α = β, that is, the same irradiation direction as the ambient light may be determined as the virtual light irradiation direction. Alternatively, the subject contrast value after the relighting process may be calculated, and the irradiation direction may be determined so that the value is closest to the target contrast value. When the irradiation direction of the virtual light is determined, the virtual light source setting unit 206 advances the process to S608.

ステップS608では、算出した仮想光源の配置を、仮想光源の位置の設定値として、仮想光源信号付加部207へ出力する。なお、被写体aに対する補正量(△C)と被写体dに対する補正量(△C)は必ずしも同じでなくても良い。   In step S608, the calculated arrangement of the virtual light source is output to the virtual light source signal adding unit 207 as a setting value of the position of the virtual light source. The correction amount (ΔC) for the subject a and the correction amount (ΔC) for the subject d are not necessarily the same.

以上、説明した通り、仮想光源設定部206は、補正対象領域のそれぞれに対して、その陰影状態に応じた仮想光源の設定値を算出し、仮想光源信号付加部207へ出力する。なお交点710から光源までの距離Dについては、たとえば定数で与えてもよい。仮想光源の方向や強度といった設定は、後述するリライティングによる被写体の補正前の陰影状態と、補正後の陰影状態との大小関係(あるいは強弱関係)が逆転しないように決定される。すなわち、たとえば図5の例で説明すれば、Cb−Ca≧ΔC>0(条件1)と、Cd−Cc≧ΔC>0(条件2)とを満たすコントラストすなわち陰影状態の補正量ΔCが得られるように、仮想光源の設定を定める。そのためには、たとえば、被写体の最も明るい領域の輝度は仮想光源によって変化しないものと仮定し、目標コントラスト値を得るための、当該被写体の最も暗い領域の目標輝度を算出する。そして、後述する数式1にしたがってその最も暗い領域の補正前の輝度を目標輝度に補正するための仮想光源の強度及び距離を決定する。その際、仮想光源の方向(法線に対する角度)は決定されているものとする。ここで、被写体の最も明るい領域の輝度は仮想光源によって変化しないものと仮定したが、この領域の輝度も仮想光源によって増加することがあり得る。この場合には、補正後のコントラスト値は目標コントラスト値よりも大きくなる可能性があるので、決定した仮想光源の強度または距離から、所定値を減じておいてもよい。   As described above, the virtual light source setting unit 206 calculates the setting value of the virtual light source corresponding to the shadow state for each correction target region, and outputs it to the virtual light source signal adding unit 207. The distance D from the intersection point 710 to the light source may be given as a constant, for example. Settings such as the direction and intensity of the virtual light source are determined so that the magnitude relationship (or strength relationship) between the shadow state before correction of the subject by relighting, which will be described later, and the shadow state after correction is not reversed. That is, for example, referring to the example of FIG. 5, the contrast, that is, the correction amount ΔC of the shadow state satisfying Cb−Ca ≧ ΔC> 0 (condition 1) and Cd−Cc ≧ ΔC> 0 (condition 2) is obtained. Thus, the setting of the virtual light source is determined. For this purpose, for example, assuming that the brightness of the brightest area of the subject does not change depending on the virtual light source, the target brightness of the darkest area of the subject is calculated to obtain the target contrast value. And the intensity | strength and distance of the virtual light source for correct | amending the brightness | luminance before correction | amendment of the darkest area | region to target brightness | luminance are determined according to Numerical formula 1 mentioned later. At this time, the direction of the virtual light source (angle with respect to the normal) is determined. Here, it is assumed that the brightness of the brightest area of the subject is not changed by the virtual light source, but the brightness of this area may also be increased by the virtual light source. In this case, since the corrected contrast value may be larger than the target contrast value, the predetermined value may be subtracted from the determined intensity or distance of the virtual light source.

<仮想光源を用いたリライティング処理>
次に、仮想光源信号付加部207での、仮想光源を用いたリライティング処理について説明する。この処理は図3のステップS310に相当する。本実施例では、仮想光源によって照射された処理対象画素の出力RGB値(Rout、Gout、Bout)は、下記の式で算出するものとする。
<Relighting process using virtual light source>
Next, relighting processing using a virtual light source in the virtual light source signal adding unit 207 will be described. This process corresponds to step S310 in FIG. In the present embodiment, the output RGB values (Rout, Gout, Bout) of the processing target pixels irradiated by the virtual light source are calculated by the following equations.

Rout=[Rt+A×cos(α)×(1/D^2)×Rv]/M
Gout=[Gt+A×cos(α)×(1/D^2)×Gv]/M ... (数式1)
Bout=[Bt+A×cos(α)×(1/D^2)×Bv]/M
ただし、|α|≦90°であり、|α|>90°であれば、仮想光源からの光で照らされないので、出力値は処理対象の画素値のままとする。(Rt、Gt、Bt)は処理対象の画素値、Aは仮想光源の強度(すなわち仮想光源の発する仮想的な照明光の強度)を表す所定の定数、Dは仮想光源と被写体までの距離、(Rv、Gv、Bv)は光源反射色を表す。光源反射色は、仮想光源が被写体表面で反射した時の反射色を、予め設定された仮想光源色と被写体色とによって推定した色である。Mはリライティング後の出力RGB値を正規化するための予め設定された定数である。角度αは、仮想光源設定部206が決定した仮想光源の方向と、対象画素における被写体の法線ベクトルの成す角である。数式1では、A×cos(α)×(1/D^2)は、仮想光源の被写体面における強度であり、その値は、被写体面における仮想光源からの光の強度のうち、仮想光源からの光の被写体面に直交する強度成分が、仮想光源の距離に反比例するものとして算出されている。そして、算出した値に光源反射色を乗じて画素値に加算し、正規化した値が着目画素の画素値として算出される。
Rout = [Rt + A × cos (α) × (1 / D ^ 2) × Rv] / M
Gout = [Gt + A × cos (α) × (1 / D ^ 2) × Gv] / M (Formula 1)
Bout = [Bt + A × cos (α) × (1 / D ^ 2) × Bv] / M
However, if | α | ≦ 90 ° and | α |> 90 °, the light is not illuminated by the light from the virtual light source, so the output value remains the pixel value to be processed. (Rt, Gt, Bt) is a pixel value to be processed, A is a predetermined constant representing the intensity of the virtual light source (that is, the intensity of virtual illumination light emitted from the virtual light source), D is the distance between the virtual light source and the subject, (Rv, Gv, Bv) represents the light source reflection color. The light source reflection color is a color obtained by estimating the reflection color when the virtual light source is reflected on the subject surface by the preset virtual light source color and subject color. M is a preset constant for normalizing the output RGB value after relighting. The angle α is an angle formed by the direction of the virtual light source determined by the virtual light source setting unit 206 and the normal vector of the subject in the target pixel. In Equation 1, A × cos (α) × (1 / D ^ 2) is the intensity of the virtual light source on the subject surface, and the value is calculated from the virtual light source out of the light intensity from the virtual light source on the subject surface. The intensity component perpendicular to the subject surface of the light is calculated as being inversely proportional to the distance of the virtual light source. Then, the calculated value is multiplied by the light source reflection color and added to the pixel value, and the normalized value is calculated as the pixel value of the target pixel.

ここで、角度αを算出する際に、リライティング対象画素の各画素に対して被写体の法線ベクトルを算出して、角度αを算出するようにしても良い。又は、図4に示したように被写体領域を複数のブロックに分割し、ブロック毎に算出した法線ベクトルに基づいて、角度αを算出するようにしても良い。又は、人物の顔のように被写体の3次元形状が予め分かっている場合には、対象画素が顔領域中でどこの位置であるかに基づいて、法線ベクトルの方向を推定し、角度αを算出するようにしても良い。また、仮想光源の強度Aは、被写体コントラスト値と目標コントラストの差分ΔCまたは−ΔCに応じて決定すれば良い。また仮想光源の距離Dは所定の距離としてもよい。距離Dを一定の距離とするならば、1/D^2は定数となるので、A×(1/D^2)を定数として与えることもできる。この場合A×(1/D^2)の値は、被写体コントラスト値と目標コントラストの差分|ΔC|(これをコントラスト調整量あるいは陰影状態調整量と呼ぶ)に応じて決定すれば良い。たとえば数式1によって変更した画素値から被写体ごとにステップS303の要領でコントラスト値を算出し、そのコントラスト値が目標コントラスト値になるようにA×(1/D^2)及び定数Mは決められる。A×(1/D^2)をあらかじめ決めておき、定数Mにより調整してもよいし、その逆でもよい。   Here, when calculating the angle α, the normal α of the subject may be calculated for each pixel of the relighting target pixel to calculate the angle α. Alternatively, as shown in FIG. 4, the subject region may be divided into a plurality of blocks, and the angle α may be calculated based on the normal vector calculated for each block. Alternatively, when the three-dimensional shape of the subject is known in advance, such as a human face, the direction of the normal vector is estimated based on where the target pixel is in the face region, and the angle α is set to It may be calculated. The intensity A of the virtual light source may be determined according to the difference ΔC or −ΔC between the subject contrast value and the target contrast. The distance D of the virtual light source may be a predetermined distance. If the distance D is a constant distance, 1 / D ^ 2 is a constant, so A * (1 / D ^ 2) can also be given as a constant. In this case, the value of A × (1 / D ^ 2) may be determined according to the difference | ΔC | between the subject contrast value and the target contrast (this is called the contrast adjustment amount or the shadow state adjustment amount). For example, the contrast value is calculated for each subject from the pixel value changed by Equation 1 in the manner of step S303, and A × (1 / D ^ 2) and the constant M are determined so that the contrast value becomes the target contrast value. A × (1 / D ^ 2) may be determined in advance and adjusted by a constant M, or vice versa.

本実施例の構成をまとめると、以下のようになる。
1)入力画像中の被写体を検出する。
2)各被写体のコントラスト値を検出する。
3)検出したコントラスト値が最大の被写体と最小の被写体とを補正対象の被写体として選択し、選択したコントラスト値が最大の被写体についてはコントラスト値を下げ、コントラスト値が最小の被写体についてコントラスト値を上げるように目標コントラスト値を設定する。このとき、入力画像中の各被写体のコントラスト値の順序が維持されるよう目標コントラスト値は決定される。
4)補正対象の被写体のコントラスト値が目標コントラスト値になるよう仮想光源を設定する。
5)仮想光源を用いて補正対象の被写体の明るさを補正する。
The configuration of this embodiment is summarized as follows.
1) Detect a subject in the input image.
2) The contrast value of each subject is detected.
3) Select the subject with the largest detected contrast value and the subject with the smallest contrast as the subject to be corrected, lower the contrast value for the subject with the largest selected contrast value, and raise the contrast value for the subject with the smallest contrast value. The target contrast value is set as follows. At this time, the target contrast value is determined so that the order of the contrast values of the subjects in the input image is maintained.
4) The virtual light source is set so that the contrast value of the subject to be corrected becomes the target contrast value.
5) The brightness of the subject to be corrected is corrected using a virtual light source.

以上説明したように、本実施例では、複数の被写体領域を対象にリライティング補正を行う際に、被写体の陰影状態を比較した結果に基づいて、それぞれの被写体に対するリライティング補正の目標とする目標陰影状態を決定するように制御した。これにより、複数の被写体が含まれる画像に対してリライティング補正を行う際に、リライティング補正によって、被写体間での陰影の状態が逆転して不自然な画像になることを避ける事が可能となる。   As described above, in this embodiment, when relighting correction is performed on a plurality of subject areas, based on the result of comparing the shadow states of the subjects, the target shadow state that is the target of relighting correction for each subject. Was controlled to determine. As a result, when relighting correction is performed on an image including a plurality of subjects, it is possible to prevent the shadowing state between subjects from being reversed and resulting in an unnatural image due to the relighting correction.

[変形例1]
なお、本実施例では、検出された複数の被写体の全てに対して、陰影の状態を検出する場合で説明したが、本発明は、リライティング処理での陰影の状態の検出方法を、これに限定するものではない。例えば、検出した複数の被写体のうち、画像中に占める面積が所定の閾値以上の被写体のみを選んで、陰影の状態を検出するようにしても良い。又は、被写体のうち、陰影が生じている領域の輪郭の特性を検出してもよい。たとえば、被写体が人物の顔である場合は、その輪郭に基づいて正面向きの顔と横向きの顔とを判別し、顔の向きが正面に近い被写体のみを選んで、横向きに近い被写体は除外し、陰影の状態を検出するようにしても良い。
[Modification 1]
In this embodiment, the case where the shadow state is detected for all of the plurality of detected subjects has been described. However, the present invention is limited to the method for detecting the shadow state in the relighting process. Not what you want. For example, only a subject whose area in the image occupies a predetermined threshold or more may be selected from a plurality of detected subjects, and the shadow state may be detected. Or you may detect the characteristic of the outline of the area | region where the shadow has arisen among the to-be-photographed objects. For example, if the subject is a person's face, the front face and the side face are discriminated based on the contour, and only those subjects whose face direction is close to the front are selected, and subjects that are close to the side are excluded. The shadow state may be detected.

[変形例2]
また、本実施例では、複数の被写体のうち、最もコントラスト値が低い(高い)被写体を、リライティング補正の対象とする場合で説明したが、本発明は、リライティング補正の対象の決定方法をこれに限定するものではない。すなわち、複数の被写体の陰影の状態を比較して、リライティング補正の対象を決定する方法であれば、どのような方法を用いても構わない。例えば、予め定められた所定の基準値と比較し、基準値と被写体コントラスト値の差分が所定の大きさを超えている場合に、その被写体をリライティング補正の対象として選択するようにしても良い。また、複数の被写体のうち、コントラスト値が複数の被写体の平均値より低い(高い)被写体を、リライティング補正の対象として選択するようにしても良い。また、複数の被写体のうち、最も主要な被写体の被写体コントラスト値と比べて、コントラスト値が低い(高い)被写体を、リライティング補正の対象として選択するようにしても良い。最も主要な被写体は、たとえば最も大きな面積の被写体や、検出された顔、あるいは焦点の合っている被写体などであってよい。焦点の合い具合はたとえばエッジ抽出などにより判定できる。また、画像中で近接する被写体同士を比較して、コントラスト値が低い(高い)被写体を、リライティング補正の対象として選択するようにしても良い。
[Modification 2]
Further, in this embodiment, the description has been given of the case where the subject having the lowest (highest) contrast value among the plurality of subjects is the target of the relighting correction. However, the present invention provides a method for determining the target of the relighting correction. It is not limited. That is, any method may be used as long as it is a method for determining the relighting correction target by comparing the shaded states of a plurality of subjects. For example, the subject may be selected as a relighting correction target when the difference between the reference value and the subject contrast value exceeds a predetermined magnitude compared with a predetermined reference value. In addition, among a plurality of subjects, a subject whose contrast value is lower (higher) than the average value of the plurality of subjects may be selected as a relighting correction target. In addition, among a plurality of subjects, a subject having a contrast value lower (higher) than the subject contrast value of the main subject may be selected as a relighting correction target. The most main subject may be, for example, the subject with the largest area, the detected face, or the subject in focus. The degree of focus can be determined by, for example, edge extraction. Further, subjects close to each other in the image may be compared, and a subject having a low (high) contrast value may be selected as a relighting correction target.

また、他の被写体と比べて、陰影の状態が大きく異なる被写体すなわち、たとえばコントラスト値が、他の被写体のコントラスト値から所定の閾値以上の差がある被写体を、リライティング補正の対象から除外するように制御しても良い。このようにすることで、陰影の状態が他の被写体と大きく異なるため、リライティング補正を行うと補正量が大きくなり、ノイズ成分が強調されるような弊害が生じないよう制御することができる。   Also, subjects whose shadows are significantly different from those of other subjects, that is, subjects whose contrast value is different from the contrast value of other subjects by a predetermined threshold or more, are excluded from the relighting correction target. You may control. By doing so, the shaded state is greatly different from that of other subjects, so that when relighting correction is performed, the correction amount becomes large, and control can be performed so as not to cause a harmful effect such that the noise component is emphasized.

[変形例3]
また、本実施例では、目標とする陰影の状態を定める際に、複数の被写体コントラスト値の平均値を基準として用いる場合で説明したが、被写体の陰影状態を比較した結果に基づいて、目標値を決定する方法であれば、どのようなものを基準として用いても構わない。例えば、予め定められた所定のコントラスト値を基準として、それぞれの被写体に対する目標コントラスト値を定めても良い。また、複数の被写体のうち、最も主要な被写体のコントラスト値を基準として用いても良い。
[Modification 3]
Further, in the present embodiment, the case where the average value of a plurality of subject contrast values is used as a reference when determining the target shadow state has been described, but the target value is based on the result of comparing the shadow states of the subject. Any method may be used as a reference as long as it is a method for determining the value. For example, the target contrast value for each subject may be determined using a predetermined contrast value as a reference. Further, the contrast value of the most main subject among a plurality of subjects may be used as a reference.

[変形例4]
また、本実施例では、リライティングの対象として選択した被写体の補正後の被写体コントラスト値と、リライティングの対象外の被写体の被写体コントラスト値の関係を用いて、目標陰影状態を設定する場合で説明したが、目標陰影状態の設定方法はこれに限定されるものではない。例えば、複数の被写体が共にリライティングの対象として選択されている場合、補正前の被写体コントラスト値の大小関係が、補正後にも保たれるよう目標陰影状態を設定するようにしても良い。
[Modification 4]
In the present embodiment, the target shadow state is set by using the relationship between the corrected subject contrast value of the subject selected as the relighting target and the subject contrast value of the subject other than the relighting target. The method for setting the target shadow state is not limited to this. For example, when a plurality of subjects are selected as relighting targets, the target shadow state may be set so that the magnitude relationship between the subject contrast values before correction is maintained even after correction.

[変形例5]
また、本実施例では、リライティング補正の目標値を、被写体のコントラスト値とし、他の被写体とのコントラスト値との大小関係が逆転しないよう設定する場合で説明したが、リライティング補正の目標値の決定方法はこれに限定されるものではない。すなわち、複数の被写体の陰影の状態を比較した結果を用いて、リライティング補正の目標値を決定する方法であれば、どのようなものを用いても構わない。例えば、リライティング補正の目標として、被写体の陰の領域の位置を定めるようにしても良い。そして、複数の被写体について、それぞれの被写体での陰の領域の位置(例えば、被写体が人物の顔であれば、顔の上下左右のどちら側が陰の領域であるか)を判定し、その位置が他の被写体と異ならないようリライティング補正の目標値を定める。また、陰影の状態を表す情報として、被写体の明るさの情報を用いるようにしても良い。具体的には、複数の被写体について、それぞれの被写体の領域における平均的な明るさを算出し、リライティング補正の前後において、被写体間で明るさの大小関係が逆転しないよう、リライティング補正の目標値を定めても良い。
[Modification 5]
In the present embodiment, the target value for relighting correction is set as the contrast value of the subject and the magnitude relationship with the contrast value with other subjects is set so as not to reverse, but the target value for relighting correction is determined. The method is not limited to this. In other words, any method may be used as long as it is a method for determining a target value for relighting correction using a result obtained by comparing shade states of a plurality of subjects. For example, the position of the shadow area of the subject may be determined as a relighting correction target. Then, for a plurality of subjects, the position of the shadow area in each subject is determined (for example, if the subject is a human face, which side of the face is the shadow region) A target value for relighting correction is determined so as not to differ from other subjects. Further, information on the brightness of the subject may be used as information representing the state of the shadow. Specifically, for multiple subjects, the average brightness in each subject area is calculated, and the target value for relighting correction is set so that the brightness relationship between subjects does not reverse before and after relighting correction. It may be determined.

[変形例6]
また、被写体の陰の領域を検出し、その境界の特性を表す情報を被写体の陰影の状態を表す情報として用いても良い。具体的には、被写体の陰の領域の境界の明るさ勾配を算出し、その値が他の被写体と比べて同程度の値となるよう、仮想光源の位置や仮想的な照明光の拡散特性を定めるようにしても良い。また、被写体領域中の陰の領域の面積を算出し、その結果を被写体の陰影の状態を表す情報として用い、その値を他の被写体と比べた結果に基づいて、リライティング補正を制御するようにしても良い。
[Modification 6]
Alternatively, a shadow area of the subject may be detected, and information representing the boundary characteristics may be used as information representing the shadow state of the subject. Specifically, the brightness gradient of the boundary of the shadow area of the subject is calculated, and the position of the virtual light source and the diffusion characteristics of the virtual illumination light so that the value is comparable to that of other subjects May be determined. Also, the area of the shadow area in the subject area is calculated, the result is used as information representing the shadow state of the subject, and the relighting correction is controlled based on the result of comparing the value with other subjects. May be.

[変形例7]
また、本実施例では、複数の被写体のそれぞれに対して、別個に目標とする陰影の状態を定める場合で説明したが、本発明は、目標とする陰影の状態を定める方法を、これに限定するものではない。すなわち、複数の被写体の陰影の状態を比較して、それぞれの被写体に対する目標陰影状態を定める方法であれば、どのようなものを用いても構わない。例えば、複数の被写体に対して、陰影の状態を比較する事で環境光の当たり方を推定し、環境光の当たり方が近い被写体同士をグループ化し、グループ毎に目標とする陰影の状態を定めるようにしても良い。
[Modification 7]
In this embodiment, the case where the target shadow state is separately determined for each of the plurality of subjects has been described. However, the present invention limits the method of determining the target shadow state to this. Not what you want. That is, any method may be used as long as it compares the shadow states of a plurality of subjects and determines the target shadow state for each subject. For example, by comparing the shadow conditions of multiple subjects, the method of estimating ambient light is estimated, and subjects with similar environmental light exposure are grouped together, and the target shadow status is determined for each group. You may do it.

[変形例8]
また、本実施例では、仮想光源の設定として、仮想光源の位置を制御する場合で説明したが、本発明は、仮想光源の設定の制御方法をこれに限定するものではない。例えば、仮想光源の強度、色、個数、形状のパラメータを制御し、被写体の陰影の状態が、目標陰影状態に近づくようリライティング補正を制御するようにしても良い。
[Modification 8]
Further, in this embodiment, the case where the position of the virtual light source is controlled as the setting of the virtual light source has been described. However, the present invention is not limited to this method of controlling the setting of the virtual light source. For example, the parameters of the intensity, color, number, and shape of the virtual light source may be controlled to control the relighting correction so that the shadow state of the subject approaches the target shadow state.

[変形例9]
本実施例の数式1において、定数Mの値が1から離れすぎると、本来近似した色を有する近隣画素の画素値の差が拡大されて境界線を生じてしまうことがある。たとえばα=±90°付近で仮想光源によって補正した画素値(cosα≒0なので例えばRout≒Rt/M)と、その付近にあって|α|>90°となるために補正対象とならない画素値(例えばRout=Rt)との差が、近隣の画素でありながら大きくなることがあり得る。これにより元々画像中には無いはずの境界線が現れてしまうこともあり得る。そこで例えば正規化定数Mで除するのは元の画素値に加算する補正値(あるいは補正量)のみとし、例えばR成分であれば、Rout=Rt+[A×cos(α)×(1/D^2)×Rv]/Mなどとしてもよい。
[Modification 9]
In Formula 1 of the present embodiment, if the value of the constant M is too far from 1, the difference between the pixel values of neighboring pixels that originally have approximate colors may be enlarged and a boundary line may be generated. For example, a pixel value corrected by a virtual light source in the vicinity of α = ± 90 ° (for example, Rout≈Rt / M because cos α≈0), and a pixel value that is in the vicinity and is not subject to correction because | α |> 90 °. The difference from (for example, Rout = Rt) can be large while being a neighboring pixel. As a result, a boundary line that should not originally exist in the image may appear. Therefore, for example, only the correction value (or correction amount) added to the original pixel value is divided by the normalization constant M. For example, in the case of the R component, Rout = Rt + [A × cos (α) × (1 / D 2) × Rv] / M or the like.

[変形例10]
またたとえば、仮想光源は被写体ごとに一つとし、次のように補正してもよい。被写体領域ごとにたとえばその重心位置を代表画素と定め、その法線ベクトルを被写体の代表法線ベクトルとする。そしてその被写体の仮想光源の位置(方向)は、代表法線ベクトルに対して設定する。ここで代表法線ベクトルに対する仮想光源の方向を角度α0で表す。そして被写体領域に属する画素pの法線ベクトルに対する仮想光源の角度αpを、代表法線ベクトルと画素pの法線ベクトルとが成す角度γpを角度α0から差し引いたα0−γpとして算出し、このαpを、実施例の数式1の角度αとして適用する。このようにすることで、被写体を構成する面の方向に応じて、その面を照射する仮想光源の光量を求めることができ、より高精度の補正が可能となる。なお計算量を減らすために、画素ごとではなく、たとえば被写体領域内にあって輝度の差が所定範囲内にある画素群から成る連続した領域ごとに法線ベクトルを定めてもよい。
[Modification 10]
Further, for example, one virtual light source may be provided for each subject, and correction may be performed as follows. For example, the position of the center of gravity is determined as a representative pixel for each subject area, and the normal vector is set as the representative normal vector of the subject. The position (direction) of the virtual light source of the subject is set with respect to the representative normal vector. Here, the direction of the virtual light source with respect to the representative normal vector is represented by an angle α0. Then, the angle αp of the virtual light source with respect to the normal vector of the pixel p belonging to the subject area is calculated as α0−γp obtained by subtracting the angle γp formed by the representative normal vector and the normal vector of the pixel p from the angle α0, and this αp Is applied as the angle α in Equation 1 of the embodiment. By doing in this way, according to the direction of the surface which comprises a to-be-photographed object, the light quantity of the virtual light source which irradiates the surface can be calculated | required, and more highly accurate correction | amendment is attained. In order to reduce the amount of calculation, the normal vector may be determined not for each pixel but for each continuous area including a group of pixels within the subject area and having a luminance difference within a predetermined range.

以下、図8,9を参照して、本発明の第二の実施例における、デジタルカメラについて説明する。第一の実施例では、複数の被写体に対し、被写体の陰影の状態を比較した結果を用いて、それぞれの被写体にリライティング補正の目標とする目標陰影状態を設定する場合で説明した。第二の実施例では、被写体の陰影の状態を比較した結果を用いて、それぞれの被写体に目標陰影状態を設定するか、複数の被写体で共通の目標陰影状態を設定するかを判定する場合の方法を説明する。第二の実施例における、デジタルカメラの全体構成、画像処理部の構成、及び、リライティング処理全体の流れは、それぞれ、図1、2、3に示した第一の実施例の場合と同様であるため、説明は省略する。   Hereinafter, a digital camera according to the second embodiment of the present invention will be described with reference to FIGS. In the first embodiment, a case has been described in which a target shadow state that is a target of relighting correction is set for each subject using a result of comparison of the shadow states of the subject for a plurality of subjects. In the second embodiment, the result of comparing the shadow states of the subjects is used to determine whether to set a target shadow state for each subject or to set a common target shadow state for a plurality of subjects. A method will be described. The overall configuration of the digital camera, the configuration of the image processing unit, and the overall relighting process in the second embodiment are the same as those in the first embodiment shown in FIGS. Therefore, explanation is omitted.

第二の実施例では、図3のステップS305における目標陰影状態の決定方法が、第一の実施例の場合と異なる。図8を参照して、第二の実施例における目標陰影状態の決定方法を、詳細に説明する。図8の手順は、目標陰影状態設定部205により実行される。   In the second embodiment, the method for determining the target shadow state in step S305 in FIG. 3 is different from that in the first embodiment. With reference to FIG. 8, the determination method of the target shadow state in the second embodiment will be described in detail. The procedure in FIG. 8 is executed by the target shadow state setting unit 205.

ステップS801では、目標陰影状態設定部205が、リライティング対象として選択された被写体のコントラスト値を比較し、その最大値と最小値との差分を算出する。
ステップS802では、目標陰影状態設定部205が、算出した差分値と、予め定められた所定のコントラスト差分閾値とを比較し、差分値がコントラスト差分閾値より小さいか判定する。差分値がコントラスト差分閾値より小さいと判定した場合は、ステップS803へ進む。差分値がコントラスト差分閾値以上と判定した場合は、ステップS806へ進む。
In step S801, the target shadow state setting unit 205 compares the contrast value of the subject selected as the relighting target, and calculates the difference between the maximum value and the minimum value.
In step S802, the target shadow state setting unit 205 compares the calculated difference value with a predetermined contrast difference threshold value, and determines whether the difference value is smaller than the contrast difference threshold value. If it is determined that the difference value is smaller than the contrast difference threshold, the process proceeds to step S803. If it is determined that the difference value is greater than or equal to the contrast difference threshold, the process proceeds to step S806.

ステップS803では、目標陰影状態設定部205が、リライティング補正の対象として選択された被写体の明るさを比較し、その最大値と最小値との差分を算出する。
ステップS804では、目標陰影状態設定部205が、算出した差分値と、予め定められた所定の明るさ差分閾値とを比較し、差分値が明るさ差分閾値より小さいか判定する。差分値が明るさ差分閾値より小さいと判定した場合は、ステップS805へ進む。差分値が明るさ差分閾値以上と判定した場合は、ステップS806へ進む。
In step S803, the target shadow state setting unit 205 compares the brightness of the subject selected as the relighting correction target, and calculates the difference between the maximum value and the minimum value.
In step S804, the target shadow state setting unit 205 compares the calculated difference value with a predetermined brightness difference threshold value, and determines whether the difference value is smaller than the brightness difference threshold value. If it is determined that the difference value is smaller than the brightness difference threshold, the process proceeds to step S805. If it is determined that the difference value is equal to or greater than the brightness difference threshold, the process proceeds to step S806.

ステップS805へ進む場合は、環境光によって生じている被写体の陰影の状態が、被写体間で近い状態である場合に対応する。この場合は、ステップS805では、目標陰影状態設定部205が、複数の被写体に対し、共通の目標陰影状態を設定する。共通の目標陰影状態としては、予め定められた見た目に好ましい陰影の状態を用いるようにすれば良い。   The case where the process proceeds to step S805 corresponds to a case where the shadow of the subject caused by the ambient light is close to the subject. In this case, in step S805, the target shadow state setting unit 205 sets a common target shadow state for a plurality of subjects. As the common target shadow state, it is preferable to use a shadow state that is preferable in appearance.

ステップS806へ進む場合は、環境光の当たり方が被写体によって大きく異なる場合に対応する。この場合に、複数の被写体に対して共通の目標陰影状態を設定し、リライティング補正を行うと、撮影時の環境光の当たり方と大きく陰影状態が変わる被写体が生じることとなり、不自然な印象の画像となる場合がある。このため、ステップS806では、目標陰影状態設定部205が、複数の被写体に対し、被写体毎に目標陰影状態を設定することとする。被写体毎の目標値としては、予め代表的な光源や撮影環境下での見た目に好ましい陰影の状態を複数定めておき、その値を用いるようにすれば良い。その際には、予め複数定められている陰影の状態の中で、被写体の陰影の状態が最も近いものを選択するようにする。   The case where the process proceeds to step S806 corresponds to a case where the manner in which the ambient light strikes varies greatly depending on the subject. In this case, if a common target shadow state is set for multiple subjects and relighting correction is performed, a subject whose shadow state changes greatly from the way the ambient light strikes during shooting will result in an unnatural impression. May be an image. For this reason, in step S806, the target shadow state setting unit 205 sets a target shadow state for each subject for a plurality of subjects. As a target value for each subject, a plurality of shade states that are preferable for appearance under a typical light source or photographing environment may be determined in advance and used. At that time, a plurality of shade states determined in advance are selected so as to have the closest shade state of the subject.

以上の処理により、それぞれの被写体に対する目標陰影状態を定めた後の仮想光源の設定値を定める処理、仮想光源に対応する画像信号を付加する処理の内容は、第一の実施例の場合と同様であるため、詳細な説明は省略する。   The content of the processing for determining the setting value of the virtual light source after determining the target shadow state for each subject by the above processing and the processing for adding the image signal corresponding to the virtual light source are the same as in the case of the first embodiment. Therefore, detailed description is omitted.

以上、説明した通り、本実施例では、複数の被写体領域を対象にリライティング補正を行う際に、被写体の陰影の状態を比較した結果を用いて、被写体毎に目標陰影状態を定めるか、被写体間で共通の目標陰影状態を定めるかを選択する方法を説明した。これにより、複数の被写体を共通の陰影状態へと補正すると不自然な画像になる場合は、被写体毎に目標陰影状態を定めることとなり、自然なリライティング結果を得ることが可能となる。逆に、被写体ごとに目標陰影状態を定めると、被写体ごとの陰影状態のばらつきが大きくなり不自然となるような画像については、共通の目標陰影状態を定めることで、その不自然さを解消できる。   As described above, in this embodiment, when relighting correction is performed on a plurality of subject areas, a target shadow state is determined for each subject using the result of comparing the shaded state of the subject, or between subjects. Explained how to select whether to define a common target shadow state. As a result, when a plurality of subjects are corrected to a common shadow state and an unnatural image is obtained, a target shadow state is determined for each subject, and a natural relighting result can be obtained. Conversely, if the target shadow state is determined for each subject, the unnaturalness can be eliminated by defining a common target shadow state for an image in which the variation of the shadow state for each subject increases and becomes unnatural. .

[変形例1]
なお、本実施例では、コントラストと明るさの差分に基づいて、目標陰影状態を被写体間で共通にするか否かを判定する場合で説明したが、複数の被写体の陰影の状態を比較した結果に基づいて、目標陰影状態の決定方法を制御する方法であれば、どのようなものを用いても構わない。例えば、被写体の明るさ、コントラストのいずれか一方のみを用いて判定してもよい。また例えば、被写体の明るさ、コントラストに加えて、影の向きや被写体の色情報も用いて、被写体間で同一の環境光が当たっているか、互いに異なる環境光が当たっているかを判定するようにしても良い。この場合、同一の環境光が当たっていると判定された場合は、被写体間で共通の目標陰影状態を設定し、異なる環境光が当たっていると判定された場合は、それぞれに当たっている環境光に適した目標陰影状態を被写体毎に設定するようにする。このようにすることで、元の環境光による特性を残しながら、より見た目に好ましくなるようリライティング補正を行う事が可能となる。
[Modification 1]
In this embodiment, the case where it is determined whether or not the target shadow state is made common among the subjects based on the difference between the contrast and the brightness is described. However, the result of comparing the shadow states of a plurality of subjects. Any method may be used as long as it is a method for controlling the method for determining the target shadow state based on the above. For example, the determination may be made using only one of the brightness and contrast of the subject. Further, for example, in addition to the brightness and contrast of the subject, the shadow direction and subject color information are also used to determine whether the subject is exposed to the same ambient light or different ambient light. May be. In this case, if it is determined that the same ambient light is shining, a common target shadow state is set between the subjects, and if it is determined that different ambient light is shining, the ambient light shining on each of the subjects is set. A suitable target shadow state is set for each subject. By doing so, it becomes possible to perform relighting correction so as to be more visually appealing while retaining the characteristics due to the original ambient light.

[変形例2]
また、複数の被写体の陰影の状態を比較し、その中で見た目に好ましい陰影の状態の被写体が存在するか否かを判定する方法を用いても良い。この場合、見た目に好ましい陰影の状態の被写体が存在しない場合は、目標陰影状態を、被写体間で共通の陰影状態とする。目標陰影状態としては、見た目に好ましい所定の陰影の状態を定めるようにすれば良い。
[Modification 2]
Further, a method may be used in which the shade states of a plurality of subjects are compared and it is determined whether or not there is a subject with a shaded state that is visually favorable among them. In this case, when there is no subject that is in a shaded state that is visually appealing, the target shaded state is set to a shaded state that is common among the subjects. As the target shade state, a predetermined shade state that is desirable to the eye may be determined.

[変形例3]
また、本実施例では、目標陰影状態として予め定められた所定の陰影状態を用いる場合で説明したが、目標陰影状態の決定方法はこれに限定されるものではない。例えば、複数の被写体の環境光での陰影の状態を検出し、その平均値を目標陰影状態として定めても良い。また、複数の被写体の中で、同一の陰影の状態である被写体の数が多い場合には、その陰影の状態を目標陰影状態として選ぶようにしても良い。
[Modification 3]
Further, in this embodiment, the case where a predetermined shadow state determined in advance is used as the target shadow state has been described, but the method for determining the target shadow state is not limited to this. For example, it is possible to detect the state of shading of a plurality of subjects with ambient light and determine the average value as the target shading state. In addition, when there are a large number of subjects in the same shadow state among a plurality of subjects, the shadow state may be selected as the target shadow state.

[変形例4]
また、共通の目標陰影状態を設定した後に、更に、第一の実施例で説明した方法を用いて、被写体の陰影の状態の関係が逆転しないよう、被写体毎に目標陰影状態を調整するようにしても良い。このようにすることで、第一の実施例の場合と同様、リライティング補正の前後で陰影の状態が逆転せず、自然な見た目のリライティング結果を得ることが可能となる。
[Modification 4]
In addition, after setting the common target shadow state, the target shadow state is adjusted for each subject so that the relationship of the shadow state of the subject is not reversed by using the method described in the first embodiment. May be. By doing so, as in the case of the first embodiment, the shaded state does not reverse before and after the relighting correction, and a natural-looking relighting result can be obtained.

[その他の実施例]
本発明は、上述の実施形態の1以上の機能を実現するプログラムを、ネットワーク又は記憶媒体を介してシステム又は装置に供給し、そのシステム又は装置のコンピュータにおける1つ以上のプロセッサがプログラムを読出し実行する処理でも実現可能である。また、1以上の機能を実現する回路(例えば、ASIC)によっても実現可能である。
[Other Examples]
The present invention supplies a program that realizes one or more functions of the above-described embodiments to a system or apparatus via a network or a storage medium, and one or more processors in the computer of the system or apparatus read and execute the program This process can be realized. It can also be realized by a circuit (for example, ASIC) that realizes one or more functions.

50 システム制御部、101 光学系、102 シャッター、103 撮像部、104 A/D変換器、105 画像処理部、106 画像メモリ、107 メモリ制御部、109 表示部、110 コーデック部、111 記録I/F、112 記録媒体、113 顔検出部、120 操作部、121 不揮発性メモリ、122 システムメモリ 50 System control unit, 101 Optical system, 102 Shutter, 103 Imaging unit, 104 A / D converter, 105 Image processing unit, 106 Image memory, 107 Memory control unit, 109 Display unit, 110 Codec unit, 111 Recording I / F 112 recording medium 113 face detection unit 120 operation unit 121 non-volatile memory 122 system memory

Claims (14)

着目画像中の被写体を検出する被写体検出手段と、
前記被写体ごとの陰影の程度を示す陰影状態を検出する状態検出手段と、
検出された前記陰影状態に基づいて、前記被写体の補正の前の陰影の程度と補正の後の陰影の程度の序列が入れ替わらないように、前記着目画像中の対象となる被写体ごとに、目標となる陰影の状態である目標陰影状態を設定する目標設定手段と、
前記着目画像に対して、前記状態検出手段により検出された陰影状態と前記目標陰影状態とに基づいて、前記対象となる被写体ごとに仮想光源の設定を決定する光源設定手段と、
前記仮想光源を用いて前記着目画像中の前記対象となる被写体の明るさを補正する補正手段と
を備えることを特徴とする画像処理装置。
Subject detection means for detecting a subject in the image of interest;
State detecting means for detecting a shadow state indicating a degree of shadow for each subject;
Based on the detected shadow state, a target for each target subject in the image of interest is arranged so that the order of the degree of shadow before correction of the subject and the order of shadow after correction are not interchanged. Target setting means for setting a target shadow state that is a shadow state to become,
A light source setting unit that determines a setting of a virtual light source for each target subject based on the shadow state detected by the state detection unit and the target shadow state for the target image;
An image processing apparatus comprising: a correction unit that corrects the brightness of the subject subject in the image of interest using the virtual light source.
前記被写体検出手段により複数の被写体が検出された場合には、前記状態検出手段により検出された前記被写体ごとの陰影状態に基づいて前記複数の被写体の中から選択された被写体を、前記対象となる被写体とすることを特徴とする請求項1に記載の画像処理装置。   When a plurality of subjects are detected by the subject detection unit, a subject selected from the plurality of subjects based on the shadow state of each subject detected by the state detection unit becomes the target. The image processing apparatus according to claim 1, wherein the image processing apparatus is a subject. 前記陰影状態とは、前記着目画像を撮影した際に、前記被写体を照らしている環境光によって、前記被写体に対応する被写体領域に生じた陰影の特性を表す情報であることを特徴とする請求項1又は2に記載の画像処理装置。   The shadow state is information representing a characteristic of a shadow generated in a subject area corresponding to the subject by ambient light illuminating the subject when the target image is captured. The image processing apparatus according to 1 or 2. 前記陰影状態とは、前記被写体領域の中の明るさの分布と、前記被写体領域の中のコントラストを表す情報と、前記被写体領域の中で陰影が生じている領域の輪郭の特性と、前記被写体領域の中で陰影が生じている領域の面積を表す情報のうちの少なくとも一つの情報を含むことを特徴とする請求項1乃至3のいずれか一項に記載の画像処理装置。   The shadow state includes information on brightness distribution in the subject area, information indicating contrast in the subject area, characteristics of the contour of the shadow area in the subject area, and the subject The image processing apparatus according to any one of claims 1 to 3, further comprising at least one piece of information representing an area of a shaded area. 前記目標設定手段は、前記着目画像中において、前記陰影の程度が最も高い被写体については前記陰影の程度を下げ、前記陰影の程度が最も低い被写体については前記陰影の程度を上げるよう前記目標陰影状態を決定することを特徴とする請求項1乃至4の何れか一項に記載の画像処理装置。   In the target image, the target setting unit reduces the shadow level for a subject with the highest shadow level and increases the shadow level for a subject with the lowest shadow level in the target image. The image processing apparatus according to any one of claims 1 to 4, wherein the image processing apparatus is determined. 前記目標設定手段は、複数の前記被写体のそれぞれに対して、被写体の陰影状態を表す評価値を算出し、前記評価値が目標となる評価値となるよう前記目標陰影状態を決定することを特徴とする請求項1乃至5の何れか一項に記載の画像処理装置。   The target setting means calculates an evaluation value representing a shadow state of a subject for each of the plurality of subjects, and determines the target shadow state so that the evaluation value becomes a target evaluation value. The image processing apparatus according to any one of claims 1 to 5. 前記評価値は、被写体領域の中の輝度が最も高い部分と最も低い部分との輝度の比を示すコントラスト値であることを特徴とする請求項6に記載の画像処理装置。   The image processing apparatus according to claim 6, wherein the evaluation value is a contrast value indicating a luminance ratio between a highest luminance portion and a lowest luminance portion in the subject area. 前記目標設定手段は、前記着目画像中の複数の前記被写体に対する前記評価値を比較した結果に基づいて、前記目標陰影状態を、被写体毎に異なる状態にするか、被写体間で同一の状態とするかを決定することを特徴とする請求項6又は7に記載の画像処理装置。   The target setting means sets the target shadow state to a different state for each subject or sets the same state between subjects based on a result of comparing the evaluation values for the plurality of subjects in the target image. The image processing apparatus according to claim 6, wherein the image processing apparatus determines whether or not. 前記目標設定手段は、複数の前記被写体間での前記評価値の差分が所定値よりも大きい場合に、前記目標陰影状態を、被写体毎に異なる状態にするよう決定することを特徴とする請求項8に記載の画像処理装置。   The target setting means determines that the target shadow state is different for each subject when a difference in the evaluation values among the plurality of subjects is larger than a predetermined value. The image processing apparatus according to 8. 前記目標設定手段は、複数の前記被写体に対する前記評価値を比較した結果に基づいて、前記対象とする被写体を決定することを特徴とする請求項6乃至9の何れか一項に記載の画像処理装置。   The image processing according to claim 6, wherein the target setting unit determines the target subject based on a result of comparing the evaluation values for the plurality of subjects. apparatus. 前記仮想光源の設定とは、前記仮想光源の前記被写体に対する位置と、前記仮想光源の発する仮想的な照明光の強度とを含むことを特徴とする請求項1乃至10の何れか一項に記載の画像処理装置。   11. The setting of the virtual light source includes a position of the virtual light source with respect to the subject and an intensity of virtual illumination light emitted from the virtual light source. Image processing apparatus. 前記陰影状態は、被写体領域の中のコントラストを表す情報であるコントラスト値により示され、
前記光源設定手段は、前記目標陰影状態を示す目標コントラスト値が、前記状態検出手段により検出された陰影状態を示すコントラスト値よりも小さい場合には、前記仮想光源の位置を、前記被写体の法線に対して前記被写体を照らしている環境光と反対側に設定し、前記状態検出手段により検出された陰影状態を示すコントラスト値が前記目標陰影状態を示す目標コントラスト値よりも小さい場合には、前記仮想光源の位置を、前記被写体の法線に対して前記環境光と同じ側に設定することを特徴とする請求項11に記載の画像処理装置。
The shaded state is indicated by a contrast value that is information representing contrast in the subject area,
When the target contrast value indicating the target shadow state is smaller than the contrast value indicating the shadow state detected by the state detection unit, the light source setting unit determines the position of the virtual light source as the normal of the subject. If the contrast value indicating the shadow state detected by the state detection means is smaller than the target contrast value indicating the target shadow state, the opposite side to the ambient light illuminating the subject, The image processing apparatus according to claim 11, wherein the position of the virtual light source is set on the same side as the ambient light with respect to the normal line of the subject.
着目画像中の被写体を検出する被写体検出手段と、
前記被写体ごとの陰影の程度を示す陰影状態を検出する状態検出手段と、
検出された前記陰影状態に基づいて、前記被写体の補正の前の陰影の程度と補正の後の陰影の程度の序列が入れ替わらないように、前記着目画像中の対象となる被写体ごとに、目標となる陰影の状態である目標陰影状態を設定する目標設定手段と、
前記着目画像に対して、前記状態検出手段により検出された陰影状態と前記目標陰影状態とに基づいて、前記対象となる被写体ごとに仮想光源の設定を決定する光源設定手段と、
前記仮想光源を用いて前記着目画像中の前記対象となる被写体の明るさを補正する補正手段と
してコンピュータを機能させるためのプログラム。
Subject detection means for detecting a subject in the image of interest;
State detecting means for detecting a shadow state indicating a degree of shadow for each subject;
Based on the detected shadow state, a target for each target subject in the image of interest is arranged so that the order of the degree of shadow before correction of the subject and the order of shadow after correction are not interchanged. Target setting means for setting a target shadow state that is a shadow state to become,
A light source setting unit that determines a setting of a virtual light source for each target subject based on the shadow state detected by the state detection unit and the target shadow state for the target image;
A program for causing a computer to function as correction means for correcting the brightness of the subject subject in the image of interest using the virtual light source.
着目画像中の被写体を検出する被写体検出工程と、
前記被写体ごとの陰影の程度を示す陰影状態を検出する状態検出工程と、
検出された前記陰影状態に基づいて、前記被写体の補正の前の陰影の程度と補正の後の陰影の程度の序列が入れ替わらないように、前記着目画像中の対象となる被写体ごとに、目標となる陰影の状態である目標陰影状態を設定する目標設定工程と、
前記着目画像に対して、前記状態検出工程により検出された陰影状態と前記目標陰影状態とに基づいて、前記対象となる被写体ごとに仮想光源の設定を決定する光源設定工程と、
前記仮想光源を用いて前記着目画像中の前記対象となる被写体の明るさを補正する補正工程と
を有することを特徴とする画像処理方法。
A subject detection step of detecting a subject in the image of interest;
A state detection step of detecting a shadow state indicating a degree of shadow for each subject;
Based on the detected shadow state, a target for each target subject in the image of interest is arranged so that the order of the degree of shadow before correction of the subject and the order of shadow after correction are not interchanged. A target setting step for setting a target shadow state, which is a shadow state to become,
A light source setting step for determining a setting of a virtual light source for each target subject based on the shadow state detected by the state detection step and the target shadow state for the target image;
And a correction step of correcting the brightness of the subject subject in the image of interest using the virtual light source.
JP2016032424A 2016-02-23 2016-02-23 Image processing apparatus and image processing method Active JP6718253B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2016032424A JP6718253B2 (en) 2016-02-23 2016-02-23 Image processing apparatus and image processing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2016032424A JP6718253B2 (en) 2016-02-23 2016-02-23 Image processing apparatus and image processing method

Publications (3)

Publication Number Publication Date
JP2017152866A true JP2017152866A (en) 2017-08-31
JP2017152866A5 JP2017152866A5 (en) 2019-04-04
JP6718253B2 JP6718253B2 (en) 2020-07-08

Family

ID=59739171

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2016032424A Active JP6718253B2 (en) 2016-02-23 2016-02-23 Image processing apparatus and image processing method

Country Status (1)

Country Link
JP (1) JP6718253B2 (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2020160945A (en) * 2019-03-27 2020-10-01 キヤノン株式会社 Image processing device, image processing method, program, and storage medium
CN113340895A (en) * 2021-06-04 2021-09-03 深圳中科飞测科技股份有限公司 Adjusting method of detection system and detection system
CN114683504A (en) * 2022-03-07 2022-07-01 深圳市友联精诚塑胶制品有限公司 Injection product molding control method and control equipment
JP7455578B2 (en) 2019-12-27 2024-03-26 キヤノン株式会社 Image processing device and image processing method

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2020160945A (en) * 2019-03-27 2020-10-01 キヤノン株式会社 Image processing device, image processing method, program, and storage medium
JP7311995B2 (en) 2019-03-27 2023-07-20 キヤノン株式会社 IMAGE PROCESSING APPARATUS AND IMAGE PROCESSING METHOD, PROGRAM, STORAGE MEDIUM
JP7455578B2 (en) 2019-12-27 2024-03-26 キヤノン株式会社 Image processing device and image processing method
CN113340895A (en) * 2021-06-04 2021-09-03 深圳中科飞测科技股份有限公司 Adjusting method of detection system and detection system
CN114683504A (en) * 2022-03-07 2022-07-01 深圳市友联精诚塑胶制品有限公司 Injection product molding control method and control equipment
CN114683504B (en) * 2022-03-07 2023-10-31 佳睦拉索(上海)有限公司 Injection molding product molding control method and control equipment

Also Published As

Publication number Publication date
JP6718253B2 (en) 2020-07-08

Similar Documents

Publication Publication Date Title
JP6442209B2 (en) Image processing apparatus and control method thereof
JP6445844B2 (en) Imaging device and method performed in imaging device
KR20130031574A (en) Image processing method and image processing apparatus
JP6412386B2 (en) Image processing apparatus, control method therefor, program, and recording medium
JP2016086246A (en) Image processing apparatus and method, and imaging device
JP6718253B2 (en) Image processing apparatus and image processing method
US11019254B2 (en) Image processing apparatus, control method for image processing apparatus, and storage medium having correction of effect of virtual light source
US11893716B2 (en) Image processing apparatus and image processing method, and image capturing apparatus
JP7059076B2 (en) Image processing device, its control method, program, recording medium
JP2016213717A (en) Image processing apparatus, image processing method, program, and storage medium
JP2017138927A (en) Image processing device, imaging apparatus, control method and program thereof
JP6666735B2 (en) Image processing apparatus, imaging apparatus, control method for image processing apparatus, and program
JP6727276B2 (en) Image processing apparatus, control method thereof, and program
JP6663246B2 (en) Image processing apparatus, imaging apparatus, control method thereof, and program
JP6675461B2 (en) Image processing apparatus, control method therefor, and program
US11842467B2 (en) Image processing apparatus, image processing method and storage medium
JP7446080B2 (en) Image processing device, imaging device, control method, program and imaging system
JP2020181330A (en) Image processing device, processing method thereof, imaging device, program and storage medium

Legal Events

Date Code Title Description
A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20190220

A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20190220

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20191024

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20191101

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20191227

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20200515

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20200612

R151 Written notification of patent or utility model registration

Ref document number: 6718253

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R151