An automatic color matching method for line drawing patterns based on scene coloring rules
Through the automatic color matching method of line pattern patterns based on scene color setting rules, the problem of insufficient analysis of color composition rules for scene series images in the existing technology is solved, and a multi-type color matching solution has been generated to meet the personalized design needs in the fields of home textiles, clothing, accessories, beauty, home decoration, etc.
Patent Information
- Application Number
- CN202310107013.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-01
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2043-02-01
AI Technical Summary
The existing technology has insufficient analysis of color composition rules in scene series images, resulting in insufficient richness of the color scheme generation of target patterns, failure to deeply explore the correlation, reuse methods, diversified pairing forms and user preferences between colors, and difficult to meet the personalized design needs in the fields of home textiles, clothing, accessories, beauty, home decoration, etc.
The automatic color matching method of line draft patterns based on scene color setting rules is adopted. Through batch scene image color extraction, image color association mining, line draft patterns extraction and morphological analysis, a multi-type color matching scheme is generated using improved genetic algorithms, combined with K-means color clustering and distance determination matrix calculation, accurate color matching recommendations are output.
It realizes the analysis of the precise correlation relationship between image colors and the fusion of pattern structure morphological characteristics, provides a concrete multi-type color scheme to meet the best needs of users, and improves the accuracy and immediacy of the design.
Smart Images

