Color balancing method, device and electronic equipment

CN113807065BActive Publication Date: 2024-10-18NEUSOFT CORP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111062795.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-10
Publication Date
2024-10-18
Estimated Expiration
2041-09-10

AI Technical Summary

Technical Problem

When designing charts in the prior art, unbalanced color proportions lead to uncoordinated visual effects. Especially when the data is uneven, the color proportions of charts rendered by the same theme are out of balance.

Method used

By obtaining the proportion of each data block in the album, calculate the proportion value and standard deviation of each color. If the standard deviation is greater than the preset threshold, replace the color with a proportion greater than the average value to a color with a proportion less than the average value until the standard If the difference is less than the threshold, adjust the color balance of the album.

Benefits of technology

The balance adjustment of the color of the album is realized, making the color of the album closer to balance and improving the visual effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113807065B_ABST
    Figure CN113807065B_ABST
Patent Text Reader

Abstract

The present invention discloses a color balancing method, device and electronic device, including: obtaining the proportion of each data block in an atlas, each data block is filled with a color, calculating the proportion value of each color in the atlas based on the proportion of each data block, calculating the standard deviation of the proportion value of each color based on the proportion value of each color, and when the standard deviation is greater than a preset threshold, changing the color of some data blocks in the data blocks corresponding to the first target color in at least one group of replacement colors to a second target color until the standard deviation is less than the preset threshold; wherein each group of replacement colors includes a first target color whose color proportion value is greater than an average value and a second target color whose color proportion value is less than an average value. Thus, by replacing the color whose proportion value is greater than the average value with the color whose proportion value is less than the average value, the balance of the atlas color is adjusted, so that the color of the atlas tends to be balanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of visualization technology, and in particular to a color balancing method, device and electronic equipment. Background Art

[0002] When designing a chart, in order to reflect the difference between different data, colors are usually used to distinguish the different data displayed in the chart. In addition, different themes are designed in advance for the convenience of users. The same theme includes a set of colors pre-designed by the designer. When generating a chart, the chart is rendered directly using a set of colors in the theme.

[0003] However, when the colors in the theme are used in the prior art, the color ratio depends entirely on the size of the data. When the data is uneven, a chart rendered with the same theme will have a large proportion of one or several colors, while the proportions of other colors are very small. The colors are very unbalanced, resulting in an overall uncoordinated visual effect. Summary of the invention

[0004] In view of this, the embodiments of the present invention disclose a color balancing method, device and electronic device, which solve the problem of color imbalance in the prior art.

[0005] The embodiment of the present invention discloses a color balancing method, comprising:

[0006] Obtaining the proportion of each data block in the atlas; each data block is filled with a color; the proportion of each data block in the atlas indicates the proportion of the size of each data block in the atlas; the atlas is composed of multiple charts;

[0007] Based on the proportion of each data block, calculate the proportion value of each color in the atlas;

[0008] Based on the ratio value of each color, calculate the standard deviation of the ratio value of each color;

[0009] If the standard deviation is greater than a preset threshold, the colors of some data blocks in the data blocks corresponding to the first target color in at least one group of replacement colors are changed to second target colors until the standard deviation is less than the preset threshold; wherein each group of replacement colors includes a first target color whose color ratio value is greater than an average value and a second target color whose color ratio value is less than an average value.

[0010] Optionally, obtaining the proportion of each data block in the atlas includes:

[0011] For any first data block, calculating the proportion of the first chart area to which the first data block belongs in the atlas;

[0012] Calculate the proportion of the actual drawing area of ​​the first chart in the area of ​​the first chart;

[0013] Calculating the proportion of the first data block in the actual drawing area of ​​the first chart;

[0014] The proportion of the first data block in the atlas is calculated based on the proportion of the actual drawing area of ​​the first chart, the proportion of the first chart area to which the first data block belongs in the atlas, and the proportion of the actual drawing area of ​​the first chart in the first chart area.

[0015] Optionally, the step of changing the colors of some data blocks in the data blocks corresponding to the first target color in at least one set of replacement colors to the second target color includes:

[0016] Based on the current ratio value of each color, calculate the average ratio value of all colors in the atlas;

[0017] If the standard deviation of the ratio value of any color is greater than the preset threshold, then:

[0018] Select a first target color from colors whose color ratio values ​​are greater than an average value, select a second target color from colors whose color ratio values ​​are less than an average value, and use the first target color and the second target color as a set of replacement colors;

[0019] The colors in the selected set of replacement colors are replaced, and the replacement process includes: changing the colors of some data blocks in the data blocks corresponding to the first target color in the selected set of replacement colors to the second target color, until the proportion value of the first target color or the proportion value of the second target color approaches the average value;

[0020] The ratio value of each color is calculated, the standard deviation is calculated based on the ratio value of each color, and the relationship between the standard deviation and a preset threshold is determined.

[0021] Optionally, changing the colors of some data blocks in the data blocks corresponding to the first target color in the selected set of replacement colors to the second target color until a proportion value of the first target color or a proportion value of the second target color approaches an average value includes:

[0022] If the ratio of the first target color is greater than the average value and the ratio of the second target color is less than the average value, then:

