The present invention relates to an image processing device, an imaging apparatus, an image processing method, and a recording medium.
There is image processing called a rewriting process (shadowing process) of generating a shaded image with shadows added through image processing. In the rewriting process, for example, a virtual light source is set, a shadow region produced by the virtual light source is calculated by using a direction of the set virtual light source and shape information of a subject, and a shaded image is generated by adding a shadow to the calculated region. Japanese Patent Laid-Open No. 2020-10168 discloses a technique of setting a position of a virtual light source on the basis of a positional relationship between a person and a shield such that an unnecessary shadow is not added on a face of the person through a rewriting process in a case where there is a shield between the set virtual light source and the face of the person.
In Japanese Patent Laid-Open No. 2020-10168, it is possible to prevent a person's face from being shaded by a shield, but there is concern that an appropriate shadow desired by a user may not be able to be produced according to the technique. In order to produce an appropriate shadow in the rewriting process, it is required to automatically determine an appropriate direction of the virtual light source.
The present invention provides an imaging apparatus capable of setting a direction of the virtual light source in which a main subject can produce an appropriate shadow on another subject.
According to the present invention, there is provided an image processing device including at least one processor and/or circuit configured to function as a shape acquisition unit configured to acquire shape information of a subject; a first region detection unit configured to detect a first region generating a shadow of the subject; a second region detection unit configured to detect a second region onto which the shadow is projected; a direction setting unit configured to set a direction of a virtual light source in which the first region projects the shadow onto the second region on the basis of the shape information, the first region, and the second region; and an image generation unit configured to generate an image with the shadow on the basis of the shape information and the set direction of the virtual light source.
Further features of the present invention will become apparent from the following description of exemplary embodiments with reference to the attached drawings.
The lens device 111 includes an imaging optical system. The imaging optical system includes a plurality of lenses 119 such as a zoom lens and a focus lens, a diaphragm, and a shutter, and forms an optical image of a subject on an imaging element. The imaging unit 112 images a subject. The subject is a target on which the image processing device 100 performs image processing. The imaging unit 112 is an imaging element having a photoelectric conversion element such as a CMOS or a CCD, and outputs an output signal (analog signal) corresponding to an optical image. In the present embodiment, an example in which the lens device 111 is detachably connected to the imaging apparatus 110 will be described, but the imaging apparatus 110 and the lens device 111 may be integrated.
The control unit 101 controls an operation of the entire imaging apparatus 110 including the image processing device 100. The control unit 101 includes, for example, a central processing unit (CPU). The CPU executes a program stored in a non-volatile memory such as a read only memory (ROM), and thus the functions of the imaging apparatus 110 or various processes that will be described later are realized.
An image (hereinafter, also referred to as image information) output by the imaging unit 112 is supplied to the image acquisition unit 104. The image acquisition unit 104 acquires an image captured by the imaging unit 112 or an image captured by an apparatus other than the imaging apparatus 110, and stores the image in the memory 102. The memory 102 stores an image. The memory 102 reads information necessary for processing in each module and stores a processing result in each module. The parameter setting unit 103 receives a setting of each parameter related to imaging, image processing, and the like from a user, and stores each piece of parameter information input by the user in the memory 102. The parameter setting unit 103 also receives designation of an approximate direction of the virtual light source designated by the user, which will be described later, from the user.
The shape information acquisition unit 105 is a shape acquisition unit configured to calculate and acquire shape information from an image captured by the imaging unit 112. The shape information acquisition unit 105 acquires the calculated shape information or shape information input to the image processing device 100 by the user. The shape information acquisition unit 105 stores the acquired shape information in the memory 102.
The first region detection unit 106 detects a first region from at least one of image information, shape information, and second region information. In the present embodiment, the first region is a subject that produces a shadow through the rewriting process, that is, a region that produces a shadow by the rewriting process. The first region detection unit 106 stores information regarding the detected first region in the memory 102. The second region detection unit 107 detects a second region from at least one of the image information, the shape information, and the first region information. In the present embodiment, the second region is a region where a shadow of the first region is projected (added) through the rewriting process. The second region detection unit 107 stores information regarding the detected second region in the memory 102.
The virtual light source direction setting unit 108 sets a direction of the virtual light source when the rewriting process is performed on the basis of the first region, the second region, and the shape information. The virtual light source direction setting unit 108 stores information regarding the set direction of the virtual light source in the memory 102. The image generation unit 109 generates a shaded image in which a shadow calculated on the basis of the direction of the virtual light source and the shape information is added to an image. The image generation unit 109 stores the generated shaded image in the memory 102. As described above, in the present embodiment, a region of a subject (first region) where a virtual light source produces a shadow is calculated, and a shaded image is generated by adding a shadow to a calculated region (second region) such as a floor surface.
(a) A distance from the imaging apparatus to a focus position of the subject
(b) A conversion coefficient determined by a size of an opening angle of the center of gravity of the light fluxes passing through the pair of distance measurement pupils
(c) A distance from an image side principal point of the lens of the imaging apparatus to the sensor surface
(d) A focal length of the imaging apparatus
The parameter setting unit 103 may acquire these parameters from the memory 102 or from each module of the imaging apparatus 110.
In step S302, the image acquisition unit 104 acquires an image. The image acquisition unit 104 may acquire an image captured by the imaging apparatus 110 from the imaging unit 112, or may acquire a stored image captured in advance from the memory 102. In step S303, the shape information acquisition unit 105 acquires shape information. Here, the shape information is information regarding a shape of the subject. Specifically, the shape information in the present embodiment is information including position information of the shape indicating a position of the shape of the subject as a point group, normal information indicating an inclination of a surface of a local region in the point group, and reliability information of the position information and the normal information. The position information of the shape may be acquired from distance information from the imaging apparatus 110 to the subject. The inclination of the surface of the local region is information such as an amount of displacement or the surface normal in the shape of the local region.
Details of the shape information acquisition process will be described with reference to
First, in step S401, the shape information acquisition unit 105 calculates distance information from the imaging apparatus 110 to the subject. For example, the shape information acquisition unit 105 calculates an image deviation amount from the parallax between a plurality of viewpoint signals through correlation calculation or the like and converts the image deviation amount into a defocus amount. The distance information can be calculated on the basis of the defocus amount. Details of the distance information calculation process will be described with reference to
In step S502, the shape information acquisition unit 105 sets a minute block for each pair of pieces of image data. In the present embodiment, minute blocks having the same size are set for the A image and the B image generated in step S501. The minute blocks are generally synonymous with windows that are set when template matching is performed. Setting of the minute block will be described with reference to
In step S503, the shape information acquisition unit 105 calculates an image deviation amount. The shape information acquisition unit 105 performs a correlation calculation process in the minute block set in step S502, and calculates an image deviation amount at each point. In the correlation calculation, a pair of pixel data in the minute block are generalized and expressed as E and F, respectively. For example, a data sequence F corresponding to the B image is deviated relative to a data sequence E corresponding to the A image, and a correlation amount C(k) at a deviation amount k between the two data sequences is calculated according to the following Equation (1).
C(k)=Σ|E(n)−F(n+k)| (1)
In Equation (1), C(k) is calculated for the number n of the data sequence. The deviation amount k is an integer, and is a relative deviation amount in units of data intervals of image data. The deviation amount k is synonymous with a parallax amount in a stereo matching method.
An example of a calculation result of Equation (1) will be described with reference to
The image deviation amount x at which the continuous correlation amount C(x) is minimized is calculated, for example, by using a three-point interpolation method according to the following Equations (2) to (5).
X=kj+D/SLOP (2)
C(x)=C(kj)−|D| (3)
D={C(kj−1)−C(kj+1)}/2 (4)
SLOP=MAX{C(kj+1)−C(kj),C(kj−1)−C(kj)} (5)
Here, kj is k at which the discrete correlation amount C(k) is minimized. The deviation amount x obtained by using Equation (2) is set as an image deviation amount in the pair of pieces of image data. The unit of the image deviation amount x is pixel.
In step S504, the shape information acquisition unit 105 converts the image deviation amount into a defocus amount. A magnitude of the defocus amount represents a distance from the image plane 120 of the subject image to the sensor surface 121. Specifically, the shape information acquisition unit 105 may obtain a defocus amount DEF by the following Equation (6) on the basis of the image deviation amount x obtained by using Equation (2).
DEF=KX·x (6)
In Equation (6), KX is a conversion coefficient determined by a size of an opening angle of the center of gravity of light fluxes passing through the pair of distance measurement pupils. As described above, a defocus amount at each pixel position can be calculated by repeating the processes in steps S502 to S504 while deviating a pixel position of interest by one pixel.
In step S505, the shape information acquisition unit 105 calculates a distance z from the sensor surface 121 of the imaging apparatus 110 to the subject on the basis of the defocus amount calculated in step S504. The distance z may be calculated by using the following Equations (7) and (8).
dist=1/(1/(dist_d+DEF)−1/f) (7)
z=length−dist (8)
dist is a distance from the focus position to the subject, dist_d is a distance from the image side principal point of the lens of the imaging unit 112 of the imaging apparatus 110 to the sensor surface 121, f is a focal length, and length is a distance from the sensor surface 121 of the imaging apparatus 110 to the focus position. The focus position corresponds to an in-focus position. In the present embodiment, the example in which the shape information acquisition unit 105 calculates the distance z at each point on the basis of the image deviation amount x by using Equations (6) to (8) has been described, but the present invention is not limited to this. The distance z at each point may be calculated according to other calculation methods.
The distance length from the sensor surface 121 of the imaging apparatus 110 to the focus position can be measured by, for example, a laser distance measurement unit (not shown). A relationship between a lens position and a focus position at the time of imaging is provided as a data table, and thus it is possible to estimate a distance to the focus position corresponding to the lens position at the time of imaging. By using the data table indicating the relationship between the lens position and the focus position, it is possible to reduce the time and effort required to measure a distance from the sensor surface 121 of the imaging apparatus 110 to the focus position.
As described above, the distance z from the sensor surface 121 of the imaging apparatus 110 to a subject can be calculated from a defocus amount or an image deviation amount obtained from a plurality of images. In the above-described way, since information can be calculated according to a method of generating a pair of pieces of image data from one image, the imaging apparatus does not need to be a binocular camera and may be a monocular camera, and thus a configuration of the imaging apparatus can be simplified. The calibration process when installing a plurality of cameras can be simplified or eliminated. Although an example in which the image processing device 100 calculates the distance z from image information captured by the imaging apparatus 110 in step S501 has been described, the present invention is not limited to this. For example, the distance z may also be calculated by a stereo camera. The distance z may also be calculated by an external device of the imaging apparatus 110, and the distance z calculated by the external device may be acquired by the image processing device 100. Instead of calculating distance information to a subject on the basis of an image, the distance information may be acquired by a device such as LiDAR. The distance information between the imaging apparatus 110 and the subject calculated in S401 has been described by taking a distance from the sensor surface 121 as an example, but the present invention is not limited to this, and the distance information may be a distance from any position such as the tip of the lens of the imaging apparatus 110.
In step S403, the shape information acquisition unit 105 acquires reliability information. The reliability may be calculated by determining an evaluation value of the reliability. The reliability may be obtained for each of the distance information and the normal information.
The reliability of the distance information will be described. The reliability of the distance information is information for determining whether or not the acquired distance information can be used. If the reliability is low, the accuracy of the calculated distance information is also low. By calculating and quantifying the reliability as an evaluation value and comparing the evaluation value with a threshold value, it is possible to evaluate whether the reliability is high or low. The evaluation value of the reliability may be calculated from, for example, the luminance of an image, the contrast of an image, a defocus amount at the time of acquiring the distance information, and the like. The reliability obtained by using the evaluation value calculated from the luminance of the image, the contrast of the image, the defocus amount at the time of acquiring the distance information, and the like is adaptable to a method of generating a pair of pieces of image data from one image and calculating a defocus amount to acquire distance information. On the other hand, if the distance information is acquired by a device such as LiDAR and an amplitude of a reflected and returned laser signal is lower than a defined value, a method such as reducing an evaluation value of the reliability of the distance information may be considered. As described above, it is possible to change evaluation items for calculating an evaluation value of the reliability of the distance information depending on a method of acquiring the distance information.
First, an evaluation value of the luminance of an image will be described. In the present embodiment, if the distance information is acquired, an image deviation amount is calculated from a pair of images, but the calculation accuracy of the image deviation amount is reduced in a region where an image signal indicates that the region is too bright or too dark. Assuming that a median value of the luminance when expressing the luminance of an image is Lm and the luminance of a pixel to be evaluated is Lp, an evaluation value L of the luminance can be obtained by using the following Equation (9).
L=−|Lm−Lp| (9)
By setting the evaluation value L as in Equation (9), it is possible to reduce the evaluation value L of the luminance as the luminance of a pixel deviates from the median value of the luminance when expressing the luminance. The influence of the luminance of an image on the reliability of the distance information can be taken into consideration according to the evaluation value L of the luminance.
Next, an evaluation value of the contrast of an image will be described. In the present embodiment, if the distance information is acquired, an image deviation amount is calculated from a pair of images, but in a region where the contrast of an image signal is low, the accuracy of obtaining the minimum value from the correlation amount C(k) is reduced. An evaluation value of the contrast of the image can be calculated by calculating a variance of the luminance from the luminance of each pixel and its surroundings and setting the variance as an evaluation value B of the contrast. The influence of the contrast of an image on the reliability of the distance information can be taken into consideration according to the evaluation value B of the contrast.
Finally, an evaluation value of the defocus amount will be described. The distance information may be calculated from a defocus amount, but blurring of an image increases as an absolute value of the defocus amount increases, and thus the distance measurement accuracy decreases. That is, as an absolute value of the defocus amount increases, an evaluation value of the reliability decreases. Assuming that an evaluation value of the defocus amount is D for the defocus amount DEF calculated by using Equation (6), the evaluation value D of the defocus amount can be obtained by using Equation (10).
D=|DEF| (10)
The influence of the defocus amount at the time of acquiring the distance information on the reliability of the distance information can be taken into consideration according to the evaluation value D of the defocus amount.
Assuming that an evaluation value of the reliability of the distance information is M, the evaluation value M of the reliability can be obtained by using the following Equation (11) on the basis of the evaluation value of the luminance of the image, the evaluation value of the contrast of the image, and the evaluation value of the defocus amount at the time of acquiring the distance information.
M=L+B+D (11)
The shape information acquisition unit 105 obtains the evaluation value M of the reliability of the distance information for each pixel. The shape information acquisition unit 105 determines whether the reliability of the distance information for each pixel is high or low by comparing the evaluation value M of each pixel with any threshold value. If the evaluation value M of the reliability of the distance information is less than the threshold value, the shape information acquisition unit 105 determines that the reliability of the distance information is low, and if the evaluation value M of the reliability of the distance information is equal to or more than the threshold value, determines that the reliability of the distance information is high.
Next, the reliability of normal information will be described. The reliability of the normal information is information for determining whether the acquired normal information can be used. As a method of calculating the reliability of the normal information, for example, there is a method of using an image captured when calculating the normal information according to an illuminance difference stereo method. The illuminance difference stereo method is a method in which a plurality of images of a scene in which a subject is irradiated with light are captured while changing a light source direction, and the surface normal of a subject surface is calculated from a ratio of the brightness of the subject imaged in each light source direction. When imaging is performed a plurality of times while changing a light source direction, it is necessary that a positional relationship between a subject and a camera is fixed and a light source direction at the time of light emission is known. Thus, if the subject or the camera moves when imaging is performed a plurality of times, or if strong light comes in from the outside, this event is detected and processed such that the event is not used for normal calculation. In this case, a ratio of the number of captured images to the number of images actually used for calculation is calculated, and if the number of images used is small, the reliability is made to be low. Assuming that the number of captured images is Gn, the number of images actually used for calculating normal information is Rn, and an evaluation value regarding the number of used images is Cn, the evaluation value Cn of reliability can be obtained by using Equation (12).
Cn=Rn/Gn (12)
If the number of images in which the luminance of the pixel of interest is saturated is equal to or more than a threshold value, the reliability of the pixel of interest is reduced. Assuming that the number of images in which the luminance of the pixel of interest is saturated is Ln and an evaluation value regarding the number of saturated images is H, the evaluation value H of the reliability can be obtained from Equation (13).
H=Ln/Gn (13)
Assuming that an evaluation value of the reliability of the normal information is N, the evaluation value N of the reliability can be obtained from Equation (14).
N=Cn×H (14)
The shape information acquisition unit 105 obtains the evaluation value N of the reliability of the normal information of each pixel. The shape information acquisition unit 105 obtains the reliability of the normal information at each pixel by setting any threshold value and comparing the threshold value with the evaluation value N of the reliability of the normal information. The shape information acquisition unit 105 determines that the reliability of the normal information is low if the evaluation value N of the reliability of the normal information is less than the threshold value, and determines that the reliability of the normal information is high if the evaluation value N of the reliability of the normal information is equal to or more than the threshold value.
An evaluation value R for evaluating both the reliability of the distance information and the reliability of the normal information can be obtained from Equation (15).
R=M×N (15)
The shape information acquisition unit 105 can obtain the reliability at each pixel by setting any threshold value for the evaluation value R and comparing the threshold value with the evaluation value R. The shape information acquisition unit 105 determines that the reliability is low if the evaluation value R is less than the threshold value, and determines that the reliability is high if the evaluation value R is equal to or more than the threshold value.
By restricting a range of image processing in the present embodiment on the basis of the reliability calculated as described above, it is possible to obtain a shaded image with more accurate shape information. It is possible to increase the region detection accuracy by using the respective reliabilities for the distance information and the normal information used in the region detection described in step S304 that will be described later. It is also possible to interpolate the distance information and the normal information by performing a hole-filling interpolation process on the distance information and the normal information having a low reliability with the distance information and the normal information having a high reliability in the surroundings.
Region Detection
First, the detection of the first region that produces a shadow will be described. Here, two detection methods will be described for the detection of the first region performed by the first region detection unit 106. The first method of detecting the first region is a method in which a region near the center of the image height within an angle of view of an acquired image is set as the first region. By setting the region near the center of the image height as the first region, a user can set the first region such that a subject placed at the center of the image is a region that produces a shadow. Consequently, it is possible to set the first region without performing particularly complicated processing.
The second method of detecting the first region is a method in which a region near a focus (in-focus position) is set as the first region. By setting the region near the focus position as the first region, it is possible to set the first region such that a subject subjected to being in focus by a user is a region that produces a shadow. Three methods will be described as an example of a method of determining that the region is near the focus position. The first method is a method of referring to the defocus amount DEF calculated by using Equation (6). A threshold value is set for the defocus amount DEF, and a region in which the defocus amount DEF is equal to or less than the threshold value is set as the region near the focus position. The second method is a contrast-based method. Since the region near the focus position generally has less blurring of an image, the contrast is stronger than other regions. Thus, the local contrast in the image is evaluated and compared with a threshold value, and a region in which the contrast is more than the threshold value is set as the region near the focus position. The third method is a method of using position information of an AF frame at the time of imaging. A region of the AF frame at the time of imaging is set as the region near the focus position. In the second method or the third method, the region near the focus position can be detected without calculating the defocus amount DEF.
As the method of detecting the first region, the above two methods may be performed independently, or detection may be performed by combining the two methods. For example, by combining the first method of detecting the first region and the second method of detecting the first region, a region near the center of the image height and a region having high contrast can be detected as the first region. Therefore, the detection accuracy of the first region can be increased. A subject region may be detected as the first region by using a method other than the three detection methods described.
Next, detection of the second region onto which a shadow is projected will be described. Here, two detection methods will be described for the detection of the second region performed by the second region detection unit 107. The first method of detecting the second region is a method of detecting the second region from acquired normal information. Generally, a region onto which a shadow is desired to be projected is a floor surface or a ground. Therefore, a floor surface is detected by using the surface normal calculated from the normal information and set as the second region. Specifically, the second region detection unit 107 takes a histogram of a direction of the surface normal to the entire angle of view of the image on the basis of the normal information acquired in step S303, and sets a region of the surface normal in which a frequency of the histogram is highest as the second region. Consequently, the floor surface can be detected by using the surface normal, especially in a scene where the floor surface occupies a large part in the angle of view, and thus the floor surface can be detected as the second region.
The second method of detecting the second region is a method of detecting the second region from acquired distance information. Generally, a region onto which a shadow is desired to be projected is a floor surface or a ground. Shape information calculated from the distance information changes continuously in a certain direction on the floor surface. Thus, the second region detection unit 107 detects, as the second region, a region in which the shape information calculated from the distance information acquired in step S303 continuously changes in a certain direction within a certain range. As described above, the two detection methods have been described for a method of detecting the second region. As the method of detecting the second region, the above two methods may be performed independently, or detection may be performed by combining the two methods. A floor surface may be detected as the second region by using a method other than the two detection methods described.
By detecting the first region and the second region as respective exclusive regions, it is possible to increase the detection accuracy of the first region and the second region. For example, a candidate of the first region can be a region other than the second region. Consequently, if the second region is detected, other regions become candidate regions of the first region, and candidates of the first region are restricted, and thus computation cost for calculating the first region can be reduced.
It is possible to detect the first region and the second region by performing image recognition for both of the regions. If, for example, a floor surface is detected as a result of image recognition, that region is set as the second region. A region of a subject recognized in a region other than the floor surface is set as the first region. Since the region can be detected on the basis of the recognized subject through the image recognition, it is possible to detect a region with higher accuracy than detection from a region near the center of the image height or a region near the focus. The region detection using image recognition may be performed in combination with the region detection using the first region detection method and the second region detection method described above. For example, by calculating a histogram of the surface normal of a region recognized as a floor and redetecting a region of the surface normal with a high frequency of the histogram as the floor, the floor that could not be detected due to image recognition failure can be detected.
If the distance information or the normal information acquired in step S303 is used in detection of the first region and the second region of step S304, information to be used may be restricted on the basis of such reliability information. For example, the reliability of the distance information is compared with a threshold value, and the distance information of which the reliability is less than the threshold value is not used for region detection. It is possible to increase the region detection accuracy by using the respective reliabilities for the distance information and the normal information used in the region detection.
In step S305, the virtual light source direction setting unit 108 determines a direction of the virtual light source. A virtual light source is a surface light source, and parallel light is applied to the subject from the determined direction of the virtual light source. A position of the virtual light source in the present embodiment is obtained with a declination as a direction in a case where a radius is infinite in a polar coordinate system. Therefore, in the present embodiment, a direction of the virtual light source is determined instead of a position of the virtual light source. By automatically determining a direction of the virtual light source, a main subject within an angle of view produces appropriate shadows on other subjects without a user adjusting an amount of distance between the virtual light source and the subject, an amount of light of the virtual light source, and a light beam direction.
A method of determining a direction of the virtual light source will be described with reference to
In step S801, the virtual light source direction setting unit 108 calculates a representative value of the first region detected in step S304. The virtual light source direction setting unit 108 calculates a representative value of the first region by calculating, for example, an average value of x, y, z coordinate values of the first region. If a focus position is included in the first region, the virtual light source direction setting unit 108 may use x, y, z coordinate values of the focus position as representative values of the first region. The virtual light source direction setting unit 108 may use a center of gravity point of the first region as a representative value of the first region.
In step S802, the virtual light source direction setting unit 108 calculates a straight line connecting a point having the smallest value in the z direction in the second region to the representative value of the first region calculated in step S801. For example, in
In step S803, the virtual light source direction setting unit 108 obtains a straight line connecting a point having the largest value in the z direction in the second region to the representative value of the first region. In
In step S804, the virtual light source direction setting unit 108 determines a direction restricted by the straight line 905 calculated in step S802 and the straight line 907 calculated in step S803 as a direction of the virtual light source. In
Through step S801 to step S804, the direction of the virtual light source in the quadratic yz space defined by the y direction and the z direction when viewed from the x direction is restricted. Similarly, it is possible to restrict the direction of the virtual light source in the xz space when viewed from the y direction. The virtual light source direction setting unit 108 sets the virtual light source within a range of the restricted direction of the virtual light source, and thus sets the direction of the virtual light source in which the first region is guaranteed to add a shadow to the second region. As described above, by automatically setting the direction of the virtual light source within the range of the restricted direction of the virtual light source, it is possible to easily obtain an image in which the first region projects a shadow onto the second region.
Next, an example of determining a direction of the virtual light source by using a defocus amount (effective distance measurement range) will be described. In a process of determining a direction of the virtual light source, it is also possible to determine a direction of the virtual light source by using an effective distance measurement range corresponding to the defocus amount calculated in step S504.
As an absolute value of the defocus amount calculated in step S504 increases, blurring of the image increases and the distance measurement accuracy decreases. Therefore, by setting a threshold value for the defocus amount, a direction of the virtual light source is restricted such that a shadow is not projected onto the second region having the defocus amount equal to or more than the threshold value. A straight line 911 and a straight line 912 are straight lines when a surface having a defocus amount separated by a threshold value from the straight line 910 is viewed from the x direction. The virtual light source direction setting unit 108 obtains each straight line connecting each point at which each straight line intersects the second region to the representative value 903 of the shape of the first region.
Specifically, a point 913 at which the straight line 911 close to the imaging apparatus 110 intersects the second region is the point 913 closest to the imaging apparatus 110 in the effective distance measurement range in the second region. The virtual light source direction setting unit 108 obtains a straight line 914 by connecting the representative value 903 of the shape of the first region to the point 913 of the second region. A point 915 at which the straight line 912 far from the imaging apparatus 110 intersects the second region is the point 915 farthest from the imaging apparatus 110 in the effective distance measurement range in the second region. The virtual light source direction setting unit 108 obtains a straight line 916 by connecting the representative value 903 of the shape of the first region to the point 915 of the second region. By performing the same process as in step S804 on the basis of the straight line 914 and the straight line 916, the virtual light source direction setting unit 108 can set a direction of the virtual light source 917 restricted by the straight line 914 and the straight line 916. The virtual light source direction setting unit 108 sets a virtual light source within a range of the restricted direction of the virtual light source, and thus sets the direction of the virtual light source in which the first region is guaranteed to add a shadow to the second region. As described above, by restricting a range of the direction of the virtual light source on the basis of the defocus amount (effective distance measurement range), it is possible to increase the accuracy of the rewriting process.
In the virtual light source direction setting unit 108, in the process of determining a direction of the virtual light source, a range of the direction of the virtual light source may be restricted such that a shadow is not added to the second region having low reliability on the basis of the reliability information acquired in step S403. By excluding the second region having a reliability less than a threshold value from a region to which a shadow is added, it is possible to obtain a shaded image with higher accuracy. The reliability information used in the process of determining a direction of the virtual light source may be an evaluation value M of the reliability of the distance information or an evaluation value N of the reliability of the normal information, or may be an evaluation value R for evaluating both the reliability of the distance information and the reliability of the normal information.
Next, a process of determining a direction of the virtual light source in a case where a user designates an approximate direction of the virtual light source will be described. In the present embodiment, it is possible to determine a direction of the virtual light source on the basis of the approximate direction of the virtual light source designated by the user. The approximate direction of the virtual light source that can be designated by the user shows, for example, whether light from a virtual light source is “forward light/backlight/top light” with respect to a subject, or is a direction of the virtual light source as viewed from the imaging apparatus 110 is “right/center/left” of a subject.
A method of determining a direction of the virtual light source based on the approximate direction of the virtual light source designated by the user will be described with reference to
In a case where there is a virtual light source in an approximate direction such as “backlight, right” designated by the user, a shadow of the subject due to the virtual light source is added to the front left side of the subject. Thus, the virtual light source direction setting unit 108 selects a point 918 on the front left side in the second region 902 within the angle of view for “backlight, right” designated by the user as the approximate direction of the virtual light source. The virtual light source direction setting unit 108 obtains a straight line 919 connecting the selected point 918 to the representative value 903 of the first region. The virtual light source direction setting unit 108 determines a direction of the virtual light source 920 restricted by the straight line 919 and the straight line 921. As described above, by restricting a direction of the virtual light source with the straight line 919, it is possible to determine a direction of the virtual light source in which the first region can project a shadow onto the second region in the approximate direction of the virtual light source designated by the user.
An approximate direction of the virtual light source designated by the user may be set to “forward light, center” as well as “backlight, right”, and a direction of the virtual light source may be determined in the same manner as in the case of “backlight, right”. As described above, by determining a direction of the virtual light source on the basis of an approximate direction of the virtual light source designated by the user, it is possible to generate a shaded image from the direction desired by the user.
A case where the approximate direction of the virtual light source designated by the user is top light will be described with reference to
If a shaded image is generated, it is also possible to generate a shaded image with a plurality of virtual light sources by setting directions of a plurality of virtual light sources. A method of generating a shaded image with a plurality of virtual light sources will be described with reference to
A shadow 1204 of the subject 1103 generated by each virtual light source may be generated by using the ray tracing method or the shadow map method in the same manner as in the case of a single virtual light source. In the same manner as in the case of a single virtual light source, by using the normal information of the first region and a direction of each virtual light source, a shadow may be added to the subject 1103 that is the first region by each virtual light source. By adding a shadow as described above, it is possible to generate a shaded image even in a case of a plurality of virtual light sources.
As described above, according to the present embodiment, it is possible to set a direction of a virtual light source in which a main subject generates an appropriate shadow on other subjects by restricting the direction of the virtual light source that can add a shadow of the first region to the second region.
Embodiment(s) of the present invention can also be realized by a computer of a system or apparatus that reads out and executes computer executable instructions (e.g., one or more programs) recorded on a storage medium (which may also be referred to more fully as a ‘non-transitory computer-readable storage medium’) to perform the functions of one or more of the above-described embodiment(s) and/or that includes one or more circuits (e.g., application specific integrated circuit (ASIC)) for performing the functions of one or more of the above-described embodiment(s), and by a method performed by the computer of the system or apparatus by, for example, reading out and executing the computer executable instructions from the storage medium to perform the functions of one or more of the above-described embodiment(s) and/or controlling the one or more circuits to perform the functions of one or more of the above-described embodiment(s). The computer may comprise one or more processors (e.g., central processing unit (CPU), micro processing unit (MPU)) and may include a network of separate computers or separate processors to read out and execute the computer executable instructions. The computer executable instructions may be provided to the computer, for example, from a network or the storage medium. The storage medium may include, for example, one or more of a hard disk, a random-access memory (RAM), a read only memory (ROM), a storage of distributed computing systems, an optical disk (such as a compact disc (CD), digital versatile disc (DVD), or Blu-ray Disc (BD)™), a flash memory device, a memory card, and the like.
While the present invention has been described with reference to exemplary embodiments, it is to be understood that the invention is not limited to the disclosed exemplary embodiments. The scope of the following claims is to be accorded the broadest interpretation so as to encompass all such modifications and equivalent structures and functions.
This application claims the benefit of Japanese Patent Application No. 2021-094028, filed Jun. 4, 2021, which is hereby incorporated by reference wherein in its entirety.
Number | Date | Country | Kind |
---|---|---|---|
2021-094028 | Jun 2021 | JP | national |