Figure CN116227173B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of product color design, and in particular relates to an automatic color matching method for line drawing patterns based on scene color setting rules. Background Art
[0002] The fashion industry, centered around the new high-quality development strategy of "technology, fashion, and green development," is accelerating the deep integration of next-generation digital, information-based, and intelligent technologies within the industry. Leveraging new technologies and methods to support intelligent design in the fashion industry has become a crucial task in the current industrial transformation and upgrading. The shifting consumer trends, such as the rise of "national trends," "Eastern aesthetics," and "new fashion," are essentially the "activation" and "regeneration" of traditional clothing culture. Deeply exploring the rules of scene color matching and integrating machine vision technology to intelligently analyze and transfer color elements has important practical application value in the design of contemporary fashion products.
[0003] Whether it's a product or a brand, color matching is crucial, conveying visual aesthetics, product style, and value to consumers. Understanding the logical understanding of color usage within imagery and designing color transfer are crucial. Designers typically struggle to effectively master the color rules within imagery. Objective color analysis and recommendations are urgently needed to assist design decision-making, meet large-scale personalized customization requirements, and enhance design precision and immediacy.
[0004] In the field of color analysis research, Steward[1] first proposed the concept of network in 1981 and established a design structure matrix model, which is similar to the "adjacency matrix" of the network topology structure; Liu Xiaojian et al.[2] improved and optimized this structure and established a color network model to analyze the pattern color matching relationship; Li Yu et al.[3] extracted the image color and applied it to product color matching design using the color adjacency network relationship model; Miao Peiyuan et al.[4] conducted a comparative study on the main color extraction method of ethnic brocade and conducted color analysis on ethnic brocade; Xu Minghui et al.[5] optimized the adjacency network model based on this structure and analyzed the binary color matching relationship, but the interpretation of color distribution and multivariate color matching relationship was insufficient. Related Patent 1: CN113284198A, Automatic Image Color Matching Method and Apparatus; Related Patent 2: CN109598770A, Intelligent Color Matching Method and System for Urban Buildings; Related Patent 3: CN108846869A, Automatic Color Matching Method for Clothing Based on Natural Image Colors. These patents extract colors from a scene and mechanically arrange and combine them according to factors such as the target structure, shape, and area. These single coloring schemes differ significantly from the actual needs of fashion products. In recent years, image style transfer research has been gradually applied to industry, simplifying and abstracting imagery to achieve a transition from the overall style to the target image. This is a different type of transfer problem compared to precise color matching of line drawings and patterns.
[0005] Existing technologies are insufficient in analyzing the color composition rules in scene series images, and the color schemes generated for target patterns are not rich enough. Specifically, (1) there is no in-depth analysis and exploration of the correlation between colors in batch images, reuse methods, multi-pairing forms, and the position relationship of colors in the source scene; (2) the target pattern structure, attribute requirements, and design rules are not fully integrated into the color scheme generation scheme; (3) the influence of user habits and preferences is not considered, which is related to the subjective and objective tendency selection in system use, that is, the system's self-correction and optimization, which is more critical for designers. Summary of the Invention
[0006] The purpose of the present invention is to provide an automatic color matching method for line drawing patterns based on scene color setting rules. It deeply explores the inherent combination logic and mechanism from the colors extracted from batch scenes, uses an improved genetic algorithm to output multiple solutions and sort them by quality, gradually approaching the user's optimal needs, and provides solutions for the color matching of line drawing patterns in the fields of home textiles, clothing, accessories, beauty, home decoration, etc.
[0007] In order to solve the above technical problems, the following technical solutions are adopted:
[0008] A method for automatically matching the colors of line drawings based on scene coloring rules, characterized by comprising the following steps:
[0009] (1) Batch scene image color extraction; a. First batch extract image colors and construct a comprehensive color map; b. Secondary color extraction of the comprehensive color map;
[0010] (2) Mining color association relationships: Analyze the association relationships between image colors, use distance judgment matrix operations to calculate the pairing frequencies between two, three, and multiple items, and output a color association relationship legend;
[0011] (3) Line drawing pattern extraction and morphological analysis: Use edge detection algorithms such as Canny to extract lines in the pattern; after obtaining the line drawing, analyze its structural morphology, find connected areas, count all connected areas, identify the morphology of each connected area, make a comprehensive judgment based on the agreed threshold, and finally form the classification and numbering of similar areas;
[0012] (4) Generation of multi-type color schemes: Color matching is essentially the pairing of image colors and marked areas. A pairing scheme is constructed, and the color matching fitness and selection probability are calculated using a random traversal sampling method to form multi-type schemes and arrange them in order.
[0013] After optimization, step (1) a: using K-means color clustering to extract the main colors of the scene image one by one; K-means clustering is to divide the color set into several clusters, with the color distance between the clusters being the smallest and the center distance between the clusters being as large as possible; for the color set X, the minimum square error E between the color set and the cluster center set C is solved, and the calculation formula is as follows:
[0014]
[0015] In formula (1), x is the data item in the color set X, μ i Cluster C i The mean vector of , its calculation formula is shown in (2); the smaller the E value, the higher the similarity of the samples in the cluster; first, randomly set K cluster centers, calculate the distance between each color data and the cluster center; classify the color into each cluster center according to the error term, recalculate the mean of each type of sample as the new cluster center; if the class center no longer changes or reaches the set number of iterations, stop the calculation; here the maximum number of iterations is set to 50;
[0016] According to the above method, the colors of each image are clustered one by one to obtain color values and their proportions; the colors obtained by clustering each image are generated according to the proportions to generate a comprehensive color map.
[0017] After optimization, the step (1) b: clustering the comprehensive color map again to obtain the comprehensive color value of the scene and its proportion. The initial cluster number K1 and the secondary cluster number K2 are set by the user and may have different values.
[0018] After optimization, the step (2) uses the distance judgment matrix operation: for a single image, based on the distance similarity between each main color and the final image color, the distance judgment matrix is constructed according to the calculation formula (3):
[0019]
[0020] In formula (3), P nk is the decision matrix; 1≤n≤N, 1≤k≤K1, N is the number of scene images; It represents the Euclidean distance between the kth main color of the nth image and the jth image color of the secondary cluster; after judging the image colors one by one, take the minimum value, compare it with the distance threshold σ, and determine whether the value of this item in the judgment matrix is 1 or 0.
[0021] After optimization, the step (2) calculates the pairing frequency between the two items: In order to clarify the high-frequency pairing frequency of image colors, the columns and column items of the above judgment matrix are analyzed, and the calculation formula is as follows:
[0022]
[0023] In formula (4), pis 、p it Respectively represent the similarity judgment items with the sth and tth image colors in the i-th image; similarly, calculate the intersection of the two columns and calculate their mean; W s,t It represents the pairing frequency of image colors s and t, from which the pairing frequency of any two image colors can be obtained.
[0024] After optimization, similarly, the pairing frequencies of three, four, and five image colors are calculated to obtain the image scene color matching association rules, and the color association relationship legend is output.
[0025] After optimization, the step (3) structural morphology analysis: first, the pattern color image is grayscaled and binarized to find connected areas; after counting all connected areas, the morphology of each connected area is identified, including the area of the area, the length of the major axis and minor axis of the ellipse with the same standard second-order central moment as the area, the eccentricity and other multi-dimensional features, and a comprehensive judgment is made based on the agreed threshold, and finally the similar areas are classified and numbered.
[0026] After optimization, step (4) constructs a pairing scheme:
[0027] P={L1,L2,…,L M} (5)
[0028] L m =(C i ,R m ) (6)
[0029] In formula (5), M represents the number of marked regions, L m Represents the color scheme of the mth marked area, which is composed of the i-th image color C i With the mth marked region R m The color scheme P is composed of M pairs of image colors and marked area groups.
[0030] After the optimization, the step (4) calculates the color matching fitness: that is, the judgment function for finding the best combination of image color and region, and the calculation method is as follows:
[0031]
[0032] In formula (7), V i Indicates the visual harmony of i image color points, C i is the i-th image color, f m is the fitness of the image color in m areas; u is the population size.
[0033] After the optimization, the step (4) calculates the selection probability: based on the color matching fitness, the selection probability of each team is calculated, and the calculation formula is as follows:
[0034]
[0035] In formula (8), P m The selection probability of the mth team pairing is calculated by random traversal sampling and sorted; after calculating the probabilities of all teams, the pairing items are replaced and cross-calculated to obtain the optimal probability, thereby forming a multi-type scheme and arranging them in order.
[0036] The above technical solution has the following beneficial effects:
[0037] The present invention is an automatic color matching method for line drawing patterns based on scene color setting rules. It deeply explores the inherent color matching logic and mechanism from the colors extracted from batch scenes, uses an improved genetic algorithm to output multiple schemes and sort them by quality, gradually approaching the user's optimal needs, and provides automatic color matching and scheme recommendations for the color matching of patterns in the fields of home textiles, clothing, accessories, beauty products, home decoration, etc.
[0038] (1) Use objective methods to accurately obtain the correlation between image colors, analyze the high-frequency combination forms between binary, ternary, and multi-color groups, and provide designers with concrete color analysis;
[0039] Specifically, compared with existing methods, this method can accurately mine multi-color groups (such as Figure 4 The matching scheme (as shown) includes elements such as pairing relationship, reproduction degree, spatial distance, etc., which clearly and visually describes the color relationship between the image colors.
[0040] (2) It can match image colors with marked areas according to the structural and morphological characteristics of the pattern and integrate visual harmony, and then evaluate and sort them, and finally output an orderly multi-type color scheme.
[0041] This method is based on the induction of the similarity of the line pattern structure and morphology. As shown in formula (5), the corresponding relationship of the image color matching is calculated and analyzed, and calculation and sorting are performed on the basis of outputting multiple schemes to form an orderly recommendation model. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] The present invention will be further described below in conjunction with the accompanying drawings:
[0043] Figure 1 is a flow chart of the present invention;
[0044] Figure 2 This is an example diagram of the image color extraction process;
[0045] Figure 3 This is an example diagram of the landing point of the image color space;
[0046] Figure 4 This is the color association diagram (a);
[0047] Figure 5 is the color association relationship legend (b);
[0048] Figure 6 This is an example diagram of line draft morphology analysis;
[0049] Figure 7 Output example graphs for multiple types of color schemes and sorting. DETAILED DESCRIPTION
[0050] The present invention aims to provide an automatic color matching method for line drawing patterns based on scene color setting rules. It deeply explores the inherent color matching logic and mechanism from the colors extracted from batch scenes, uses an improved genetic algorithm to output multiple schemes and sort them by quality, gradually approaching the user's optimal needs, and provides automatic color matching and scheme recommendations for the color matching of patterns in the fields of home textiles, clothing, accessories, beauty, home decoration, etc.
[0051] Combined with attachment Figures 1 to 7 , the present invention will be further described by specific examples:
[0052] A method for automatically matching the colors of line drawings based on scene coloring rules, characterized by comprising the following steps:
[0053] (1) Batch scene image color extraction;
[0054] a. Construct a comprehensive color map: First, use K-means color clustering to extract the main colors of the scene image one by one. K-means clustering divides the color set into several clusters, with the color distance between clusters being minimal and the center distance between clusters being as large as possible. For the color set X, find the minimum square error E between the color set and the cluster center set C. The calculation formula is as follows:
[0055]
[0056] In formula (1), x is the data item in the color set X, μ i Cluster C i The mean vector of , its calculation formula is shown in (2); the smaller the E value, the higher the similarity of the samples in the cluster; first, randomly set K cluster centers, calculate the distance between each color data and the cluster center; classify the color into each cluster center according to the error term, recalculate the mean of each type of sample as the new cluster center; if the class center no longer changes or reaches the set number of iterations, stop the calculation; here the maximum number of iterations is set to 50;
[0057] According to the above method, the colors of each image are clustered one by one to obtain color values and their proportions; the colors obtained by clustering each image are generated according to the proportions to generate a comprehensive color map.
[0058] b. Color extraction of comprehensive color map: perform secondary clustering on the comprehensive color map again to obtain the comprehensive color value and its proportion of the scene. The initial cluster number K1 and the secondary cluster number K2 are set by the user and the values can be different. The results are as follows: Figure 3 shown.
[0059] (2) Mining color association relationships;
[0060] The color matching relationship between image colors is extremely important and is also one of the important bases for color migration. Therefore, it is necessary to analyze the correlation between image colors, use distance judgment matrix operations, calculate the matching frequency between two, three, and multiple items, and output the color correlation relationship legend.
[0061] First, for a single image, based on the distance similarity between each main color and the final image color, a distance judgment matrix is constructed according to the calculation formula (3):
[0062]
[0063] In formula (3), P nk is the decision matrix; 1≤n≤N, 1≤k≤K1, N is the number of scene images; It represents the Euclidean distance between the kth main color of the nth image and the jth image color of the secondary cluster; after judging the image colors one by one, take the minimum value, compare it with the distance threshold σ, and determine whether the value of this item in the judgment matrix is 1 or 0.
[0064] Secondly, in order to clarify the frequency of high-frequency pairing of image colors, the columns and column items of the above judgment matrix are analyzed, and the calculation formula is as follows:
[0065]
[0066] In formula (4), p is 、p it Respectively represent the similarity judgment items with the sth and tth image colors in the i-th image; similarly, calculate the intersection of the two columns and calculate their mean; W s,t It represents the pairing frequency of image colors s and t, from which the pairing frequency of any two image colors can be obtained.
[0067] Similarly, the pairing frequencies of three, four, and five image colors are calculated to obtain the image scene color matching association rules and output the color association relationship legend. The pairing relationship description example is as follows: Figure 5 shown.
[0068] (3) Pattern line drawing extraction and morphological analysis;
[0069] After selecting a color matching object, such as a pattern image, if it is not a line drawing, first extract its line drawing structure. Use edge detection algorithms such as Canny to extract the lines in the pattern. After obtaining the line drawing, analyze its structural morphology.
[0070] First, the pattern image is grayscaled and binarized to identify connected regions. After counting all connected regions, the morphology of each region is identified, including multi-dimensional features such as area, the length of the major and minor axes of an ellipse with the same standard second-order central moment, and eccentricity. Based on an agreed threshold, a comprehensive assessment is made, ultimately leading to the classification and numbering of similar regions.
[0071] (4) Generation of multiple color schemes;
[0072] Color matching is essentially the pairing of image colors and marked areas. Build a pairing scheme:
[0073] P={L1,L2,…,L M} (5)
[0074] L m =(C i ,R m ) (6)
[0075] In formula (5), M represents the number of marked regions, L m Represents the color scheme of the mth marked area, which is composed of the i-th image color C i With the mth marked region R m The color scheme P is composed of M pairs of image colors and marked area groups.
[0076] Secondly, calculate the color matching fitness, that is, find the judgment function for the best combination of image color and region. The calculation method is as follows:
[0077]
[0078] In formula (7), V i Indicates the visual harmony of i image color points, C i is the i-th image color, f m is the fitness of the image color in m areas; u is the population size.
[0079] Based on the color matching fitness, the selection probability of each team is calculated. The calculation formula is as follows:
[0080]
[0081] In formula (8), P mThe selection probability of the mth team pairing is calculated by random traversal sampling and sorted. After calculating the probability of all teams, the pairing items are replaced and cross-calculated to obtain the optimal probability, thereby forming a multi-type scheme and arranging them in order. The schematic effect is as follows: Figure 6 shown.
[0082] The above are only specific embodiments of the present invention, but the technical features of the present invention are not limited thereto. Any simple changes, equivalent substitutions, or modifications based on the present invention to solve substantially the same technical problems and achieve substantially the same technical effects are included within the scope of protection of the present invention.
Claims
1. A method for automatically matching color of line drawings based on scene coloring rules, characterized in that The steps include: (1) Scene image color extraction: a. First batch extraction of image colors to construct a comprehensive color map; b. Secondary color extraction of the comprehensive color map; (2) Mining color association relationships: Analyze the association relationships between image colors, use distance judgment matrix operations to calculate the pairing frequencies between two, three, and multiple items, and output a color association relationship legend; use distance judgment matrix operations: For a single image, based on the distance similarity between each main color and the final image color, construct a distance judgment matrix according to calculation formula (3): In formula (3), P nk is the decision matrix; 1≤n≤N, 1≤k≤K1, N is the number of scene images; Represents the Euclidean distance between the kth main color of the nth image and the jth image color of the secondary cluster; after judging the image colors one by one, take the minimum value, compare it with the distance threshold σ, and determine whether the element value in the judgment matrix is 1 or 0; (3) Line pattern extraction and morphological analysis: Use the Canny edge detection algorithm to extract the lines in the pattern; After obtaining the line drawing, its structural morphology is analyzed to find the connected areas. After counting all the connected areas, the morphology of each connected area is identified. A comprehensive judgment is made based on the agreed threshold, and finally similar areas are classified and numbered. (4) Generation of multi-type color schemes: Color matching is essentially the pairing of image colors and marked areas. A pairing scheme is constructed, and the color matching fitness and selection probability are calculated using a random traversal sampling method to form multi-type schemes and arrange them in order; Construct a pairing scheme: P={L1,L2,…,L M } (5) L m =(C i ,R m ) (6) In formula (5), M represents the number of marked regions, L m Represents the color scheme of the mth marked area, which is composed of the i-th image color C i With the mth marked region R m Pairing is performed; the color scheme P is composed of M pairs of image colors and marked area groups; Calculate color matching fitness: that is, find the judgment function for the optimal combination of image color and region. The calculation method is as follows: In formula (7), V i Indicates the visual harmony of i image color points, C i is the i-th image color, f m is the fitness of the image color in m areas; u is the population size; Calculate the selection probability: Based on the color matching fitness, calculate the selection probability of each team. The calculation formula is as follows: In formula (8), P m The selection probability of the mth team pairing is calculated using random traversal sampling and sorted; After calculating the probabilities of all team formations, replace the pairing items and perform cross calculations to obtain the optimal probability, thereby forming multiple types of solutions and arranging them in order.
2. The method for automatically matching color of line drawings based on scene coloring rules according to claim 1, characterized in that: Step (1) a: using K-means color clustering to extract the main colors of the scene image one by one; K-means clustering is to divide the color set into several clusters, with the color distance between the clusters being the smallest and the center distance between the clusters being as large as possible; for the color set X, solving the minimized square error E between the color set and the cluster center set C, the calculation formula is as follows: In formula (1), x is the data item in the color set X, μ i Cluster C i The mean vector of , its calculation formula is shown in (2); the smaller the E value, the higher the similarity of the samples in the cluster; first, randomly set K cluster centers, calculate the distance between each color data and the cluster center; classify the color into each cluster center according to the error term, recalculate the mean of each type of sample as the new cluster center; if the class center no longer changes or reaches the set number of iterations, stop the calculation; the maximum number of iterations is set to 50; According to the above method, the colors of each image are clustered one by one to obtain color values and their proportions; the colors obtained by clustering each image are generated according to the proportions to generate a comprehensive color map.
3. The method for automatically matching line drawing patterns based on scene coloring rules according to claim 2, characterized in that: Step (1) b: clustering the comprehensive color map again to obtain the comprehensive color value of the scene and its proportion. The initial cluster number K1 and the secondary cluster number K2 are set by the user and may have different values.
4. The method for automatically matching line drawing patterns based on scene coloring rules according to claim 1, characterized in that: The step (2) calculates the pairing frequency between two items: In order to clarify the high-frequency pairing frequency of image colors, the columns and column items of the above judgment matrix are analyzed, and the calculation formula is as follows: In formula (4), p is 、p it Respectively represent the similarity judgment items between the i-th image and the s-th and t-th image colors; Calculate the intersection of the two columns and calculate their mean; W s,t It represents the pairing frequency of image colors s and t, from which the pairing frequency of any two image colors can be obtained.
5. The method for automatically matching color of line drawings based on scene coloring rules according to claim 4, characterized in that: Calculate the pairing frequencies of three, four, and five image colors, obtain the image scene color matching association rules, and output the color association relationship legend.
6. The method for automatically matching color of line drawings based on scene coloring rules according to claim 1, characterized in that: The step (3) structural morphology analysis: first, the pattern color image is grayscaled and binarized to find connected areas; after counting all connected areas, the morphology of each connected area is identified, including the area of the area, the length of the major axis and minor axis of the ellipse with the same standard second-order central moment as the area, and the eccentricity multi-dimensional features, and a comprehensive judgment is made based on the agreed threshold, and finally the similar areas are classified and numbered.
Citation Information
Patent Citations
Automatic color matching method for clothing based on natural image color
CN108846869A
An intelligent color matching method and an intelligent color matching system for urban buildings
CN109598770A
Automatic image color matching method and device
CN113284198A
Mixed motion target detection method
CN104933728A
Animation coloring system and coloring method based on mobile terminal
CN111724461A