[0023] Select a second target data block from the data block corresponding to the first target color;

[0024] changing the color of the second target data block to a second target color;

[0025] Calculate the ratio value of the first target color and the ratio value of the second target color respectively;

[0026] The ratio value of the first target color and the ratio value of the second target color are calculated, and the relationship between the ratio value of the first target color and the average value, and the relationship between the ratio value of the second target color and the average value are determined.

[0027] Optionally, the ratio value of the first target color or the ratio value of the second target color approaches an average value, including:

[0028] The ratio value of the first target color is less than or equal to the average value, or the ratio value of the second target color is less than or equal to the average value.

[0029] The embodiment of the present invention discloses a color balancing device, comprising:

[0030] An acquisition unit, used for acquiring the proportion of each data block in the atlas; each data block is filled with a color; the proportion of each data block in the atlas indicates the proportion of the size of each data block in the atlas; the atlas is composed of a plurality of charts;

[0031] A first calculation unit, used for calculating a proportion value of each color in the atlas based on the proportion of each data block;

[0032] A second calculation unit, configured to calculate a standard deviation of the ratio value of each color based on the ratio value of each color;

[0033] A color replacement unit is used to change the color of some data blocks in the data blocks corresponding to the first target color in at least one group of replacement colors to the second target color if the standard deviation is greater than a preset threshold value, until the standard deviation is less than the preset threshold value; wherein each group of replacement colors includes a first target color whose color ratio value is greater than an average value and a second target color whose color ratio value is less than an average value.

[0034] Optionally, the color replacement unit includes:

[0035] A first calculation subunit, used for calculating an average value of the ratio values ​​of all colors in the atlas based on the current ratio value of each color;

[0036] The color replacement subunit is used to:

[0037] If the standard deviation of the ratio value of any color is greater than the preset threshold, then:

[0038] Select a first target color from colors whose color ratio values ​​are greater than an average value, select a second target color from colors whose color ratio values ​​are less than an average value, and use the first target color and the second target color as a set of replacement colors;

[0039] The colors in the selected set of replacement colors are replaced, and the replacement process includes: changing the colors of some data blocks in the data blocks corresponding to the first target color in the selected set of replacement colors to the second target color, until the proportion value of the first target color or the proportion value of the second target color approaches the average value;

[0040] The ratio value of each color is calculated, the standard deviation is calculated based on the ratio value of each color, and the relationship between the standard deviation and a preset threshold is determined.

[0041] Optionally, the color replacement subunit:

[0042] The loop subunit is used for, if the ratio value of the first target color is greater than the average value and the ratio value of the second target color is less than the average value, then:

[0043] A selection subunit, used to select a second target data block from the data blocks corresponding to the first target color;

[0044] A color changing subunit, used for changing the color of the second target data block to a second target color;

[0045] A first calculation subunit, used to calculate a ratio value of a first target color and a ratio value of a second target color respectively;

[0046] The second calculation subunit is used to calculate the ratio value of the first target color and the ratio value of the second target color, and determine the relationship between the ratio value of the first target color and the average value, and the relationship between the ratio value of the second target color and the average value.

[0047] Optionally, the ratio value of the first target color or the ratio value of the second target color approaches an average value, including:

[0048] The ratio value of the first target color is less than or equal to the average value, or the ratio value of the second target color is less than or equal to the average value.

[0049] An embodiment of the present invention discloses an electronic device, including:

[0050] Memory and processor;

[0051] The memory is used to store a program, and the processor is used to execute the following color balancing method when executing the program:

[0052] Obtaining the proportion of each data block in the atlas; each data block is filled with a color; the proportion of each data block in the atlas indicates the proportion of the size of each data block in the atlas; the atlas is composed of multiple charts;

[0053] Based on the proportion of each data block, calculate the proportion value of each color in the atlas;

[0054] Based on the ratio value of each color, calculate the standard deviation of the ratio value of each color;

[0055] If the standard deviation is greater than a preset threshold, the colors of some data blocks in the data blocks corresponding to the first target color in at least one group of replacement colors are changed to second target colors until the standard deviation is less than the preset threshold; wherein each group of replacement colors includes a first target color whose color ratio value is greater than an average value and a second target color whose color ratio value is less than an average value.

[0056] The embodiment of the present invention discloses a color balancing method, device and electronic device, including: obtaining the proportion of each data block in an atlas, each data block is filled with a color, and the proportion of each data block in the atlas indicates the proportion of the size of each data block in the atlas; the atlas is composed of multiple charts; based on the proportion of each data block, the proportion value of each color in the atlas is calculated, and when the standard deviation of the proportion value of each color is greater than a preset threshold, the color of some data blocks in the data block corresponding to the first target color in at least one group of replacement colors is changed to a second target color, until the standard deviation of the proportion value of each color is less than the preset threshold; wherein each group of replacement colors includes a first target color with a color proportion greater than an average value and a second target color with a color proportion less than an average value. Thus, by replacing the color with a proportion value greater than the average value with the color with a proportion value less than the average value, the balance of the atlas color is adjusted, so that the color of the atlas is close to balance. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0058] Figure 1 A schematic diagram of a flow chart of a color balancing method provided by an embodiment of the present invention is shown;

