Ancient architectural style matching method based on contour extraction
Through the pyramid network, multi-scale decomposition and outline information extraction of ancient building images, combined with the fusion of shape, texture and proportional features, the problem of insufficient style matching accuracy in the existing technology is solved, and higher matching accuracy and adaptability are achieved.
Patent Information
- Application Number
- CN202510174618.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-18
- Publication Date
- 2025-06-06
AI Technical Summary
The existing technology is difficult to fully capture the detailed characteristics of ancient buildings at different scales in the style matching of ancient buildings, resulting in insufficient accuracy of style matching and the inability to adapt to the complex and changeable ancient buildings, reducing the flexibility and applicability of matching.
The pyramid network is used to decompose the ancient building images on multiple scales, extract the contour information of different scales, and select the best algorithm through calculation adaptability, and integrate shape features, texture features and proportional features to build a more representative feature vector of ancient building styles.
It significantly improves the accuracy and adaptability of style matching, can more accurately capture the detailed characteristics of ancient buildings, and provides more reliable technical support for ancient building protection and digital research.
Smart Images

Figure CN120107616A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of ancient building protection and digitization, and in particular to an ancient building style matching method based on contour extraction. Background Art
[0002] In today's society, ancient buildings, as treasures of human history and culture, carry rich historical, artistic and scientific values. As time goes by, many ancient buildings are facing the threat of natural erosion, human destruction and urbanization. In order to better protect and inherit ancient buildings, digital technology is being used more and more widely in the field of ancient building protection. Accurate matching of ancient building styles is one of the key links in digital protection. It not only helps the restoration and protection of ancient buildings, but also provides a more realistic and accurate model for the digital display of ancient buildings.
[0003] At present, the ancient building style matching method mainly relies on image recognition and machine learning technology, but in terms of contour extraction, the existing technology often only focuses on the contour information of a single scale, ignoring the rich details and layering of ancient buildings at different scales. This single-scale extraction method is difficult to fully capture the detailed features of ancient buildings, namely the delicate carving textures and diverse structural connections, resulting in insufficient accuracy in style matching. In addition, different ancient buildings have significant differences in shape, size, and detail richness. The single-scale extraction method cannot adapt to the complex and changeable ancient building forms, further reducing the flexibility and applicability of matching. Summary of the invention
[0004] To solve the above problems, the present invention provides an ancient building style matching method based on contour extraction, comprising the following steps:
[0005] S1. Acquire an ancient building image and preprocess it to obtain a preprocessed image;
[0006] S2. Input the preprocessed image into the pyramid network to obtain a multi-scale image, wherein the multi-scale image includes a large-scale image s 1 , medium-scale image s 2 , low-scale image s 3 ;
[0007] S3. Extracting contour information from the multi-scale image to obtain multi-scale contour features, wherein the multi-scale contour features include a large-scale contour feature map, a medium-scale contour feature map, and a low-scale contour feature map;
[0008] S4. extracting shape features, texture features and scale features of each scale according to the multi-scale contour features, and fusing the shape features, texture features and scale features of each scale to obtain style features;
[0009] S5. The style features of each scale are fused and input into the style matching model to obtain the matching result.
[0010] Beneficial effects of the present invention:
[0011] The present invention performs multi-scale decomposition of images through a pyramid network, extracts different contour information for images of each scale, and realizes multi-level decomposition and contour information extraction of ancient building images from coarse to fine and at different resolutions. This method can not only accurately capture the detailed features of ancient buildings at different scales, but also effectively integrate these feature information to construct a more representative ancient building style feature vector, which significantly improves the accuracy and adaptability of style matching and provides more reliable technical support for the protection and digital research of ancient buildings. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Figure 1 The present invention is a flow chart of the method. DETAILED DESCRIPTION
[0013] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0014] The present invention provides a method for matching ancient architectural styles based on contour extraction. Figure 1 As shown, the following steps are included:
[0015] S1. Acquire an ancient building image and preprocess it to obtain a preprocessed image.
[0016] Specifically, in the embodiment of the present invention, a high-resolution camera is used to capture images of ancient buildings, and pre-processing operations such as denoising, contrast enhancement, and brightness adjustment are performed on the images of ancient buildings, so that the outlines and details of the buildings in the images of ancient buildings are more distinct.
[0017] S2. Input the preprocessed image into the pyramid network to obtain a multi-scale image, wherein the multi-scale image includes a large-scale image s 1 , medium-scale image s 2 , low-scale image s 3 .
[0018] Specifically, the present invention performs multi-scale decomposition on the preprocessed image through a pyramid network, and the pyramid network includes K downsampling layers. In order to obtain images with different resolutions from coarse to fine and extract contour information at different scales, the present invention comprehensively considers factors such as the size, shape, and richness of details of ancient buildings in terms of scale selection, so that small scales focus on minute carving details, the edges of decorative patterns, and delicate texture changes, such as the carved patterns on the doors and windows of ancient buildings, the murals on the walls, and other detailed parts; medium scales focus on the local structures and features of ancient buildings, such as the shapes, proportions, and connection methods between beams, columns, brackets, etc.; large scales focus on the overall contour and layout of ancient buildings, including the relationship between ancient buildings and the surrounding environment, the distribution rules of building complexes, and the overall spatial pattern. Therefore, the present invention uses the output of the first downsampling layer in the pyramid network as the large-scale image, the output of the nth < K downsampling layer as the medium-scale image, and the output of the Kth downsampling layer as the low-scale image.
[0019] Specifically, the image processing process of each downsampling layer is expressed as
[0020]
[0021] where I(x, y) represents the value of a pixel coordinate (x, y) in the preprocessed image I, and I k (x k , y k ) represents the coordinate value of the pixel coordinate (x, y) in the preprocessed image I after k times of downsampling.
[0022] S3. Extract contour information from the multi-scale images to obtain multi-scale contour features, and the multi-scale contour features include a large-scale contour feature map, a medium-scale contour feature map, and a low-scale contour feature map.
[0023] Specifically, since the form of ancient buildings is relatively complex and different contour extraction algorithms have different processing capabilities for image features, a single algorithm cannot comprehensively extract the contour information of ancient buildings at different scales. Therefore, the present invention adaptively selects the best algorithm for each scale by calculation, thereby more accurately describing the contour of ancient buildings and improving the accuracy of contour extraction.
[0024] Step S3 specifically includes:
[0025] S31. Determine the contour extraction algorithm parameter set, which includes parameter sets of different contour extraction algorithms;
[0026] S32. For the large-scale image s 1 , calculate the adaptability of each contour extraction algorithm for the large-scale image s 1 , and the adaptability calculation formula is
[0027]
[0028] in, Denotes the jth contour extraction algorithm for large-scale image s 1 The adaptability, E(s 1 ,A j ) represents the jth contour extraction algorithm for large-scale image s 1 The obtained contour point set, |E(s 1 ,A j )| represents the contour point set E(s 1 ,A j ) in the contour points; α s1 , β s1 is the weight coefficient; S(x′ 1 ,y′ 1 ) represents the contour point (x′ 1 ,y′ 1 ), N(x 1 ,y 1 ) represents the pixel (x 1 ,y 1 ) at the noise intensity;
[0029] Select the contour extraction algorithm with the greatest adaptability to process large-scale images 1 Get the large-scale contour feature map C s1 ;
[0030] S33. For medium-scale images s 2 , calculate each contour extraction algorithm for the mesoscale image s 2 The adaptability is calculated as follows:
[0031]
[0032] in, Denotes the jth contour extraction algorithm for the mesoscale image s 2 The adaptability, E(s 2 ,A j ) represents the jth contour extraction algorithm for the mesoscale image s 2 The obtained contour point set, |E(s 2 ,A j )| represents the contour point set E(s 2 ,A j ) in the contour points; α s2 , β s2 is the weight coefficient; S(x′ 2 ,y′ 2 ) represents the contour point (x′ 2 ,y′2 ), D(x′ 2 ,y′ 2 ) represents the contour point (x′ 2 ,y′ 2 ), N(x 2 ,y 2 ) represents the pixel (x 2 ,y 2 ) at the noise intensity;
[0033] Select the contour extraction algorithm with the greatest adaptability to process the mesoscale image s 2 Get the mesoscale contour feature map C s2 ;
[0034] S34. For small-scale images s 3 , calculate each contour extraction algorithm for small-scale image s 3 The adaptability is calculated as follows:
[0035]
[0036] in, Denotes the jth contour extraction algorithm for small-scale image s 3 The adaptability, E(s 3 ,A j ) represents the jth contour extraction algorithm for small-scale image s 3 The obtained contour point set, |E(s 3 ,A j )| represents the contour point set E(s 3 ,A j ) in the contour points; α s3 , β s3 is the weight coefficient; S(x′ 3 ,y′ 3 ) represents the contour point (x′ 3 ,y′ 3 ), D(x′ 3 ,y′ 3 ) represents the contour point (x′ 3 ,y′ 3 ) is the detail richness measure at the location, T(x′ 3 ,y′ 3 ) represents the contour point (x′ 3 ,y′ 3 ) is the texture feature saliency measure at N(x 3 ,y 3 ) represents the pixel (x 3 ,y 3 ) at the noise intensity;
[0037] Select the contour extraction algorithm with the greatest adaptability to process small-scale images 3 Get the small-scale contour feature map C s3 .
[0038] S4. The shape features, texture features and scale features of each scale are extracted based on the multi-scale contour features, and the shape features, texture features and scale features of each scale are fused to obtain the style features.
[0039] Specifically, the present invention describes the overall shape and structural characteristics of the ancient building by analyzing the aspect ratio, symmetry and other shape characteristics of each part of the ancient building in the image, so as to understand the layout and design style of the ancient building. For the large-scale contour feature map, it is mainly used to analyze the direction and proportion of the overall shape of the ancient building; for the medium-scale contour feature map, it is mainly used to analyze the geometric characteristics of the local structure of the ancient building, and judge the regularity and style characteristics of the local structure; for the small-scale contour feature map, it is mainly used to analyze the tiny geometric shapes of the carvings and decorative details. Specifically, the process of extracting shape features according to multi-scale contour features in step S4 includes:
[0040] S411. Calculate the overall contour aspect ratio R based on the large-scale contour feature map s1 and the symmetry measure S s ymm s1 As the shape feature of large-scale images,
[0041]
[0042] Among them, L s1 Represents the longest axis length of the contour shape in the large-scale contour feature, W s1 represents the width perpendicular to the longest axis; represents the number of symmetric point pairs in large-scale contour features, Represents the total number of contour points in the large-scale contour feature;
[0043] S412. Determine the structural shape type of the contour in the mesoscale contour feature image. If the structural shape type is a rectangular structure, calculate the side length ratio as the shape feature of the mesoscale image; if the structural shape type is a circular structure, calculate the center coordinates between the center of the circular structure and each contour point to obtain a center coordinate set, and use the center coordinate set as the shape feature of the mesoscale image;
[0044] Specifically, the side length ratio a s2 、b s2 Represent the length and width of the rectangular structure respectively.
[0045] S413. Count the number of triangles, the area of each triangle, the number of circles, the area of each circle in the small-scale contour feature map, and calculate the average area of triangles and the average area of circles as shape features of the small-scale image.
[0046] Specifically, the present invention reflects the material and process characteristics of ancient buildings by analyzing the texture patterns on the surface of ancient buildings, such as the texture of bricks and stones, the texture of wood, etc. Step S4 The process of extracting texture features according to multi-scale contour features includes:
[0047] S421. Calculate the texture feature T corresponding to the large-scale image based on the large-scale contour feature map s1 , expressed as
[0048]
[0049] Represents the pixel point (x 1 ″ ,y 1 ″ ) and the reference axis, C s1 represents a large-scale contour feature map, Represents the total number of contour points in the large-scale contour feature;
[0050] S422. Calculate the gray level co-occurrence matrix of the mesoscale contour feature map, and calculate the contrast D through the gray level co-occurrence matrix s2 and Corr s2 ; Fusion contrast D s2 and Corr s2 Get the texture feature T corresponding to the mesoscale image s2 ;in
[0051]
[0052]
[0053] Among them, p(i,j) represents the probability of gray levels i and j appearing at the same time, μ and v represent the displacement between pixels, which are used to define the relative position offset between two pixels, σ represents the standard deviation of gray levels in different directions, and ρ is an adjustment factor used to balance the contribution of different gray level pairs;
[0054] S423. Calculate the texture feature T corresponding to the small-scale image based on the small-scale contour feature s3 , expressed as
[0055]
[0056] Among them, N s3represents the total number of contour points in the small-scale contour feature, C s3 Represents the small-scale contour feature map, T(x″ 3 ,y″ 3 ) represents the pixel point (x″) in the small-scale contour feature map 3 ,y″ 3 ) is a saliency measure of texture features at .
[0057] Specifically, the present invention extracts the proportional feature by analyzing the geometric proportional relationship in the contour feature, and the geometric proportional relationship includes the relative size and position relationship between the building elements, that is, the geometric proportional relationship is determined by the ratio of the door and window to the wall. Step S4 comprises:
[0058] S431. Count the number of door and window contour points in the large-scale contour feature map Wall outline points Calculate the proportional features corresponding to large-scale images
[0059] S432. Count the number of door and window contour points in the mesoscale contour feature map Wall outline points Calculate the scale features corresponding to the mesoscale image
[0060] S433. Count the number of door and window contour points in the small-scale contour feature map Wall outline points Calculate the proportional features corresponding to the small-scale image
[0061] Specifically, shape features, texture features and scale features are sorted and normalized, and different weight coefficients are assigned to different types of features according to their importance and influence on the style.
[0062] Specifically, the shape features are normalized as
[0063]
[0064] in, Represents image s i Normalized shape features, i=1,2,3, Represents image s i The shape feature, min() represents the minimum value, and max() represents the maximum value. The same normalization process is performed on the texture feature and the scale feature.
[0065] The weight coefficient is set according to the characteristics of the architectural style. If the architectural style focuses on the overall layout and shape, the shape feature weight α = 0.5, the texture feature weight β = 0.5, and the scale feature weight γ = 0.2. Therefore, the style feature corresponding to the large-scale image is expressed as in Represents a large-scale image s 1 Normalized texture features, Represents a large-scale image s 1 Normalized scale features. The medium-scale image and the small-scale image are fused in the same way to obtain the corresponding style features, and then the style features of the three scales are fused to obtain the overall style features. ω 1 ,ω 2 ,ω 3 is the scale weight.
[0066] S5. The style features of each scale are fused and input into the style matching model to obtain the matching result.
[0067] Specifically, a large number of ancient building samples are collected and the corresponding style feature vectors (i.e., the fusion results of style features at all scales) are obtained to train a style matching module; the style feature vectors of the ancient buildings to be matched are input into the style matching model, and the model will output one or more style types as matching results. In order to improve the accuracy of matching, the model is optimized and adjusted. The construction process of the style matching model includes feature selection, weight allocation, and model parameter adjustment. After the matching results are obtained, an optimization and feedback mechanism is provided for users to use. Users can verify and adjust the matching results according to actual needs, and intuitively view the differences and similarities between the ancient buildings to be matched and the ancient buildings of known style types through image comparison, feature analysis, etc.
[0068] In the present invention, unless otherwise clearly stipulated and limited, the terms such as "installation", "setting", "connection", "fixation" and "rotation" should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral one; it can be a mechanical connection or an electrical connection; it can be directly connected or indirectly connected through an intermediate medium; it can be the internal connection of two elements or the interaction relationship between two elements. Unless otherwise clearly defined, ordinary technicians in this field can understand the specific meanings of the above terms in the present invention according to the specific circumstances.
[0069] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for matching ancient architectural styles based on contour extraction, characterized in that: The following steps are involved: S1. Acquire an ancient building image and preprocess it to obtain a preprocessed image; S2. Input the preprocessed image into the pyramid network to obtain a multi-scale image, wherein the multi-scale image includes a large-scale image s1, a medium-scale image s2, and a low-scale image s3; S3. Extracting contour information from the multi-scale image to obtain multi-scale contour features, wherein the multi-scale contour features include a large-scale contour feature map, a medium-scale contour feature map, and a low-scale contour feature map; S4. extracting shape features, texture features and scale features of each scale according to the multi-scale contour features, and fusing the shape features, texture features and scale features of each scale to obtain style features; S5. The style features of each scale are fused and input into the style matching model to obtain the matching result.
2. The ancient building style matching method based on contour extraction according to claim 1 is characterized in that: The pyramid network in step S2 includes K downsampling layers, wherein the output of the first downsampling layer is used as a large-scale image, the output of the n<K downsampling layer is used as a medium-scale image, and the output of the Kth downsampling layer is used as a low-scale image.
3. The ancient building style matching method based on contour extraction according to claim 2 is characterized in that: The image processing process of each downsampling layer is expressed as Where I(x,y) represents the value of the coordinates (x,y) of a pixel point in the preprocessed image I. k (x k ,y k ) represents the coordinate value of the pixel point (x, y) in the preprocessed image I after k times of downsampling.
4. The ancient building style matching method based on contour extraction according to claim 1 is characterized in that: Step S3 specifically includes: S31. Determine a contour extraction algorithm parameter set, including parameter sets of different contour extraction algorithms; S32. For the large-scale image s1, calculate the adaptability of each contour extraction algorithm for the large-scale image s1. The adaptability calculation formula is: in, represents the adaptability of the j-th contour extraction algorithm for large-scale image s1, E(s1,A j ) represents the set of contour points obtained by using the jth contour extraction algorithm for the large-scale image s1, |E(s1,A j )| represents the contour point set E(s1,A j ) in the contour points; α s1 , β s1 is the weight coefficient; S(x′1,y′1) represents the structural significance measure at the contour point (x′1,y′1), and N(x1,y1) represents the noise intensity at the pixel point (x1,y1); Select the contour extraction algorithm with the greatest adaptability to process the large-scale image s1 to obtain the large-scale contour feature map C s1 ; S33. For the mesoscale image s2, calculate the adaptability of each contour extraction algorithm for the mesoscale image s2. The adaptability calculation formula is: in, represents the adaptability of the j-th contour extraction algorithm for the mesoscale image s2, E(s2,A j ) represents the set of contour points obtained by using the jth contour extraction algorithm for the mesoscale image s2, |E(s2,A j )| represents the contour point set E(s2,A j ) in the contour points; α s2 , β s2 is the weight coefficient; S(x′2,y′2) represents the structural saliency measure at the contour point (x′2,y′2), D(x′2,y′2) represents the detail richness measure at the contour point (x′2,y′2), and N(x2,y2) represents the noise intensity at the pixel point (x2,y2); Select the contour extraction algorithm with the greatest adaptability to process the mesoscale image s2 to obtain the mesoscale contour feature map C s2 ; S34. For the small-scale image s3, calculate the adaptability of each contour extraction algorithm for the small-scale image s3. The adaptability calculation formula is: in, represents the adaptability of the jth contour extraction algorithm for the small-scale image s3, E(s3, A j ) represents the set of contour points obtained by using the jth contour extraction algorithm for the small-scale image s3, |E(s3, A j )| represents the contour point set E(s3, A j ) in the contour points; α s3 , β s3 is the weight coefficient; S(x′3, y′3) represents the structural significance measure at the contour point (x′3, y′3), D(x′3, y′3) represents the detail richness measure at the contour point (x′3, y′3), T(x′3, y′3) represents the texture feature significance measure at the contour point (x′3, y′3), and N(x3, y3) represents the noise intensity at the pixel point (x3, y3); Select the contour extraction algorithm with the greatest adaptability to process the small-scale image s3 to obtain the small-scale contour feature map C s3 .
5. The ancient building style matching method based on contour extraction according to claim 1 is characterized in that: The process of extracting shape features according to multi-scale contour features in step S4 includes: S411. Calculate the overall contour aspect ratio R based on the large-scale contour feature map s1 and the symmetry measure S s ymm s1 As the shape feature of large-scale images, Among them, L s1 represents the longest axis length in the large-scale contour feature, W s1 represents the width perpendicular to the longest axis; represents the number of symmetric point pairs in large-scale contour features, Represents the total number of contour points in the large-scale contour feature; S412. Determine the structural shape type of the contour in the mesoscale contour feature map. When the structural shape type is a rectangular structure, calculate the side length ratio as the shape feature of the mesoscale image; when the structural shape type is a circular structure, calculate the center coordinates between the center of the circular structure and each contour point to obtain a central coordinate set, and use the central coordinate set as the shape feature of the mesoscale image; S413. Count the number of triangles, the area of each triangle, the number of circles, the area of each circle in the small-scale contour feature map, and calculate the average area of triangles and the average area of circles as shape features of the small-scale image.
6. The ancient building style matching method based on contour extraction according to claim 1 is characterized in that: The process of extracting texture features according to multi-scale contour features in step S4 includes: S421. Calculate the texture feature T corresponding to the large-scale image based on the large-scale contour feature map s1 , expressed as represents the angle between the texture direction and the reference axis at the pixel point (x″1, y″1) in the large-scale contour feature map, C s1 represents a large-scale contour feature map, Represents the total number of contour points in the large-scale contour feature; S422. Calculate the gray level co-occurrence matrix of the mesoscale contour feature map, and calculate the contrast D through the gray level co-occurrence matrix s2 and Corr s2 ; Fusion contrast D s2 and Corr s2 Get the texture feature T corresponding to the mesoscale image s2 ; S423. Calculate the texture feature T corresponding to the small-scale image based on the small-scale contour feature s3 , expressed as Among them, N s3 represents the total number of contour points in the small-scale contour feature, C s3 represents the small-scale contour feature map, and T(x″3,y″3) represents the texture feature significance measure at the pixel point (x″3,y″3) in the small-scale contour feature map.
7. The ancient building style matching method based on contour extraction according to claim 1 is characterized in that: The process of extracting the scale feature according to the multi-scale contour feature in step S4 includes: S431. Count the number of door and window contour points in the large-scale contour feature map Wall outline points Calculate the proportional features corresponding to large-scale images S432. Count the number of door and window contour points in the mesoscale contour feature map Wall outline points Calculate the scale features corresponding to the mesoscale image S433. Count the number of door and window contour points in the small-scale contour feature map Wall outline points Calculate the proportional features corresponding to the small-scale image