CN105744173A - A method, device and mobile terminal for distinguishing front and rear areas of an image - Google Patents
A method, device and mobile terminal for distinguishing front and rear areas of an image Download PDFInfo
- Publication number
- CN105744173A CN105744173A CN201610085915.6A CN201610085915A CN105744173A CN 105744173 A CN105744173 A CN 105744173A CN 201610085915 A CN201610085915 A CN 201610085915A CN 105744173 A CN105744173 A CN 105744173A
- Authority
- CN
- China
- Prior art keywords
- area
- region
- image
- foreground
- brightness
- 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
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N23/00—Cameras or camera modules comprising electronic image sensors; Control thereof
- H04N23/70—Circuitry for compensating brightness variation in the scene
- H04N23/74—Circuitry for compensating brightness variation in the scene by influencing the scene brightness using illuminating means
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N23/00—Cameras or camera modules comprising electronic image sensors; Control thereof
- H04N23/80—Camera processing pipelines; Components thereof
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Image Processing (AREA)
Abstract
Description
技术领域technical field
本发明实施例涉及拍照技术领域,尤其涉及一种区分图像前后景区域的方法、装置及移动终端。Embodiments of the present invention relate to the technical field of photographing, and in particular, to a method, device and mobile terminal for distinguishing front and rear background areas of an image.
背景技术Background technique
目前,摄像头已经成为大多移动终端的标准配置,随着摄像头性能的不断提升,移动终端中的拍照功能也越来越强大,为喜欢拍照的用户带来了便利。At present, the camera has become the standard configuration of most mobile terminals. With the continuous improvement of the performance of the camera, the camera function in the mobile terminal is also becoming more and more powerful, which brings convenience to users who like to take pictures.
在拍摄过程中,为了能够凸显拍摄主体,可利用拍摄技巧拍出前景(拍摄主体)清晰而后景(背景)模糊的具有景深效果的照片,该拍摄技巧尤其适用于人像拍摄。现在,许多移动终端用户都喜欢使用移动终端上的前置摄像头来自拍,并希望获得上述具有景深效果的自拍照片,而为了得到具有景深效果的照片,需要对景深进行计算以区分图像前后景区域,一般通过激光对焦或者双摄像头来实现。然而,现有的手机及平板电脑等移动终端的硬件配置无法计算景深,所以在拍摄时无法区分前景和后景,因而不能拍摄出具有景深效果的自拍照片。为了得到具有景深效果的自拍照片,用户只能拍摄正常效果的照片,并在后期对图像进行景深处理,操作复杂,为移动终端用户带来不便。During the shooting process, in order to highlight the subject, you can use shooting techniques to take photos with a clear foreground (subject) and blurred background (background) with depth-of-field effects. This shooting technique is especially suitable for portrait shooting. Now, many mobile terminal users like to use the front camera on the mobile terminal to take selfies, and hope to obtain the above-mentioned selfie photos with depth of field effects, but in order to obtain photos with depth of field effects, it is necessary to calculate the depth of field to distinguish the front and back of the image. , generally achieved by laser focusing or dual cameras. However, the hardware configuration of existing mobile terminals such as mobile phones and tablet computers cannot calculate the depth of field, so the foreground and the background cannot be distinguished when shooting, and thus self-portraits with depth of field effects cannot be taken. In order to obtain a selfie photo with a depth of field effect, the user can only take a photo with a normal effect, and perform depth of field processing on the image in a later stage, which is complicated to operate and brings inconvenience to mobile terminal users.
发明内容Contents of the invention
本发明实施例的目的是提供一种区分图像前后景区域的方法、装置及移动终端,以解决移动终端摄像头在拍摄照片时无法区分前后景区域的问题。The purpose of the embodiments of the present invention is to provide a method, device and mobile terminal for distinguishing the foreground and foreground areas of an image, so as to solve the problem that the camera of the mobile terminal cannot distinguish the foreground and foreground areas when taking pictures.
第一方面,本发明实施例提供了一种区分图像前后景区域的方法,包括:In the first aspect, an embodiment of the present invention provides a method for distinguishing front and rear background areas of an image, including:
监测到区分图像前后景区域事件被触发时,控制屏幕进行补光;When it is detected that the event of distinguishing the foreground and foreground areas of the image is triggered, control the screen to fill in the light;
控制摄像头在屏幕补光过程中捕捉图像;Control the camera to capture images during the process of screen fill light;
获取所述图像的亮度数据;Acquiring brightness data of the image;
根据所述亮度数据对所述图像进行区域划分,并根据各区域的亮度之间的高低关系确定前景区域和后景区域。The image is divided into regions according to the brightness data, and a foreground region and a background region are determined according to the high-low relationship between the brightness of each region.
第二方面,本发明实施例提供了一种区分图像前后景区域的装置,包括:In the second aspect, an embodiment of the present invention provides a device for distinguishing front and rear background areas of an image, including:
补光控制模块,用于在监测到区分图像前后景区域事件被触发时,控制屏幕进行补光;The supplementary light control module is used to control the screen to perform supplementary light when it is detected that the event of distinguishing the foreground and foreground areas of the image is triggered;
图像捕捉控制模块,用于控制摄像头在屏幕补光过程中捕捉图像;The image capture control module is used to control the camera to capture images during the screen fill light process;
亮度数据获取模块,用于获取所述图像的亮度数据;A brightness data acquisition module, configured to acquire brightness data of the image;
区域划分模块,用于根据所述亮度数据对所述图像进行区域划分;an area division module, configured to perform area division on the image according to the brightness data;
前后景区域确定模块,用于根据各区域的亮度之间的高低关系确定前景区域和后景区域。The foreground and foreground area determination module is used to determine the foreground area and the background area according to the relationship between the brightness of each area.
第三方面,本发明实施例提供了一种移动终端,所述移动终端集成了本发明实施例中的区分图像前后景区域的装置。In a third aspect, an embodiment of the present invention provides a mobile terminal, and the mobile terminal integrates the device for distinguishing the front and rear background areas of an image in the embodiment of the present invention.
本发明实施例中提供的区分图像前后景区域的方案,在监测到区分图像前后景区域事件被触发时,控制屏幕进行补光并控制摄像头捕捉图像,根据图像的亮度数据对图像进行区域划分,最后根据各区域的亮度之间的高低关系确定前景区域和后景区域。通过采用上述技术方案,可在不改变移动终端原有硬件配置的情况下,利用屏幕补光时不同距离的被摄物所接受的光的照度的不同来区分前景和后景,且计算量小,响应速度快,方便用户拍摄出具有景深效果的自拍照片,该方案尤其适用于低光自拍场景中对前后景的区分。The solution for distinguishing the foreground and foreground areas of the image provided in the embodiment of the present invention, when the event of distinguishing the foreground and foreground areas of the image is detected, the screen is controlled to fill in the light and the camera is controlled to capture the image, and the image is divided into regions according to the brightness data of the image. Finally, the foreground area and the background area are determined according to the relationship between the brightness of each area. By adopting the above technical solution, without changing the original hardware configuration of the mobile terminal, it is possible to distinguish the foreground and the background by using the difference in the illuminance of the light received by the subject at different distances when the screen is supplemented with light, and the amount of calculation is small , fast response speed, convenient for users to take selfie photos with depth of field effect, this solution is especially suitable for distinguishing front and back scenes in low-light selfie scenes.
附图说明Description of drawings
图1为本发明实施例一提供的一种区分图像前后景区域的方法的流程示意图;FIG. 1 is a schematic flowchart of a method for distinguishing front and rear background areas of an image provided by Embodiment 1 of the present invention;
图2为本发明实施例二提供的一种区分图像前后景区域的方法的流程示意图;FIG. 2 is a schematic flowchart of a method for distinguishing front and rear background areas of an image provided by Embodiment 2 of the present invention;
图3为本发明实施例三提供的一种区分图像前后景区域的方法的流程示意图;FIG. 3 is a schematic flowchart of a method for distinguishing front and rear background areas of an image provided by Embodiment 3 of the present invention;
图4为本发明实施例四提供的一种区分图像前后景区域的装置的结构框图。FIG. 4 is a structural block diagram of an apparatus for distinguishing front and rear background areas of an image according to Embodiment 4 of the present invention.
具体实施方式detailed description
下面结合附图并通过具体实施方式来进一步说明本发明的技术方案。可以理解的是,此处所描述的具体实施例仅仅用于解释本发明,而非对本发明的限定。另外还需要说明的是,为了便于描述,附图中仅示出了与本发明相关的部分而非全部结构。The technical solutions of the present invention will be further described below in conjunction with the accompanying drawings and through specific implementation methods. It should be understood that the specific embodiments described here are only used to explain the present invention, but not to limit the present invention. In addition, it should be noted that, for the convenience of description, only some structures related to the present invention are shown in the drawings but not all structures.
在更加详细地讨论示例性实施例之前应当提到的是,一些示例性实施例被描述成作为流程图描绘的处理或方法。虽然流程图将各步骤描述成顺序的处理,但是其中的许多步骤可以被并行地、并发地或者同时实施。此外,各步骤的顺序可以被重新安排。当其操作完成时所述处理可以被终止,但是还可以具有未包括在附图中的附加步骤。所述处理可以对应于方法、函数、规程、子例程、子程序等等。Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the steps as sequential processing, many of the steps may be performed in parallel, concurrently, or simultaneously. Additionally, the order of steps may be rearranged. The process may be terminated when its operations are complete, but may also have additional steps not included in the figure. The processing may correspond to a method, function, procedure, subroutine, subroutine, or the like.
实施例一Embodiment one
图1为本发明实施例一提供的一种区分图像前后景区域的方法的流程示意图,该方法可以由区分图像前后景区域的装置执行,其中该装置可由软件和/或硬件实现,一般可集成在移动终端中。如图1所示,该方法包括:Fig. 1 is a schematic flowchart of a method for distinguishing the foreground and foreground areas of an image provided by Embodiment 1 of the present invention. The method can be executed by a device for distinguishing the foreground and foreground regions of an image, wherein the device can be implemented by software and/or hardware, and generally can be integrated in the mobile terminal. As shown in Figure 1, the method includes:
步骤101、监测到区分图像前后景区域事件被触发时,控制屏幕进行补光。Step 101, when it is detected that the event of distinguishing the foreground and foreground areas of the image is triggered, control the screen to perform supplementary light.
示例性的,本实施例中的移动终端具体可为手机、平板电脑以及数码照相机等配置有显示屏的终端设备。Exemplarily, the mobile terminal in this embodiment may specifically be a terminal device configured with a display screen, such as a mobile phone, a tablet computer, and a digital camera.
示例性的,监测到区分图像前后景区域事件被触发具体可指监测到用户通过按键等方式主动触发区分图像前后景区域事件,例如,当移动终端中的摄像头(具体可为固定在移动终端正面的前置摄像头,即与屏幕同侧的前置摄像头;也可为当前位置处于移动终端正面的可旋转摄像头)处于开启状态时,用户通过按下区分前后景按键主动触发区分图像前后景区域事件;监测到区分图像前后景区域事件被触发具体也可指监测到移动终端自动触发区分图像前后景区域事件,例如,当移动终端中的摄像头处于开启状态,且区分前后景功能处于开启状态下,检测到用户按下拍照键时,可自动触发区分图像前后景区域事件。Exemplarily, detecting that the event of distinguishing the foreground and foreground areas of the image is triggered specifically refers to detecting that the user actively triggers the event of distinguishing the foreground and foreground areas of the image by pressing a button, for example, when the camera in the mobile terminal (specifically, it can be fixed on the front of the mobile terminal The front-facing camera, that is, the front-facing camera on the same side as the screen; it can also be a rotatable camera whose current position is on the front of the mobile terminal) is turned on, and the user actively triggers the event of distinguishing the foreground and foreground areas of the image by pressing the button to distinguish the foreground and foreground. ; It is detected that the event of distinguishing the foreground and foreground areas of the image is triggered. Specifically, it may also refer to the detection that the mobile terminal automatically triggers the event of distinguishing the foreground and foreground areas of the image. When it is detected that the user presses the camera button, an event for distinguishing the foreground and foreground areas of the image can be automatically triggered.
示例性的,控制屏幕进行补光具体可指通过控制屏幕显示合适的亮度来为摄像头补光,也就是说,先按照屏幕亮度设置规则确定屏幕亮度,再控制屏幕以所确定的屏幕亮度进行补光。具体屏幕亮度设置规则不作限定,例如,可通过环境光传感器进行测光,并根据测光结果中包含的环境光亮度来确定屏幕的亮度。优选的,当环境光亮度低于预设第一亮度阈值时,可说明当前拍摄环境较暗,可按照预设反比关系确定屏幕亮度,即环境亮度越低则屏幕亮度越高,这样设置的好处在于可对被摄物进行合理的补光,有助于后续前后景的确定,并且在确定好前后景后可直接生成补光效果较佳的具有景深效果的照片。进一步的,当环境光亮度高于预设第二亮度阈值时,可说明当前环境较亮,可按照预设正比关系确定屏幕亮度,即环境亮度越高则屏幕亮度越高,这样设置的好处在于,由于拍摄环境本身已比较亮,只有提供亮度更高的补光才容易将不同距离的被摄物的受光情况进行区分,可提高区分前后景的准确度。其中,第一亮度阈值和第二亮度阈值可以相同,也可以不同,可自由设置。Exemplarily, controlling the screen to fill in light specifically refers to filling in light for the camera by controlling the screen to display an appropriate brightness, that is to say, first determine the screen brightness according to the screen brightness setting rules, and then control the screen to perform fill-in light at the determined screen brightness. Light. The specific screen brightness setting rules are not limited. For example, the ambient light sensor may be used to perform light metering, and the brightness of the screen may be determined according to the ambient light brightness included in the light metering result. Preferably, when the ambient light brightness is lower than the preset first brightness threshold, it can indicate that the current shooting environment is relatively dark, and the screen brightness can be determined according to the preset inverse relationship, that is, the lower the ambient brightness, the higher the screen brightness. The benefits of such settings The reason is that it can provide reasonable supplementary light to the subject, which is helpful for the subsequent determination of the foreground and foreground, and after the foreground and foreground are determined, it can directly generate a photo with a better supplementary light effect and a depth of field effect. Further, when the brightness of the ambient light is higher than the preset second brightness threshold, it can indicate that the current environment is brighter, and the screen brightness can be determined according to the preset proportional relationship, that is, the higher the ambient brightness, the higher the screen brightness. The advantage of this setting is that , since the shooting environment itself is relatively bright, only by providing higher brightness fill light can it be easy to distinguish the light receiving conditions of the subjects at different distances, which can improve the accuracy of distinguishing the front and back scenes. Wherein, the first brightness threshold and the second brightness threshold may be the same or different, and may be set freely.
步骤102、控制摄像头在屏幕补光过程中捕捉图像。Step 102, controlling the camera to capture images during the process of screen fill light.
示例性的,本实施例中的摄像头具体可为固定在移动终端正面(与屏幕同侧)的前置摄像头,也可为当前位置处于移动终端正面的可旋转摄像头。Exemplarily, the camera in this embodiment may specifically be a front-facing camera fixed on the front of the mobile terminal (on the same side as the screen), or a rotatable camera whose current position is on the front of the mobile terminal.
步骤103、获取图像的亮度数据。Step 103, acquiring brightness data of the image.
示例性的,所述亮度数据具体可包括亮度值分布情况相关数据,如图像中每个像素的亮度值以及亮度直方图数据等等。Exemplarily, the brightness data may specifically include data related to the distribution of brightness values, such as the brightness value of each pixel in the image, brightness histogram data, and the like.
步骤104、根据亮度数据对图像进行区域划分,并根据各区域的亮度之间的高低关系确定前景区域和后景区域。Step 104: Divide the image into regions according to the brightness data, and determine the foreground region and the background region according to the high-low relationship between the brightness of each region.
示例性的,在屏幕补光过程中,不同距离的被摄物所接受的光的照度是不同的,而图像是在屏幕补光过程中捕捉到的,所以该图像中不同位置的亮度情况能够反映相应位置所对应的被摄物距离屏幕的远近情况。通常情况下,由于光在空气中会因灰尘等因素的影响而发散,距离屏幕(相当于光源)越近的被摄物呈现在图像中的亮度越高,而距离屏幕越远的被摄物呈现在图像中的亮度越低。所以,可按照图像中的不同位置的亮度情况对图像进行区域划分,将亮度较高的区域确定为前景区域,将亮度较低的区域确定为后景区域,方便后续应用。Exemplarily, in the process of screen fill light, the illuminance of light received by objects at different distances is different, and the image is captured during the screen fill light process, so the brightness of different positions in the image can be It reflects the distance between the subject corresponding to the corresponding position and the screen. Under normal circumstances, because light will diverge due to the influence of dust and other factors in the air, the closer the subject is to the screen (equivalent to the light source), the higher the brightness in the image will be, while the farther the subject is from the screen, the brightness will be higher in the image. The lower the brightness appears in the image. Therefore, the image can be divided into regions according to the brightness of different positions in the image, and the region with higher brightness is determined as the foreground region, and the region with lower brightness is determined as the background region, which is convenient for subsequent applications.
优选的,根据亮度数据对图像进行区域划分,具体可包括:根据亮度数据中的亮度分布情况相关数据和预设分区规则对图像进行区域划分。所述预设分区规则可根据实际情况进行调整,本实施例不作具体限定。例如,可将亮度值接近且集中出现的像素划分至同一区域,也就是说,对于两个亮度值接近的像素来说,在划分时可考虑像素之间的位置关系,以及他们之间是否间隔存在与该两个像素亮度值相差较远的其他像素;可设置同一区域内允许的最大亮度差值,例如,该区域中包含的最高亮度值减去最低亮度值的差应在预设最大亮度差值范围内。Preferably, performing region division on the image according to the brightness data may specifically include: performing region division on the image according to brightness distribution related data in the brightness data and preset partition rules. The preset partition rules can be adjusted according to actual conditions, and are not specifically limited in this embodiment. For example, pixels with similar brightness values and concentrated occurrence can be divided into the same area, that is, for two pixels with similar brightness values, the positional relationship between pixels and whether there is a gap between them can be considered when dividing. There are other pixels with far different brightness values from these two pixels; the maximum brightness difference allowed in the same area can be set, for example, the difference between the highest brightness value minus the lowest brightness value contained in this area should be within the preset maximum brightness within the difference range.
需要说明的是,设计人员可通过试验得出在固定屏幕亮度照射下,同一环境亮度中不同距离的物体被补光后的亮度,形成亮度与距离的对应关系(不同屏幕亮度对应不同的亮度与距离的对应关系,不同环境亮度对应不同的亮度与距离的对应关系),利用上述亮度与距离的对应关系,就可以在实际应用中根据补光后的亮度反推出距离的远近,在设计分区规则时可参考上述亮度与距离的对应关系进行设计。例如,在设计分区规则时,若想将距离差为A(如20厘米)的两个被摄物划分至同一区域内,参照上述亮度与距离的对应关系,距离差为A的两个被摄物的亮度差值为B,则上述的同一区域内允许的最大亮度差值可设置为B。It should be noted that the designer can obtain the brightness of objects at different distances in the same environment brightness after being illuminated by experiments through experiments, and form a corresponding relationship between brightness and distance (different screen brightness corresponds to different brightness and distance). The corresponding relationship between distance, different ambient brightness corresponds to different brightness and distance), using the above-mentioned corresponding relationship between brightness and distance, the distance can be inversely deduced according to the brightness after supplementing light in practical applications, and in the design of partition rules You can refer to the corresponding relationship between brightness and distance above for design. For example, when designing partition rules, if you want to divide two subjects with a distance difference of A (such as 20 cm) into the same area, refer to the above-mentioned corresponding relationship between brightness and distance, and the two subjects with a distance difference of A If the brightness difference value of the object is B, then the above-mentioned maximum brightness difference allowed in the same area can be set to B.
本发明实施例一提供的区分图像前后景区域的方法,在监测到区分图像前后景区域事件被触发时,控制屏幕进行补光并控制摄像头捕捉图像,根据图像的亮度数据对图像进行区域划分,最后根据各区域的亮度之间的高低关系确定前景区域和后景区域。通过采用上述技术方案,可在不改变移动终端原有硬件配置的情况下,利用屏幕补光时不同距离的被摄物所接受的光的照度的不同来区分前景和后景,且计算量小,响应速度快,方便用户拍摄出具有景深效果的自拍照片,该方法尤其适用于低光自拍场景中对前后景的区分。In the method for distinguishing the foreground and foreground areas of an image provided by Embodiment 1 of the present invention, when the event of distinguishing the foreground and foreground areas of an image is detected, the screen is controlled to fill in light and the camera is controlled to capture the image, and the image is divided into regions according to the brightness data of the image. Finally, the foreground area and the background area are determined according to the relationship between the brightness of each area. By adopting the above technical solution, without changing the original hardware configuration of the mobile terminal, it is possible to distinguish the foreground and the background by using the difference in the illuminance of the light received by the subject at different distances when the screen is supplemented with light, and the amount of calculation is small , fast response, convenient for users to take selfie photos with depth of field effect, this method is especially suitable for distinguishing front and back scenes in low-light selfie scenes.
实施例二Embodiment two
图2为本发明实施例二提供的一种区分图像前后景区域的方法的流程示意图,本实施例以上述实施例为基础进行优化,在本实施例中,将步骤“根据各区域的亮度之间的高低关系确定前景区域和后景区域”优化为:确定各区域的亮度值;按照各区域的亮度值的高低关系对各区域进行排序;将亮度值最高的区域确定为前景区域,将剩余区域确定为后景区域。Fig. 2 is a schematic flow chart of a method for distinguishing the foreground and foreground areas of an image provided by Embodiment 2 of the present invention. This embodiment is optimized on the basis of the above-mentioned embodiments. The high and low relationship between determine the foreground area and the background area" optimization is: determine the brightness value of each area; sort each area according to the high and low relationship of the brightness value of each area; determine the area with the highest brightness value as the foreground area, and the remaining The area is determined as the background area.
相应的,本实施例的方法包括如下步骤:Correspondingly, the method of this embodiment includes the following steps:
步骤201、监测到区分图像前后景区域事件被触发时,控制屏幕进行补光。Step 201, when it is detected that the event of distinguishing the foreground and foreground areas of the image is triggered, control the screen to perform supplementary light.
步骤202、控制摄像头在屏幕补光过程中捕捉图像。Step 202, controlling the camera to capture images during the process of screen fill light.
步骤203、获取图像的亮度数据,根据亮度数据对图像进行区域划分。Step 203, acquire brightness data of the image, and divide the image into regions according to the brightness data.
步骤204、确定各区域的亮度值。Step 204, determine the brightness value of each area.
示例性的,对于每个区域,可计算当前区域中所有像素的亮度值的平均值,并以该平均值作为当前区域的亮度值。Exemplarily, for each area, an average value of brightness values of all pixels in the current area may be calculated, and the average value may be used as the brightness value of the current area.
步骤205、按照各区域的亮度值的高低关系对各区域进行排序。Step 205, sort the regions according to the relationship between the brightness values of the regions.
示例性的,可按照亮度值从高到低的顺序将各区域进行排序。Exemplarily, the regions may be sorted in descending order of brightness values.
步骤206、将亮度值最高的区域确定为前景区域。Step 206. Determine the region with the highest brightness value as the foreground region.
优选的,将亮度值最高的区域确定为前景区域,可具体包括:计算亮度值最高的第一区域的面积;判断第一区域的面积是否高于预设面积阈值,若是,则将第一区域确定为前景区域。进一步的,还可包括:若否,则顺次计算排在第一区域后面的区域的面积,直到计算出第二区域的面积高于预设面积阈值时,将第二区域确定为前景区域。这样设置的好处在于,在自拍时,前景一般为用户人脸,而后景中可能会出现路灯等干扰光源,若直接将亮度最高的区域确定为前景区域可能会出现误判情况。对于自拍照来说,人脸图像所占面积通常较大,而路灯等干扰光源由于距离摄像头较远,所占面积通常较小,会低于预设面积阈值,因而可排除干扰光源对前后景区分过程中的干扰,提高准确度。Preferably, determining the area with the highest brightness value as the foreground area may specifically include: calculating the area of the first area with the highest brightness value; identified as the foreground area. Further, the method may further include: if not, sequentially calculating the areas of the areas behind the first area until the calculated area of the second area is higher than the preset area threshold, then determining the second area as the foreground area. The advantage of this setting is that when taking a selfie, the foreground is generally the user's face, and there may be interfering light sources such as street lights in the background. If the area with the highest brightness is directly determined as the foreground area, misjudgment may occur. For selfies, the area occupied by human face images is usually large, while interfering light sources such as street lights are usually far away from the camera, and the area occupied is usually small, which will be lower than the preset area threshold. Interference during the classification process, improve accuracy.
步骤207、将剩余区域确定为后景区域。Step 207, determine the remaining area as the background area.
优选的,在将亮度值排序靠前且面积高于预设面积阈值的区域确定为前景区域后,将包括干扰光源在内的其他区域确定后景区域,准确对前后景进行区分。Preferably, after the area whose brightness value ranks first and whose area is higher than the preset area threshold is determined as the foreground area, other areas including interfering light sources are determined as the background area, so as to accurately distinguish the foreground and the foreground.
本发明实施例二提供的区分图像前后景区域的方法,确定各区域的亮度值后,按照各区域的亮度值的高低关系对各区域进行排序,并将亮度值最高的区域确定为前景区域,将剩余区域确定为后景区域,可进一步提升区分图像前后景区域的准确度。In the method for distinguishing the foreground and foreground regions of an image provided by Embodiment 2 of the present invention, after determining the brightness values of each region, the regions are sorted according to the relationship between the brightness values of each region, and the region with the highest brightness value is determined as the foreground region, Determining the remaining area as the background area can further improve the accuracy of distinguishing the foreground area of the image.
实施例三Embodiment three
图3为本发明实施例三提供的一种区分图像前后景区域的方法的流程示意图,本实施例以上述实施例为基础进行优化,在本实施例中,在最后增加了步骤:对后景区域作模糊处理,并根据处理后的图像生成照片。Fig. 3 is a schematic flowchart of a method for distinguishing the foreground and foreground areas of an image provided by Embodiment 3 of the present invention. This embodiment is optimized on the basis of the above-mentioned embodiments. In this embodiment, a step is added at the end: Areas are blurred and a photo is generated from the processed image.
相应的,本实施例的方法包括如下步骤:Correspondingly, the method of this embodiment includes the following steps:
步骤301、监测到区分图像前后景区域事件被触发时,控制屏幕进行补光。Step 301 , when it is detected that the event of distinguishing the foreground and foreground areas of the image is triggered, control the screen to perform supplementary light.
步骤302、控制摄像头在屏幕补光过程中捕捉图像。Step 302, controlling the camera to capture images during the process of screen fill light.
步骤303、获取图像的亮度数据,根据亮度数据对图像进行区域划分。Step 303, acquire brightness data of the image, and divide the image into regions according to the brightness data.
步骤304、确定各区域的亮度值,按照各区域的亮度值的高低关系对各区域进行排序。Step 304, determine the brightness value of each region, and sort the regions according to the relationship between the brightness values of each region.
步骤305、计算当前亮度值最高的区域的面积。Step 305. Calculate the area of the region with the highest current brightness value.
示例性的,第一次执行本步骤时,当前亮度值最高的区域即上述实施例中的第一区域。Exemplarily, when this step is performed for the first time, the area with the highest current brightness value is the first area in the above embodiment.
步骤306、判断当前亮度值最高的区域的面积是否高于预设面积阈值,若否,则执行步骤307;若是,执行步骤308。Step 306 , judging whether the area of the region with the highest current brightness value is higher than the preset area threshold, if not, execute step 307 ; if yes, execute step 308 .
步骤307、将排序中下一个区域作为新的当前亮度值最高的区域,返回执行步骤305。Step 307 , take the next area in the sorting as the new area with the highest current brightness value, and return to step 305 .
步骤308、将当前亮度值最高的区域确定为前景区域,执行步骤309。Step 308 , determine the region with the highest current brightness value as the foreground region, and execute step 309 .
步骤309、将剩余区域确定为后景区域。Step 309, determine the remaining area as the background area.
步骤310、对后景区域作模糊处理,并根据处理后的图像生成照片。Step 310, perform blur processing on the background area, and generate a photo according to the processed image.
示例性的,对后景区域作模糊处理,保留清晰的前景区域,并对处理后的图像进行编码等操作生成照片,提供给用户,此时的照片即为具有景深效果的自拍照,满足用户需求。其中,对后景区域作模糊处理的过程可参照现有的图像模糊处理技术,如高斯模糊处理等,本实施例不作具体限定。Exemplarily, the background area is blurred, the clear foreground area is reserved, and the processed image is encoded to generate a photo and provided to the user. The photo at this time is a selfie with a depth of field effect, satisfying the user need. Wherein, the process of blurring the background area may refer to existing image blurring techniques, such as Gaussian blurring, which is not specifically limited in this embodiment.
优选的,如本发明实施例一中所述,当环境光亮度高于预设第二亮度阈值时,可按照预设正比关系确定屏幕亮度,此时的图像会因曝光过度而影响拍照效果,在这种情况下,可对前景区域和后景区域进行记录,重新确定屏幕亮度,控制屏幕以重新确定的屏幕亮度进行补光(或停止补光),控制摄像头捕捉第二图像,根据所记录的前景区域和后景区域对第二图像进行区域划分,得到第二图像的前景区域和后景区域,并对第二图像中的后景区域作模糊处理,根据处理后的第二图像生成自拍照片。此时的自拍照片曝光合理,拍照效果理想,可满足用户需求。Preferably, as described in Embodiment 1 of the present invention, when the brightness of the ambient light is higher than the preset second brightness threshold, the brightness of the screen can be determined according to the preset proportional relationship, and the image at this time will affect the photographing effect due to overexposure. In this case, the foreground area and the background area can be recorded, the brightness of the screen can be re-determined, the screen can be controlled to fill in the light (or stop the light) at the re-determined screen brightness, and the camera can be controlled to capture the second image. The foreground area and the background area of the second image are divided into regions to obtain the foreground area and the background area of the second image, and the background area in the second image is blurred, and a selfie is generated according to the processed second image photo. At this time, the exposure of the selfie photo is reasonable, and the photo effect is ideal, which can meet the needs of users.
本发明实施例三提供的区分图像前后景区域的方法,在确定了前景区域和后景区域后,对后景区域作模糊处理,并根据处理后的图像生成照片,用户可轻松拍摄具有景深效果的自拍照片,满足用户需求,提升用户体验。In the method for distinguishing the foreground and foreground areas of an image provided by Embodiment 3 of the present invention, after the foreground area and the background area are determined, the background area is blurred, and a photo is generated according to the processed image, and the user can easily take pictures with a depth of field effect selfie photos to meet user needs and improve user experience.
实施例四Embodiment Four
图4为本发明实施例四提供的一种区分图像前后景区域的装置的结构框图,该装置可由软件和/或硬件实现,一般集成在移动终端中,可通过执行区分图像前后景区域的方法来区分图像前后景区域。如图4所示,该装置包括补光控制模块401、图像捕捉控制模块402、亮度数据获取模块403、区域划分模块404和前后景区域确定模块405。Fig. 4 is a structural block diagram of a device for distinguishing the foreground and foreground areas of an image provided in Embodiment 4 of the present invention. The device can be implemented by software and/or hardware, and is generally integrated in a mobile terminal. To distinguish the foreground and foreground regions of the image. As shown in FIG. 4 , the device includes a supplementary light control module 401 , an image capture control module 402 , a brightness data acquisition module 403 , an area division module 404 and a foreground and background area determination module 405 .
其中,补光控制模块401,用于在监测到区分图像前后景区域事件被触发时,控制屏幕进行补光;图像捕捉控制模块402,用于控制摄像头在所述屏幕补光过程中捕捉图像;亮度数据获取模块403,用于获取所述图像的亮度数据;区域划分模块404,用于根据所述亮度数据对所述图像进行区域划分;前后景区域确定模块405,用于根据各区域的亮度之间的高低关系确定前景区域和后景区域。Among them, the supplementary light control module 401 is used to control the screen to perform supplementary light when it is detected that the event of distinguishing the foreground and foreground areas of the image is triggered; the image capture control module 402 is used to control the camera to capture images during the screen supplementary light process; The brightness data acquisition module 403 is used to obtain the brightness data of the image; the region division module 404 is used to divide the image into regions according to the brightness data; the front and back background region determination module 405 is used to determine the brightness of each region according to The high-low relationship between determines the foreground and background regions.
本发明实施例四提供的区分图像前后景区域的装置,可在不改变移动终端原有硬件配置的情况下,利用屏幕补光时不同距离的被摄物所接受的光的照度的不同来区分前景和后景,且计算量小,响应速度快,方便用户拍摄出具有景深效果的自拍照片,该方案尤其适用于低光自拍场景中对前后景的区分。The device for distinguishing the foreground and foreground areas of an image provided by Embodiment 4 of the present invention can be distinguished by using the difference in the illuminance of light received by objects at different distances when the screen is supplemented with light without changing the original hardware configuration of the mobile terminal. Foreground and background, with a small amount of calculation and fast response, it is convenient for users to take selfie photos with depth of field effects. This solution is especially suitable for distinguishing front and back scenes in low-light selfie scenes.
在上述实施例的基础上,所述区域划分模块具体可用于:根据所述亮度数据中的亮度分布情况相关数据和预设分区规则对所述图像进行区域划分。On the basis of the above embodiments, the region division module may be specifically configured to: perform region division on the image according to brightness distribution related data in the brightness data and preset partition rules.
在上述实施例的基础上,所述前后景区域确定模块可包括亮度值确定单元、区域排序单元和前后景区域确定单元。其中,亮度值确定单元,用于确定各区域的亮度值;区域排序单元,用于按照所述各区域的亮度值的高低关系对所述各区域进行排序;前后景区域确定单元,用于将亮度值最高的区域确定为前景区域,将剩余区域确定为后景区域。On the basis of the above embodiments, the foreground and foreground area determination module may include a brightness value determination unit, an area sorting unit, and a foreground and foreground area determination unit. Wherein, the brightness value determination unit is used to determine the brightness value of each region; the region sorting unit is used to sort the regions according to the relationship between the brightness values of the regions; The area with the highest brightness value is determined as the foreground area, and the remaining area is determined as the background area.
在上述实施例的基础上,所述前后景区域确定单元可包括面积计算子单元和前景区域确定子单元。其中,面积计算子单元,用于计算亮度值最高的第一区域的面积;前景区域确定子单元,用于判断所述第一区域的面积是否高于预设面积阈值,若是,则将所述第一区域确定为前景区域。On the basis of the above embodiments, the foreground and foreground area determination unit may include an area calculation subunit and a foreground area determination subunit. Among them, the area calculation subunit is used to calculate the area of the first region with the highest brightness value; the foreground region determination subunit is used to judge whether the area of the first region is higher than the preset area threshold, and if so, the The first area is determined as a foreground area.
在上述实施例的基础上,所述面积计算子单元,还可用于在判断所述第一区域的面积不高于预设面积阈值时,顺次计算排在所述第一区域后面的区域的面积,直到计算出第二区域的面积高于所述预设面积阈值;所述前景区域确定子单元,还可用于在所述面积计算子单元计算出第二区域的面积高于所述预设面积阈值时,将所述第二区域确定为前景区域。On the basis of the above-mentioned embodiments, the area calculation subunit can also be configured to sequentially calculate the area of the area behind the first area when it is judged that the area of the first area is not higher than the preset area threshold. area until the calculated area of the second area is higher than the preset area threshold; the foreground area determination subunit can also be used to calculate the area of the second area higher than the preset area in the area calculation subunit When the area threshold is greater than the area threshold, the second area is determined as the foreground area.
在上述实施例的基础上,该装置还可包括:照片生成模块,用于在所述根据各区域的亮度之间的高低关系确定前景区域和后景区域之后,对所述后景区域作模糊处理,并根据处理后的图像生成照片。On the basis of the above embodiments, the device may further include: a photo generation module, used to blur the background area after the foreground area and the background area are determined according to the high-low relationship between the brightness of each area processing, and generate photos from the processed images.
在上述实施例的基础上,所述摄像头为前置摄像头或当前位置处于移动终端正面的可旋转摄像头。On the basis of the above embodiments, the camera is a front camera or a rotatable camera whose current position is in front of the mobile terminal.
实施例五Embodiment five
本发明实施例五提供了一种移动终端,移动终端集成了本发明实施例提供的区分图像前后景区域的装置,可通过执行区分图像前后景区域的方法来区分图像前后景区域。Embodiment 5 of the present invention provides a mobile terminal. The mobile terminal integrates the device for distinguishing the foreground and foreground areas of an image provided in the embodiment of the present invention, and can distinguish the foreground and foreground areas of an image by executing the method for distinguishing the foreground and foreground areas of an image.
示例性的,本实施例中的移动终端具体可为手机、平板电脑以及数码照相机等配置有显示屏的终端设备。Exemplarily, the mobile terminal in this embodiment may specifically be a terminal device configured with a display screen, such as a mobile phone, a tablet computer, and a digital camera.
当用户使用本实施例中的移动终端进行自拍时,移动终端可快速自动实现前后景的区分,并可拍摄出具有景深效果的照片,满足用户需求,提升用户体验。When a user uses the mobile terminal in this embodiment to take a selfie, the mobile terminal can quickly and automatically distinguish between the foreground and the foreground, and can take photos with a depth of field effect to meet user needs and improve user experience.
上述实施例中提供的区分图像前后景区域的装置及移动终端可执行本发明任意实施例所提供的区分图像前后景区域的方法,具备执行该方法相应的功能模块和有益效果。未在上述实施例中详尽描述的技术细节,可参见本发明任意实施例所提供的区分图像前后景区域的方法。The device for distinguishing the foreground and background regions of an image and the mobile terminal provided in the above embodiments can execute the method for distinguishing the foreground and foreground regions of an image provided in any embodiment of the present invention, and have corresponding functional modules and beneficial effects for executing the method. For technical details not exhaustively described in the foregoing embodiments, reference may be made to the method for distinguishing the foreground and foreground regions of an image provided in any embodiment of the present invention.
注意,上述仅为本发明的较佳实施例及所运用技术原理。本领域技术人员会理解,本发明不限于这里所述的特定实施例,对本领域技术人员来说能够进行各种明显的变化、重新调整和替代而不会脱离本发明的保护范围。因此,虽然通过以上实施例对本发明进行了较为详细的说明,但是本发明不仅仅限于以上实施例,在不脱离本发明构思的情况下,还可以包括更多其他等效实施例,而本发明的范围由所附的权利要求范围决定。Note that the above are only preferred embodiments of the present invention and applied technical principles. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the protection scope of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and can also include more other equivalent embodiments without departing from the concept of the present invention, and the present invention The scope is determined by the scope of the appended claims.
Claims (15)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201610085915.6A CN105744173B (en) | 2016-02-15 | 2016-02-15 | Method and device for distinguishing foreground and background areas of image and mobile terminal |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201610085915.6A CN105744173B (en) | 2016-02-15 | 2016-02-15 | Method and device for distinguishing foreground and background areas of image and mobile terminal |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN105744173A true CN105744173A (en) | 2016-07-06 |
| CN105744173B CN105744173B (en) | 2019-04-16 |
Family
ID=56245931
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201610085915.6A Expired - Fee Related CN105744173B (en) | 2016-02-15 | 2016-02-15 | Method and device for distinguishing foreground and background areas of image and mobile terminal |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN105744173B (en) |
Cited By (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107370958A (en) * | 2017-08-29 | 2017-11-21 | 广东欧珀移动通信有限公司 | Image virtualization processing method, device and shooting terminal |
| CN108616699A (en) * | 2018-04-25 | 2018-10-02 | 努比亚技术有限公司 | It takes pictures light compensation method, equipment and computer storage media |
| CN109005361A (en) * | 2018-08-06 | 2018-12-14 | Oppo广东移动通信有限公司 | Control method, device, imaging device, electronic equipment and readable storage medium storing program for executing |
| CN113132617A (en) * | 2019-12-31 | 2021-07-16 | 北京中安未来科技有限公司 | Image jitter judgment method and device and image identification triggering method and device |
| CN114302057A (en) * | 2021-12-24 | 2022-04-08 | 维沃移动通信有限公司 | Image parameter determination method and device, electronic equipment and storage medium |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101873416A (en) * | 2009-04-24 | 2010-10-27 | 宏达国际电子股份有限公司 | Image capture device and image capture method |
| US8363908B2 (en) * | 2006-05-03 | 2013-01-29 | DigitalOptics Corporation Europe Limited | Foreground / background separation in digital images |
| CN104065862A (en) * | 2013-03-18 | 2014-09-24 | 联想(北京)有限公司 | Information processing method and electronic device |
| CN104580883A (en) * | 2013-10-09 | 2015-04-29 | 卡西欧计算机株式会社 | Image processing device and image processing method |
| CN104811631A (en) * | 2014-01-27 | 2015-07-29 | 华为技术有限公司 | Image processing method and image processor |
| CN105005973A (en) * | 2015-06-30 | 2015-10-28 | 广东欧珀移动通信有限公司 | Fast image denoising method and apparatus |
-
2016
- 2016-02-15 CN CN201610085915.6A patent/CN105744173B/en not_active Expired - Fee Related
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US8363908B2 (en) * | 2006-05-03 | 2013-01-29 | DigitalOptics Corporation Europe Limited | Foreground / background separation in digital images |
| CN101873416A (en) * | 2009-04-24 | 2010-10-27 | 宏达国际电子股份有限公司 | Image capture device and image capture method |
| CN104065862A (en) * | 2013-03-18 | 2014-09-24 | 联想(北京)有限公司 | Information processing method and electronic device |
| CN104580883A (en) * | 2013-10-09 | 2015-04-29 | 卡西欧计算机株式会社 | Image processing device and image processing method |
| CN104811631A (en) * | 2014-01-27 | 2015-07-29 | 华为技术有限公司 | Image processing method and image processor |
| CN105005973A (en) * | 2015-06-30 | 2015-10-28 | 广东欧珀移动通信有限公司 | Fast image denoising method and apparatus |
Cited By (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107370958A (en) * | 2017-08-29 | 2017-11-21 | 广东欧珀移动通信有限公司 | Image virtualization processing method, device and shooting terminal |
| CN108616699A (en) * | 2018-04-25 | 2018-10-02 | 努比亚技术有限公司 | It takes pictures light compensation method, equipment and computer storage media |
| CN109005361A (en) * | 2018-08-06 | 2018-12-14 | Oppo广东移动通信有限公司 | Control method, device, imaging device, electronic equipment and readable storage medium storing program for executing |
| WO2020029920A1 (en) * | 2018-08-06 | 2020-02-13 | Guangdong Oppo Mobile Telecommunications Corp., Ltd. | Control method, control apparatus, imaging device, and electronic device |
| CN113132617A (en) * | 2019-12-31 | 2021-07-16 | 北京中安未来科技有限公司 | Image jitter judgment method and device and image identification triggering method and device |
| CN113132617B (en) * | 2019-12-31 | 2023-04-07 | 北京中安未来科技有限公司 | Image jitter judgment method and device and image identification triggering method and device |
| CN114302057A (en) * | 2021-12-24 | 2022-04-08 | 维沃移动通信有限公司 | Image parameter determination method and device, electronic equipment and storage medium |
Also Published As
| Publication number | Publication date |
|---|---|
| CN105744173B (en) | 2019-04-16 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN105554411B (en) | A kind of photographic method based on screen light filling, device and mobile terminal | |
| CN105554413B (en) | A kind of screen light filling photographic method, device and mobile terminal | |
| TWI530911B (en) | Dynamic exposure adjusting method and electronic apparatus using the same | |
| CN111586282B (en) | Shooting method, shooting device, terminal and readable storage medium | |
| CN105744175B (en) | A kind of screen light compensation method, device and mobile terminal | |
| CN105959581A (en) | Electronic device for image capture with dynamically controlled flash and related control method | |
| CN104539864B (en) | The method and apparatus for recording image | |
| EP2733925B1 (en) | Photographing apparatus and method for controlling image processing thereof | |
| CN109671106A (en) | A kind of image processing method, device and equipment | |
| CN105744176A (en) | A method, device, and mobile terminal for supplementing light on a screen | |
| US10609265B2 (en) | Methods and apparatus for synchronizing camera flash and sensor blanking | |
| CN105744173A (en) | A method, device and mobile terminal for distinguishing front and rear areas of an image | |
| CN104394329B (en) | A kind of photographic method, device and mobile terminal | |
| CN105915815A (en) | Method and device for shooting based on mobile device, and mobile device | |
| CN108040204B (en) | A multi-camera-based image capturing method, device and storage medium | |
| CN105391940B (en) | An image recommendation method and device | |
| CN119631419A (en) | Image processing method and related equipment | |
| CN106657798A (en) | Photographing method for intelligent terminal | |
| CN111586280B (en) | Shooting method, device, terminal and readable storage medium | |
| WO2023236209A1 (en) | Image processing method and apparatus, electronic device, and storage medium | |
| CN107820025B (en) | Method and device for photographing processing | |
| CN106878606A (en) | An image generation method based on an electronic device and the electronic device | |
| CN106878604A (en) | Method and electronic device for image generation based on electronic device | |
| WO2023236215A1 (en) | Image processing method and apparatus, and storage medium | |
| CN111277754B (en) | Mobile terminal shooting method and device |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| C06 | Publication | ||
| PB01 | Publication | ||
| C10 | Entry into substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| CB02 | Change of applicant information |
Address after: 523860 No. 18, Wu Sha Beach Road, Changan Town, Dongguan, Guangdong Applicant after: GUANGDONG OPPO MOBILE TELECOMMUNICATIONS Corp.,Ltd. Address before: 523860 No. 18, Wu Sha Beach Road, Changan Town, Dongguan, Guangdong Applicant before: GUANGDONG OPPO MOBILE TELECOMMUNICATIONS Corp.,Ltd. |
|
| CB02 | Change of applicant information | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant | ||
| CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20190416 |
|
| CF01 | Termination of patent right due to non-payment of annual fee |