[0059] Figure 2 An example diagram showing the chart area and the actual plotted area;

[0060] Figure 3 A schematic diagram showing the proportion of calculated data blocks in the atlas is shown;

[0061] Figure 4 Another schematic diagram of a process of a color balancing method provided by an embodiment of the present invention is shown;

[0062] Figure 5 A schematic diagram of the structure of a color balancing device disclosed in an embodiment of the present invention is shown;

[0063] Figure 6 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention is shown;

[0064] Figure 7 A schematic diagram of a color imbalance chart provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0065] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0066] The inventor of the present application has discovered through research that when designing a chart, colors are usually used to distinguish different data displayed in the chart, and different themes are designed in advance for the convenience of users. Currently, the themes are mainly color matching, so that data is distinguished by different colors under the same theme. However, when designing charts through themes, the ratio of each color depends entirely on the size of the data. When the data is uneven, the performance of the charts rendered under the same theme is completely different. For example, the proportion of one or several colors will be very large, and the proportion of other colors will be very small, making the overall picture very inconsistent visually. For example, if Figure 7 As shown in the figure, different shades of gray represent different colors. It can be seen from the figure that two colors are very prominent, making the overall look inconsistent.

[0067] In order to solve this technical problem, the technical solution provides a color balancing method. When the color ratios representing different data in an atlas (an atlas is composed of multiple charts) are not coordinated, the color of the atlas is adjusted by using different color replacement methods. When color replacement is performed, the colors of some data blocks in the data blocks whose color ratio values ​​are greater than the average value are changed to colors whose ratio values ​​are less than the average value, until the standard deviation of the ratio value of each color is less than a preset threshold. In this way, the balance of the atlas color is adjusted, so that the color of the atlas is close to balance.

[0068] The following is a detailed introduction to the above color balancing method:

[0069] Embodiment 1:

[0070] refer to Figure 1 , shows a flow chart of a color balancing method provided by an embodiment of the present invention. In this embodiment, the method includes:

[0071] S101: Obtain the proportion of each data block in the atlas; each data block is filled with a color;

[0072] In this embodiment, the chart is a form of reflecting the data status, for example, the chart includes: a bar chart, a pie chart, a bar chart, etc. A complete data analysis may include multiple charts, and the chart composed of multiple charts is represented as an atlas. In addition, the data in each chart is represented by a data block, and different data blocks are rendered in different colors.

[0073] Furthermore, each data block constituting the chart is filled with a color, and, in order to facilitate distinction and to highlight the visual effect, the colors of adjacent data blocks are usually different.

[0074] Among them, the proportion of each data block in the atlas indicates the proportion of the size of the data block in the atlas, and each data block is rendered with color, so the proportion of each data block in the atlas can indicate the proportion of the color in the data block in the atlas.

[0075] In one implementation, the process of calculating the proportion of each data block in the atlas includes:

[0076] For any first data block, calculating the proportion of the first chart area to which the first data block belongs in the atlas;

[0077] Calculate the proportion of the actual drawing area of ​​the first chart in the area of ​​the first chart;

[0078] Calculating the proportion of the first data block in the actual drawing area of ​​the first chart;

[0079] The proportion of the first data block in the atlas is calculated based on the proportion of the actual drawing area of ​​the first chart, the proportion of the first chart area to which the first data block belongs in the atlas, and the proportion of the actual drawing area of ​​the first chart in the first chart area.

[0080] Specifically, the proportion of the first data block marked in the atlas, the proportion of the first chart area to which the first data block belongs in the atlas, and the proportion of the actual drawing area of ​​the first chart in the first chart area are multiplied to obtain the proportion of the first data block in the atlas.

[0081] In this embodiment, the chart area represents the area selected when the chart is selected, such as Figure 2As shown, the rectangular box area represents the chart area, and the actual drawing area represents the area where the actual results of the chart are presented in the chart area, such as Figure 2 As shown, the circular area represents the actual drawn area.

[0082] When generating a chart, the proportion of each data block is recorded in advance, wherein the proportion indicates the proportion of the data block in the actual drawing area of ​​the chart.

[0083] For example: Figure 3 As shown, the first data block is a sector area A in a pie chart of the atlas, the rectangular area of ​​the pie chart when selected is the first chart area B, the pie chart area is the actual drawing area C, the atlas area is represented by D (the atlas is composed of multiple charts), the proportion of the first chart area to which the first data block belongs in the atlas is S1=B / D, the proportion of the actual drawing area of ​​the first chart in the first chart area is S2=C / B, and the proportion of the first data block in the actual drawing area of ​​the first chart is S3=A / C. However, the actual drawing area of ​​the first data block in the first chart is known in advance, and the proportion of the first data block in the atlas is S=S1*S2*S3.

[0084] S102: Calculate the proportion value of each color in the atlas based on the proportion of each data block;

[0085] In this embodiment, the colors filled in different data blocks in the atlas may be the same or different, and the proportions of data blocks of the same color are added together, and the result obtained is the ratio value of one color.

[0086] S103: Calculate the standard deviation of the ratio value of each color based on the ratio value of each color;

