Common pattern basic form extraction method based on image superposition
By employing image overlay and structured processing techniques, the problems of accuracy and subjective dependence in extracting commonalities of ethnic patterns were solved, and an image knowledge graph supporting cultural research and design was constructed.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-27
- Publication Date
- 2026-03-13
AI Technical Summary
Existing technologies for extracting ethnic patterns suffer from problems such as low accuracy in common extraction, lack of quantitative analysis capabilities, strong subjective dependence, and incomplete technology chains, making it difficult to meet the needs of cultural research and design innovation.
Using image overlay and structured processing techniques, pattern images are collected from physical objects, pattern libraries, and documents. Preprocessing, pixel binarization, overlay matrix generation, and brightness threshold adjustment are performed to extract common and characteristic features and construct an image knowledge graph.
It achieves objective and accurate extraction of patterns, reduces subjective bias, and forms a systematic image knowledge graph to support cultural preservation and innovative design.
Smart Images

Figure CN121661357A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a method for extracting common pattern basics based on image overlay. Background Technology
[0002] In the fields of cultural studies, intangible cultural heritage protection, and modern design, basic pattern types refer to the basic constituent units of ethnic patterns that carry cultural connotations. They are the core visual carriers for analyzing cultural contexts, developing derivative products, and simplifying cultural dissemination. They are also key elements in building a cultural traceability system.
[0003] In the field of intangible cultural heritage protection, the extraction of traditional patterns has long relied on manual drawing. For example, Zhao Feng's team (Zhao Feng, chief editor, and Mao Huiwei, ed. A Series of Ancient Chinese Silk Design Materials [M]. Hangzhou: Zhejiang University Press, 2018) completed the vector reconstruction of silk patterns through steps such as physical extraction, screening, and copying in "A Series of Ancient Chinese Silk Design Materials". However, this method has three limitations: it is cumbersome and time-consuming, highly dependent on the professional level of researchers, and easily damages the authenticity of the pattern's dissemination, making it difficult to meet the needs of large-scale extraction.
[0004] To address the shortcomings of manual methods, current research has shifted towards deep learning technology: Zhao Kaiwen et al. achieved pattern classification of textiles of nomadic ethnic groups in Xinjiang based on the ResNet model (Zhao Kaiwen, Bo Xianshu, Qian Juan, et al. Pattern classification of traditional textiles of nomadic ethnic groups in Xinjiang based on ResNet 18 model [J]. Wool Textile Technology, 2024, 52(11): 111-118.), Kong Qian et al. completed intelligent classification of Yao ethnic patterns using CNN (Kong Qian, Shi Zhuo, Feng Ye, et al. Intelligent classification method of Yao ethnic pattern symbols [J]. Packaging Engineering, 2021, 42(10): 244-250.), and Dai Yongqi et al. obtained digital line drawings of Miao embroidery patterns with the help of visual Transformer (Dai Yongqi, Peng Li, Xie Naipeng. Digital empowerment: digital extraction of Miao embroidery patterns based on visual Transformer [J]. Silk, 2024, 61(07): 14-24.). However, this type of technology is still in the stage of "physical fabric - digital image" conversion, and has two major defects: First, the model is a "black box" and cannot explore the common characteristics and evolution rules of different patterns of the same type (such as patterns of different branches of the same ethnic group); second, it has not been extended to the downstream application of "digital pattern - design innovation", and the technological value has not been realized.
[0005] Image blending technology offers new possibilities for extracting common features of patterns. Its principle is to mine potential correlations between multiple images through pixel-level calculations. It has mature applications in many fields: in industry, it's used for defect detection image denoising (James AP, Dasarathy B V. Medical image fusion: A survey of the state of the art[J]. Information fusion, 2014, 19: 4-19.); in visual arts, it's used for photographic scene integration and enhancing the sense of hierarchy in graphic design; in the field of cultural images, 3type successfully extracted common features of Chinese character strokes by overlaying 9169 Chinese character shapes (3type. "Chinese Font Deciphering Project" Phase I Results[EB / OL]. 2025-05-21(2025-07-20).). However, this technology has insufficient adaptability in extracting the "basic type" of ethnic patterns: it can only obtain fragmented common parts, cannot process the structural features of patterns, and has not formed a standardized extraction process.
[0006] In summary, existing technologies have three significant shortcomings:
[0007] First, the accuracy of common feature extraction is low: simple image alpha mixing cannot reflect the core composition of the pattern, and cannot meet the needs of cultural studies for extracting "essential features"; second, the quantitative analysis capability is lacking: it is impossible to accurately describe features such as line thickness and structural proportion, which restricts the standardization of academic research; third, it is highly subjective: pattern redesign depends on the designer's aesthetics and is difficult to objectively reflect the essence of national culture; fourth, the technology chain is incomplete: it is impossible to connect the entire process of "extraction-application".
[0008] Therefore, there is an urgent need for an "image overlay + structured processing" technology that is compatible with ethnic patterns, in order to solve the core problems of objectivity, accuracy and information carrying capacity in common feature extraction, and to provide strong technical support for the protection, inheritance and innovative development of ethnic culture. Summary of the Invention
[0009] To address the aforementioned problems in the prior art, this invention proposes a method for extracting common pattern basics based on image overlay.
[0010] To achieve the above objectives, the present invention provides the following technical solution:
[0011] This invention provides a method for extracting common pattern basics based on image overlay, comprising the following steps:
[0012] S 1. Taking the patterns of the target ethnic group as the research object, pattern images are collected through three paths: extraction from physical carriers, extraction from existing pattern libraries, and extraction from literature cases. The target pattern set is then screened and classified according to core features.
[0013] S2. Preprocess the pattern, including vertically or horizontally splitting it into multiple core parts according to the pattern's structural features, aligning the scale, and saving it as a standardized image format.
[0014] S3. Perform pixel binarization on the split pattern, read the image as a grayscale image and convert it into a 0-1 matrix, remove invalid rows and columns, unify the matrix size, and generate an extended matrix.
[0015] S4. Generate an overlay matrix by accumulating the extended matrix through the overlay algorithm, and obtain a grayscale image with transparency channel by linear normalization to generate an overlay pattern.
[0016] S5. The segmented stitching technique is used to integrate the superimposed patterns of each feature part into a complete pattern;
[0017] S6. Extract common and characteristic features from the complete pattern by adjusting the pixel brightness threshold range; among them, the common features are the basic type, and the characteristic features are the differentiated decorative elements;
[0018] S7. Taking the basic type as the core and differentiated decorative elements as branches, and combining the historical and regional factors of the culture to which the pattern belongs, construct an image knowledge graph to form the image knowledge system of the pattern.
[0019] Furthermore, the method for preprocessing the pattern in step S2 is as follows:
[0020] S21. Feature part segmentation: According to the structural features of the pattern, each sample is manually divided into multiple core feature parts in the same vertical or horizontal direction. The common and difference attributes of each feature part are clarified. For composite patterns containing main and secondary graphics, the integrity of the feature parts of the main graphic is retained first.
[0021] S22. Scale alignment: Align the samples of each feature part after splitting according to a unified dimension to ensure the correspondence of pixel positions in subsequent superposition calculations.
[0022] S23. Standardize the format: Manually save the aligned feature samples as a general image format and store them according to the naming rule of feature part-pattern category-serial number to provide standardized input for subsequent algorithm processing.
[0023] Furthermore, the pixel binarization process in step S3 is as follows:
[0024] The computer vision tool library OpenCV and the numerical computation tool library NumPy are used to digitize the standardized image format samples obtained in step S2:
[0025] S31. Grayscale image conversion: Read samples of each feature region in grayscale mode to obtain a grayscale image; S32. Binary matrix generation: Convert the grayscale image into a 0-1 binary matrix by setting a pixel threshold.
[0026] S33. Invalid row and column removal: retain rows and columns that contain at least one valid pixel (value 1), and remove all zero invalid rows and columns to simplify the matrix structure.
[0027] S34. Size unification and saving: Calculate the maximum number of rows and columns of all binary matrices, determine the target shape, center each binary matrix and embed it into the zero matrix of the target shape to generate an extended matrix, and save the extended matrix in a general text format.
[0028] Furthermore, the method for generating the overlay pattern in step S4 is as follows:
[0029] S41. Overlay matrix calculation: Traverse all extended matrix text files for the same feature region, and accumulate all extended matrices by matrix addition to obtain the overlay matrix of the feature region.
[0030] S42. Linear normalization: The superimposed matrix values are normalized to the [0, 1] interval by linear mapping using formula (1.1). The normalized values are used to characterize pixel transparency.
[0031]
[0032] Where s is the normalized value, v is the original value in the superposition matrix, and v min v is the minimum value of the superimposed matrix. max This represents the maximum value of the superimposed matrix;
[0033] S43. Overlay image synthesis: fix the value of the image brightness channel L as a set constant, use formula (1.2) to map the normalized transparency value to the range of 0-255 as the transparency channel A value, synthesize the grayscale overlay image with transparency, and save it as a general image format.
[0034] a = s × 255 (1.2)
[0035] Where 'a' is the pixel value of the transparency channel.
[0036] Furthermore, when the pattern is vertically split, the method for generating the complete pattern in step S5 is as follows:
[0037] S51. Unify the number of columns. Extract the maximum number of columns (max_cols) of the superimposed matrix of each feature part, and fill each matrix with symmetrical zeros so that the number of columns of all matrices is max_cols.
[0038] S52. Key row location: Calculate the theoretical median value M of each filled matrix according to formula (1.3), and select the smallest value greater than or equal to M as the key value V of the matrix. key Locate the upper key row (the upper matrix contains V) respectively. key The last row), the first and last rows of the middle key row (the middle matrix contains V) key The first and last rows), the next key row (the lower matrix contains V) key (First line);
[0039]
[0040] Where M is the median of the matrix, V max This represents the maximum value of the filled matrix;
[0041] S53. Target row size calculation: Determine the target image row size according to formula (1.4);
[0042] target_row = R up_key +(R mid_end -R mid_start )+(N low_rows -R low_key (1.4)
[0043] Among them, R up_key R is the row number corresponding to the previous key row. mid_end R is the line number of the middle key line and the last line. mid_start N is the line number of the first line of the key line. low_rows R is the total number of rows in the matrix of the lower feature parts. low_kev This is the line number corresponding to the next key line;
[0044] S54. Matrix Expansion and Assembly:
[0045] (a) Fill the bottom of the matrix of the upper feature parts with 0s, and calculate the filling amount according to formula (1.5):
[0046] P up_bottom =target_rows-N up_rows (1.5)
[0047] Where, is the bottom padding amount of the upper feature region matrix, and is the total number of rows of the upper feature region matrix;
[0048] (b) Fill the top of the matrix of the central feature parts with 0, and the filling amount is calculated according to formula (1.6), and fill the bottom with 0, and the filling amount is calculated according to formula (1.7):
[0049] P mid_top =R up_key -R mid_start (1.6)
[0050] P mid_bottom =target_rows-N mid_rows -P mid_top (1.7)
[0051] Among them, P mid_top P represents the top fill amount of the feature region matrix. mid_bottom N represents the bottom padding amount of the feature region matrix. mid_rows The total number of rows in the matrix of characteristic parts;
[0052] (c) Fill the top of the lower feature region matrix with 0s, and calculate the fill amount according to formula (1.8):
[0053] P low_top =R up_key -(R mid_end -R mid_start +1)-R low_key (1.8)
[0054] Among them, P low_top This is the amount of padding at the top of the matrix for the lower feature region;
[0055] The above filling process ensures that all matrix rows have the same number of rows (target_rows). The upper, middle, and lower matrices are then summed to obtain the splicing matrix. A complete spliced image with grayscale transparency is generated using the image compositing method in step S43. The splicing matrix and the spliced image are saved separately. The splicing matrix is saved in a general text format, and the spliced image is saved in a general image format.
[0056] Furthermore, the specific method for step S6 is as follows:
[0057] S61. Common feature extraction: Set a high threshold range (lower limit is taken from 40% to 55%, such as [45%, 100%]), and filter pixel areas with superposition density in this range. The threshold range is set based on the standard that the extracted feature edges are clear and continuous, which serves as the core source of the basic pattern library and represents the common structure of this type of pattern.
[0058] S62. Feature extraction: Set a low threshold range (upper limit is taken from 40% to 55%, such as [0%, 44%)), filter pixel areas with superimposed density in this range, corresponding to the unique differentiated elements of the pattern, reflecting the individual characteristics of patterns of different categories or sources.
[0059] S63. Feature verification: Compare the extracted features with the original pattern sample set to ensure that the features conform to the cultural essence and core attributes of this type of pattern.
[0060] Furthermore, the specific method for step S7 is as follows:
[0061] S71. Core Node Definition: The basic type corresponding to the common features is taken as the core node and labeled as target pattern - basic type;
[0062] S72. Branch node expansion: Link the characteristic features to the core node according to the hierarchical structure of pattern category - regional culture branch - element type;
[0063] S73. Cultural attribute labeling: Supplement cultural attribute information at each node, including the symbolic meaning of the pattern and the usage scenario;
[0064] S74. Visualization of the graph: Using graphical tools to present nodes and relationships, forming a knowledge system of target pattern images.
[0065] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0066] This invention proposes a method for extracting common pattern basics based on image overlay. Through computer-aided image overlay and decomposition techniques, it achieves objective extraction of common patterns, avoiding biases caused by subjective human processing. The constructed visual recognition framework abandons traditional text encoding, allowing users to directly search and identify patterns through visual features, lowering the barrier to entry for non-professionals. The resulting image knowledge graph effectively carries unstructured image information, clearly presenting the commonalities, characteristics, and cultural connections of patterns. It provides a systematic tool for the protection, research, and modern design applications of national culture, and has significant value in the fields of cultural inheritance and innovation. Attached Figure Description
[0067] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this invention. For those skilled in the art, other drawings can be obtained based on these drawings.
[0068] Figure 1 The flowchart illustrates the method for extracting common pattern basics based on image overlay, as provided in this embodiment of the invention.
[0069] Figure 2 This is a flowchart of the pattern overlay method provided in an embodiment of the present invention.
[0070] Figure 3 This is a schematic diagram of a pattern overlay method provided in an embodiment of the present invention.
[0071] Figure 4 This is a flowchart of the overlay pattern splicing method provided in an embodiment of the present invention.
[0072] Figure 5 This is a schematic diagram of the overlay pattern splicing method provided in an embodiment of the present invention.
[0073] Figure 6 This is a schematic diagram of the pattern basic type selection method provided in an embodiment of the present invention. Detailed Implementation
[0074] 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, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0075] This invention provides a method for extracting common pattern basics based on image overlay, such as... Figure 1 As shown, it includes the following steps:
[0076] S 1. Taking the patterns of the target ethnic group as the research object, pattern images are collected through three paths: extraction from physical carriers, extraction from existing pattern libraries, and extraction from literature cases. The target pattern set is then screened and classified according to core features.
[0077] S2. Preprocess the pattern, including vertically or horizontally splitting it into multiple core parts according to the pattern's structural features, aligning the scale, and saving it as a standardized image format.
[0078] S3. Perform pixel binarization on the split pattern, read the image as a grayscale image and convert it into a 0-1 matrix, remove invalid rows and columns, unify the matrix size, and generate an extended matrix.
[0079] S4. Generate an overlay matrix by accumulating the extended matrix through the overlay algorithm, and obtain a grayscale image with transparency channel by linear normalization to generate an overlay pattern.
[0080] S5. The segmented stitching technique is used to integrate the superimposed patterns of each feature part into a complete pattern;
[0081] S6. Extract common and characteristic features from the complete pattern by adjusting the pixel brightness threshold range; among them, the common features are the basic type, and the characteristic features are the differentiated decorative elements;
[0082] S7. Taking the basic type as the core and differentiated decorative elements as branches, and combining the historical and regional factors of the culture to which the pattern belongs, construct an image knowledge graph to form the image knowledge system of the pattern.
[0083] Specifically, the specific methods for data collection and classification in step S1 are as follows:
[0084] Based on physical carriers related to the target cultural patterns, existing pattern libraries, and documentary materials, a pattern library was constructed through multiple channels. The collected patterns were screened to determine the effective pattern sample set, and then divided into several categories according to core characteristics, thus completing data collection and preliminary classification.
[0085] The method for preprocessing the pattern in step S2 is as follows:
[0086] S21. Feature part segmentation: According to the structural features of the pattern, each sample is manually divided into multiple core feature parts (such as head, body, and legs) in one direction (vertical or horizontal). The common and different attributes of each feature part are clarified. For composite patterns containing main and secondary graphics, the integrity of the feature parts of the main graphic is retained first.
[0087] S22. Scale alignment: Align the samples of each feature part after splitting according to a unified dimension (height or width) to ensure the correspondence of pixel positions in subsequent superposition calculations.
[0088] S23. Standardize the format: Manually save the aligned feature samples as a common image format (such as PNG), and store them according to the naming rule of feature part-pattern category-serial number to provide standardized input for subsequent algorithm processing.
[0089] The pixel binarization process in step S3 is as follows:
[0090] The computer vision tool library OpenCV and the numerical computation tool library NumPy are used to digitize the standardized image format samples obtained in step S2:
[0091] S31. Grayscale image conversion: Read samples of each feature part in grayscale mode to obtain a grayscale image; S32. Binary matrix generation: Convert the grayscale image into a 0-1 binary matrix by setting a pixel threshold (e.g., assigning a value of 0 to white pixels and 1 to dark pixels).
[0092] S33. Invalid row and column removal: retain rows and columns that contain at least one valid pixel (value 1), and remove all zero invalid rows and columns to simplify the matrix structure.
[0093] S34. Size unification and saving: Calculate the maximum number of rows (max_rows) and the maximum number of columns (max_cols) of all binary matrices, determine the target shape (max_rows, max_cols), center each binary matrix and embed it into the zero matrix of the target shape to generate an extended matrix, and save the extended matrix in a common text format (such as TXT).
[0094] The method for generating the overlay pattern in step S4 is as follows:
[0095] Based on the extended matrix obtained in step c, an overlay pattern is generated through matrix operations and image synthesis:
[0096] S41. Overlay matrix calculation: Traverse all extended matrix text files for the same feature region, and accumulate all extended matrices by matrix addition to obtain the overlay matrix of the feature region.
[0097] S42. Linear normalization: The superimposed matrix values are normalized to the [0, 1] interval by linear mapping using formula (1.1). The normalized values are used to characterize pixel transparency.
[0098]
[0099] Where s is the normalized value, v is the original value in the superposition matrix, and v min v is the minimum value of the superimposed matrix. max This represents the maximum value of the superimposed matrix;
[0100] S43. Overlay image synthesis: fix the image brightness channel L value to a set constant (e.g., pure black, 0), use formula (1.2) to map the normalized transparency value to the 0-255 range as the transparency channel A value, synthesize the grayscale image with transparency (LA mode), and save it as a general image format.
[0101] a = s × 255 (1.2)
[0102] Where 'a' is the pixel value of the transparency channel.
[0103] The process of pattern overlay is as follows: Figure 2 As shown. The superposition result is as follows. Figure 3 As shown.
[0104] The method for generating the complete pattern in step S5 is as follows (taking the stitching of vertically split feature area images as an example):
[0105] S51. Unify the number of columns. Extract the maximum number of columns (max_cols) of the superimposed matrix of each feature part, and fill each matrix with symmetrical zeros so that the number of columns of all matrices is max_cols.
[0106] S52. Key row location: Calculate the theoretical median value M of each filled matrix according to formula (1.3), and select the smallest value greater than or equal to M as the key value V of the matrix. key Locate the upper key row (the upper matrix contains V) respectively. key The last row), the first and last rows of the middle key row (the middle matrix contains V) key The first and last rows), the next key row (the lower matrix contains V) key (First line);
[0107]
[0108] Where M is the median of the matrix, V max This represents the maximum value of the filled matrix;
[0109] S53. Target row size calculation: Determine the target image row size according to formula (1.4); target_row = R up_key +(R mid_end -R mid_start )+(N low_rows -R low_key (1.4)
[0110] Among them, R up_key R is the row number corresponding to the previous key row. mid_end R is the line number of the middle key line and the last line. mid_start N is the line number of the first line of the key line. low_rows R is the total number of rows in the matrix of the lower feature parts. low_kev This is the line number corresponding to the next key line;
[0111] S54. Matrix Expansion and Assembly:
[0112] (a) Fill the bottom of the matrix of the upper feature parts with 0s, and calculate the filling amount according to formula (1.5):
[0113] P up_bottom =target_rows-N up_rows (1.5)
[0114] Where, is the bottom padding amount of the upper feature region matrix, and is the total number of rows of the upper feature region matrix;
[0115] (b) Fill the top of the matrix of the central feature parts with 0, and the filling amount is calculated according to formula (1.6), and fill the bottom with 0, and the filling amount is calculated according to formula (1.7):
[0116] P mid_top =R up_key -R mid_start (1.6)
[0117] P mid_bottom =target_rows-N mid_rows -P mid_top (1.7)
[0118] Among them, P mid_top P represents the top fill amount of the feature region matrix. mid_bottom N represents the bottom padding amount of the feature region matrix. mid_rows The total number of rows in the matrix of characteristic parts;
[0119] (c) Fill the top of the lower feature region matrix with 0s, and calculate the fill amount according to formula (1.8):
[0120] P low_top =R up_key -(R mid_end -R mid_start +1)-R low_key (1.8)
[0121] Among them, P low_top This is the amount of padding at the top of the matrix for the lower feature region;
[0122] The above filling process ensures that all matrix rows have the same number of rows (target_rows). The upper, middle, and lower matrices are then summed to obtain the splicing matrix. A complete spliced image with grayscale transparency (LA mode) is generated using the image compositing method in step S43. The splicing matrix and the spliced image are saved separately. The splicing matrix is saved in a general text format, and the spliced image is saved in a general image format.
[0123] The process of overlaying patterns is as follows: Figure 4 As shown. The splicing result is as follows. Figure 5 As shown.
[0124] The specific method for step S6 is as follows:
[0125] S61. Common feature extraction: Set a high threshold range (lower limit is taken from 40% to 55%, such as [45%, 100%]), and filter pixel areas with superposition density in this range. The threshold range is set based on the standard that the extracted feature edges are clear and continuous, which serves as the core source of the basic pattern library and represents the common structure of this type of pattern.
[0126] S62. Feature extraction: Set a low threshold range (upper limit is taken from 40% to 55%, such as [0%, 44%)), filter pixel areas with superimposed density in this range, corresponding to the unique differentiated elements of the pattern, reflecting the individual characteristics of patterns of different categories or sources.
[0127] S63. Feature verification: Compare the extracted features with the original pattern sample set to ensure that the features conform to the cultural essence and core attributes of this type of pattern.
[0128] Basic pattern selection, such as Figure 6 As shown.
[0129] The specific method for step S7 is as follows:
[0130] S71. Core Node Definition: The basic type corresponding to the common features is taken as the core node and labeled as target pattern - basic type;
[0131] S72. Branch node expansion: Link the characteristic features to the core node according to the hierarchical structure of pattern category - regional culture branch - element type;
[0132] S73. Cultural attribute labeling: Supplement cultural attribute information at each node, including the symbolic meaning of the pattern and the usage scenario;
[0133] S74. Visualization of the graph: Using graphical tools to present nodes and relationships, forming a knowledge system of target pattern images.
[0134] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for extracting common pattern basics based on image overlay, characterized in that, Includes the following steps: S1. Taking the target ethnic patterns as the research object, pattern images are collected through three paths: physical carrier extraction, existing pattern library extraction, and literature case extraction. The target pattern set is then screened and classified according to core features. S2. Preprocess the pattern, including vertically or horizontally splitting it into multiple core parts according to the pattern's structural features, aligning the scale, and saving it as a standardized image format. S3. Perform pixel binarization on the split pattern, read the image as a grayscale image and convert it into a 0-1 matrix, remove invalid rows and columns, unify the matrix size, and generate an extended matrix. S4. Generate an overlay matrix by accumulating the extended matrix through the overlay algorithm, and obtain a grayscale image with transparency channel by linear normalization to generate an overlay pattern. S5. The segmented stitching technique is used to integrate the superimposed patterns of each feature part into a complete pattern; S6. Extract common and characteristic features from the complete pattern by adjusting the pixel brightness threshold range; among them, the common features are the basic type, and the characteristic features are the differentiated decorative elements; S7. Taking the basic type as the core and differentiated decorative elements as branches, and combining the historical and regional factors of the culture to which the pattern belongs, construct an image knowledge graph to form the image knowledge system of the pattern.
2. The method for extracting common pattern basics based on image overlay according to claim 1, characterized in that, The method for preprocessing the pattern in step S2 is as follows: S21. Feature part segmentation: According to the structural features of the pattern, each sample is manually divided into multiple core feature parts in the same vertical or horizontal direction. The common and difference attributes of each feature part are clarified. For composite patterns containing main and secondary graphics, the integrity of the feature parts of the main graphic is retained first. S22. Scale alignment: Align the samples of each feature part after splitting according to a unified dimension to ensure the correspondence of pixel positions in subsequent superposition calculations. S23. Standardize the format: Manually save the aligned feature samples as a general image format and store them according to the naming rule of feature part-pattern category-serial number to provide standardized input for subsequent algorithm processing.
3. The method for extracting common pattern basics based on image overlay according to claim 1, characterized in that, The pixel binarization process in step S3 is as follows: The standardized image format samples obtained in step S2 are digitized using the computer vision tool library OpenCV and the numerical computation tool library NumPy. S31. Grayscale image conversion: Read samples of each feature region in grayscale mode to obtain a grayscale image; S32. Binary matrix generation: Convert the grayscale image into a 0-1 binary matrix by setting a pixel threshold. S33. Invalid row and column removal: retain rows and columns containing at least one valid pixel, and remove all zero invalid rows and columns to simplify the matrix structure; S34. Size unification and saving: Calculate the maximum number of rows and columns of all binary matrices, determine the target shape, center each binary matrix and embed it into the zero matrix of the target shape to generate an extended matrix, and save the extended matrix in a general text format.
4. The method for extracting common pattern basics based on image overlay according to claim 1, characterized in that, The method for generating the overlay pattern in step S4 is as follows: S41. Overlay matrix calculation: Traverse all extended matrix text files for the same feature region, and accumulate all extended matrices by matrix addition to obtain the overlay matrix of the feature region. S42. Linear normalization: The superimposed matrix values are normalized to the [0, 1] interval by linear mapping using formula (1.1). The normalized values are used to characterize pixel transparency. Where s is the normalized value, v is the original value in the superposition matrix, and v min v is the minimum value of the superimposed matrix. max This represents the maximum value of the superimposed matrix; S43. Overlay image synthesis: fix the value of the image brightness channel L as a set constant, use formula (1.2) to map the normalized transparency value to the range of 0-255 as the transparency channel A value, synthesize the grayscale overlay image with transparency, and save it as a general image format. a = s × 255 (1.2) where a is the pixel value of the transparency channel.
5. The method for extracting common pattern basics based on image overlay according to claim 4, characterized in that, When the pattern is vertically split, the method for generating the complete pattern in step S5 is as follows: S51. Unify the number of columns. Extract the maximum number of columns (max_cols) of the superimposed matrix of each feature part, and fill each matrix with symmetrical zeros so that the number of columns of all matrices is max_cols. S52. Key row location: Calculate the theoretical median value M of each filled matrix according to formula (1.3), and select the smallest value greater than or equal to M as the key value V of the matrix. key ; Locate the key row above, i.e., the upper matrix containing V. key The last row, the first row of the middle key row, and the last row of the middle matrix contain V. key The first and last rows, and the next key row, i.e., the lower matrix, contain V. key The first line; Where M is the median of the matrix, V max This represents the maximum value of the filled matrix; S53. Target row size calculation: Determine the target image row size according to formula (1.4); target_row = R up_key +(R mid_end -R mid_start )+(N low_rows -R low_key (1.4) Among them, R up_key R is the row number corresponding to the previous key row. mid_end R is the line number of the middle key line and the last line. mid_start N is the line number of the first line of the key line. low_rows R is the total number of rows in the matrix of the lower feature parts. low_key This is the line number corresponding to the next key line; S54. Matrix Expansion and Assembly: (a) Fill the bottom of the matrix of the upper feature parts with 0s, and calculate the filling amount according to formula (1.5): P up_bottom =target_rows-N up_rows (1.5) Where, is the bottom padding amount of the upper feature region matrix, and is the total number of rows of the upper feature region matrix; (b) Fill the top of the matrix of the central feature parts with 0, and the filling amount is calculated according to formula (1.6), and fill the bottom with 0, and the filling amount is calculated according to formula (1.7): P mid_top =R up_key -R mid_start (1.6) P mid_bottom =target_rows-N mid_rows -P mid_top (1.7) Among them, P mid_top P is the top fill amount of the feature region matrix. mid_bottom N represents the bottom padding amount of the feature region matrix. mid_rows This represents the total number of rows in the matrix of characteristic parts. (c) Fill the top of the lower feature region matrix with 0s, and calculate the fill amount according to formula (1.8): P low_top =R up_key -(R mid_end -R mid_start +1)-R low_key (1.8) Among them, P low_top This is the amount of padding at the top of the matrix for the lower feature region; The above filling process ensures that all matrix rows have the same number of rows (target_rows). The upper, middle, and lower matrices are then summed to obtain the splicing matrix. A complete spliced image with grayscale transparency is generated using the image compositing method in step S43. The splicing matrix and the spliced image are saved separately. The splicing matrix is saved in a general text format, and the spliced image is saved in a general image format.
6. The method for extracting common pattern basics based on image overlay according to claim 1, characterized in that, The specific method for step S6 is as follows: S61. Common feature extraction: Set a high threshold range, with the lower limit set between 40% and 55%. Filter pixel areas with superimposed density within this range. The threshold range is set based on the standard that the extracted feature edges are clear and continuous. This serves as the core source of the basic pattern library and represents the common structure of this type of pattern. S62. Feature extraction: Set a low threshold range, with the upper limit set between 40% and 55%. Filter pixel areas with superimposed density within this range to identify unique and differentiating elements of the pattern, reflecting the individual characteristics of patterns from different categories or sources. S63. Feature verification: Compare the extracted features with the original pattern sample set to ensure that the features conform to the cultural essence and core attributes of this type of pattern.
7. The method for extracting common pattern basics based on image overlay according to claim 1, characterized in that, The specific method for step S7 is as follows: S71. Core Node Definition: The basic type corresponding to the common features is taken as the core node and labeled as target pattern - basic type; S72. Branch node expansion: Link the characteristic features to the core node according to the hierarchical structure of pattern category - regional culture branch - element type; S73. Cultural attribute labeling: Supplement cultural attribute information at each node, including the symbolic meaning of the pattern and the usage scenario; S74. Visualization of the graph: Using graphical tools to present nodes and relationships, forming a knowledge system of target pattern images.