JP2018010498A - Image processing device and method and control program - Google Patents
Image processing device and method and control program Download PDFInfo
- Publication number
- JP2018010498A JP2018010498A JP2016139141A JP2016139141A JP2018010498A JP 2018010498 A JP2018010498 A JP 2018010498A JP 2016139141 A JP2016139141 A JP 2016139141A JP 2016139141 A JP2016139141 A JP 2016139141A JP 2018010498 A JP2018010498 A JP 2018010498A
- Authority
- JP
- Japan
- Prior art keywords
- face
- light source
- image
- virtual light
- lighting
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Landscapes
- Processing Or Creating Images (AREA)
- Image Processing (AREA)
- Studio Devices (AREA)
- Image Analysis (AREA)
Abstract
Description
本発明は、明るさ補正を行う画像処理装置及び方法並びに制御プログラムに関する。 The present invention relates to an image processing apparatus and method for performing brightness correction, and a control program.
画像中の被写体に対して仮想光源による照明効果を適用することで被写体の暗部の明るさを補正することが、知られている(例えば、特許文献1参照)。 It is known to correct the brightness of a dark part of a subject by applying a lighting effect by a virtual light source to the subject in the image (see, for example, Patent Document 1).
特許文献1に記載される技術では、複数の画像の同様の被写体に同じ照明効果を与えるのが難しい。具体的には、第1の画像に含まれる人物の顔に対してユーザが所望の位置に仮想光源を設定した場合、他の画像に含まれる顔に対して仮想光源による同様の照明効果を当てるのが難しい。
With the technique described in
本発明は、ある画像の被写体に設定した仮想光源を別の画像の被写体にも同じ設定で適用できるようにした画像処理装置及び方法並びに制御プログラムを提示することを目的とする。 It is an object of the present invention to present an image processing apparatus and method, and a control program that can apply a virtual light source set to a subject of an image to a subject of another image with the same setting.
本発明に係る画像処理装置は、第1の画像および第2の画像から顔を検出する顔検出手段と、前記顔検出手段で検出される顔に仮想光源によるライティングを施すライティング手段と、前記第1の画像の顔に対する前記仮想光源の相対位置と同じ相対位置で前記第2の画像の顔に適用するように、前記ライティング手段において前記第1の画像に適用した仮想光源パラメータを前記第2の画像に適用する制御手段とを有することを特徴とする。 An image processing apparatus according to the present invention includes a face detection unit that detects a face from a first image and a second image, a lighting unit that performs lighting with a virtual light source on the face detected by the face detection unit, and the first The virtual light source parameter applied to the first image by the lighting means is applied to the second image face at the same relative position as the relative position of the virtual light source with respect to the face of the first image. And control means applied to the image.
本発明によれば、第1の画像に含まれる顔に適用されるライティングと同じ条件のライティングを、簡単な操作で第2の画像に含まれる顔に適用できる。 According to the present invention, lighting under the same conditions as lighting applied to the face included in the first image can be applied to the face included in the second image with a simple operation.
以下、図面を参照して、本発明の実施例を詳細に説明する。なお,本明細書では、仮想光源を設定して疑似的なライティングを行う画像処理を以降、リライティングと記す。仮想光源の撮像装置の撮影光軸に対する水平方向の角度をlight_hと記し、撮影光軸と直角に交差する垂直軸に対する角度をlight_vと記す。仮想光源の位置の水平座標値をlight_x、垂直座標値をlight_y、奥行き座標値をlight_zと記す。仮想光源に関する、光のオンオフ情報、光源種類、光の強さ、光源の位置、角度及び光源色温度を総称して、以降、仮想光源パラメータと記す。 Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings. In the present specification, image processing that performs virtual lighting by setting a virtual light source is hereinafter referred to as relighting. The angle of the virtual light source in the horizontal direction with respect to the photographing optical axis of the imaging device is denoted as light_h, and the angle with respect to the vertical axis that intersects the photographing optical axis at right angles is denoted as light_v. The horizontal coordinate value of the position of the virtual light source is denoted as light_x, the vertical coordinate value is denoted as light_y, and the depth coordinate value is denoted as light_z. The light on / off information, light source type, light intensity, light source position, angle, and light source color temperature related to the virtual light source are collectively referred to as virtual light source parameters hereinafter.
図1は、本発明に係る画像処理装置の一実施例の概略構成ブロック図を示す。図1に示す画像処理装置100の主要な機能は、コンピュータ上で動作するコンピュータプログラムにより実現される。
FIG. 1 shows a schematic block diagram of an embodiment of an image processing apparatus according to the present invention. The main functions of the
101は画像処理装置100の全体の制御を司るCPUである。102は、CPU101の動作処理手順(例えばコンピュータの立ち上げ処理や基本入出力処理等のプログラム)を記憶するROMである。103はRAMであり、CPU101のメインメモリとして機能する。RAM103には後述の処理を実現するための制御プログラムを含む各種プログラムがハードディスクドライブ105等からロードされ、CPU101によって実行される。RAM103は、CPU101が各種処理を実行する際のワークエリアを提供する。
A
104はディスプレイであり、CPU101の制御下で各種表示を行なう。105はハードディスクドライブ(以下、HDD)であり、アプリケーションプログラム、データ及びライブラリなどの保存に用いられる。リラインティん具の対象となる画像データは、HDD105に格納されている。
106はポインティングデバイス及びキーボード等からなる入力装置である。107は記憶媒体を着脱可能な記憶媒体装着ユニット(メディアドライブ)である。記憶媒体は例えば、デジタルスチルカメラに着脱可能な、撮影画像を記憶するメモリカードである。
An
108はネットワークインターフェイスであり、通信回線110を介してコンピュータネットワーク111と接続する。CPU101は、ネットワークインターフェイス108により、コンピュータネットワーク111上の機器との間でデータを送受信する。
A
109は、上述した各ユニット間を接続するシステムバスであり、アドレスバス、データバスおよび制御バスからなる。
図2は、画像処理装置100のユーザインターフェイスの一例である。図2を用いて、ユーザが仮想光源パラメータを設定する方法を説明する。
FIG. 2 is an example of a user interface of the
201は、ユーザが画像データのあるフォルダを選択するフォルダ選択エリアである。CPU101は、HDD105のフォルダ構成を読みとり、フォルダツリーを表示する。
202は、ユーザが選択したフォルダを示すフォルダフォーカス枠である。ユーザが入力装置106のポインティングデバイス等で所望のフォルダをクリックした場合、CPU101は、フォルダフォーカス枠202をそのフォルダの位置に描画する。その後、CPU101は、HDD105からそのフォルダ内の画像データを読み込む。
203は、画像処理結果を表示するプレビューエリアである。204は、フォルダ選択エリア201でユーザが指定したフォルダ内の画像データを縮小画像で一覧表示するサムネイルエリアである。205は、サムネイルエリア204内にユーザが選択したフォルダ内の画像データを縮小画像で表示しきれない場合に、表示範囲を変更するためのサムネイルエリアスクロールバーである。サムネイルエリアスクロールバー205をユーザが操作すると、CPU101は、サムネイルエリア204の表示領域を変更すべくサムネイルエリア204の表示を更新する。
A
206は、ユーザが画像処理対象として選択した画像データを示す画像フォーカス枠である。サムネイルエリア204内でユーザが所望の縮小画像を入力装置106のポインティングデバイス等でクリックした場合、CPU101は、ユーザから画像処理対象の画像データ指定があったものと判定する。そして、CPU101は、画像フォーカス枠206をユーザがクリックした位置の縮小画像を囲む形で描画すると共に、その縮小画像に対応する画像データを読み込み、プレビューエリア203に表示する。
207は、ユーザが画像処理対象として選択した画像データの表示結果例である。208は、ユーザが設定した仮想光源を画像データに重畳して表示している例である。
209は、光源のオンオフ指定ラジオボタンであり、仮想光源を疑似的に点灯するか否かをCPU101に指示するのに使用される。ユーザがONを押下した場合、CPU101は、ユーザから仮想光源点灯の操作があったと判定し、仮想光源が点灯しているものとして後述のリライティングを行う。ユーザがOFFを押下した場合、CPU101は、ユーザから仮想光源消灯の操作があったと判定して、仮想光源が消灯しているものとして、リライティングしない。リライティングの後ではリライティングの効果を消去する。
210は、光源種類選択リストボックスである。ユーザが光源種類選択リストボックス210の下矢印ボタンを押下すると、光源の種類として、点光源及び面光源がリストされる。そして、ユーザがいずれかを選択した場合、CPU101はユーザから仮想光源の種類を指定する操作があったと判定して、後述のリライティングを行う。211は、光の強さスライダである。ユーザがスライダ211のツマミを操作した場合、CPU101は、ユーザから仮想光源の光の強さの変更操作があったと判定して、つまみの位置に対応する光の強さで、後述のリライティングを行う。
210 is a light source type selection list box. When the user presses the down arrow button of the light source type
212は、光源水平座標値light_xを入力する水平座標入力エディットボックスである。仮想光源の水平座標値を数値で指定する。画像の中心座標を0、左方向の座標値を負値、右方向の座標値を正値とする。213は、光源垂直座標値light_yを入力する垂直座標入力エディットボックスである。仮想光源の垂直座標を数値で指定する。画像の中心座標を0、上方向の座標値を負値、下方向の座標値を正値とする。214は、光源奥行き座標値light_zを入力する奥行き座標入力エディットボックスである。仮想光源の奥行き座標値を数値で指定する。仮想空間上の撮像装置の位置を0、撮像装置から被写体に近づく方向の座標値を正値、遠ざかる方向の座標値を負値とする。エディットボックス212,213,214で指定された座標値を総称して、以降、仮想光源絶対座標値と記す。
215は、水平角度light_hを入力する水平角度入力エディットボックスである。仮想光源の撮像装置の撮影光軸に対する水平角度light_hを指定する。撮像装置の撮影光軸と平行な場合に0となり、撮影光軸よりも右方向に向いた場合に正値、左方向に向いた場合に負値とする。216は、垂直角度light_vを入力する垂直角度入力エディットボックスである。撮影光軸と直角に交差する垂直軸に対する角度(垂直角度)light_vを指定する。撮像装置の撮影光軸と平行な場合に0となり、上方向に向いた場合に正値、下方向に向いた場合に負値とする。
各エディットボックス212〜216の初期値は0とする。各エディットボックス212〜216でユーザが値を指定した場合、CPU101は、仮想光源の位置変更操作があったものとして、仮想空間上の仮想光源の位置および角度を入力値に応じて変更し、後述のリライティングを行う。
The initial value of each
217は、光源色温度入力エディットボックスであり、2700K〜10000Kまでの値を入力可能とする。エディットボックス217の初期値は、白色蛍光ランプの色温度4500Kとする。ユーザが光源色温度入力エディットボックス217の値を変更した場合、CPU101はユーザから仮想光源の色温度の変更操作があったと判定して、指定された光源色温度で後述のリライティングを行う。
CPU101は、要素209〜217によりユーザが指定した仮想光源パラメータを、処理対象の画像データと関連付けて、RAM103に記憶する。いずれかの仮想光源パラメータに変更があった場合、CPU101は、RAM103の対応する記憶値を更新する。
The
218は、仮想光源パラメータコピーボタンである。ユーザが仮想光源パラメータコピーボタン218を押下した場合、CPU101は、ユーザから仮想光源パラメータコピー指示があったと判定する。そして、CPU101は、仮想光源に関して要素209〜217で指定された各種設定情報を後述の方法で仮想光源パラメータを相対位置に変換して、RAM103に記憶する。
219は、仮想光源パラメータペーストボタンである。ユーザが仮想光源パラメータペーストボタン219を押下した場合、CPU101は、ユーザから仮想パラメータペースト指示があったと判定する。そして、CPU101は、RAM103に仮想光源パラメータが格納されている場合、後述の方法でその仮想光源パラメータを絶対座標に変換し、その後、処理対象の画像データに対してリライティングを行う。
220から224は、処理前または処理後の説明例の画像データである。例えば、画像データ220に対して仮想光源によるライティングした後に画像データ221に対して同様のライティング効果を得たいとする。この場合、ユーザは、画像データ220を選択した状態で仮想光源パラメータコピーボタン218を押下し、その後、画像データ221を選択し、仮想光源パラメータペーストボタン219を押下する。仮想光源パラメータのペースト先の画像データが、画像データ222,223のように複数の顔を含む場合、各顔に対してコピー元と同様のリライティングが適用される。仮想光源パラメータコピー処理および仮想光源パラメータペースト処理については、後述する。
225は、終了ボタンである。ユーザが終了ボタン225を押下した場合、CPU101は、ユーザから終了指示があったと判定し、RAM103に記憶している情報を破棄した後、画像処理装置100による画像処理を終了する。
図3は、ある画像データに設定された仮想光源パラメータに基づき他の画像に同様のライティングを施す本実施例の動作フローチャートである。CPU101が、RAM103に格納される制御プログラムを実行することにより、図3に示す処理を実現する。
FIG. 3 is an operation flowchart of the present embodiment in which similar lighting is performed on other images based on the virtual light source parameters set in certain image data. The
ステップS300で、CPU101は、処理対象とする画像データと、その画像データと関連付けられた関連情報を読み込む。関連情報は、距離マップとして表現される、撮像時の撮像装置と被写体との間の距離情報を含む。距離マップは、処理対象として選択された画像データの撮像時に、被写体像の各画素に対して撮像素子から被写体までの物理的な距離を数値化した画像データである。距離マップは、撮像装置において、ぼけ方の異なる複数の画像から被写体距離を算出して生成され、画像データの関連情報として画像データと共に記憶媒体に記録される。距離マップの代わりに、ステレオカメラによる写真測量またはスポット光の照射もしくは走査による3次元計測などで得られる3次元形状データを使っても良い。
In step S300, the
ステップS301で、CPU101は、RAM103から仮想光源パラメータを読み込む。仮想光源パラメータは、光のオンオフ情報、光源種類、光の強さ、仮想光源の位置、角度及び光源色温度の各設定値からなる。ユーザがサムネイルエリア204で未調整の画像データを選択した場合、CPU101は、初期値を読み込む。ユーザが要素209〜217で仮想光源パラメータを変更している場合、CPU101は、変更後の仮想光源パラメータを読み込む。ユーザが仮想光源パラメータペーストボタン219を押下したとき、CPU101は、ペースト処理で算出した仮想光源パラメータを読み込む。
In step S <b> 301, the
ステップS302で、CPU101は、処理対象となる画像データの被写体像内に含まれる人物の顔を検出する。CPU101はまず、顔の個数を検出し、検出した各顔に0から順のユニークな顔IDを割り振る。CPU101は、顔IDに対応付けられて、顔の中心座標、顔の大きさ、顔の角度及び顔向きを決定する。顔の中心座標値は、仮想光源の絶対座標と同じ座標系で出力される。
In step S302, the
ステップS303で、CPU101は、カウンタiに0を代入する。カウンタiは、ステップS305からS308までの処理を、顔の個数分繰り返すためのループ変数である。
In step S303, the
ステップS304で、CPU101は、カウンタiが顔の個数よりも小さい値か否かを判定する。カウンタiが顔の個数よりも小さい値の場合、CPU101は、ステップS305に進む。カウンタiが顔の個数以上の値の場合、CPU101は、ステップS305〜S308の処理を顔の個数分繰り返したと判定し、ステップS309に進む。
In step S304, the
ステップS305で、CPU101は、顔IDがiの顔に関して、撮像素子からの物理的距離を算出する。物理距離算出の為に、CPU101は、距離マップから顔の中心座標までの距離を取得する。
In step S <b> 305, the
ステップS306で、CPU101は、顔IDがiの顔の顔器官を検出する。顔器官は、左右の目、鼻及び口である。CPU101は、顔器官の検出結果として、各顔器官の2次元の画像データ上での左右の端、及び、上下の端に該当する座標を出力する。
In step S306, the
ステップS307で、CPU101は、顔器官の検出結果から、顔の法線情報を生成する。CPU101は、被写体像の仮想空間上で顔の凹凸をシミュレートした結果から、顔の向き、則ち、顔の法線を決定する。CPU101は、顔の向きから既定のマスクに最も近いマスクを選択し、顔の大きさと顔器官の位置に合わせて、当該マスクを正面向きに変形する。
In step S307, the
ステップS308で、CPU101は、ステップS307で算出した顔法線情報を顔IDがiの顔法線情報としてRAM103に記憶する。
In step S308, the
ステップS309で、CPU101は、RAM103から顔IDが0〜iまでの顔法線情報を読み込み、各顔の距離に合わせて距離マップの各顔の位置に合成し、顔の部分の距離精度が高い距離マップを生成する。
In step S309, the
ステップS310で、CPU101は、仮想光源パラメータに基づいて出力画像データを生成する。仮想光源によって照射された処理対象の出力RGB値(Rout,Gout,Bout)は、下記式(1)で得られる。すなわち、
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
ここで、(Rt,Gt,Bt)は処理対象の入力画素値、Aは仮想光源の強度、Dは仮想光源とリライティング処理対象の被写体との距離、(Rv,Gv,Bv)は光源反射色を示す。Mは、リライティング後の出力RGB値を正規化するための予め設定された定数を示す。角度θは、仮想光源の照射方向と処理対象画素の被写体の法線ベクトルとがなす角度を示す。
In step S310, the
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
Here, (Rt, Gt, Bt) is the input pixel value to be processed, A is the intensity of the virtual light source, D is the distance between the virtual light source and the subject to be relighted, and (Rv, Gv, Bv) is the light source reflection color. Indicates. M represents a preset constant for normalizing the output RGB value after relighting. The angle θ represents an angle formed by the irradiation direction of the virtual light source and the normal vector of the subject of the processing target pixel.
処理対象の入力画素値(Rt,Gt,Bt)は、ステップS300で読み込んだ画像データを構成する画素値である。仮想光源の強度Aは、光の強さスライダ211でユーザが指定する値である。ペースト時の強度は後述する。
The input pixel values (Rt, Gt, Bt) to be processed are pixel values constituting the image data read in step S300. The intensity A of the virtual light source is a value designated by the user with the
CPU101は、仮想光源とリライティング処理対象の被写体との距離Dを、ステップS309で算出した各画素の位置と仮想光源の絶対座標(light_x,light_y,light_z)から算出する。距離Dは、下記式(2)に従い算出される。すなわち、
D={(tP_x-light_x)2+(tP_y-light_y)2+(tP_z-light_z)2}1/2 (2)
ここで、(tP_x,tP_y,tP_z)は対象画像の座標位置を示す。
The
D = {(tP_x-light_x) 2 + (tP_y-light_y) 2 + (tP_z-light_z) 2 } 1/2 (2)
Here, (tP_x, tP_y, tP_z) indicates the coordinate position of the target image.
光源反射色(Rv,Gv,Bv)は、光源色温度入力エディットボックス217でユーザが指定する光源色温度に応じて決定される。色温度の値が低いほど、赤みがかった反射色となり、色温度が高いほど、青みがかった反射色となる。CPU101は、公知の変換テーブルを参照して、光源色温度を光源反射色(Rv,Gv,Bv)に変換する。
The light source reflection colors (Rv, Gv, Bv) are determined according to the light source color temperature specified by the user in the light source color temperature
CPU101は、仮想光源の絶対位置と角度から仮想光の処理対象への照射方向を特定し、この照射方向と、ステップS309で算出した各画素の仮想空間上での法線ベクトルとから、角度θを算出する。
The
図4は、仮想光源が点光源の場合の、法線ベクトルと仮想光源照射方向との関係を示す概念図である。401は、仮想光源である。402は、仮想空間上の処理対象画素である。403は、処理対象画素402に仮想光源から照射された光の照射方向を示す直線である。点光源である仮想光源401は、出力光を放射状に照射するものとする。404は、処理対象画素402における法線ベクトルである。405は、法線ベクトル404と照射方向403が成す角度であり、処理対象画素402への入射角度θである。
FIG. 4 is a conceptual diagram showing the relationship between the normal vector and the virtual light source irradiation direction when the virtual light source is a point light source. 401 is a virtual light source.
図5は、仮想光源が面光源の場合の、法線ベクトルと仮想光源照射方向との関係を示す概念図である。501は、仮想光源である。仮想光源の位置を示す座標は、仮想光源501となる面光源の中央座標を示す。502は、仮想空間上の処理対象画素である。503は、処理対象画素502に仮想光源から照射された光の照射方向を示す直線である。面光源である仮想光源501は、その出力面から垂直に光を照射するものとする。504は、処理対象画素502における法線ベクトルである。505は、法線ベクトル504と照射方向503が成す角度であり、処理対象画素502への入射角度θである。
FIG. 5 is a conceptual diagram showing the relationship between the normal vector and the virtual light source irradiation direction when the virtual light source is a surface light source.
図6は、仮想光源パラメータのコピー処理のフローチャートである。CPU101は、RAM103に格納された制御プログラムを実行することにより、図6に示す処理を実現する。図6を用いて、仮想光源パラメータのコピー処理において、絶対座標でRAM103に記憶されている仮想光源位置を顔に対する相対位置に変換する方法を説明する。
FIG. 6 is a flowchart of virtual light source parameter copy processing. The
ステップS601で、CPU101は、ユーザが仮想光源パラメータのコピー操作をしたか否かを判定する。ユーザが仮想光源パラメータコピーボタン218を押下した場合、CPU101は、コピー操作をしたと判定し、ステップS602に進む。ユーザが仮想光源パラメータコピーボタン218を押下していない場合、CPU101は、コピー操作がないと判定し、図6に示す処理を終了する。
In step S601, the
ステップS602で、CPU101は、主被写体の顔の位置を読み込む。以降、主被写体の顔のことを主顔と記す。被写体像に顔が1つであった場合、CPU101は、その顔を主顔とする。被写体像に複数の顔が存在する場合、CPU101は、合焦距離に存在する顔の中で最も大きい顔を主顔とする。ステップS302およびステップS305での算出結果に従い、主顔の位置は予めRAM103に記憶されている。
In step S602, the
ステップS603で、CPU101は、RAM103に記憶されている仮想光源絶対座標と主顔の位置から、主顔に対する相対座標を算出する。仮想光源の相対座標(reLight_x,reLight_y,reLight_z)は、下記式3により算出される。則ち、
reLight_x=sFace_x-sLight_x
reLight_y=sFace_y-sLight_y (3)
reLight_z=sFace_z-sLight_z
ただし、パラメータコピー元の画像における仮想光源絶対座標を(sLight_x,sLight_y,sLight_z)とし、主顔の中心座標を(sFace_x,sFace_y,sFace_z)とする。
In step S <b> 603, the
reLight_x = sFace_x-sLight_x
reLight_y = sFace_y-sLight_y (3)
reLight_z = sFace_z-sLight_z
However, the virtual light source absolute coordinates in the parameter copy source image are (sLight_x, sLight_y, sLight_z), and the center coordinates of the main face are (sFace_x, sFace_y, sFace_z).
ステップS604で、CPU101は、コピーされた仮想光源パラメータをRAM103に記憶する。その際、CPU101は、仮想光源パラメータを構成する仮想光源の位置については、ステップS603で算出した相対座標を記憶する。それ以外の仮想光源パラメータに関しては、CPU101は、コピー元の画像データに適用されている値をそのまま記憶する。コピーされた仮想光源パラメータは、ユーザが異なる画像データを選択して、仮想光源パラメータコピーボタン218を押下するまで、または画像処理装置100が終了するまで、RAM103に保持される。
In step S <b> 604, the
図7は、仮想光源パラメータのペースト処理を示すフローチャートである。CPU101は、RAM103に格納された制御プログラムを実行することにより、図7に示す処理を実現する。図7を用いて、仮想光源パラメータのペースト処理において、仮想光源相対座標をペースト先の画像の被写体像の仮想空間内における絶対座標に変換する方法を説明する。
FIG. 7 is a flowchart showing virtual light source parameter paste processing. The
ステップS700で、CPU101は、ユーザが仮想光源パラメータのペースト操作をしたか否かを判定する。ユーザが仮想光源パラメータペーストボタン219を押下した場合、CPU101は、ペースト操作をしたと判定し、ステップS702に進む。ユーザが仮想光源パラメータペーストボタン219を押下していない場合、CPU101は、ペースト操作は無かったと判定し、図7に示す処理を終了する。
In step S700, the
ステップS701で、CPU101は、RAM103内にコピーされた仮想光源パラメータがあるか否かを判定する。ある場合、CPU101は、ステップS702に進む。ない場合、CPU101は、ステップS708に進む。
In step S <b> 701, the
ステップS702で、CPU101は、RAM103内からコピーされた仮想光源パラメータを読み込む。
In step S <b> 702, the
ステップS703で、CPU101は、ペースト先の画像における主顔の位置と距離を取得する。取得方法は、ステップS302およびステップS305と同様である。CPU101は、取得した主顔の位置と距離を、ライティングに備えてRAM103(またはHDD105)に保存する。
In step S703, the
ステップS704で、CPU101は、仮想光源位置として記憶されている相対座標をペースト先の画像における絶対座標に変換する。仮想光源絶対座標(tLight_x,tLight_y,tLight_z)は、下記式(4)におより算出される。すなわち、
tLight_x=tFace_x-reLight_x
tLight_y=tFace_y-reLight_y (4)
tLight_z=tFace_z-reLight_z
ただし、主顔の中心座標を(tFace_x,tFace_y,tFace_z)、仮想光源の相対座標(reLight_x,reLight_y,reLight_z)とする。
In step S704, the
tLight_x = tFace_x-reLight_x
tLight_y = tFace_y-reLight_y (4)
tLight_z = tFace_z-reLight_z
However, the center coordinates of the main face are (tFace_x, tFace_y, tFace_z) and the relative coordinates of the virtual light source (reLight_x, reLight_y, reLight_z).
ステップS705で、CPU101は、ペースト先の画像と関連付けて、ステップS702で参照した仮想光源パラメータをコピーする。そして、CPU101は、仮想光源パラメータを構成する光源の位置を、ステップS704で算出した絶対座標に変更する。これにより、ペースト先の画像の顔に対して、コピー元の画像の顔に対するのと同じ相対位置に、仮想光源を配置できる。
In step S705, the
ステップS706で、CPU101は、ペースト先の画像に対してライティングを実行する。ステップS707で、CPU101は、プレビューエリア203とサムネイルエリア204の対象画像の表示をライティング結果による出力画像データで更新する。ステップS707の後、CPU101は、図7に示す処理を終了する。
In step S706, the
ステップS708で、CPU101は、ペーストする仮想光源パラメータがない旨をユーザに通知する警告を表示し、図7に示す処理を終了する。
In step S708, the
図8は、CPU101がステップS302およびステップS305で顔検出した結果の一例である。CPU101は、この顔検出結果をRAM103(またはHDD105)に格納する。
FIG. 8 shows an example of the result of
801は、検出した顔を一意に特定するための顔Noである。顔No801は、複数画像から検出した結果の顔毎にインクリメントされた連続番号からなる。複数画像から検出した複数の顔を管理するために用いる。
802は、顔検出を行った画像データのファイル名である。
803は、主顔かどうかの判定結果である。主顔かどうかの判定方法は前述の通りである。
804は、顔IDである。対象となる画像データ毎に0から割り振られる値からなる。
805は、画像データにおける水平方向の顔の中心座標である。806は、画像データにおける垂直方向の顔の中心座標である。807は、顔の距離である。撮像素子から被写体の顔の物理的な距離を数値化したものである。
808は、画像データにおける顔の大きさである。
809は、撮像装置の光軸を軸とした顔の角度である。
810は、顔の向きである。顔の正面が撮像装置の方向を向いている場合に0となる。
811から817は顔毎の検出結果例を示すエントリまたはレコードである。エントリ811は、画像例220に対する結果を示す。エントリ812は画像例221に対する結果を示す。エントリ813,814は、画像例222に対する結果を示す。エントリ815,816は、画像例223に対する結果を示す。エントリ817は、画像例224に対する結果を示す。
上記説明では、リライティングの処理工程および仮想光源パラメータペースト処理工程において顔を検出した。この代わりに、フォルダ選択エリア201で処理対象となる画像データが含まれるフォルダが選択された時点で、顔検出および顔距離取得をしてもよい。この場合、リライティング処理工程および仮想光源パラメータペースト処理における顔検出および顔距離取得は、顔検出結果読み込み処理で代替できる。
In the above description, the face is detected in the relighting process and the virtual light source parameter paste process. Instead, face detection and face distance acquisition may be performed when a folder including image data to be processed is selected in the
上記説明では、合焦時に用いた測距離枠位置から主顔を決定したが、ユーザ指示またはユーザが仮想光源を設定したときに一番近くの顔を主顔にするようにしてもよい。こうすることにより、ユーザが主被写体と指定した顔や一番手間をかけて輝度を調整した顔に対する疑似的なライティング処理を、他の画像の顔に適用できる。 In the above description, the main face is determined from the distance measurement frame position used at the time of focusing. However, when the user instruction or the user sets the virtual light source, the closest face may be set as the main face. By doing this, it is possible to apply pseudo lighting processing to the face of the other image, for the face designated as the main subject by the user or the face whose brightness is adjusted with the most effort.
上記説明では、仮想光源パラメータをコピーする際に、相対位置に変換した仮想光源パラメータをRAM103に記憶した。この代わりに、HDD105に画像ファイルとは別ファイルとして記憶してもよいし、画像ファイルのヘッダまたはフッダに付与して記憶してもよい。この場合、コピー元の画像ファイルとペースト先の画像ファイルが異なる機器間でも、ファイルを介して同様のリライティング処理を行うことが可能となる。
In the above description, the virtual light source parameter converted into the relative position is stored in the
仮想光源が1つの場合を説明したが、これは理解を容易にするためである。複数の仮想光源を利用できる場合でも、コピー元の画像の主顔に対する相対位置とペースト先の主顔に対する相対位置が同じになるように、個々の光源位置を変換することで、同様のリライティング処理を行うことが可能である。 Although the case where there is one virtual light source has been described, this is for ease of understanding. Even when multiple virtual light sources can be used, the same relighting process is performed by converting the individual light source positions so that the relative position of the copy source image to the main face is the same as the relative position of the paste destination main face. Can be done.
本実施例によれば、被写体像の平面上の位置だけではなく、撮像素子から被写体の顔までの物理的な距離も算出する。これにより、仮想光源パラメータコピー元の画像(第1の画像)に含まれる顔と、仮想光源パラメータペースト先の画像(第2の画像)に含まれる顔とで奥行き方向の位置が異なっても、第2の画像に第1の画像と同様のライティング効果を与えることができる。 According to this embodiment, not only the position of the subject image on the plane but also the physical distance from the image sensor to the subject's face is calculated. Thereby, even if the position in the depth direction differs between the face included in the virtual light source parameter copy source image (first image) and the face included in the virtual light source parameter paste destination image (second image), A lighting effect similar to that of the first image can be given to the second image.
第2の画像に複数の顔が含まれていても、その中で主顔を特定し、第1の画像の主顔と仮想光源の相対位置が同じになるように第2の画像の主顔における仮想光源位置を決定する。これにより、第1の画像に含まれる主顔と同様のライティングを第2の画像の主顔に適用できる。第1及び第2の画像における主顔の向きをも加味して、第2の画像の主顔に対する仮想光源位置を決定しても良い。こうすることで、第1の画像の主顔に対するのと同じ照射方向のライティングを第2の画像の主顔に適用できる。 Even if the second image includes a plurality of faces, the main face is specified in the second image, and the main face of the second image is set so that the relative position of the main face of the first image and the virtual light source is the same. The virtual light source position at is determined. Accordingly, the same lighting as the main face included in the first image can be applied to the main face of the second image. The virtual light source position with respect to the main face of the second image may be determined in consideration of the orientation of the main face in the first and second images. By doing so, lighting in the same irradiation direction as that for the main face of the first image can be applied to the main face of the second image.
第1の画像に対する仮想光源パラメータをコピーする際に位置情報を相対値に変換した上でコピーし、第2の画像に対してペーストの際に主顔と同じ座標上の絶対値に変換するので、第2の画像に対して同じライティング環境を実現できる。コピーした仮想光源のパラメータを保持することにより、複数の第2の画像に対して同じライティング環境を実現できる。 When the virtual light source parameter for the first image is copied, the position information is converted into a relative value and then copied, and when the second image is pasted, it is converted into an absolute value on the same coordinates as the main face. The same lighting environment can be realized for the second image. By holding the copied virtual light source parameters, the same lighting environment can be realized for a plurality of second images.
仮想光源パラメータのペースト先の画像の複数の顔のそれぞれにコピー元と同じライティングを実現する実施例2を説明する。図9は、その動作フローチャートを示す。CPU101が、RAM103に格納される制御プログラムを実行することにより、図9に示す処理を実現する。例えば、仮想光源パラメータのコピー先の画像における各顔に、ステップS702〜S706で説明した処理を適用する。
A second embodiment in which the same lighting as the copy source is realized on each of the plurality of faces of the virtual light source parameter paste destination image will be described. FIG. 9 shows a flowchart of the operation. The
なお、図9に示す処理を実行する前の仮想光源パラメータコピー時に、CPU101は、コピー元の画像における、主顔のリライティング前の顔輝度とリライティング後の顔輝度を、予めRAM103に記憶しておく。以降、リライティング前の顔輝度を基準顔輝度、リライティング後の顔輝度を目標顔輝度と記す。基準顔輝度は、リライティング前の画像データにおける顔位置の平均輝度とする。目標顔輝度は、リライティング後の画像データにおける顔位置の平均輝度とする。CPU101は、基準顔輝度と目標顔輝度をステップS603とS604の間で求め、ステップS604において、仮想光源パラメータと共に、RAM103に記憶する。
When copying the virtual light source parameter before executing the processing shown in FIG. 9, the
ステップS901,S902,S903の処理はそれぞれ、ステップS702,S302,S303と同様なので、説明を省略する。 Since the processing of steps S901, S902, and S903 is the same as that of steps S702, S302, and S303, description thereof will be omitted.
ステップS904で、CPU101は、カウンタiが顔数FaceNumよりも小さい値か否かを判定する。カウンタiが顔数FaceNumよりも小さい値の場合、CPU101は、ステップS905に進む。カウンタiが顔数FaceNum以上の値の場合、CPU101は、ステップS905からS912までの処理を顔数FaceNumだけ繰り返したと判定し、ステップS913に進む。ステップS905からS907の処理は、ステップS305からS307の処理と同様なので、詳細な説明を省略する。
In step S904, the
ステップS908で、CPU101は、顔IDがiである顔に関して顔の輝度を取得する。CPU101はまず、顔の中心座標および顔の大きさから、注目する顔の含まれる画像データの範囲を算出し、算出した範囲の平均輝度を顔の輝度とする。
In step S908, the
ステップS909で、CPU101は、仮想光源位置として記憶されている相対座標を、顔IDがiである顔に対して仮想光源の相対位置が同じになるように絶対座標に変換する。仮想光源絶対座標(tLight_x,tLight_y,tLight_z)は、先に説明した式(4)で算出できる。式(4)において、顔IDがiの顔の中心座標を(tFace_x,tFace_y,tFace_z)とし、仮想光源の相対座標(reLight_x,reLight_y,reLight_z)とする。
In step S909, the
ステップS910で、CPU101は、顔IDがiである顔についてライティング後の顔輝度が目標顔輝度と同じになる、仮想光源の光強度を算出する。目標輝度と同じになる光強度outAは、式(5)により算出でできる。すなわち、
outA = (tLumi-b2Lumi)×inA/(tLumi-b1Lumi) (5)
ただし、基準顔輝度をb1Lumiとし、目標顔輝度をtLumiとし、ステップS901で読み込んだ仮想光源パラメータの光強度をinA、ステップS908で取得した顔輝度をb2Lumiとする。ステップS908で取得した顔輝度b2Lumiが目標顔輝度tLumiよりも大きい場合、光強度outAを0にする。
In step S <b> 910, the
outA = (tLumi-b2Lumi) x inA / (tLumi-b1Lumi) (5)
However, the reference face luminance is b1Lumi, the target face luminance is tLumi, the light intensity of the virtual light source parameter read in step S901 is inA, and the face luminance acquired in step S908 is b2Lumi. When the face luminance b2Lumi acquired in step S908 is larger than the target face luminance tLumi, the light intensity outA is set to zero.
ステップS911で、CPU101は、顔IDがiである顔に対して、ステップS909で算出した光源絶対座標とステップS910で算出した光強度を用いて、出力画像を生成する。出力画像の算出方法は、ステップS310と同様であるので、詳細な説明を省略する。
In step S911, the
ステップS912で、CPU101は、顔IDがiであることと、ステップS912で生成した出力画像を関連付けてRAM103に記憶する。
In step S <b> 912, the
ステップS913で、CPU101は、顔ID=0から顔ID=(FaceNum-1)に関連付けられた出力画像を、各顔の元々の位置で合成する。
In step S913, the
実施例2では、仮想光源パラメータのペースト先の画像(第2の画像)に含まれる各顔に対して、仮想光源パラメータのコピー元の画像(第1の画像)の主顔に対するのと同じ相対関係で仮想光源を設定して同じライティングを適用できる。 In the second embodiment, for each face included in the virtual light source parameter paste destination image (second image), the same relative to the main face of the virtual light source parameter copy source image (first image). The same lighting can be applied by setting a virtual light source in relation.
第2の画像に第1の画像の主顔と同じ顔が含まれる場合、第2の画像のその顔には、第1の画像の主顔と同じ照射方向でのライティングを適用するようにしてもよい。 When the same face as the main face of the first image is included in the second image, lighting in the same irradiation direction as that of the main face of the first image is applied to the face of the second image. Also good.
また、第1の画像の主顔の輝度と、第2の画像に含まれる各顔の輝度の違いに応じて、仮想光源の光強度を変更するので、第2の画像の各顔について、輝度が同じになるライティングを適用できる。加えて、ストロボ発光撮影において撮像装置から遠い顔ほど顔輝度が暗くなってしまっている場合にも、暗い顔ほど仮想光源の光強度が強くなるので、暗い顔ほど明るくなるという明るさ補正の効果も得られる。 Further, since the light intensity of the virtual light source is changed according to the difference between the luminance of the main face of the first image and the luminance of each face included in the second image, the luminance of each face of the second image You can apply lighting that makes the same. In addition, even when the face is farther away from the imaging device in flash photography, the brightness of the virtual light source becomes stronger as the face becomes darker. Can also be obtained.
以上、本発明をその好適な実施形態に基づいて詳述してきたが、本発明はこれら特定の実施形態に限られるものではなく、この発明の要旨を逸脱しない範囲の様々な形態も本発明に含まれる。上述の実施形態の一部を適宜組み合わせてもよい。 Although the present invention has been described in detail based on preferred embodiments thereof, the present invention is not limited to these specific embodiments, and various forms within the scope of the present invention are also included in the present invention. included. A part of the above-described embodiments may be appropriately combined.
また、本発明は、以下の処理を実行することによっても実現される。即ち、上述した実施形態の機能を実現するソフトウェア(プログラム)を、ネットワーク又は各種記憶媒体を介してシステム或いは装置に供給し、そのシステム或いは装置のコンピュータ(またはCPUやMPU等)がプログラムを読み出して実行する処理である。 The present invention can also be realized by executing the following processing. That is, software (program) that realizes the functions of the above-described embodiments is supplied to a system or apparatus via a network or various storage media, and a computer (or CPU, MPU, or the like) of the system or apparatus reads the program. It is a process to be executed.
Claims (9)
前記顔検出手段で検出される顔に仮想光源によるライティングを施すライティング手段と、
前記第1の画像の顔に対する前記仮想光源の相対位置と同じ相対位置で前記第2の画像の顔に適用するように、前記ライティング手段において前記第1の画像に適用した仮想光源パラメータを前記第2の画像に適用する制御手段
とを有することを特徴とする画像処理装置。 Face detection means for detecting a face from the first image and the second image;
Writing means for performing lighting with a virtual light source on the face detected by the face detection means;
The virtual light source parameter applied to the first image in the lighting means is applied to the face of the second image at the same relative position as the relative position of the virtual light source with respect to the face of the first image. And an image processing apparatus having a control unit applied to the second image.
前記第1の顔検出ステップで検出された顔に仮想光源によるライティングを施す第1のライティングステップと、
第2の画像から顔を検出する第2の顔検出ステップと、
前記第2の画像から検出された顔に、前記第1の画像の顔に対する前記仮想光源の相対位置と同じ相対位置でライティングを施す第2のライティングステップ
とを有することを特徴とする画像処理方法。 A first face detection step of detecting a face from the first image;
A first lighting step of performing lighting with a virtual light source on the face detected in the first face detecting step;
A second face detection step of detecting a face from the second image;
An image processing method comprising: a second lighting step of performing lighting on the face detected from the second image at the same relative position as the relative position of the virtual light source with respect to the face of the first image. .
前記第1の顔検出ステップで検出された顔に仮想光源によるライティングを施す第1のライティングステップと、
前記第1のライティングステップで前記第1の顔検出ステップで検出された顔に適用される前記仮想光源の、前記第1の顔検出ステップで検出された顔に対する相対位置をコピーするコピーステップと、
第2の画像から顔を検出する第2の顔検出ステップと、
前記第2の画像から検出された顔に対して前記コピーステップでコピーされた前記相対位置に仮想光源を置き、前記第2の画像から検出された顔にライティングを施す第2のライティングステップ
とを有することを特徴とする画像処理方法。 A first face detection step of detecting a face from the first image;
A first lighting step of performing lighting with a virtual light source on the face detected in the first face detecting step;
A copy step of copying a relative position of the virtual light source applied to the face detected in the first face detection step in the first lighting step with respect to the face detected in the first face detection step;
A second face detection step of detecting a face from the second image;
A second lighting step of placing a virtual light source at the relative position copied in the copy step with respect to the face detected from the second image, and lighting the face detected from the second image; An image processing method comprising:
前記顔検出手段に第1の画像から顔を検出させる第1の顔検出ステップと、
前記第1の顔検出ステップで検出された顔を前記対象として前記ライティング手段に供給し、前記ライティング手段に仮想光源によるライティングを施させる第1のライティングステップと、
前記第1のライティングステップにおける前記仮想光源の仮想光源パラメータの変更を前記操作手段から受け付けるステップと、
前記操作手段によるコピー操作に従い、前記第1のライティングステップで前記第1の顔検出ステップで検出された顔に適用される前記仮想光源の、前記第1の顔検出ステップで検出された顔に対する相対位置をコピーするコピーステップと、
前記顔検出手段に第2の画像から顔を検出させる第2の顔検出ステップと、
前記第2の顔検出ステップで検出される顔を前記ライティング手段に供給するステップと、
前記ライティング手段に対し、前記操作手段によるペースト操作に従い、前記第2の画像から検出された顔に対して前記コピーステップでコピーされた前記相対位置に仮想光源を配置する配置ステップと、
前記ライティング手段に、前記配置ステップで配置された仮想光源によるライティングを第2の画像から検出された顔にライティングを施させる第2のライティングステップ
とを有することを特徴とする画像処理装置の制御プログラム。 In a control program executed by the control means in an image processing apparatus having a face detection means for detecting a face from an image, a lighting means for lighting a target based on a virtual light source, an operation means, and a control means There,
A first face detection step for causing the face detection means to detect a face from a first image;
Supplying the face detected in the first face detection step as the target to the writing means, and causing the writing means to perform lighting by a virtual light source;
Receiving a change in the virtual light source parameter of the virtual light source in the first lighting step from the operation means;
Relative to the face detected in the first face detection step of the virtual light source applied to the face detected in the first face detection step in the first writing step according to the copy operation by the operation means A copy step to copy the position;
A second face detection step of causing the face detection means to detect a face from a second image;
Supplying the lighting means with the face detected in the second face detection step;
An arrangement step of arranging a virtual light source at the relative position copied in the copy step with respect to the face detected from the second image in accordance with a paste operation by the operation unit with respect to the writing unit;
A control program for an image processing apparatus, comprising: a second writing step for causing the lighting unit to perform lighting on a face detected from a second image by lighting using the virtual light source arranged in the arranging step. .
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2016139141A JP2018010498A (en) | 2016-07-14 | 2016-07-14 | Image processing device and method and control program |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2016139141A JP2018010498A (en) | 2016-07-14 | 2016-07-14 | Image processing device and method and control program |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| JP2018010498A true JP2018010498A (en) | 2018-01-18 |
Family
ID=60994305
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP2016139141A Pending JP2018010498A (en) | 2016-07-14 | 2016-07-14 | Image processing device and method and control program |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JP2018010498A (en) |
Cited By (3)
| 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 |
| JP2021069004A (en) * | 2019-10-23 | 2021-04-30 | キヤノン株式会社 | Image processing device, image processing method, and program |
| JP7565762B2 (en) | 2020-11-16 | 2024-10-11 | キヤノン株式会社 | Information processing device, imaging device, control method and program |
-
2016
- 2016-07-14 JP JP2016139141A patent/JP2018010498A/en active Pending
Cited By (4)
| 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 |
| JP2021069004A (en) * | 2019-10-23 | 2021-04-30 | キヤノン株式会社 | Image processing device, image processing method, and program |
| JP7565762B2 (en) | 2020-11-16 | 2024-10-11 | キヤノン株式会社 | Information processing device, imaging device, control method and program |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| KR102338576B1 (en) | Electronic device which stores depth information associating with image in accordance with Property of depth information acquired using image and the controlling method thereof | |
| US8774562B2 (en) | Systems, methods, and media for creating multiple layers from an image | |
| JP6576083B2 (en) | Image processing apparatus, image processing method, and program | |
| JP6027581B2 (en) | Image composition device, image composition method, control program for image composition device, and recording medium storing the program | |
| JP2017083550A (en) | Information processing apparatus, image projection system, and program | |
| JP2018163648A (en) | Image processing apparatus, image processing method, and program | |
| JP2016086246A (en) | Image processing apparatus and method, and imaging device | |
| JP6028527B2 (en) | Display processing apparatus, display processing method, and program | |
| JP2018010498A (en) | Image processing device and method and control program | |
| JP2017138927A (en) | Image processing device, imaging apparatus, control method and program thereof | |
| CN108282622B (en) | Photo shooting method and device | |
| JP7462464B2 (en) | Image processing device and method, program, and storage medium | |
| JP6896811B2 (en) | Image processing equipment, image processing methods, and programs | |
| JP2020024581A (en) | Image processing apparatus, image processing method, and program | |
| JP2012195760A (en) | Shooting setting adjustment system, information processing unit, and control method and control program therefor | |
| JP2008067093A (en) | Camera system, image processing apparatus, and image processing program | |
| JP6100086B2 (en) | Image processing apparatus and image processing method | |
| JP6995554B2 (en) | Imaging device and imaging method | |
| JP2015045958A (en) | Display processing unit, display processing method, and program | |
| JP2008140107A (en) | Image processing apparatus, image processing method, control program, and recording medium | |
| JP2021069004A (en) | Image processing device, image processing method, and program | |
| JP7654390B2 (en) | Image processing device and control method thereof, imaging device, and program | |
| JP7565762B2 (en) | Information processing device, imaging device, control method and program | |
| WO2012074505A1 (en) | System and method for creating a three-dimensional image file | |
| JP7169841B2 (en) | IMAGE PROCESSING DEVICE, IMAGING DEVICE, IMAGE PROCESSING METHOD, AND PROGRAM |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| RD01 | Notification of change of attorney |
Free format text: JAPANESE INTERMEDIATE CODE: A7421 Effective date: 20180227 |