[0087] In this embodiment, the standard deviation is also called variance, which represents the average value of the distance of each data from the mean, and the standard deviation is the arithmetic square root of the variance. Among them, the standard deviation of the ratio value of each color represents the average value of the distance of the ratio value of each color from the mean.

[0088] S104: if the standard deviation is greater than a preset threshold, changing the color of a portion of the data blocks corresponding to the first target color in at least one group of replacement colors to a second target color until the standard deviation is less than the preset threshold; each group of replacement colors includes a first target color having a color ratio greater than an average value and a second target color having a color ratio less than an average value;

[0089] In this embodiment, if the standard deviation represents the average value of the distance that the proportion value of each color deviates from the mean, when the standard deviation is greater than a preset threshold, it means that the colors in the atlas are unbalanced and need to be adjusted.

[0090] The process of adjusting the color to a balanced state includes:

[0091] Until the standard deviation of the ratio value of each color is less than the preset threshold, the following process is repeated:

[0092] Based on the current ratio value of each color, calculate the average ratio value of all colors in the atlas;

[0093] Select a first target color from the colors whose color ratio values ​​are greater than the average value, select a second target color from the colors whose color ratio values ​​are less than the average value, and use the first target color and the second target color as a set of replacement colors;

[0094] Changing the colors of some data blocks in the data blocks corresponding to the first target color in a set of replacement colors to the second target color;

[0095] Determine the relationship between the standard deviation of the current ratio value of each color and the preset threshold.

[0096] Or, in another embodiment:

[0097] If the standard deviation of the ratio value of any color is greater than the preset threshold, and the number of substitutions is less than the preset substitution threshold, the following process is repeated:

[0098] The process of a replacement includes:

[0099] Based on the current ratio value of each color, calculate the average ratio value of all colors in the atlas;

[0100] Select a first target color from the colors whose color ratio values ​​are greater than the average value, select a second target color from the colors whose color ratio values ​​are less than the average value, and use the first target color and the second target color as a set of replacement colors;

[0101] Changing the colors of some data blocks in the data blocks corresponding to the first target color in a set of replacement colors to the second target color;

[0102] Determine the relationship between the standard deviation of the current ratio value of each color and the preset threshold.

[0103] In this embodiment, in order to prevent the substitution from falling into an endless loop, after several substitutions, if the standard deviation of the ratio value of any color is still greater than a preset threshold, but the number of substitutions is less than the preset substitution threshold, the substitution is stopped.

[0104] For example: Assume that the proportion of each color in the current atlas is: orange, dark blue, green, brown, lake blue, purple, wherein the proportion of each color is: 29%, 22%, 17%, 15%, 12%, 5%, the average is 16.6%, the standard deviation is 14.47%, and the preset threshold is 10%. If the standard deviation is greater than the preset threshold, it means that there is a color imbalance. Therefore, the colors in the atlas are replaced to make each color tend to be balanced. The replacement process is: randomly select a group of replacement colors, the replacement colors include a color with a proportion greater than the average value, such as orange, and a color with a proportion value less than the average value, such as purple, change the color of some data blocks in the data block rendered with orange to purple, and repeat the process continuously, that is, change the color of some data blocks in the data block corresponding to the color with a proportion value greater than the preset threshold to a color with a proportion value less than the preset threshold, until the standard deviation of the proportion value of each color is less than or equal to the preset threshold, thereby indicating that color balance is achieved. Further, two colors in a group of replacement colors can be randomly selected or selected based on preset rules.

[0105] In this embodiment, the applicant found that when selecting color rendering data blocks from a theme, the selection is usually based on the order of colors. Assuming that a theme contains 6 colors, then these 6 colors are taken cyclically. However, when color replacement is performed, this order will be disrupted, and adjacent data blocks may have the same colors. In order to avoid this problem as much as possible, the technical personnel of this application found that each time a replacement color is selected, one is randomly selected from the colors whose proportion value is greater than the average value, and one is randomly selected from the colors whose proportion value is less than the average value. If random selection is performed each time, the situation where the same color appears in two adjacent data blocks can be reduced.

[0106] In this embodiment, the proportion of each data block in the atlas is obtained, and each data block is filled with a color. Based on the proportion of each data block, the proportion value of each color in the atlas is calculated, and when the standard deviation of the proportion value of each color is greater than a preset threshold, the color of some data blocks in the data block corresponding to the first target color in at least one group of replacement colors is changed to the second target color, until the standard deviation of the proportion value of each color is less than the preset threshold; wherein each group of replacement colors includes the first target color with a color proportion greater than the average value and the second target color with a color proportion less than the average value. Thus, by replacing the color with a proportion value greater than the average value with the color with a proportion value less than the average value, the balance of the atlas color is adjusted, so that the color tends to be balanced.

[0107] Furthermore, since a group of replacement colors are randomly selected from colors with proportion values ​​less than the average value and colors with proportion values ​​greater than the average value, the problem of consecutive data blocks having the same color is avoided to a large extent.

[0108] Embodiment 2:

[0109] Based on the above embodiment 1, Figure 4 , shows another flow chart of a color balancing method provided by an embodiment of the present invention, the method comprising:

