CN114399523A - Image data processing method, electronic device, and computer storage medium - Google Patents
Image data processing method, electronic device, and computer storage medium Download PDFInfo
- Publication number
- CN114399523A CN114399523A CN202111674842.1A CN202111674842A CN114399523A CN 114399523 A CN114399523 A CN 114399523A CN 202111674842 A CN202111674842 A CN 202111674842A CN 114399523 A CN114399523 A CN 114399523A
- Authority
- CN
- China
- Prior art keywords
- color
- background
- image
- processed
- range
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 30
- 238000003860 storage Methods 0.000 title claims abstract description 6
- 238000009826 distribution Methods 0.000 claims abstract description 44
- 230000036961 partial effect Effects 0.000 claims abstract description 6
- 238000000034 method Methods 0.000 claims description 49
- 238000012545 processing Methods 0.000 claims description 35
- 238000004891 communication Methods 0.000 claims description 28
- 239000003086 colorant Substances 0.000 claims description 17
- 230000011218 segmentation Effects 0.000 claims description 13
- 238000004590 computer program Methods 0.000 claims description 5
- 230000008030 elimination Effects 0.000 claims description 4
- 238000003379 elimination reaction Methods 0.000 claims description 4
- 238000004364 calculation method Methods 0.000 description 21
- 230000008569 process Effects 0.000 description 16
- 230000002829 reductive effect Effects 0.000 description 15
- 235000019580 granularity Nutrition 0.000 description 13
- 238000013459 approach Methods 0.000 description 8
- 230000009467 reduction Effects 0.000 description 6
- 230000006870 function Effects 0.000 description 5
- 238000004422 calculation algorithm Methods 0.000 description 4
- 238000010586 diagram Methods 0.000 description 4
- 230000000694 effects Effects 0.000 description 4
- 230000008859 change Effects 0.000 description 3
- 230000007423 decrease Effects 0.000 description 2
- 238000001514 detection method Methods 0.000 description 2
- 238000004519 manufacturing process Methods 0.000 description 2
- 230000000717 retained effect Effects 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 206010033307 Overweight Diseases 0.000 description 1
- 230000002159 abnormal effect Effects 0.000 description 1
- 230000003190 augmentative effect Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 238000004737 colorimetric analysis Methods 0.000 description 1
- 238000004042 decolorization Methods 0.000 description 1
- 238000005034 decoration Methods 0.000 description 1
- 230000003247 decreasing effect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000003709 image segmentation Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 230000010354 integration Effects 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 230000000670 limiting effect Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000011022 operating instruction Methods 0.000 description 1
- 238000005192 partition Methods 0.000 description 1
- 238000000638 solvent extraction Methods 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
- 230000007704 transition Effects 0.000 description 1
- 230000037303 wrinkles Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/194—Segmentation; Edge detection involving foreground-background segmentation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/136—Segmentation; Edge detection involving thresholding
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/90—Determination of colour characteristics
Landscapes
- Engineering & Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Image Processing (AREA)
Abstract
The embodiment of the application provides an image data processing method, electronic equipment and a computer storage medium, wherein the image data processing method comprises the following steps: obtaining an image to be processed under a preset color space, wherein the preset color space is a color space capable of reflecting the tone of the image to be processed; determining a plurality of color components corresponding to the background reference color system according to the background reference color system of the image to be processed, and obtaining at least partial single-color components in the plurality of color components; obtaining a color range corresponding to the monochromatic color component according to the pixel number distribution of the monochromatic color component; and obtaining the background color range of the image to be processed based on the color range corresponding to the single color component. Through the embodiment of the application, the determined background color range is more accurate.
Description
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to an image data processing method, electronic equipment and a computer storage medium.
Background
Image processing is a technique of processing image information by a computer, and in image processing, many scenes depend on processing for an image background, for example, recognition for an image background, background segmentation, and the like.
At present, most background segmentation processes work in a scene with a preset background object, for example, a green or other color curtain, a wall, a display screen, etc. are used as a background, and the similarity between each target pixel and the background color or the background color interval corresponding to these background objects is calculated to distinguish the foreground from the background. However, in scenes with preset background objects such as a curtain, a wall, a display screen, and the like, due to reasons such as curtain wrinkles, light consistency, exposure consistency, interference, and the like, the background color is actually a dynamically changing range, and changes and spans in many scenes are large, so that manual calibration is difficult, and accuracy of determining the image background is also difficult to ensure.
Therefore, how to accurately determine the background color of the image in the complex scene of the preset background scene becomes an urgent problem to be solved.
Disclosure of Invention
In view of the above, embodiments of the present application provide an image data processing scheme to at least partially solve the above problems.
According to a first aspect of embodiments of the present application, there is provided an image data processing method, including: obtaining an image to be processed under a preset color space, wherein the preset color space is a color space capable of reflecting the tone of the image to be processed; determining a plurality of color components corresponding to the background reference color system according to the background reference color system of the image to be processed, and obtaining at least partial single-color components in the plurality of color components; obtaining a color range corresponding to the monochromatic color component according to the pixel number distribution of the monochromatic color component; and obtaining the background color range of the image to be processed based on the color range corresponding to the single color component.
According to a second aspect of embodiments of the present application, there is provided an image data processing method including: acquiring an image to be processed and a preset background reference color system of the image to be processed; converting the image to be processed into a preset color space, and determining a plurality of color components of the background reference color system in the preset color space based on the image to be processed in the preset color space, wherein the preset color space is a color space capable of reflecting the color tone of the image to be processed; obtaining a background color range of the image to be processed based on the pixel number distribution of at least part of single-color components in the plurality of color components of the background reference color system; and performing background segmentation processing on the image to be processed based on the background color range.
According to a third aspect of embodiments of the present application, there is provided an electronic apparatus, including: the system comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface complete mutual communication through the communication bus; the memory is used for storing at least one executable instruction, and the executable instruction causes the processor to execute the corresponding operation of the method of the first aspect or the second aspect.
According to a fourth aspect of embodiments of the present application, there is provided a computer storage medium having stored thereon a computer program which, when executed by a processor, implements a method according to the first or second aspect.
According to a fifth aspect of embodiments of the present application, there is provided a computer program product comprising computer instructions for instructing a computing device to perform operations corresponding to the method according to the first aspect or the second aspect.
According to the image data processing scheme provided by the embodiment of the application, when the background color of the image to be processed is identified, at least part of the color components in the color space is reduced to the monochrome color component based on the preset background reference color system (such as a color system corresponding to a preset background object of a curtain, a wall, a display screen and the like), and further, the color range corresponding to the monochrome color component is obtained based on the pixel number distribution of the monochrome color component, and then the background color range is obtained based on the color range corresponding to the monochrome color component. The pixel number distribution can represent different background color conditions, such as the condition that the background color is relatively pure and the condition that the background color span is large, the obtained color range can effectively adapt to the dynamic change of the background color in an actual scene caused by the reason of the preset background object, and the determined background color range is more accurate. In addition, when the color range is calculated, the dimension is reduced to the calculation on the monochromatic color component, so that the time complexity of the calculation and the complexity of the algorithm logic are greatly reduced.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments described in the embodiments of the present application, and other drawings can be obtained by those skilled in the art according to the drawings.
FIG. 1 is a schematic diagram of an exemplary system to which an image data processing method of an embodiment of the present application is applicable;
FIG. 2 is a flowchart illustrating steps of a method for processing image data according to a first embodiment of the present application;
FIG. 3A is a flowchart illustrating steps of a method for processing image data according to a second embodiment of the present application;
FIG. 3B is a process diagram of a specific example of the embodiment shown in FIG. 3A;
FIG. 4 is a flowchart illustrating steps of a method for processing image data according to a third embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic device according to a fourth embodiment of the present application.
Detailed Description
In order to make those skilled in the art better understand the technical solutions in the embodiments of the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, but not all embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application shall fall within the scope of the protection of the embodiments in the present application.
The following further describes specific implementations of embodiments of the present application with reference to the drawings of the embodiments of the present application.
Fig. 1 illustrates an exemplary system to which an image data processing method according to an embodiment of the present application is applied. As shown in fig. 1, the system 100 may include a server 102, a communication network 104, and/or one or more user devices 106, illustrated in fig. 1 as a plurality of user devices.
In some embodiments, the communication network 104 may be any suitable combination of one or more wired and/or wireless networks. For example, the communication network 104 can include any one or more of the following: the network may include, but is not limited to, the internet, an intranet, a Wide Area Network (WAN), a Local Area Network (LAN), a wireless network, a Digital Subscriber Line (DSL) network, a frame relay network, an Asynchronous Transfer Mode (ATM) network, a Virtual Private Network (VPN), and/or any other suitable communication network. The user device 106 can be connected to the communication network 104 by one or more communication links (e.g., communication link 112), and the communication network 104 can be linked to the server 102 via one or more communication links (e.g., communication link 114). The communication link may be any communication link suitable for communicating data between the user device 106 and the server 102, such as a network link, a dial-up link, a wireless link, a hardwired link, any other suitable communication link, or any suitable combination of such links.
In some embodiments, user devices 106 may comprise any suitable type of device. For example, in some embodiments, the user device 106 may include a mobile device, a tablet computer, a laptop computer, a desktop computer, a wearable computer, a game console, a media player, a vehicle entertainment system, and/or any other suitable type of user device.
Although server 102 is illustrated as one device, in some embodiments, any suitable number of devices may be used to perform the functions performed by server 102. For example, in some embodiments, multiple devices may be used to implement the functions performed by the server 102. Alternatively, the functionality of the server 102 may be implemented using a cloud service.
Based on the above system, the present application provides an image data processing method, and the following description is provided by a plurality of embodiments.
Example one
Referring to fig. 2, a flowchart illustrating steps of an image data processing method according to a first embodiment of the present application is shown.
The image data processing method of the present embodiment includes the steps of:
step S202: and obtaining the image to be processed under the preset color space.
The preset color space is a color space capable of reflecting the tone of the image to be processed.
In colorimetry, people establish a plurality of color models, and a certain color is represented by a one-dimensional, two-dimensional, three-dimensional or even four-dimensional space coordinate, and a color range defined by the coordinate system is a color space. More commonly used color spaces are typically three-dimensional, including RGB color spaces, HSV color spaces, HSL color spaces, YUV color spaces, and the like. In the embodiment of the application, for convenience of data processing, a color space capable of reflecting the tone of the image to be processed, such as an HSV color space, an HSL color space and the like, is selected and used. It should be clear to those skilled in the art that if the original image to be processed takes the form of other color spaces, the color space of the original image to be processed is converted into a color space that reflects the color tone of the image to be processed before the image data processing according to the embodiment of the present application. The specific conversion method can be described with reference to the related art, and is not described in detail here.
The color space is generally composed of a plurality of components, which are referred to as color components in the embodiments of the present application. For example, in the RGB color space, it includes an R component, a G component, and a B component; as another example, in HSV color space, it includes an H component, an S component, and a V component, among others. The color space that can reflect the hue of the image to be processed needs to have corresponding color components, such as H color components. The subsequent image data processing can be facilitated based on the color space, and the efficiency of the image data processing is improved. The hue can be measured by angle, and the value range is 0-360 degrees, the hue is calculated from red in a counterclockwise direction, the red is 0 degrees, the green is 120 degrees, the blue is 240 degrees, and the like.
Step S204: according to a background reference color system of the image to be processed, a plurality of color components corresponding to the background reference color system are determined, and at least partial single color components in the plurality of color components are obtained.
As described above, in the solution of the embodiment of the present application, the preset background objects such as a curtain, a wall, a display screen, etc. are generally used, and therefore, the background reference color system can be determined based on the colors of the preset background objects. Based on this background reference color system, non-background colors can be quickly filtered out from the approximate range first. The background reference color system may be determined manually during implementation, or may be obtained by performing rough estimation on color detection of a preset region (usually, a corner region where the background region is located, or the like) in the image to be processed. At this time, the background reference color system is used as an initial color system for subsequently performing more accurate background color range determination, and then provides a relatively better background color determination basis for further processing.
Taking the HSV color space as an example, it includes an H component, an S component, and a V component, and HSV model data is formed by fusing these components together. In this example, the multiple color components of the image to be processed in the HSV color space are HSV model data of the image to be processed, which includes an H component, an S component, and a V component; similarly, a plurality of color components of the background color reference color system in the HSV color space are HSV model data of the background reference color system, which also includes an H component, an S component, and a V component. In addition, in the embodiments of the present application, "color" means a combination of a plurality of components in a color space, and does not mean a specific color (hue). For example, still taking the HSV color space as an example, the color of a pixel means the HSV model data to which the pixel corresponds, not just the H component thereof.
In the case of color space determination, the color component corresponding to the background reference color system may also be determined. For example, if the color space is an HSV color space, the plurality of color components corresponding to the background reference color system include an H component, an S component, and a V component; if the color space is the HSL color space, the plurality of color components corresponding to the background reference color system include an H component, an S component, and an L component.
However, in the color space, the components are merged into a whole, and processing based on the whole results in a complex algorithm and low accuracy of determination for the background color. Therefore, in the embodiment of the present application, after determining the plurality of color components of the background reference color system, the dimension of the plurality of color components may be reduced as a whole. In one way, partial components in the whole can be obtained, such as obtaining the H component and the S component in the HSV color space. In another possible way, the dimensions of the multiple color components of the color space may be reduced integrally, that is, the multiple color components are reduced to the single color components corresponding to different components, for example, the HSV color space is reduced to the separate H component, S component, and V component. When the dimension reduction is specifically performed, the data part corresponding to each color component can be extracted from the whole, or a high-weight mode can be set for the color component needing to be obtained through a weight mode, and other color components are taken as a low-weight mode. Of course, other dimension reduction methods are also applicable.
Taking the case of reducing the dimensions of the plurality of color components corresponding to the background reference color system to the monochrome color components corresponding to different components, the plurality of components corresponding to the monochrome color components are obtained after reducing the dimensions of the plurality of color components to the monochrome color components corresponding to different components. For example, after dimension reduction is performed on HSV in the background reference color system, three corresponding components, namely an H component, an S component and a V component, are obtained respectively.
Step S206: and obtaining a color range corresponding to the monochromatic color component according to the pixel number distribution of the monochromatic color component.
In the embodiment of the present application, the color range corresponding to the monochrome color component is obtained based on the pixel number distribution of the monochrome color component. If all the monochrome color components are obtained in step S204, in this step, the color range corresponding to each monochrome color component is obtained according to the pixel data distribution of each monochrome color component, for example, the color range corresponding to each of the H component, the S component, and the V component is obtained according to the respective pixel number distributions, such as HD, SD, and VD, corresponding to each of the H component, the S component, and the V component. On the other hand, if only a part of the monochrome color components is obtained in step S204, the color range corresponding to each monochrome color component is obtained for the pixel number distribution of each monochrome color component in the part of the monochrome color components in this step. For example, only the H component and the S component are obtained, and the color ranges corresponding to the H component and the S component can be obtained according to the respective pixel number distributions, such as HD and SD, corresponding to the H component and the S component, respectively.
Taking an H (hue) component in an HSV color space as an example, assuming that a background reference color system is a green reference color system, the range is 60-180 degrees, if the number of pixels corresponding to 110 degrees is 140, the number of pixels corresponding to 115 degrees is 1000, and then the number of pixels is continuously increased along with the increase of the degrees, and the number of pixels corresponding to 120 degrees is 1300; further, as the number of degrees increases, the pixel data decreases again, 1000 at 130 degrees, 400 at 140 degrees, and 30 at 142 degrees. Then, in a rough estimation, the H component can be roughly considered to correspond to a color range of 115 degrees to 130 degrees according to the distribution.
In addition, in practical applications, the number of pixels corresponding to the component values in the monochrome color component may be grouped, as shown in the above example, 140 pixels corresponding to 110 degrees are grouped, 1000 pixels corresponding to 115 degrees are grouped, and so on. And the pixels of each group may be sorted according to component values, e.g., sorted from low to high according to H component values, which are (110-
In a feasible manner, the color range corresponding to each monochrome color component can be obtained according to the maximum value and the average value of the pixel number distribution of each monochrome color component.
When the background color is not a pure color, the maximum value and the average value of the pixel number distribution can reflect the change or transition of the background color. As also described above, in the solution of the embodiment of the present application, since the situation of the used preset background is complex, the background in the image to be processed is likely not a pure color. Based on this, in the embodiment of the present application, for each monochromatic color component, the maximum value and the average value of the pixel number distribution of the monochromatic color component are obtained, so as to consider the case that the background color in the background is relatively pure and the portion with a large background color span.
The maximum value and the average value of the pixel number distribution of each single color component can be obtained by counting and calculating the pixels under the dimensionality corresponding to each color component.
In a possible way, this step may be implemented such that, for each monochrome color component, the first color threshold and the second color threshold are respectively determined according to the maximum value and the average value of the distribution of the number of pixels of the monochrome color component; and obtaining the color range corresponding to the single color component by taking the color corresponding to the maximum value as a center color according to the first color threshold value and the second color threshold value.
For example, the first color threshold may be determined by multiplying the maximum value and the average value of the pixel number distribution by coefficients, respectively; and after the first color threshold value is determined, multiplying the coefficient to obtain a second color threshold value.
Illustratively, such as:
threshold1=min(maxVal*a,avgVal*b);
threshold2=threshold1*c
wherein threshold1 represents a first color threshold, threshold2 represents a second color threshold, maxVal represents a maximum value of the pixel number distribution, avgcal represents an average value of the pixel number distribution, min () represents a small value, and a, b, and c are coefficients. In practical applications, a, b, and c can be set by the background color range that one skilled in the art can look for according to practical needs, and b is usually much larger than a and c. For example, a can be 1% -2%, b can be 100% -150%, c can be 5% -10%, etc. That is, if a larger background color range is desired to be found, the threshold1 is made larger by setting a and b, or the threshold2 may be made smaller by setting c. Of course, both may be used. It should be noted that the above formula can be applied to each component in the color space.
Thus, the pixels in the first and second color threshold intervals are made to cover as much as possible the range possible for the background color. Further, for those pixels outside the interval, it does not substantially affect the determination of the background color range, so excluding them outside the interval can also reduce the corresponding data processing load and the amount of calculation.
After the first color threshold value and the second color threshold value are determined, the color corresponding to the maximum value of the pixel number distribution of the single color component is also taken as the center color, and the color range corresponding to the single color component is obtained according to the first color threshold value and the second color threshold value. In one possible approach, the operation may be implemented as: the method comprises the steps of firstly, taking the color corresponding to the maximum value of the pixel number distribution of the single-color component as a central color; obtaining the relation between the pixel quantity corresponding to the central color and a second color threshold value, and obtaining the color range corresponding to the single color component at the time according to the relation; and/or, in the second mode, obtaining a first proportion of the first color threshold value and the number of pixels corresponding to the central color, and a second proportion of the number of pixels corresponding to the central color and the number of pixels of the central color used in the previous determination of the color range corresponding to the single-color component; and obtaining the color range corresponding to the single color component at this time according to the first proportion and the second proportion.
In one possible approach, as previously described, the individual monochrome color components may be grouped, such as according to component values, and sorted to form a corresponding sorted sequence. Based on this, the above process can be realized as a process of performing searches in two directions to both sides of the sorting sequence respectively with the center color as the center, and any one of the groups on both sides is truncated without satisfying the above manner, and the downward search is not continued.
In order to make the obtained background color range more accurate, the image data processing of the embodiment of the present application is implemented as an iterative loop execution process, that is, after the background color range is determined once, the background color range is used as a new background reference color system, and the process returns to step S204 to continue execution until an iteration termination condition is met, such as iteration is performed to a preset number of times or a difference between the currently determined background color range and the previously determined background color range is within a preset small range.
Based on this, in one iteration, according to the first method, the color range corresponding to the monochrome color component may be determined according to the relationship between the number of pixels corresponding to the current center color and the second color threshold. For example, if the number of pixels corresponding to the center color is less than the second color threshold, it may be determined that the center color may be excluded. This is because the second color threshold is a small number, and for most images, the background color is generally relatively concentrated and appears continuously distributed on the histogram, so if the number of pixels of the center color is smaller than the second color threshold, the probability of belonging to the background color is small, and the search in the direction can be stopped. By the mode, the non-background color can be accurately and quickly eliminated, and the background color range determination efficiency is improved.
In most cases, the center color is not less than the second color threshold, so that a second way can be used to determine whether the center color falls within the background color range. The proportion condition between the number of pixels of the center color and the number of pixels of the background color represented by the first color threshold value can be obtained through the first proportion; through the second proportion, the decreasing rate of the number of pixels corresponding to the central color twice can be obtained. If the value determined based on both is greater than some cutoff threshold, the center color will be considered to belong to the background color range. By the method, two aspects of the pixel quantity and the descending speed of the pixel quantity are comprehensively considered, whether the center color belongs to the background color range or not can be judged more effectively, and the self-adaption degree of background color determination is improved. Generally, the faster the falling speed, the less likely it is to belong to the background color range.
In one example, approach two may be implemented in the form of the following equation:
pow (threshold1/currentVal, pow (currentVal/lastVal, exp)) > targetThreshold, wherein currentVal represents the number of pixels corresponding to the current central color, lastVal represents the number of pixels corresponding to the previous central color, pow () represents an exponential function, exp represents a specific exponent, which is generally clearly >1, and targetThreshold represents a truncation threshold. That is, if the result calculated by the above formula > targetThreshold, it indicates that the current center color belongs to the background color range.
Step S208: and obtaining the background color range of the image to be processed based on the color range corresponding to the single color component.
After the color range corresponding to each single color component in the at least part of single color components is obtained, each single color component can be fused into a whole, for example, the H component, the S component and the V component are fused into HSV model data together, and the background color range of the image to be processed is obtained based on the HSV model data.
In a practical implementation, in one possible way, other colors except for the color range corresponding to each single color component in the multiple color components can be removed; and obtaining the background color range of the image to be processed according to the plurality of color components after being removed. Thus, the obtained background color range is more accurate.
In one example scenario, it is assumed that the original image is an RGB image, and the background scene is a green curtain with folds. Then, it is transformed into HSV space to become HSV image as the image to be processed.
As can be seen from the above, the background reference color system in the HSV image is the green color system in the HSV space, so that the range of the hue in the neighborhood centered at 120 degrees, such as 60-180 degrees, can be determined as the range of the background reference color system of the HSV image. Accordingly, the range corresponds to the corresponding HSV model data. In this example, based on the HSV model data, the dimension reduction is performed, and the H component, the S component, and the V component are respectively obtained to form three single component data.
Further, a maximum value 1 and an average value 1 of the pixel number distribution of the H component, a maximum value 2 and an average value 2 of the pixel number distribution of the S component, and a maximum value 3 and an average value 3 of the pixel number distribution of the V component are acquired. In this example, for the H component, based on the maximum value 1 and the average value 1, the color range 1 is obtained, and then, corresponding to the HSV model data, colors other than the color corresponding to the color range 1 in the HSV model data are removed (referred to as first removal); then, for the S component in the HSV model data after the first culling, obtaining a color range 2 based on a maximum value 2 and an average value 2, and then, corresponding to the HSV model data, culling colors (called as second culling) except the color corresponding to the color range 2 in the HSV model data after the first culling; then, for the V component in the HSV model data after the second culling, based on the maximum value 3 and the average value 3, the color range 3 is obtained, and then the V component is added to the HSV model data, and colors except for the color corresponding to the color range 3 in the HSV model data after the second culling are culled (referred to as third culling). And determining the background color range of the HSV image according to the obtained HSV model data subjected to the third elimination, wherein the colors corresponding to the range are the background colors of the HSV image.
It should be noted that the above elimination manner is only an exemplary manner, and in practical applications, other manners of obtaining the background color range of the HSV image may also be adopted, such as operating each monochromatic color component respectively to obtain the color range corresponding to each monochromatic color component, and then performing integration based on these color ranges, and the like, which are all within the protection scope of the embodiment of the present application.
As can be seen, according to this embodiment, when the background color of the image to be processed is identified, at least part of the plurality of color components in the color space is reduced to the monochrome color component based on the predetermined background reference color system (e.g., a color system corresponding to a predetermined background object such as a curtain, a wall, or a display screen), and then the color range corresponding to the monochrome color component is obtained based on the pixel number distribution of the monochrome color component, and then the background color range is obtained based on the color range corresponding to the monochrome color component. The pixel number distribution can represent different background color conditions, such as the condition that the background color is relatively pure and the condition that the background color span is large, the obtained color range can effectively adapt to the dynamic change of the background color in an actual scene caused by the reason of the preset background object, and the determined background color range is more accurate. In addition, when the color range is calculated, the dimension is reduced to the calculation on the monochromatic color component, so that the time complexity of the calculation and the complexity of the algorithm logic are greatly reduced.
Example two
Referring to fig. 3A, a flowchart illustrating steps of an image data processing method according to a second embodiment of the present application is shown.
In this embodiment, how to accurately determine the background reference color system is taken as an emphasis point to describe the image data processing method in the embodiment of the present application.
The image data processing method of the present embodiment includes the steps of:
step S302: and obtaining the image to be processed under the preset color space.
The preset color space is a color space capable of reflecting the tone of the image to be processed.
For the specific implementation of this step, reference may be made to the related description in the foregoing first embodiment, and details are not described herein again.
Step S304: and determining a background reference color system of the image to be processed.
In one possible approach, a predetermined background color system of the image to be processed may be obtained; and determining a neighborhood color space corresponding to the preset background color system according to a preset first neighborhood amplitude range, and determining a background reference color system of the image to be processed according to the neighborhood color space. For example, if the preset background scene is a green curtain, in the HSV space corresponding to the image to be processed, a range of a hue in a neighborhood centered at 120 degrees, such as 60 degrees to 180 degrees, may be determined as the background reference color system of the image.
In this way, on one hand, based on the background reference color system, non-background colors can be quickly filtered out from the approximate range; on the other hand, the predetermined background color system can be used as an initial reference of a subsequent background color system, and on the other hand, the background color range can be restricted in a neighborhood space with the corresponding background reference color as the center for subsequent data processing, so that the accuracy of the subsequently obtained background color can be ensured, and the data processing speed and efficiency can be greatly improved.
Further optionally, when the background reference color system of the image to be processed is determined according to the neighborhood color space, the neighborhood color space may be divided into a plurality of color regions of a first region granularity according to a preset first color region division granularity; determining a background reference color according to the color densest area in each color area; and determining a background reference color system of the image to be processed according to the background reference color. Therefore, the data processing complexity is reduced, more accurate background center color can be determined more quickly, and the reliability of calculating the background center color is ensured. The first color region partition granularity may be set by a person skilled in the art according to actual requirements, for example, in an HSV space, a neighborhood color space corresponding to a predetermined background color system may be partitioned into a space of nH × nS × nV, where nH, nS, and nV are the number of regions for uniformly partitioning the H component, the S component, and the V component of the neighborhood color space, respectively. Illustratively, n may be 30-10.
However, in order to further improve the accuracy of determining the background color range, in a feasible manner, according to the background reference color, determining the background reference color system of the image to be processed may be implemented as: determining a candidate background reference color system of the image to be processed according to the background reference color; determining a neighborhood color space corresponding to the candidate background reference color system according to a preset second neighborhood amplitude range, wherein the second neighborhood amplitude range is smaller than the first neighborhood amplitude range; dividing a neighborhood color space corresponding to the candidate background reference color system into a plurality of color areas with second area granularity according to preset second color area granularity; and determining a background reference color system of the image to be processed according to the color densest area in each color area. The second color region granularity may be smaller than the first color region granularity, or may be the same as the first color region granularity.
For example, still taking the HSV space as an example, after determining the candidate background reference color system, the HSV model data corresponding to the candidate background reference color system may be divided again, for example, uniformly divided into a space of mH mS mV, where mH mS mV is the number of regions where the H component, the S component, and the V component of the neighborhood color space are uniformly divided. Illustratively, m may be 20-10.
Until, although the background color system range can be determined more accurately, some noise data may be included therein, in order to make the obtained result more accurate and pure, in a feasible manner, the determination of the background reference color system of the image to be processed according to the most dense color areas in each color area may be implemented as follows: determining the background central color of the image to be processed according to the color densest area in each color area; with the background central color as a color center, eliminating colors, the color difference of which with the color center exceeds a preset difference threshold value, in a neighborhood color space corresponding to a candidate background reference color system; and determining a background reference color system of the image to be processed according to the elimination result.
Therefore, the background color range is determined by dividing the color space model into a plurality of levels, and the calculation complexity and the time complexity caused by calculation by taking the color space model data as a whole can be effectively reduced while the reliability of the calculation result is ensured.
Step S306: and determining a plurality of color components corresponding to the background reference color system for the image to be processed according to the background reference color system of the image to be processed.
For example, the background reference color system corresponds to multiple components of HSV space, or multiple components of HSL space, etc. Specific implementation means thereof can be seen from description in related art, and detailed description is omitted here.
Step S308: and reducing the dimensions of the plurality of color components to the single color components corresponding to different components respectively.
Step S310: and obtaining the color range corresponding to each monochromatic color component according to the pixel number distribution of each monochromatic color component.
The detailed implementation of the steps S308 to S310 can refer to the description of the relevant parts in the first embodiment, and will not be described herein again.
Step S312: and obtaining the background color range of the image to be processed based on the color range corresponding to each single color component.
The method comprises the following steps: obtaining a corresponding candidate background color range based on the color range corresponding to each single color component; taking the candidate background color range as a new background reference color system, returning to the background reference color system according to the image to be processed, and iteratively executing the operation (step S306) of determining a plurality of color components corresponding to the background reference color system for the image to be processed until an iteration termination condition is reached; and taking the candidate background color range at the termination of the iteration as the background color range of the image to be processed.
The iteration termination condition may be that the background color range obtained by the current calculation is consistent with the previous calculation result, or the number of times of the iteration calculation reaches a preset upper limit, and the like.
By the multi-round iterative calculation mode, the detection range aiming at the background color range can be continuously narrowed to approach to the true background color distribution range, and the single calculation complexity is low, and the overall calculation complexity and accuracy are good.
Hereinafter, the above-described process is exemplified by a specific example, and the image data processing process of this example is shown in fig. 3B.
The process comprises the following steps:
(A) and adjusting the resolution of the image to be processed to be a preset resolution.
The specific value of the preset resolution can be set by those skilled in the art according to actual needs, and this example does not limit this. If the resolution of the image to be processed is consistent with the preset resolution, the step is not required to be executed.
(B) And converting the image to be processed into a target color space.
In this example, the target color space is HSV color space, and the original image is converted into HSV image, but it should be clear to those skilled in the art that other color spaces capable of reflecting the hue of the image to be processed may also implement corresponding image data processing with reference to this example.
(C) And according to the specified background reference color system, a neighborhood color space is defined, and pixel points with the color distance obviously too far away from the background reference color system are eliminated.
Wherein, whether the color distance from the background reference color system is too far can be judged by setting a corresponding threshold value. For example, if the designated reference background color is green, pixels with hue not included in the neighborhood centered at 120 degrees (e.g., 60-180 degrees) or with low saturation (less than a predetermined saturation threshold, e.g., 10%) are excluded.
For convenience of description, in this example, the defined neighborhood color space is referred to as a first neighborhood color space.
(D) And dividing the first neighborhood color space into uniform regions of the first region granularity according to the first color region granularity, so that the color space in the neighborhood is uniformly divided into a 3-dimensional space of nH nS nV. Where nH, nS, and nV are the number of regions that evenly divide H, S, V of the neighborhood color space, respectively. Illustratively, n may be 30.
(E) In a plurality of uniform areas of the first area granularity corresponding to the first neighborhood color space, calculating the distribution condition (full component) of the pixels of the HSV image which are not removed, and obtaining a relatively reliable background reference color according to the area with the densest distribution.
For convenience of description, the color space in the case of the full component is simply referred to as 3-dimensional gradation in the drawing.
In addition, if there is a case where the number of regional pixels is too small (for example, the ratio of the number of pixels in the first neighborhood color space is less than 2%) in the obtained background reference color, the abnormal condition is treated (the calculation is terminated, and it is determined that there is no background object).
(F) And defining a smaller color neighborhood space by taking the background reference color as a center.
In this example, the exact background color range is computed by specifically probing the smaller color neighborhood space, and pixels outside the neighborhood interval are culled.
The range of the smaller color neighborhood space can be set by those skilled in the art according to practical situations, and is smaller than the neighborhood range in (C) above. Illustratively, pixels whose hue is not included in a neighborhood centered at 120 degrees (e.g., 39-150 degrees) are culled centered around the background reference color as green.
In addition, in this example, for the convenience of distinguishing, the background reference color system corresponding to the smaller color neighborhood space is referred to as a candidate background reference color system.
(G) And dividing the smaller color neighborhood space into a plurality of uniform intervals according to the granularity of the second color region.
For example, the smaller color neighborhood space is uniformly divided into mH mS mV color space, where mH, mS, mV are the number of regions into which H, S, V of the smaller neighborhood color space is uniformly divided, respectively, where mH/mS/mV may be equal to nH/nS/nV in (D), or may be adjusted to different values as needed.
(H) In the smaller color neighborhood space, the distribution (full component) of the remaining pixels after the pixels are removed in the step (F) is calculated, and the more accurate background center color is calculated according to the most densely distributed area.
(I) And taking the more accurate central color of the background as a center, and eliminating the color which is too far away from the central color of the background.
This step may directly perform processing on the result of the pixel distribution in the color neighborhood space calculated in (H), and the culling method may use, for example, manhattan distance or chebyshev distance, or the like.
A color distance threshold may be set, and if the color distance is greater than the threshold, the color is considered too far from the center of the background. The threshold may be set by a person skilled in the art according to actual situations, and the embodiment of the present application does not limit this. Illustratively, the threshold may be a hue value of 10-15 degrees, or the like.
(J) To reduce computational complexity, the full components of HSV are reduced to single components.
For example, in HSV, a dimension reduction will result in an H component, an S component, and a V component, which are all one-dimensional gradations.
For convenience of description, the H component is only used as an example in the figure, but it should be understood by those skilled in the art that the processing of the H component can be referred to for the processing of other components.
(K) And respectively multiplying the maximum value and the average value of each one-dimensional color gradation by the corresponding coefficient to determine a minimum value as a first color threshold value, and reducing the first color threshold value by a certain multiple to determine a second color threshold value.
For example, threshold1 ═ min (maxVal a, avgVal b);
threshold2=threshold1*c;
wherein threshold1 represents the first color threshold, threshold2 represents the second color threshold, maxVal represents the maximum value, avgVal represents the average value, min () represents the small value, and a, b, and c are all coefficients. In practical applications, a, b, and c can be set by the background color range that one skilled in the art can look for according to practical needs, and b is usually much larger than a and b. For example, a can be 1% -2%, b can be 100% -150%, c can be 5% -10%, etc. That is, if a larger background color range is desired to be found, the threshold1 is made larger by setting a and b, or the threshold2 may be made smaller by setting c. Of course, both may be used. It should be noted that the above formula can be applied to each component in the color space.
It should be noted that, for each component, there are its corresponding threshold1 and threshold 2.
(L) a distribution range of each component in two directions with a maximum value corresponding to each component as a center, for each component, based on threshold1 and threshold 2.
For example, taking the H component as an example, according to the threshold1 and threshold2 of the H component, the distribution range search of the H component is performed with the maximum value of the H component as the center.
Wherein the logic of searching is: and if the number of pixels corresponding to the current maximum value is less than the second color threshold value, truncating, namely excluding the possible background color range.
Or,
if the pixel number corresponding to the current maximum value is smaller than the first color threshold value, and the first color threshold value, the pixel number corresponding to the current maximum value and the pixel number corresponding to the maximum value used in the previous search satisfy the following conditions:
pow(threshold1/currentVal,pow(currentVal/lastVal,exp))>targetThreshold,
it can be classified into a range of possible background colors.
Where currentVal represents the number of pixels corresponding to the current maximum value, lastVal represents the number of pixels corresponding to the maximum value used in the previous search, exp is a specific index, typically clearly >1, and targetThreshold represents the specified truncation threshold.
By this procedure, a range of possible background colors, which is referred to as a background color plausible range of a certain component in the present example, can be obtained. Such as the background color gamut of the H component. Similarly, the above-mentioned processing is performed on each component, and the background color pseudo range corresponding to each component is obtained.
And (M) according to the background color suspected range of each component, removing the parts except the background color suspected range in the neighborhood color space subjected to color removal in the step (I).
In one possible approach, the culling may be done directly on the 3-dimensional tone scale.
Thus, the background color range of the current round of calculation can be obtained.
And (N) after 1 round of processing from (C) to (M) is finished, continuing the processing of the 2 nd round until the background color range obtained by certain calculation is consistent with the calculation result of the previous round or the calculation repetition number reaches a preset upper limit.
The background color range at the termination of the iteration may be finally determined as the background color range of the image to be processed.
Through the embodiment, (1) the background color range is restricted to be searched in a neighborhood space with a certain reference background color as a center, so that the searching speed and efficiency are improved; (2) the full-component model data of the background reference color system is calculated in a plurality of levels and different region granularities, so that the reliability of calculating the central color of the background is ensured, and the color space calculation complexity and the time complexity of subsequent searching are greatly reduced; (3) when the background color range is calculated, dimension reduction is respectively carried out on the components for searching, so that the time complexity of calculation and the complexity of algorithm logic are greatly reduced; (4) when the background color range is searched on a single component, the maximum value and the average value are used, and the situation that the background color is relatively pure and the span is large is taken into consideration; when searching in 2 directions by taking the maximum value as the center, the proportion of the pixel number corresponding to the current maximum value in the suspected background range and the rate of the decrease of the pixel number are considered, and the self-adaptive capacity of various scenes is good; (5) through multi-round iterative computation, the search range is continuously narrowed to approach the distribution range of the real background color, the complexity of single computation is low, and the overall computation complexity and accuracy are good.
EXAMPLE III
Referring to fig. 4, a flowchart illustrating steps of an image data processing method according to a third embodiment of the present application is shown.
Step S402: and acquiring the image to be processed and a preset background reference color system of the image to be processed.
In this embodiment, the image to be processed is an image to be subjected to foreground and background segmentation, and may be a single still image or a video frame image in a video, including but not limited to: video frame images in a video conference, director images of a studio director, live images in a video live, images to be AR (augmented reality) processed, images for video production, and the like.
The background reference color system for the image to be processed may be set manually, for example, may be preset according to the color of the background object in the image to be processed.
Step S404: and converting the image to be processed into a preset color space, and determining a plurality of color components of the background reference color system in the preset color space.
The preset color space is a color space capable of reflecting the hue of the image to be processed, and includes but is not limited to HSV color space, HSL color space, and the like.
In general, the image to be processed is mostly an RGB image, and therefore, it needs to be converted into a color space capable of reflecting hue, such as an HSV color space or an HSL color space. Correspondingly, the background reference color system also needs to be consistent with the color space adopted by the image to be processed, i.e. the color space capable of reflecting the color tone is also needed.
Step S406: and obtaining the background color range of the image to be processed based on the pixel number distribution of at least part of single-color components in the plurality of color components of the background reference color system.
In one possible approach, at least a portion of the single color components of the plurality of color components of the background reference color system may be obtained; obtaining a color range corresponding to the monochromatic color component according to the pixel number distribution of the monochromatic color component; and obtaining the background color range of the image to be processed based on the color range corresponding to the single color component.
Step S408: and performing background segmentation processing on the image to be processed based on the background color range.
After the background color range of the image to be processed is determined, the background area of the image to be processed can be determined, foreground and background segmentation can be further carried out, and further subsequent processing is carried out based on the result of the foreground and background segmentation.
It should be noted that the above process is described simply, and the detailed implementation of each step may refer to the description of relevant parts in the foregoing embodiments.
In the following, taking different scenes as examples, the background segmentation of the image to be processed is exemplarily described.
Scene one: video conference scenario
In many video conferences there is often a need for content presentation or product presentation or other background replacement. Therefore, when a video conference is to be held, a background scene is set in a physical conference place, and image acquisition of the video conference is carried out by taking the background scene as a background. Then, for each frame of video frame image in the video stream of the video conference collected in real time, the background color range is determined by using the image data processing method, the background area is determined based on the background color range, and then foreground and background segmentation is carried out based on the background area. Then, the foreground part, such as the image part of the speaker of the conference, etc., is retained, and the divided background part is replaced with the image part including the content to be presented (such as the PPT content), or the image part including the product to be presented (such as the product picture), or simply replaced with the background image part conforming to the subject of the conference, etc. Therefore, effective combination of the conference and the conference content is realized.
Scene two: live or studio director scene
Similar to video conferencing, there is also a content display or product display or scene display requirement in such scenes. Taking live broadcasting for tourism as an example, the anchor program needs to introduce special products, scenery and the like of scenic spots, and can attract audiences by using scenic pictures of the scenic spots. Based on the background, a background scene can be preset in the physical live broadcast room, and live broadcast with the background scene as a background is carried out. In the live broadcast process, aiming at each frame of video frame image in the live broadcast video stream, the image data processing method is used for determining the background color range, determining the background area based on the background color range, and further performing foreground and background segmentation based on the background area. Then, the foreground part is reserved, such as the image part of the anchor, and the divided background part is replaced by the image part including the special feature content of the scenery to be shown, or the image part of the known scenery of the scenery, or the image part of the scenery picture of the scenery, and so on. Therefore, effective display of live content is achieved. The studio director scene is similar to this, and is not described in detail.
Scene three: online education scene
Similar to video conferencing, content presentation is also performed in online education. Therefore, a background scene may be first preset in a physical space such as a physical classroom, and an explanation may be made with the background scene as a background. The method comprises the steps of recording a video in the explanation process of a teacher, determining the background color range of each frame of video frame image in the video by using the image data processing method, determining the background area of each frame of video frame image based on the background color range, and further performing foreground background segmentation based on the background area. Then, a foreground portion such as an image portion of a teacher or the like is retained, and the divided background portion is replaced with an image portion including courseware contents to be presented, or an image portion of a graphic drawing (dynamic or static) related to the lecture contents or the like. Therefore, vivid and vivid classroom content display is realized.
Scene four: AR scene
Whether for video frame images in a video stream or for a single still image, there may be a possibility to use the AR effect. For example, AR objects (e.g., red envelope or pet, etc.) are added to video frame images to interact with the video audience, or AR objects (e.g., text notes or interesting instructions or portrait decorations, etc.) are added to still images. Under these circumstances, if the image to be processed has relatively few background colors, the background reference color system corresponding to the background colors may be determined first, and then the background color range is determined by using the image data processing method, and then the background area in the video frame image or the static image is determined, and the addition of the corresponding AR effect is performed based on the background area. But not limited to this, can also replace its whole with AR effect to whole background area that determines to satisfy different demands, for example interactive demand or taste demand, promote user experience.
Scene five: video production scene
In the process of making video, the background of some images to be used is usually found to be undesirable and needs to be modified. In this case, if the image to be processed has relatively few background colors, the background reference color system corresponding to the background color may be determined first, then the background color range is determined by using the image data processing method, then the background region in the image to be used is determined, and the background region is modified or replaced, so as to satisfy the overall requirements of the video to be produced and achieve the overall improvement of the video effect.
Therefore, through the embodiment, services can be provided for various different use scenes on the basis of actually generating the background area of the image and performing the front background segmentation, the requirements of different use scenes are greatly met, and the user experience is improved.
Example four
Referring to fig. 5, a schematic structural diagram of an electronic device according to a fourth embodiment of the present application is shown, and the specific embodiment of the present application does not limit a specific implementation of the electronic device.
As shown in fig. 5, the electronic device may include: a processor (processor)502, a Communications Interface 504, a memory 506, and a communication bus 508.
Wherein:
the processor 502, communication interface 504, and memory 506 communicate with one another via a communication bus 508.
A communication interface 504 for communicating with other electronic devices or servers.
The processor 502 is configured to execute the program 510, and may specifically execute relevant steps in any of the above-described embodiments of the image data processing method.
In particular, program 510 may include program code that includes computer operating instructions.
The processor 502 may be a CPU, or an Application Specific Integrated Circuit (ASIC), or one or more Integrated circuits configured to implement embodiments of the present application. The intelligent device comprises one or more processors which can be the same type of processor, such as one or more CPUs; or may be different types of processors such as one or more CPUs and one or more ASICs.
And a memory 506 for storing a program 510. The memory 506 may comprise high-speed RAM memory, and may also include non-volatile memory (non-volatile memory), such as at least one disk memory.
The program 510 may be specifically configured to enable the processor 502 to execute operations corresponding to the image data processing method described in the foregoing embodiment one, two, or three.
For specific implementation of each step in the program 510, reference may be made to corresponding steps and corresponding descriptions in units in the foregoing embodiments of the image data processing method, and corresponding beneficial effects are provided, which are not described herein again. It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described devices and modules may refer to the corresponding process descriptions in the foregoing method embodiments, and are not described herein again.
The embodiment of the present application further provides a computer program product, which includes computer instructions for instructing a computing device to execute an operation corresponding to any one of the image data processing methods in the foregoing method embodiments.
It should be noted that, in the embodiments of the present application, the color space is taken as an HSV space as an example, but it should be clear to those skilled in the art that other manners for determining the background color range of the color space capable of reflecting the hue may be implemented by referring to the embodiments of the present application, such as an HSL space, a YUV space, and the like.
It should be noted that, according to the implementation requirement, the components/steps described in the embodiments of the present application may be split into more components/steps, or two or more components/steps or partial operations of the components/steps may be combined into new components/steps to achieve the purpose of the embodiments of the present application.
The above-described methods according to embodiments of the present application may be implemented in hardware, firmware, or as software or computer code storable in a recording medium such as a CD ROM, a RAM, a floppy disk, a hard disk, or a magneto-optical disk, or as computer code originally stored in a remote recording medium or a non-transitory machine-readable medium downloaded through a network and to be stored in a local recording medium, so that the methods described herein may be stored in such software processes on a recording medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware such as an ASIC or FPGA. It will be appreciated that the computer, processor, microprocessor controller or programmable hardware includes memory components (e.g., RAM, ROM, flash memory, etc.) that can store or receive software or computer code that, when accessed and executed by the computer, processor or hardware, implements the image data processing methods described herein. Further, when a general-purpose computer accesses code for implementing the image data processing method shown herein, execution of the code converts the general-purpose computer into a special-purpose computer for executing the image data processing method shown herein.
Those of ordinary skill in the art will appreciate that the various illustrative elements and method steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the embodiments of the present application.
The above embodiments are only used for illustrating the embodiments of the present application, and not for limiting the embodiments of the present application, and those skilled in the relevant art can make various changes and modifications without departing from the spirit and scope of the embodiments of the present application, so that all equivalent technical solutions also belong to the scope of the embodiments of the present application, and the scope of patent protection of the embodiments of the present application should be defined by the claims.
Claims (14)
1. An image data processing method, comprising:
obtaining an image to be processed under a preset color space, wherein the preset color space is a color space capable of reflecting the tone of the image to be processed;
determining a plurality of color components corresponding to the background reference color system according to the background reference color system of the image to be processed, and obtaining at least partial single-color components in the plurality of color components;
obtaining a color range corresponding to the monochromatic color component according to the pixel number distribution of the monochromatic color component;
and obtaining the background color range of the image to be processed based on the color range corresponding to the single color component.
2. The method according to claim 1, wherein the obtaining the color range corresponding to the monochrome color component according to the pixel number distribution of the monochrome color component comprises:
for each monochrome color component of the at least part of monochrome color components, respectively determining a first color threshold value and a second color threshold value according to the maximum value and the average value of the pixel number distribution of the monochrome color component;
and obtaining the color range corresponding to the single color component according to the first color threshold value and the second color threshold value by taking the color corresponding to the maximum value as a center color.
3. The method according to claim 2, wherein obtaining the color range corresponding to the monochrome color component according to the first color threshold and the second color threshold comprises:
obtaining the relation between the pixel quantity corresponding to the central color and the second color threshold value, and obtaining the color range corresponding to the single color component at this time according to the relation;
and/or obtaining a first proportion of the first color threshold value and the number of pixels corresponding to the central color, and a second proportion of the number of pixels corresponding to the central color and the number of pixels of the central color used in the previous determination of the color range corresponding to the single color component; and obtaining the color range corresponding to the single color component at this time according to the first proportion and the second proportion.
4. The method according to any one of claims 1 to 3, wherein the obtaining the background color range of the image to be processed based on the color range corresponding to the single color component comprises:
removing other colors except the color range corresponding to each single color component in the plurality of color components;
and obtaining the background color range of the image to be processed according to the plurality of color components after being removed.
5. The method according to claim 1, wherein before the determining a plurality of color components corresponding to the background reference color system according to the background reference color system of the image to be processed, the method further comprises:
obtaining a preset background color system of the image to be processed;
and determining a neighborhood color space corresponding to the preset background color system according to a preset first neighborhood amplitude range, and determining a background reference color system of the image to be processed according to the neighborhood color space.
6. The method of claim 5, wherein the determining a background reference color system of the image to be processed from the neighborhood color space comprises:
dividing the neighborhood color space into a plurality of color areas with first area granularity according to preset first color area division granularity;
determining a background reference color according to the color densest area in each color area;
and determining a background reference color system of the image to be processed according to the background reference color.
7. The method according to claim 6, wherein the determining the background reference color of the image to be processed according to the background reference color comprises:
determining a candidate background reference color system of the image to be processed according to the background reference color;
determining a neighborhood color space corresponding to the candidate background reference color system according to a preset second neighborhood amplitude range, wherein the second neighborhood amplitude range is smaller than the first neighborhood amplitude range;
dividing a neighborhood color space corresponding to the candidate background reference color system into a plurality of color areas with second area granularity according to preset second color area granularity;
and determining a background reference color system of the image to be processed according to the color densest area in each color area.
8. The method according to claim 7, wherein the determining a background reference color system of the image to be processed according to the most dense color region in each color region comprises:
determining the background central color of the image to be processed according to the color densest area in each color area;
with the background central color as a color center, eliminating colors, of which the color difference with the color center exceeds a preset difference threshold value, in a neighborhood color space corresponding to the candidate background reference color system;
and determining a background reference color system of the image to be processed according to the elimination result.
9. The method according to claim 1, wherein the obtaining the background color range of the image to be processed based on the color range corresponding to the single color component comprises:
obtaining a corresponding candidate background color range based on the color range corresponding to the single color component;
taking the candidate background color range as a new background reference color system, returning the background reference color system according to the image to be processed, and determining the operation iteration execution of a plurality of color components corresponding to the background reference color system for the image to be processed until an iteration termination condition is reached;
and taking the candidate background color range when the iteration is terminated as the background color range of the image to be processed.
10. An image data processing method, comprising:
acquiring an image to be processed and a preset background reference color system of the image to be processed;
converting the image to be processed into a preset color space, and determining a plurality of color components of the background reference color system in the preset color space, wherein the preset color space is a color space capable of reflecting the color tone of the image to be processed;
obtaining a background color range of the image to be processed based on the pixel number distribution of at least part of single-color components in the plurality of color components of the background reference color system;
and performing background segmentation processing on the image to be processed based on the background color range.
11. The method according to claim 10, wherein the obtaining the background color range of the image to be processed based on the pixel number distribution of at least part of single color components in the plurality of color components of the background reference color system comprises:
obtaining at least a portion of the single color components of the plurality of color components of the background reference color system;
obtaining a color range corresponding to the monochromatic color component according to the pixel number distribution of the monochromatic color component;
and obtaining the background color range of the image to be processed based on the color range corresponding to the single color component.
12. An electronic device, comprising: the system comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface complete mutual communication through the communication bus;
the memory is used for storing at least one executable instruction which causes the processor to execute the corresponding operation of the method according to any one of claims 1-11.
13. A computer storage medium having stored thereon a computer program which, when executed by a processor, carries out the method of any one of claims 1 to 11.
14. A computer program product comprising computer instructions to instruct a computing device to perform operations corresponding to the method of any of claims 1-11.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111674842.1A CN114399523A (en) | 2021-12-31 | 2021-12-31 | Image data processing method, electronic device, and computer storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111674842.1A CN114399523A (en) | 2021-12-31 | 2021-12-31 | Image data processing method, electronic device, and computer storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114399523A true CN114399523A (en) | 2022-04-26 |
Family
ID=81229375
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111674842.1A Pending CN114399523A (en) | 2021-12-31 | 2021-12-31 | Image data processing method, electronic device, and computer storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114399523A (en) |
-
2021
- 2021-12-31 CN CN202111674842.1A patent/CN114399523A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107516319B (en) | High-precision simple interactive matting method, storage device and terminal | |
CN101635859B (en) | Method and device for converting plane video to three-dimensional video | |
WO2018082185A1 (en) | Image processing method and device | |
CN100514367C (en) | Color segmentation-based stereo 3D reconstruction system and process | |
JP7461478B2 (en) | Method and Related Apparatus for Occlusion Handling in Augmented Reality Applications Using Memory and Device Tracking - Patent application | |
CN110248242B (en) | Image processing and live broadcasting method, device, equipment and storage medium | |
JP2008547097A (en) | Image segmentation | |
CN107507144B (en) | Skin color enhancement processing method and device and image processing device | |
US10171785B2 (en) | Color balancing based on reference points | |
US10846887B2 (en) | Machine vision processing system | |
CN111556227B (en) | Video denoising method and device, mobile terminal and storage medium | |
CN113688907B (en) | A model training and video processing method, which comprises the following steps, apparatus, device, and storage medium | |
CN113301409B (en) | Video synthesis method and device, electronic equipment and readable storage medium | |
CN109859236B (en) | Moving object detection method, system, computing device and storage medium | |
CN111491149B (en) | Real-time image matting method, device, equipment and storage medium based on high-definition video | |
CN114677394B (en) | Matting method, matting device, image pickup apparatus, conference system, electronic apparatus, and medium | |
CN113505799B (en) | Significance detection method and training method, device, equipment and medium of model thereof | |
CN110569859A (en) | Color feature extraction method for clothing image | |
JP7374582B2 (en) | Image processing device, image generation method and program | |
CN111667541B (en) | Image color quantization method, device, electronic equipment and storage medium | |
WO2022217470A1 (en) | Hair rendering system based on deep neural network | |
CN114677393B (en) | Depth image processing method, depth image processing device, image pickup apparatus, conference system, and medium | |
CN114399523A (en) | Image data processing method, electronic device, and computer storage medium | |
CN112435173A (en) | Image processing and live broadcasting method, device, equipment and storage medium | |
CN110996173B (en) | Image data processing method and device and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |