A method for determining a main color tone of an ancient building based on a weighted average method
By using a weighted average method to process the colors of ancient buildings and calculating the contrast of hue, chroma, and brightness, the problem of objectively judging the main color tone under multi-color contrast is solved, providing a quantitative reference for new buildings and ensuring the consistency of color style.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HEFEI UNIV OF TECH
- Filing Date
- 2023-09-27
- Publication Date
- 2026-06-23
AI Technical Summary
Existing technology makes it difficult to accurately determine the dominant color tone of the colors in ancient buildings, especially when there is a contrast between multiple colors.
The weighted average method is used to extract the hue, chroma, brightness and area ratio of colors through digital image processing, establish a contrast algorithm model, calculate the contrast of hue, chroma and brightness, and select the color that meets the requirements as the main color tone.
It enables accurate determination of the main color tone of ancient buildings under multi-color contrast conditions, providing a quantitative reference for new buildings and ensuring the consistency of color style.
Smart Images

Figure CN117351098B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of ancient building color style migration technology, specifically a method for determining the main color tone of ancient buildings based on the weighted average method. Background Technology
[0002] The diverse contrasts between different color interfaces create rich spatial color layers, resulting in different visual experiences from different color interfaces.
[0003] Traditional methods for determining the dominant color scheme in architecture, based on the contrast between multiple colors, often rely on subjective judgment. The industry standard is to calculate the contrast ratio based on the differences in hue, chroma, and value attributes, using this calculation as the basis for determining the dominant color. However, this method is only highly reliable when there are only two or three colors. If multiple colors are involved, it becomes difficult to accurately determine the basis for the contrast calculation, making it challenging to objectively identify the dominant color.
[0004] To avoid the problems in existing technologies, current industry algorithms for calculating color contrast mainly include the traditional difference method and the product method based on the ratio of primary and secondary color differences, which is based on area. The traditional difference method simply calculates the difference in hue, chroma, and brightness between colors, without considering the influence of area, and is only applicable to the contrast calculation between two colors. The difference ratio product method, compared to the traditional difference method, considers the impact of area on color contrast, incorporating area as a weight into the calculation formula, but it is still limited to the calculation of contrast between two colors. When multiple colors appear in the color interface, it still uses the data of the two colors with the largest area proportion as the basis for calculation, discarding the data of other colors without mathematically normalizing them, hastily ignoring the impact of other color data on the overall color interface contrast, and thus failing to accurately calculate the contrast between colors. Summary of the Invention
[0005] To avoid and overcome the technical problems existing in the prior art, this invention provides a method for determining the dominant color tone of ancient buildings based on a weighted average method. This invention can accurately determine the dominant color tone in the colors of ancient buildings.
[0006] To achieve the above objectives, the present invention provides the following technical solution:
[0007] A method for determining the dominant color tone of ancient buildings based on a weighted average method includes the following determination steps:
[0008] S1. Obtain the digital image of the ancient building facade after digital processing;
[0009] S2. Remove non-architectural wall color carriers from the digital image to obtain the wall image;
[0010] S3. Extract the hue, chroma, and lightness values of each color in the wall image, as well as the area ratio of each color in the wall image, and store them in the database.
[0011] S4. Input the data from the database into the contrast algorithm model to solve for the hue contrast, chroma contrast and brightness contrast in the wall image.
[0012] S5. Based on hue contrast, chroma contrast, and brightness contrast, select colors from the database that meet the selected requirements as the main color scheme of the ancient buildings.
[0013] As a further aspect of the present invention, the specific process of establishing the contrast algorithm model is as follows:
[0014] S41. Define the color whose area ratio reaches the primary color threshold as the primary color tone, and define the color whose area ratio reaches the secondary color threshold but is lower than the primary color threshold as the secondary color tone.
[0015] S42. Calculate the sum of the area proportions of each primary color and the sum of the area proportions of each secondary color; the calculation formula is as follows:
[0016]
[0017]
[0018] Where R1 represents the sum of the area proportions of each primary color, r i Ri represents the area percentage of the i-th primary color, n represents the number of primary colors; R2 represents the sum of the area percentages of all secondary colors, ri j This represents the area percentage of the j-th auxiliary hue, and m represents the number of auxiliary hues.
[0019] S43. Calculate the mean hue of the primary color and the mean hue of the secondary color; the calculation formula is as follows:
[0020]
[0021]
[0022] in, h represents the mean hue of the primary color. i This represents the hue value of the i-th primary color. h represents the mean hue of the secondary color tone. j This represents the hue value of the j-th auxiliary hue;
[0023] S44. Calculate the hue contrast ratio C using area proportion and hue mean. h The calculation formula is as follows:
[0024]
[0025] S45. Calculate the mean chroma of the primary color and the mean chroma of the secondary color; the calculation formula is as follows:
[0026]
[0027]
[0028] in, The s value represents the average chroma of the primary color. i This represents the chroma value of the i-th primary color. The s value represents the average chroma of the secondary hue. j This represents the chroma value of the j-th auxiliary hue;
[0029] S46. Calculate the chroma contrast ratio C using the area ratio and the chroma mean. s The calculation formula is as follows:
[0030]
[0031] S47. Calculate the mean value of the primary color tone and the mean value of the secondary color tone; the calculation formula is as follows:
[0032]
[0033]
[0034] in, v represents the average brightness of the primary color. i This represents the brightness value of the i-th primary color. v represents the average value of the secondary hue. j This represents the brightness value of the j-th auxiliary hue;
[0035] S48. Calculate the lightness contrast ratio C using area ratio and average lightness value. v The calculation formula is as follows:
[0036]
[0037] Among them, C v Indicates brightness and contrast.
[0038] As a further aspect of the present invention: the primary color threshold is 70%, and the secondary color threshold is 25%.
[0039] As a further aspect of the present invention: the non-building wall color carrier includes the sky, roof and vegetation in the wall image.
[0040] As a further aspect of the present invention: the wall image in RGB format is converted into a wall image in HSV format through the conversion relationship between the RGB color model and the HSV color model, and the hue value, chroma value, lightness value and area ratio of each color in the wall image are extracted through the HSV color model.
[0041] As a further aspect of the present invention: after calculating the hue contrast, chroma contrast and lightness contrast, a selection requirement of ±5% for each contrast is set, and the colors whose hue, chroma and lightness values all fall within the corresponding range are the main color tones of the ancient buildings.
[0042] Compared with the prior art, the beneficial effects of the present invention are:
[0043] 1. This invention can solve the problem of color contrast calculation for multi-color building interfaces with different area proportions, and can more accurately determine their blending method. Compared with traditional color contrast algorithms that are only applicable to the contrast calculation between two colors, it fills the gap in multi-color contrast algorithms and solves the drawback of existing algorithms that cannot perform contrast calculations for multiple colors.
[0044] 2. This invention determines the main color scheme of a new building based on contrast ratio calculation results. A target building is selected, and its H, S, and V contrast ratios are calculated using a contrast ratio calculation formula. Based on this, quantitative reference indicators can be provided for the color scheme design of the new building. This ensures that the color scheme of the target building and the new building are consistent, facilitating preliminary work for color scheme migration.
[0045] 3. This invention utilizes the mathematical relationship between the RGB color model and the HSV color model to perform color space conversion, and further visualizes the spatial distribution of H, S, and V component attribute values based on the completed HSV color space conversion. Attached Figure Description
[0046] Figure 1 This is a schematic diagram of the judgment process structure of the present invention.
[0047] Figure 2 This refers to the digital image used in this invention.
[0048] Figure 3 This is an image of the wall in this invention.
[0049] Figure 4 This is an elevation view of the newly constructed building in this invention.
[0050] Figure 5 This is a standard elevation drawing of the new building in this invention.
[0051] Figure 6This is a diagram showing the main color scheme of the newly constructed building in this invention. Detailed Implementation
[0052] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0053] like Figure 1 The image shown is obtained by capturing a building facade image as a reference building object and using a combination of adjusting the color sampling device parameters and then color calibration on the software platform to obtain an accurate digital image.
[0054] Specific steps:
[0055] First, use the digital camera's histogram to determine the exposure status, and then adjust the exposure parameters in real time based on ISO, aperture, and shutter speed to determine the optimal camera exposure parameter settings.
[0056] Next, place the datacolor24 color chart in the shooting scene and take a picture of the color chart with the light coming on, using it as a reference sample for white balance adjustment; then remove the color chart, keep the original exposure parameter settings, perform digital image acquisition, and save the acquired image in RAW format.
[0057] The captured digital images are loaded into Lightroom 3 software. First, white balance is adjusted using different grayscale patches on a color chart. Then, the SpyderCheckr plugin is used for color calibration to obtain accurate digital images. Figure 2 The digital image is saved as a PNG file, with dimensions of 1844px x 1790px and a resolution of 300ppi.
[0058] The acquired digital image was processed using Photoshop. The cropping tool in Photoshop was used to select a relatively regular section of the wall. Then, the magic wand tool was used to remove non-architectural elements such as the sky, roof, and vegetation. The image was then saved as a PNG file with dimensions of 1268*1253px and a resolution of 300ppi. Figure 3 As shown.
[0059] Color attribute value extraction: The processed wall image was loaded into Colorimpact software for color analysis. The recognition parameter was set to 64, and the software automatically extracted the H, S, V attribute data of the colors and the area ratio of the colors in the interface. Colors with an area ratio of less than 1% and colors that do not conform to the visual effect can be removed according to research needs. The color attribute data and area ratio of the colors that meet the conditions are extracted, as shown in Table 1.
[0060] Table 1 Color attribute data and area proportion
[0061]
[0062] Based on the judgment of the wall color harmony type: Table 1 shows that the first 1-5 colors can be defined as the main color tone of the wall, the 6-12 colors can be defined as the auxiliary color tone of the wall, and the 13th color can be defined as the accent color tone of the wall. Then, according to the contrast algorithm model, the contrast of hue, chroma, and brightness of the building's color interface is calculated respectively, and the results are shown in Table 2.
[0063] Table 2 Mean values of hue, chroma, and lightness
[0064]
[0065] The brightness threshold range is divided into three levels: high brightness, medium brightness, and low brightness. Values of 1-33 are low brightness, 34-66 are medium brightness, and 67-100 are high brightness. When the main color tone in the color interface is in the high brightness range, the brightness tone of the color interface is a high-key color. When the brightness difference between the main color tone and the other two colors is 1-2 levels, it is short contrast; 3-5 levels is medium contrast; and above 5 levels is long contrast, as shown in Table 3.
[0066] Table 3 Basic Types of Brightness Contrast
[0067]
[0068] Chroma is divided into ten levels, with 1-3 classified as low chroma, 8-10 as high chroma, and 4-7 as medium chroma. When the primary color is in the low chroma range, the color interface is called a grayscale interface. When the maximum level difference between the primary color and the secondary or accent color is more than 5 levels, it is called strong contrast, as shown in Table 4.
[0069] Table 4 Basic Types of Chroma Contrast
[0070]
[0071] Levels 3-5 are called medium contrast; levels 1-2 are called weak contrast; hue values are in angles, indicating the position of the hue on the color wheel. Hues within 15° of each other on the color wheel are analogous colors, within 60° are similar colors, within 90° are moderately different colors, and within 180° are complementary colors, as shown in Table 5.
[0072] Table 5 Basic Types of Hue Contrast
[0073]
[0074] Based on the calculation results, the color harmony type of the building wall is high-mid tone, low-gray tone, and analogous color.
[0075] The main color of the target wall was determined based on the quantitative indicators of hue, chroma, brightness and contrast of the reference building. The hue, chroma and brightness attribute values of the main color of the new building were objectively selected, as shown in Table 1. The H, S and V values of the reference building's main color were 39.70, 6.89 and 89.16, respectively.
[0076] Will as Figure 4 Import the newly constructed building facade into Photoshop and remove non-building wall elements such as the roof and windows. Figure 5 As shown, the wall base color with H, S, and V values of 40, 7, and 90 respectively was filled in, thus completing the selection of the main color scheme for the new building's color appearance and the configuration of the main color scheme for the new building, as shown. Figure 6 As shown.
[0077] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A method for determining the dominant color tone of ancient buildings based on a weighted average method, characterized in that, The following determination steps are included: S1. Obtain the digital image of the ancient building facade after digital processing; S2. Remove non-architectural wall color carriers from the digital image to obtain the wall image; S3. Extract the hue, chroma, and lightness values of each color in the wall image, as well as the area ratio of each color in the wall image, and store them in the database. S4. Input the data from the database into the contrast algorithm model to solve for the hue contrast, chroma contrast and brightness contrast in the wall image. S5. Based on hue contrast, chroma contrast and brightness contrast, select colors from the database that meet the selected requirements as the main color scheme of the ancient buildings. The specific process of establishing the contrast algorithm model is as follows: S41. Define the color whose area ratio reaches the primary color threshold as the primary color tone, and define the color whose area ratio reaches the secondary color threshold but is lower than the primary color threshold as the secondary color tone. S42. Calculate the sum of the area proportions of each primary color and the sum of the area proportions of each secondary color; the calculation formula is as follows: in, R 1 represents the sum of the area proportions of each primary color tone. r i Indicates the first i The area ratio of each main color. n Indicates the quantity of the primary color; R 2 represents the sum of the area proportions of each auxiliary hue. r j Indicates the first j The area proportion of each secondary color tone m Indicates the number of secondary hues; S43. Calculate the mean hue of the primary color and the mean hue of the secondary color; the calculation formula is as follows: in, This represents the average hue of the primary color. h i Indicates the first i The hue value of each primary color; The mean hue of the secondary color tone. h j Indicates the first j The hue value of each auxiliary hue; S44. Calculate hue contrast using area proportion and hue mean. C h The calculation formula is as follows: S45. Calculate the mean chroma of the primary color and the mean chroma of the secondary color; the calculation formula is as follows: in, This represents the average chroma of the primary color. s i Indicates the first i The chroma value of each primary color; This represents the average chroma of the secondary hue. s j Indicates the first j The chroma values of each secondary hue; S46. Calculate chroma contrast using area proportion and chroma mean. C s The calculation formula is as follows: S47. Calculate the mean value of the primary color and the mean value of the secondary color; the calculation formula is as follows: in, This represents the average brightness of the primary color tone. v i Indicates the first i The brightness value of each main color tone; This represents the average brightness value of the secondary color tone. v j Indicates the first j The brightness value of each secondary color tone; S48. Calculate brightness contrast ratio using area ratio and average brightness value. C v The calculation formula is as follows: in, C v Indicates brightness and contrast.
2. The method for determining the main color tone of ancient buildings based on the weighted average method according to claim 1, characterized in that, The primary color threshold is 70%, and the secondary color threshold is 25%.
3. The method for determining the main color tone of ancient buildings based on the weighted average method according to claim 2, characterized in that, Non-architectural wall color carriers include the sky, roof, and vegetation in wall images.
4. The method for determining the main color tone of ancient buildings based on the weighted average method according to claim 3, characterized in that, The conversion relationship between the RGB color model and the HSV color model is used to convert the RGB format wall image to the HSV format wall image, and the hue value, chroma value, lightness value and area ratio of each color in the wall image are extracted by the HSV color model.
5. The method for determining the main color tone of ancient buildings based on the weighted average method according to claim 4, characterized in that, After calculating the hue contrast, chroma contrast, and lightness contrast, a selection requirement of ±5% for each contrast is set. Colors whose hue, chroma, and lightness values all fall within the corresponding range are selected as the main color scheme of the ancient buildings.