[0110] S201: Obtain the proportion of each data block in the atlas; each data block is filled with a color;

[0111] In this embodiment, step S201 is consistent with the above-mentioned step S101 and will not be described in detail in this embodiment.

[0112] S202: Calculate the proportion value of each color in the atlas based on the proportion of each data block;

[0113] In this embodiment, step S202 is consistent with the above-mentioned step S102 and will not be described in detail in this embodiment.

[0114] S203: Calculate the standard deviation of the ratio value of each color based on the ratio value of each color;

[0115] In this embodiment, step S203 is consistent with the above step S103 and will not be described in detail in this embodiment.

[0116] S204: Calculate the average value of the ratio values ​​of all colors in the atlas;

[0117] In this embodiment, one atlas includes multiple data tables, each data table represents different data, each data is represented as a data block, and the data blocks are distinguished by different colors.

[0118] In this embodiment, it is assumed that the atlas contains 6 colors, namely: orange, dark blue, green, brown, lake blue, and purple, and the proportions of each color are: 29%, 22%, 17%, 15%, 12%, and 5%, respectively. The average value = (29% + 22% + 17% + 15% + 12% + 5%) / 6 = 16.6%.

[0119] S205: If the standard deviation is greater than a preset threshold, then: repeat the following S206-S208:

[0120] S206: Select a first target color from the colors whose color ratio values ​​are greater than the average value, select a second target color from the colors whose color ratio values ​​are less than the average value, and use the first target color and the second target color as a set of replacement colors;

[0121] S207: replacing the colors in the selected set of replacement colors, the replacement process comprising: changing the colors of some data blocks in the data blocks corresponding to the first target color in the selected set of replacement colors to the second target color, until the proportion value of the first target color or the proportion value of the second target color approaches the average value;

[0122] Specifically, the judgment criteria for whether the ratio value of the first target color or the ratio value of the second target color is close to the average value may include multiple ones, which are not limited in the present embodiment. Preferably, it can be considered that if the ratio value of the first target color is less than the average value, or the ratio value of the second target color is greater than the average value, then it is considered that the ratio value of the first target color or the ratio value of the second target color is close to the average value.

[0123] The replacement color may be selected randomly, for example, one may be randomly selected from colors whose color ratio values ​​are greater than the average value, or one may be randomly selected from colors whose color ratio values ​​are less than the average value.

[0124] In this embodiment, since the proportion value of the first target color in a set of replacement colors is greater than the average value, and the proportion value of the second target color is less than the average value, in order to achieve balance, the two are replaced in color so that the proportion value of the first target color or the proportion value of the second target color approaches the average value.

[0125] Specifically, in one implementation, the process of changing the color of the data block corresponding to the first target color includes:

[0126] S2071: Select a second target data block from the data blocks corresponding to the first target color;

[0127] S2072: changing the color of the second target data block to a second target color;

[0128] S2073: Calculate the ratio value of the first target color and the ratio value of the second target color respectively;

[0129] S2074: If the ratio value of the first target color is greater than the average value and the ratio value of the second target color is less than the average value, return to execute S2071.

[0130] S2075: If the ratio value of the first target color is less than or equal to the average value, or the ratio value of the second target color is greater than or equal to the average value, then stop replacing.

[0131] In this embodiment, the method of selecting a second target data block from the data block corresponding to the first target color may include the following two implementations:

[0132] Implementation method 1:

[0133] A second target data block is randomly selected from the data blocks corresponding to the first target color.

[0134] Implementation method 2:

[0135] If the difference between the ratio value of the first target color and the ratio value of the second target color is greater than a preset second threshold, the data blocks are selected in order from the largest to the smallest data block areas;

[0136] If the difference between the ratio value of the first target color and the ratio value of the second target color is less than a preset second threshold, the data blocks are selected in order from the smallest to the largest data block areas.

[0137] S208: Calculate the ratio value of each color, determine the standard deviation based on the ratio value of each color, and determine the relationship between the standard deviation and a preset threshold.

[0138] In this embodiment, it is assumed that the atlas contains 6 colors, namely: orange, dark blue, green, brown, lake blue, and purple, wherein the proportion of each color is: 29%, 22%, 17%, 15%, 12%, and 5%, respectively, the average value is 16.6%, and the standard deviation is 14.47%. Assuming that the preset threshold is 10%, then the standard deviation is greater than the preset threshold, indicating that there is a color imbalance, and the color balance needs to be adjusted by replacement, wherein the colors greater than the average value include: orange, dark blue, and green; the colors less than the average value include: brown, lake blue, and purple, then a color can be selected from the colors greater than the average value as the first target color, and a color can be selected from the colors less than the average value as the second target color, and the color of the data block corresponding to the first target color in the replacement color is continuously changed to the second target color until the proportion value of the first target color is less than the average value, or the proportion value of the second target color is greater than the average value, then the replacement is stopped. The standard deviation is recalculated based on the proportion value of each color. If the standard deviation is greater than the preset threshold, a group of replacement colors are selected again for replacement until the standard deviation is less than or equal to the preset threshold, then the replacement is stopped.

[0139] Furthermore, if the process of S206-S208 is repeated multiple times and the standard deviation is still greater than the preset threshold, then in order to avoid falling into an infinite loop, if the number of times S206-S208 is looped is greater than the preset number threshold and the standard deviation is still greater than the preset threshold, execution is stopped.

[0140] In this embodiment, the proportion of each data block in the atlas is obtained, and each data block is filled with a color. Based on the proportion of each data block, the proportion value of each color in the atlas is calculated, and when the standard deviation of the proportion value of each color is greater than a preset threshold, the color of some data blocks in the data block corresponding to the first target color in at least one group of replacement colors is changed to the second target color, until the standard deviation of the proportion value of each color is less than the preset threshold; wherein each group of replacement colors includes the first target color with a color proportion greater than the average value and the second target color with a color proportion less than the average value. Thus, by replacing the color with a proportion value greater than the average value with the color with a proportion value less than the average value, the balance of the atlas color is adjusted, so that the color tends to be balanced.

[0141] Furthermore, since a group of replacement colors are randomly selected from colors with proportion values ​​less than the average value and colors with proportion values ​​greater than the average value, the problem of consecutive data blocks having the same color is avoided to a large extent.

[0142] refer to Figure 5 , shows a schematic diagram of the structure of a color balancing device disclosed in an embodiment of the present invention. In this embodiment, the device includes:

[0143] The acquisition unit 301 is used to acquire the proportion of each data block in the atlas; each data block is filled with a color; the proportion of each data block in the atlas indicates the proportion of the size of each data block in the atlas; the atlas is composed of multiple charts;

[0144] A first calculation unit 302, used to calculate a ratio value of each color in the atlas based on the ratio of each data block;

[0145] A second calculation unit 303 is used to calculate the standard deviation of the ratio value of each color based on the ratio value of each color;

[0146] The color replacement unit 304 is used to change the color of some data blocks in the data blocks corresponding to the first target color in at least one group of replacement colors to the second target color if the standard deviation is greater than a preset threshold value, until the standard deviation is less than the preset threshold value; wherein each group of replacement colors includes a first target color whose color ratio value is greater than an average value and a second target color whose color ratio value is less than an average value.

[0147] Optionally, the color replacement unit includes:

[0148] A first calculation subunit, used for calculating an average value of the ratio values ​​of all colors in the atlas based on the current ratio value of each color;

[0149] The color replacement subunit is used to:

[0150] If the standard deviation of the ratio value of any color is greater than the preset threshold, then:

[0151] Select a first target color from colors whose color ratio values ​​are greater than an average value, select a second target color from colors whose color ratio values ​​are less than an average value, and use the first target color and the second target color as a set of replacement colors;

[0152] The colors in the selected set of replacement colors are replaced, and the replacement process includes: changing the colors of some data blocks in the data blocks corresponding to the first target color in the selected set of replacement colors to the second target color, until the proportion value of the first target color or the proportion value of the second target color approaches the average value;

[0153] The ratio value of each color is calculated, and the relationship between the standard deviation of the ratio value of each color and a preset threshold is determined.

[0154] Optionally, the color replacement subunit:

[0155] The loop subunit is used for, if the ratio value of the first target color is greater than the average value and the ratio value of the second target color is less than the average value, then:

[0156] A selection subunit, used to select a second target data block from the data blocks corresponding to the first target color;

[0157] A color changing subunit, used for changing the color of the second target data block to a second target color;

[0158] A first calculation subunit, used to calculate a ratio value of a first target color and a ratio value of a second target color respectively;

[0159] The second calculation subunit is used to calculate the ratio value of the first target color, calculate the ratio value of the second target color, and determine the relationship between the ratio value of the first target color and the average value, and the relationship between the ratio value of the second target color and the average value.

[0160] Optionally, the ratio value of the first target color or the ratio value of the second target color approaches an average value, including:

[0161] The ratio value of the first target color is less than or equal to the average value, or the ratio value of the second target color is less than or equal to the average value.

[0162] Optionally, the acquisition unit includes:

[0163] A third calculation subunit is used to calculate, for any first data block, a proportion of a first chart area to which the first data block belongs in the atlas;

[0164] A fourth calculation subunit, configured to calculate a proportion of the actual drawing area of ​​the first chart in the first chart area;

[0165] A fifth calculation subunit, configured to calculate a proportion of the first data block in an actual drawing area of ​​the first chart;

[0166] The sixth calculation subunit is used to calculate the proportion of the first data block in the atlas based on the proportion of the first data block in the actual drawing area of ​​the first chart, the proportion of the first chart area to which the first data block belongs in the atlas, and the proportion of the actual drawing area of ​​the first chart in the first chart area.

[0167] Through the device of this embodiment, the proportion of each data block in the atlas is obtained, and each data block is filled with a color. Based on the proportion of each data block, the proportion value of each color in the atlas is calculated, and when the standard deviation of the proportion value of each color is greater than a preset threshold, the color of some data blocks in the data block corresponding to the first target color in at least one group of replacement colors is changed to the second target color, until the standard deviation of the proportion value of each color is less than the preset threshold; wherein each group of replacement colors includes the first target color with a color proportion greater than the average value and the second target color with a color proportion less than the average value. Thus, by replacing the color with a proportion value greater than the average value with the color with a proportion value less than the average value, the balance of the atlas color is adjusted, so that the color tends to be balanced.

[0168] refer to Figure 6 , shows a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. In this embodiment, the electronic device includes:

[0169] Memory 401 and processor 402;

[0170] The memory 401 is used to store a program, and the processor 402 is used to execute the following color balancing method when executing the program:

[0171] Obtaining the proportion of each data block in the atlas; each data block is filled with a color; the proportion of each data block in the atlas indicates the proportion of the size of each data block in the atlas; the atlas is composed of multiple charts;

[0172] Based on the proportion of each data block, calculate the proportion value of each color in the atlas;

[0173] Based on the ratio value of each color, calculate the standard deviation of the ratio value of each color;

[0174] If the standard deviation is greater than a preset threshold, the colors of some data blocks in the data blocks corresponding to the first target color in at least one group of replacement colors are changed to second target colors until the standard deviation is less than the preset threshold; wherein each group of replacement colors includes a first target color whose color ratio value is greater than an average value and a second target color whose color ratio value is less than an average value.

[0175] Optionally, obtaining the proportion of each data block in the atlas includes:

[0176] For any first data block, calculating the proportion of the first chart area to which the first data block belongs in the atlas;

[0177] Calculate the proportion of the actual drawing area of ​​the first chart in the area of ​​the first chart;

[0178] Calculating the proportion of the first data block in the actual drawing area of ​​the first chart;

[0179] The proportion of the first data block in the atlas is calculated based on the proportion of the actual drawing area of ​​the first chart, the proportion of the first chart area to which the first data block belongs in the atlas, and the proportion of the actual drawing area of ​​the first chart in the first chart area.

[0180] Optionally, the step of changing the colors of some data blocks in the data blocks corresponding to the first target color in at least one set of replacement colors to the second target color includes:

[0181] Based on the current ratio value of each color, calculate the average ratio value of all colors in the atlas;

[0182] If the standard deviation of the ratio value of any color is greater than the preset threshold, then:

[0183] Select a first target color from colors whose color ratio values ​​are greater than an average value, select a second target color from colors whose color ratio values ​​are less than an average value, and use the first target color and the second target color as a set of replacement colors;

[0184] The colors in the selected set of replacement colors are replaced, and the replacement process includes: changing the colors of some data blocks in the data blocks corresponding to the first target color in the selected set of replacement colors to the second target color, until the proportion value of the first target color or the proportion value of the second target color approaches the average value;

[0185] The ratio value of each color is calculated, the standard deviation is calculated based on the ratio value of each color, and the relationship between the standard deviation and a preset threshold is determined.

[0186] Optionally, the step of changing the colors of some data blocks in the data blocks corresponding to the first target color in the selected set of replacement colors to the second target color until a ratio value of the first target color or a ratio value of the second target color approaches an average value comprises: if the ratio value of the first target color is greater than the average value and the ratio value of the second target color is less than the average value, then:

[0187] Select a second target data block from the data block corresponding to the first target color;

[0188] changing the color of the second target data block to a second target color;

[0189] Calculate the ratio value of the first target color and the ratio value of the second target color respectively;

[0190] The ratio value of the first target color is calculated, the ratio value of the second target color is calculated, and the relationship between the ratio value of the first target color and the average value, and the relationship between the ratio value of the second target color and the average value are determined.

[0191] Optionally, the ratio value of the first target color or the ratio value of the second target color approaches an average value, including:

[0192] The ratio value of the first target color is less than or equal to the average value, or the ratio value of the second target color is less than or equal to the average value.

[0193] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0194] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A color balancing method, It is characterized in that include: Obtaining the proportion of each data block in the atlas; each data block is filled with a color; the proportion of each data block in the atlas indicates the proportion of the size of each data block in the atlas; the atlas is composed of multiple charts; Based on the proportion of each data block, calculate the proportion value of each color in the atlas; Based on the ratio value of each color, calculate the standard deviation of the ratio value of each color; If the standard deviation is greater than a preset threshold, the colors of some data blocks in the data blocks corresponding to the first target color in at least one group of replacement colors are changed to second target colors until the standard deviation is less than the preset threshold; wherein each group of replacement colors includes a first target color whose color ratio value is greater than an average value and a second target color whose color ratio value is less than an average value.

2. The method according to claim 1, It is characterized in that The obtaining of the proportion of each data block in the atlas includes: For any first data block, calculating the proportion of the first chart area to which the first data block belongs in the atlas; Calculate the proportion of the actual drawing area of ​​the first chart in the area of ​​the first chart; Calculating the proportion of the first data block in the actual drawing area of ​​the first chart; The proportion of the first data block in the atlas is calculated based on the proportion of the actual drawing area of ​​the first chart, the proportion of the first chart area to which the first data block belongs in the atlas, and the proportion of the actual drawing area of ​​the first chart in the first chart area.

3. The method according to claim 1, It is characterized in that The step of changing the colors of some data blocks in the data blocks corresponding to the first target color in at least one set of replacement colors to the second target color includes: Based on the current ratio value of each color, calculate the average ratio value of all colors in the atlas; If the standard deviation of the ratio value of any color is greater than the preset threshold, then: Select a first target color from colors whose color ratio values ​​are greater than an average value, select a second target color from colors whose color ratio values ​​are less than an average value, and use the first target color and the second target color as a set of replacement colors; The colors in the selected set of replacement colors are replaced, and the replacement process includes: changing the colors of some data blocks in the data blocks corresponding to the first target color in the selected set of replacement colors to the second target color, until the proportion value of the first target color or the proportion value of the second target color approaches the average value; The ratio value of each color is calculated, the standard deviation is calculated based on the ratio value of each color, and the relationship between the standard deviation and a preset threshold is determined.

4. The method according to claim 3, It is characterized in that The step of changing the colors of some data blocks in the data blocks corresponding to the first target color in the selected set of replacement colors to the second target color until the proportion value of the first target color or the proportion value of the second target color approaches an average value includes: If the ratio of the first target color is greater than the average value and the ratio of the second target color is less than the average value, then: Select a second target data block from the data block corresponding to the first target color; Changing the color of the second target data block to a second target color; Calculate the ratio value of the first target color and the ratio value of the second target color respectively; The ratio value of the first target color and the ratio value of the second target color are calculated, and the relationship between the ratio value of the first target color and the average value, and the relationship between the ratio value of the second target color and the average value are determined.

5. The method according to claim 3 or 4, It is characterized in that The ratio value of the first target color or the ratio value of the second target color approaches an average value, including: The ratio value of the first target color is less than or equal to the average value, or the ratio value of the second target color is less than or equal to the average value.

6. A color balancing device, It is characterized in that include: An acquisition unit, used for acquiring the proportion of each data block in the atlas; each data block is filled with a color; the proportion of each data block in the atlas indicates the proportion of the size of each data block in the atlas; the atlas is composed of a plurality of charts; A first calculation unit, used for calculating a proportion value of each color in the atlas based on the proportion of each data block; A second calculation unit, configured to calculate a standard deviation of the ratio value of each color based on the ratio value of each color; A color replacement unit is used to change the color of some data blocks in the data blocks corresponding to the first target color in at least one group of replacement colors to the second target color if the standard deviation is greater than a preset threshold value, until the standard deviation is less than the preset threshold value; wherein each group of replacement colors includes a first target color whose color ratio value is greater than an average value and a second target color whose color ratio value is less than an average value.

7. The device according to claim 6, It is characterized in that The color replacement unit comprises: A first calculation subunit, used for calculating an average value of the ratio values ​​of all colors in the atlas based on the current ratio value of each color; The color replacement subunit is used to: If the standard deviation of the ratio value of any color is greater than the preset threshold, then: Select a first target color from colors whose color ratio values ​​are greater than an average value, select a second target color from colors whose color ratio values ​​are less than an average value, and use the first target color and the second target color as a set of replacement colors; The colors in the selected set of replacement colors are replaced, and the replacement process includes: changing the colors of some data blocks in the data blocks corresponding to the first target color in the selected set of replacement colors to the second target color, until the proportion value of the first target color or the proportion value of the second target color approaches the average value; The ratio value of each color is calculated, the standard deviation is calculated based on the ratio value of each color, and the relationship between the standard deviation and a preset threshold is determined.

8. The device according to claim 7, It is characterized in that The color replacement subunit then: A loop subunit is used for, if the ratio value of the first target color is greater than the average value and the ratio value of the second target color is less than the average value, then: A selection subunit, used to select a second target data block from the data blocks corresponding to the first target color; A color changing subunit, used for changing the color of the second target data block to a second target color; A first calculation subunit, used to calculate a ratio value of a first target color and a ratio value of a second target color respectively; The second calculation subunit is used to calculate the ratio value of the first target color and the ratio value of the second target color, and determine the relationship between the ratio value of the first target color and the average value, and the relationship between the ratio value of the second target color and the average value.

9. The device according to claim 7, It is characterized in that The ratio value of the first target color or the ratio value of the second target color approaches an average value, including: The ratio value of the first target color is less than or equal to the average value, or the ratio value of the second target color is less than or equal to the average value.

10. An electronic device, It is characterized in that include: Memory and processor; The memory is used to store a program, and the processor is used to execute the following color balancing method when executing the program: Obtaining the proportion of each data block in the atlas; each data block is filled with a color; the proportion of each data block in the atlas indicates the proportion of the size of each data block in the atlas; the atlas is composed of multiple charts; Based on the proportion of each data block, calculate the proportion value of each color in the atlas; Based on the ratio value of each color, calculate the standard deviation of the ratio value of each color; If the standard deviation is greater than a preset threshold, the colors of some data blocks in the data blocks corresponding to the first target color in at least one group of replacement colors are changed to second target colors until the standard deviation is less than the preset threshold; wherein each group of replacement colors includes a first target color whose color ratio value is greater than an average value and a second target color whose color ratio value is less than an average value.

Citation Information

Patent Citations

  • Game exception detection method and apparatus

    CN106651968A

  • Method for embedding and extracting data in image

    CN112233004A