A data processing method and system for drawing analysis
By combining multi-scale geometric hashing and an improved dynamic time warping algorithm, the problems of subtle deformation of primitives and noise interference in drawing analysis are solved, achieving efficient and robust drawing analysis and feature extraction, and supporting automated drawing review and intelligent process planning.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- TIANJIN YITIAN DIGITAL SERVICE CO LTD
- Filing Date
- 2026-06-25
- Publication Date
- 2026-07-24
AI Technical Summary
Existing technologies struggle to effectively handle issues such as subtle deformations, local missing elements, noise interference, and non-uniform scaling in drawing analysis, leading to incorrect classification and matching of elements. Traditional binary processing methods lack semantic structure and robustness, while dynamic time warping algorithms are prone to incorrect matching when path directions change drastically.
A multi-scale geometric hashing algorithm and an improved dynamic time warping algorithm are adopted. Candidate primitive pairs are generated through a multi-scale geometric hashing table. The cumulative distance formula of the improved dynamic time warping algorithm is combined with an added structural change penalty term to perform clustering of similar primitives and extraction of common features.
It improves the accuracy and recall of drawing analysis, significantly enhances the recognition rate and robustness of duplicate elements, and can overcome the barriers of scale, deformation and noise to reveal design patterns and parametric rules in drawings, providing support for automated drawing review and intelligent process planning.
Smart Images

Figure CN122454593A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of drawing data processing technology, and in particular to a data processing method and system for drawing analysis. Background Technology
[0002] With the development of digital design and intelligent manufacturing, a large number of technical drawings exist in the form of electronic documents. Analyzing these drawings and extracting their geometric information, annotation information, topological relationships and design intent is a key step in realizing drawing retrieval, version comparison, process planning, quality inspection and even reverse engineering.
[0003] In existing technologies for analyzing drawing images, there are schemes that convert the drawings into hash representations and then perform hash clustering for analysis. However, existing hash-based clustering methods have significant limitations. They typically rely on hard matching, meaning that two elements are only classified into the same category if their hash keys are completely identical or extremely similar. This mechanism cannot effectively handle problems commonly found in engineering drawings, such as subtle deformations, local missing elements, noise interference, and non-uniform scaling. For example, a standard circle and a slightly elliptical circle, or a complete rectangle and a rectangle missing a corner, may have completely different hash keys, leading to them being incorrectly classified into different categories.
[0004] Meanwhile, in existing technologies, the distance between candidate primitive pairs is calculated using dynamic time warping. However, when measuring the similarity between two primitive sequences, traditional dynamic time warping algorithms are prone to mismatching unrelated protrusions and depressions when the direction of the path movement in the candidate primitives changes drastically.
[0005] Meanwhile, in the process of image preprocessing, binary processing is generally used to obtain binary images. However, although the original edge pixel data of the binary image obtained by the traditional binary processing method is accurate, it lacks semantic structure and robustness. Especially when faced with a large number of repeated primitives such as holes arranged in arrays and similar contour lines in the drawing, the traditional point-by-point feature description method is difficult to effectively distinguish subtle differences and achieve efficient clustering. Summary of the Invention
[0006] To address the aforementioned technical problems, this invention provides a data processing method and system for drawing analysis, which solves the problems existing in the prior art.
[0007] This invention provides a data processing method for drawing analysis, the method comprising the following steps: S1: Parse and process the drawing file to obtain the drawing data; S2: Perform image preprocessing on the drawing data to obtain a binary image of the drawing data; S3: Perform primitive feature enhancement based on multi-scale geometric hashing on the binary image to obtain a multi-scale geometric hash table; S4: Similar primitive clustering based on an improved dynamic time warping algorithm is applied to the multi-scale geometric hash table; Specifically, S4 is: S4.1: Generate a set of candidate primitive pairs based on the multi-scale geometric hash table; S4.2: Construct and normalize the feature sequences of all candidate primitives in the candidate primitive pair set to obtain the feature vector sequence of the candidate primitive pair set; S4.3: Perform similarity calculation on the candidate primitive pairs based on the improved dynamic time warping algorithm; in S4.3, the cumulative distance formula of the improved dynamic time warping algorithm is: ; In the formula, For the sequence of feature vectors The first a boundary points and the sequence of eigenvectors The minimum cumulative structural distance between the first b boundary points, For the feature vector sequence The eigenvector of the boundary point a with the feature vector sequence The eigenvector of the boundary point b The basic distance between them; D() is the cumulative structural distance function, and P() is the structural change penalty term; S4.4: Perform similarity clustering on the candidate primitive pairs to obtain similar primitive clusters; S5: Extract common features from the similar primitive clusters.
[0008] Preferably, S4.1 specifically includes: Traverse the multi-scale geometric hash table, for the multi-scale geometric hash table For each hash key h, retrieve all the primitives associated with it to form a primitive set. ; In the set of primitives Internally, it generates all possible primitive pairs. As preliminary candidate primitive pairs, among which... These primitive pairs share the exact same local geometry at at least one scale and are potential similar primitives.
[0009] Preferably, S4.2 specifically includes: Each candidate primitive The Moore-Neighbortracing algorithm is used to extract the pixel boundary points of its outer contour or internal holes, forming a boundary point sequence. ,in, The Cartesian coordinates of the k-th boundary point; Calculate the boundary point sequence main direction ; By calculating the boundary point sequence The covariance matrix is calculated, and the direction of the eigenvector corresponding to its largest eigenvalue is taken as the boundary point sequence. main direction ; Transform the coordinates of all boundary points to a coordinate system with the centroid of the candidate primitive as the origin and the main direction as the coordinates. In the new coordinate system with the x-axis; The new coordinates are: ; In the formula, Candidate primitives The coordinates of the centroid, and For the k-th boundary point New coordinates in a new coordinate system with the centroid of the primitive as the origin and the principal direction as the x-axis; The transformed ordered point sequence Further converted into a sequence of feature vectors ; Each feature vector Defined as: ; In the formula, This represents the u-axis displacement from the current point to the next point. This represents the v-axis displacement from the current point to the next point. Boundary point The curvature at that point.
[0010] Preferably, S4.3 specifically involves: processing the feature vector sequence of the primitive sequence in the candidate primitive pair. and Create the cumulative distance matrix D and initialize it. , Where a and b are the row and column indices representing the current position being calculated; for each Calculate three possible path transitions: from the previous step (a) 1,b) are transferred from, plus the penalty term P(a,b,a) 1,b), from the previous step (a,b) 1) Transferred from, plus penalty term P(a,b,a,b) 1) From the previous step (a) 1,b 1) Transferred from, plus penalty term P(a,b,a) 1,b 1) Calculate the cumulative distance based on the cumulative distance formula of the improved dynamic time warping algorithm, and select the one with the smallest cumulative distance among the three, assigning it to... Traverse a=1 to m, b=1 to n, where m and n are sequences of eigenvectors. and The length of the primitive sequence in the candidate primitive pair is used to obtain the feature vector sequence. and final similarity .
[0011] Preferably, the structural change penalty term P is defined as follows: ; In the formula, and For the sequence of feature vectors The two index points indicate that from arrive The local direction, and For the sequence of feature vectors The two index points indicate that from arrive The local direction, For the sequence of feature vectors Zhong Cong point to The vector, For the sequence of feature vectors Zhong Cong point to The vector, where λ is the penalty coefficient.
[0012] Preferably, S3 specifically comprises: S3.1: Construct the binary image into a multi-scale Gaussian pyramid to obtain image representations at different resolutions; S3.2: Perform local feature extraction on each layer of the pyramid image to obtain multi-scale local feature vectors; S3.3: Map the local feature vectors to a discrete hash space to construct a hash table; S3.4: Perform multi-scale hash table fusion and collision resolution on hash tables of various scales to obtain a multi-scale geometric hash table.
[0013] Preferably, S3.2 specifically involves: processing each pixel of each pyramid image layer. Extract a local window centered on it. In the local window Within the range, all edge points are detected, and their coordinate sets relative to the center point are recorded to form an edge point set. For each edge point set, its principal direction and geometric distance are calculated as local geometric features, wherein the principal direction... The geometric distance, obtained by calculating the eigenvectors of the covariance matrix of the edge point set, reflects the extension direction of the local structure. The geometric distance includes the normalized first-order moment in the x-direction. Normalized first moment in the y-direction Normalized second central moments in the x-direction Normalized second central moments in the y-direction Normalized cross second-order central moments ; The normalized first moment in the x-direction The average offset of the edge point set of the k-th pyramid image relative to the center point along the x-axis is represented by the normalized first moment in the y-direction. The average offset of the local edge point set of the k-th pyramid image relative to the center point along the y-axis is represented by the normalized second-order central moment in the x-direction. Describes the width or energy distribution of the edge point set of the k-th pyramid image along the x-axis, and the normalized second-order central moments along the y-axis. The normalized cross second-order central moments describe the height or energy distribution of the edge point set of the k-th layer pyramid image along the y-axis. The value reflects the correlation or tilt of the edge point set in the x and y directions of the k-th pyramid image. A non-zero value usually indicates that the edge point set is elliptical or diagonally distributed. The normalized first moment in the principal direction, the normalized first moment in the x-direction, the normalized second central moment in the x-direction, the normalized second central moment in the y-direction, and the normalized cross second central moment are combined to form the local feature vector at each scale. The expression is: .
[0014] Preferably, S3.3 specifically includes: For local feature vectors at each scale k The components are discretized using quantiles; Concatenate the discrete indices of each component into a string hash key; The specific formula is as follows: ; In the formula, This is the index of the discrete interval to which the corresponding component belongs. For hash keys; Using the hash key as the key, the original binary image coordinates The value is the scale k, which is stored in the hash table of the k-th level. The specific formula is as follows: .
[0015] Preferably, in step S3.4, a global hash table is created as a multi-scale geometric hash table. The multi-scale geometric hash table The key is a scale-hash key combination The value is the set of coordinates of the corresponding original binary image, and the hash table for each scale k. Insert all its entries into the multi-scale geometric hash table. middle; If the same key If multiple coordinate points exist, clustering is performed based on the Euclidean distance of the local feature vectors. If the distance is less than a preset distance threshold, clustering is performed. Points are grouped into the same group. For each group of points, the coordinates of its center point and the average feature vector are calculated as the representative feature vector of the group. The representative feature vector and its corresponding primitive address are retained, and redundant points are discarded. The final formula for the multi-scale geometric hash table is: .
[0016] According to another aspect of the present invention, a data processing system for drawing analysis is provided, the system employing the above-described data processing method for drawing analysis, the system comprising: The drawing data acquisition module is used to parse and process the drawing files to obtain the drawing data; The drawing data preprocessing module is used to perform image preprocessing operations on the drawing data to obtain a binary image of the drawing data; A hash table construction module is used to perform primitive feature enhancement based on multi-scale geometric hashing on the binary image to obtain a multi-scale geometric hash table; The primitive clustering module is used to implement similar primitive clustering based on the improved dynamic time warping algorithm according to the multi-scale geometric hash table; The feature extraction module is used to extract common features from the similar primitive clusters to achieve drawing analysis.
[0017] The embodiments of the present invention have the following technical effects: The improved dynamic time warping algorithm employed in this invention adds a structural change penalty term to the cumulative distance formula of the traditional dynamic time warping algorithm. This term measures the consistency of the two sequences in the direction of local structural change at the current alignment path point (a, b). The larger the penalty term, the more severe the structural abrupt change in the current alignment path, and thus the more likely it is to be avoided by the algorithm. When the direction of path movement in candidate primitive A changes drastically from that in candidate primitive B, a penalty is applied. This forces the improved dynamic time warping algorithm to prioritize alignment paths where the direction of structural change in the two primitives is consistent, effectively preventing the algorithm from incorrectly matching irrelevant convexities and concaveities in order to minimize distance, thereby significantly improving the structural fidelity of clustering.
[0018] This invention constructs an efficient and robust feature index structure by hashing local geometric structures in a multi-resolution space. It can overcome the barriers of scale, deformation and noise, and accurately discover all duplicate primitives belonging to the same family in the drawing. This greatly improves the accuracy and recall of the analysis, and significantly enhances the recognition rate and robustness of duplicate primitives.
[0019] This invention can not only identify graphic elements, but also reveal hidden design patterns and parametric rules in drawings through common feature extraction, providing deeper support for automated drawing review, intelligent process planning and design knowledge mining. Attached Figure Description
[0020] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0021] Figure 1 This is a flowchart of a data processing method for drawing analysis provided by an embodiment of the present invention; Figure 2 This is a flowchart of the process of performing primitive feature enhancement based on multi-scale geometric hashing on the binary image to obtain a multi-scale geometric hash table, provided by an embodiment of the present invention. Figure 3 This is a flowchart of similar primitive clustering based on an improved dynamic time warping algorithm for the multi-scale geometric hash table provided in an embodiment of the present invention. Detailed Implementation
[0022] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0023] Example 1, Figure 1 A flowchart of a data processing method for drawing analysis is shown, such as... Figure 1 As shown, a data processing method for drawing analysis includes the following steps: S1: Parse and process the drawing file to obtain the drawing data; In this step, the drawing file input by the user is received, and the format of the drawing file is automatically identified. Generally, the format of the drawing file includes DWG, DXF, PDF, PNG, JPG, TIFF, etc. For vector formats, it is converted into a bitmap image by calling a file parsing library. For files that are already bitmaps, they are loaded directly.
[0024] S2: Perform image preprocessing on the drawing data to obtain a binary image of the drawing data; The image preprocessing operations include grayscale conversion, noise reduction, binarization, tilt correction, and size normalization.
[0025] The grayscale conversion specifically involves using a weighted average method to convert the drawing data. The specific formula is as follows: ; In the formula, R, G, and B represent the pixel values of the red, green, and blue channels in the drawing data, respectively, and Gray is the normalized value.
[0026] The denoising process specifically involves using a median filtering algorithm to remove random noise generated during the scanning or digitization of the drawing data, preventing them from being misidentified as valid primitives. Specifically, a 5x5 pixel sliding window is used to traverse the drawing data, and the value of the center pixel of the window is replaced with the median value of all pixels in its neighborhood. Median filtering effectively removes noise while also protecting the sharpness of the edges of the drawing data.
[0027] The binarization process involves converting grayscale drawing data into a pure black-and-white binary image, making the lines of the drawing data completely black and the background completely white.
[0028] In this step, an adaptive thresholding method is used to binarize the grayscale drawing data. The grayscale drawing data is divided into a preset number of image blocks, each with a size of 51x51 pixels. For each image block, the mean grayscale value is calculated, and then the mean value is subtracted by a preset constant offset to obtain the threshold for all pixels within that image block. This can be described by the following formula: For a pixel (x, y), its threshold T(x, y) and its final binarized value The calculation is as follows: ; ; In the formula, ω is the value of the original grayscale drawing data at (x,y), mean() is the function to calculate the mean of the neighborhood, ω is the radius of the neighborhood window in the horizontal direction, h is the radius of the neighborhood window in the numerical direction, and C is a constant offset.
[0029] The tilt correction detects and corrects the overall tilt of the drawing caused by improper scanning placement, ensuring that the drawing data is in the correct horizontal and vertical orientation. Specifically, the tilt correction involves using a Hough transform on the binary image of the drawing data to detect all approximately horizontal or vertical line segments, collecting the angle information of all line segments exceeding a preset length threshold, statistically analyzing the angles of all detected line segments, identifying the angle interval with the highest frequency, and determining the center value of this interval as the estimated tilt angle θ. Then, using an affine transformation with the data center point of the drawing data as the rotation center, the entire drawing data is rotated in the opposite direction by an angle θ, thereby achieving tilt correction. The resulting blank edges are filled with white.
[0030] In this embodiment, the preset length threshold is 10% of the diagonal length of the drawing data.
[0031] The size normalization involves scaling all processed images to a standard size or resolution to ensure consistent input scale for subsequent feature extraction steps and avoid incomparable feature scales due to differences in image size. Specifically, size normalization employs a bilinear interpolation algorithm for image scaling.
[0032] S3: Perform primitive feature enhancement based on multi-scale geometric hashing on the binary image to obtain a multi-scale geometric hash table; After preprocessing the drawing image, a high-quality binary image is obtained, which contains the contour information of all geometric primitives in the drawing. However, although the original edge pixel data of the binary image is accurate, it lacks semantic structure and robustness. Especially when faced with a large number of repeated primitives such as arrayed holes and similar contour lines in the drawing, traditional point-by-point feature description methods are difficult to effectively distinguish subtle differences and achieve efficient clustering.
[0033] Specifically, such as Figure 2 As shown, S3 specifically includes: S3.1: Construct the binary image into a multi-scale Gaussian pyramid to obtain image representations at different resolutions; The binary image is then subjected to Gaussian downsampling to generate an N-layer pyramid image. , where the k-th layer image The scale is the original binary image. Each layer of the image is binarized while preserving its spatial coordinate mapping.
[0034] S3.2: Perform local feature extraction on each layer of the pyramid image to obtain multi-scale local feature vectors; In this step, a fixed-size local window is slidably set on each layer of the pyramid image, and local geometric features are extracted at the center of each window for subsequent hash encoding.
[0035] Specifically, S3.2 involves processing each pixel of each pyramid image layer. Extract a local window centered on it. In the local window Within the range, all edge points are detected, and their coordinate sets relative to the center point are recorded to form an edge point set. For each edge point set, its principal direction and geometric distance are calculated as local geometric features, wherein the principal direction... The geometric distance, obtained by calculating the eigenvectors of the covariance matrix of the edge point set, reflects the extension direction of the local structure. The geometric distance includes the normalized first-order moment in the x-direction. Normalized first moment in the y-direction Normalized second central moments in the x-direction Normalized second central moments in the y-direction Normalized cross second-order central moments .
[0036] The normalized first moment in the x-direction The x-axis represents the average offset of the edge point set of the k-th pyramid image relative to the center point, reflecting the centroid of the edge point distribution in the horizontal direction. It is used to measure the stretching or offset of the local structure in the horizontal direction, and the normalized first moment in the y-direction is also mentioned. This represents the average offset of the local edge point set of the k-th pyramid image relative to the center point along the y-axis, reflecting the centroid of the edge point distribution in the vertical direction and the normalized first moment in the x-direction. Together, they can characterize the tilt or asymmetry of the local structure, the normalized second-order central moment in the x-direction. The x-axis describes the width or energy distribution of the edge point set in the k-th layer pyramid image, reflecting its concentration or diffusion in the horizontal direction. It is often used to describe the elongated or compact characteristics of local structures. The normalized second-order central moment in the y-direction... The normalized cross second-order central moments describe the height or energy distribution of the edge point set of the k-th layer pyramid image along the y-axis, reflecting its concentration or diffusion in the vertical direction. It reflects the correlation or tilt of the edge point set of the k-th pyramid image between the x and y directions. Non-zero values usually indicate that the edge point set is elliptical or diagonally distributed, rather than axisymmetric.
[0037] The normalized first moment in the principal direction, the normalized first moment in the x-direction, the normalized second central moment in the x-direction, the normalized second central moment in the y-direction, and the normalized cross second central moment are combined to form the local feature vector at each scale. The expression is: .
[0038] S3.3: Map the local feature vectors to a discrete hash space to construct a hash table; This step is used to map the local feature vectors to a discrete hash space and construct a geometric hash table, so that primitives with similar geometric structures fall into the same or adjacent hash buckets.
[0039] Specifically, S3.3 is as follows: For local feature vectors at each scale k The components are discretized using quantiles; Concatenate the discrete indices of each component into a string hash key; The specific formula is as follows: ; In the formula, This is the index of the discrete interval to which the corresponding component belongs. For hash keys; Using the hash key as the key, the original binary image coordinates The value is the scale k, which is stored in the hash table of the k-th level. middle.
[0040] The specific formula is as follows: .
[0041] S3.4: Perform multi-scale hash table fusion and collision resolution on hash tables of various scales to obtain a multi-scale geometric hash table; Create a global hash table as a multi-scale geometric hash table The multi-scale geometric hash table The key is a scale-hash key combination The value is the set of coordinates of the corresponding original binary image, and the hash table for each scale k. Insert all its entries into the multi-scale geometric hash table. middle If the same key If multiple coordinate points exist, clustering is performed based on the Euclidean distance of the local feature vectors. If the distance is less than a preset distance threshold, clustering is performed. Points are grouped together. For each group of points, the coordinates of its center point and the average feature vector are calculated as the representative feature vector of the group. The representative feature vector and its corresponding primitive address are retained, and redundant points are discarded.
[0042] The final formula for the multi-scale geometric hash table is: ; This step constructs an efficient and robust feature index structure by hashing the local geometry in a multi-resolution space. It can overcome the barriers of scale, deformation and noise, and accurately discover all duplicate primitives belonging to the same family in the drawing. This greatly improves the accuracy and recall of the analysis, and significantly enhances the recognition rate and robustness of duplicate primitives.
[0043] S4: Perform similar primitive clustering on the multi-scale geometric hash table based on the improved dynamic time warping algorithm; The multi-scale geometric hash table can quickly index primitives with similar local geometries into the same hash bucket. However, existing hash-based clustering methods have significant limitations: they typically rely on hard matching, meaning that primitives are only classified into the same category if their hash keys are completely identical or extremely similar. This mechanism cannot effectively handle problems commonly found in engineering drawings, such as subtle deformations, local missing elements, noise interference, and non-uniform scaling. For example, a standard circle and a slightly elliptical circle, or a complete rectangle and a rectangle missing a corner, may have completely different hash keys, leading to them being incorrectly classified into different categories.
[0044] Based on this, this embodiment provides a similar primitive clustering based on improved dynamic time warping, which performs distance measurement on candidate primitive pairs selected by hash table, thereby achieving more robust and refined similar primitive clustering.
[0045] Specifically, such as Figure 3 As shown, S4 specifically includes: S4.1: Generate a set of candidate primitive pairs based on the multi-scale geometric hash table; Using the pre-constructed multi-scale geometric hash table It can quickly filter out all potentially similar primitive pairs, avoiding expensive pairwise comparisons on the entire primitive set.
[0046] Specifically, S4.1 is as follows: Traverse the multi-scale geometric hash table, for the multi-scale geometric hash table For each hash key h, retrieve all the primitives associated with it to form a primitive set. ; In the set of primitives Internally, it generates all possible primitive pairs. As preliminary candidate primitive pairs, among which... These primitive pairs share the exact same local geometry at at least one scale and are potential similar primitives; To capture cross-scale similarity, primitive pairs with the same hash key at a coarser scale (e.g., k=2) are also added to the candidate set, resulting in a candidate primitive pair set. Simultaneously, the scale information of their successful matching is recorded as prior weights for subsequent improved dynamic time warping calculations.
[0047] S4.2: Construct and normalize the feature sequences of all candidate primitives in the candidate primitive pair set to obtain the feature vector sequence of the candidate primitive pair set; Specifically, S4.2 is as follows: Each candidate primitive The Moore-Neighbortracing algorithm is used to extract the pixel boundary points of its outer contour or internal holes, forming a boundary point sequence. ,in, The Cartesian coordinates of the k-th boundary point; Calculate the boundary point sequence main direction ; By calculating the boundary point sequence The covariance matrix is calculated, and the direction of the eigenvector corresponding to its largest eigenvalue is taken as the boundary point sequence. main direction .
[0048] Transform the coordinates of all boundary points to a coordinate system with the centroid of the candidate primitive as the origin and the main direction as the coordinates. In the new coordinate system with the x-axis; The new coordinates are: ; In the formula, Candidate primitives The coordinates of the centroid, and For the k-th boundary point The new coordinates in a new coordinate system with the centroid of the primitive as the origin and the principal direction as the x-axis.
[0049] The transformed ordered point sequence Further converted into a sequence of feature vectors ; Each feature vector Defined as: ; In the formula, This represents the u-axis displacement from the current point to the next point. This represents the v-axis displacement from the current point to the next point. Boundary point The curvature at that point.
[0050] The lengths of the feature vectors in the feature vector sequence are unified to a preset standard length L through linear interpolation, so that primitives of different complexities can be compared on sequences of the same length.
[0051] S4.3: Perform similarity calculation on the candidate primitive pairs based on the improved dynamic time warping algorithm; In existing technologies, the distance between candidate primitive pairs can be calculated using dynamic time warping. However, when measuring the similarity between two primitive sequences, traditional dynamic time warping algorithms are prone to mismatching unrelated convexities and concaveities when the direction of the path moves drastically within the candidate primitives.
[0052] The improved dynamic time warping algorithm adds a structural change penalty term to the cumulative distance formula of the traditional dynamic time warping algorithm. This penalty term measures the consistency of the two sequences in the direction of local structural change at the current alignment path point (a,b). The larger the penalty term, the more severe the structural abrupt change in the current alignment path, and thus the more likely it is to be avoided by the algorithm.
[0053] S4.3 specifically refers to: the feature vector sequence of the primitive sequence in the candidate primitive pair. and Create the cumulative distance matrix D and initialize it. , Where a and b are the row and column indices representing the current position being calculated; for each Calculate three possible path transitions: from the previous step (a) 1,b) are transferred from, plus the penalty term P(a,b,a) 1,b), from the previous step (a,b) 1) Transferred from, plus penalty term P(a,b,a,b) 1) From the previous step (a) 1,b 1) Transferred from, plus penalty term P(a,b,a) 1,b 1) Calculate the cumulative distance using the cumulative distance formula based on the improved dynamic time warping algorithm, and select the one with the smallest cumulative distance among the three as the value. Traverse a=1 to m, b=1 to n, where m and n are sequences of eigenvectors. and The length of the primitive sequence in the candidate primitive pair is used to obtain the feature vector sequence. and final similarity .
[0054] The cumulative distance formula of the improved dynamic time warping algorithm is as follows: ; In the formula, For the sequence of feature vectors The first a boundary points and the sequence of eigenvectors The minimum cumulative structural distance between the first b boundary points, For the feature vector sequence The eigenvector of the boundary point a with the feature vector sequence The eigenvector of the boundary point b The basic distance between them, in this embodiment, is the Euclidean distance; This is a structural change penalty term, measuring the impact of changes from the previous state. To the current state At that time, whether the changes of the two feature vector sequences in the direction of local structure are drastic.
[0055] The structural change penalty term P is defined as follows: ; In the formula, and For the sequence of feature vectors The two index points indicate that from arrive The local direction, and For the sequence of feature vectors The two index points indicate that from arrive The local direction, For the sequence of feature vectors Zhong Cong point to The vector, For the sequence of feature vectors Zhong Cong point to The vector is denoted by λ, which is a penalty coefficient, a constant greater than 0, used to control the penalty intensity. The larger λ is, the heavier the penalty for alignment paths with inconsistent structural orientations. In this embodiment, λ is 0.5.
[0056] When the direction of a path moving in candidate primitive A changes drastically from that in candidate primitive B, a penalty is applied. This forces the improved dynamic time warping algorithm to prioritize aligned paths whose structural change directions are consistent in both primitives. This effectively prevents the algorithm from incorrectly matching unrelated convexities and depressions in order to minimize distance, thereby significantly improving the structural fidelity of clustering.
[0057] S4.4: Cluster similar primitives based on the similarity of the candidate primitive pairs to obtain clusters of similar primitives; S5: Extract common features from the similar primitive clusters to achieve drawing analysis; For each cluster of similar primitives, the average or median of the feature vectors of all primitives within the cluster is calculated to obtain a prototype vector representing the typical features of the cluster. At the same time, the original image regions of all primitives within the cluster are superimposed and averaged to generate a visualized average primitive image.
[0058] This invention can not only identify graphic elements, but also reveal hidden design patterns and parametric rules in drawings through common feature extraction, providing deeper support for automated drawing review, intelligent process planning and design knowledge mining.
[0059] Example 2: The present invention also provides a data processing system for drawing analysis, wherein the system employs a data processing method for drawing analysis according to Example 1, and the system includes: The drawing data acquisition module is used to parse and process the drawing files to obtain the drawing data; The drawing data preprocessing module is used to perform image preprocessing operations on the drawing data to obtain a binary image of the drawing data; A hash table construction module is used to perform primitive feature enhancement based on multi-scale geometric hashing on the binary image to obtain a multi-scale geometric hash table; The primitive clustering module is used to implement similar primitive clustering based on the improved dynamic time warping algorithm according to the multi-scale geometric hash table; The feature extraction module is used to extract common features from the similar primitive clusters to achieve drawing analysis.
[0060] Example 3: The present invention also provides an electronic device, including one or more processors and a memory.
[0061] A processor can be a central processing unit (CPU) or other form of processing unit with data processing and / or instruction execution capabilities, and can control other components in an electronic device to perform desired functions.
[0062] The memory may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and a processor may execute the program instructions to implement a data processing method for drawing analysis as described above in any embodiment of this application, and / or other desired functions. Various contents such as initial extrinsic parameters and thresholds may also be stored in the computer-readable storage medium.
[0063] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the technical solutions of the embodiments of the present invention.
Claims
1. A data processing method for drawing analysis, characterized in that, The method includes the following steps: S1: Parse and process the drawing file to obtain the drawing data; S2: Perform image preprocessing on the drawing data to obtain a binary image of the drawing data; S3: Perform primitive feature enhancement based on multi-scale geometric hashing on the binary image to obtain a multi-scale geometric hash table; S4: Similar primitive clustering based on an improved dynamic time warping algorithm is applied to the multi-scale geometric hash table; Specifically, S4 consists of: S4.1: Generating a set of candidate primitive pairs based on the multi-scale geometric hash table; S4.2: Constructing and normalizing the primitive feature sequences of all candidate primitives in the set of candidate primitive pairs to obtain the feature vector sequence of the set of candidate primitive pairs; S4.3: Performing similarity calculation on the candidate primitive pairs based on an improved dynamic time warping algorithm; in S4.3, the cumulative distance formula of the improved dynamic time warping algorithm is: ; In the formula, For the sequence of feature vectors The first a boundary points and the sequence of eigenvectors The minimum cumulative structural distance between the first b boundary points, For the feature vector sequence The eigenvector of the boundary point a with the feature vector sequence The eigenvector of the boundary point b The basic distance between them; D() is the cumulative structural distance function, and P() is the structural change penalty term; S4.4: Perform similarity clustering on the candidate primitive pairs to obtain similar primitive clusters; S5: Extract common features from the similar primitive clusters.
2. The data processing method for drawing analysis according to claim 1, characterized in that, Specifically, S4.1 is as follows: Traverse the multi-scale geometric hash table, for the multi-scale geometric hash table For each hash key h, retrieve all the primitives associated with it to form a primitive set. ; In the set of primitives Internally, it generates all possible primitive pairs. As preliminary candidate primitive pairs, among which... These primitive pairs share the exact same local geometry at at least one scale and are potential similar primitives.
3. The data processing method for drawing analysis according to claim 2, characterized in that, Specifically, S4.2 is as follows: Each candidate primitive The Moore-Neighbortracing algorithm is used to extract pixel boundary points of its outer contour or internal holes, forming a boundary point sequence. ,in, The Cartesian coordinates of the k-th boundary point; Calculate the boundary point sequence main direction ; By calculating the boundary point sequence The covariance matrix is calculated, and the direction of the eigenvector corresponding to its largest eigenvalue is taken as the boundary point sequence. main direction ; Transform the coordinates of all boundary points to a coordinate system with the centroid of the candidate primitive as the origin and the main direction as the coordinates. In the new coordinate system with the x-axis; The new coordinates are: ; In the formula, Candidate primitives The coordinates of the centroid, and For the k-th boundary point New coordinates in a new coordinate system with the centroid of the primitive as the origin and the principal direction as the x-axis; The transformed ordered point sequence Further converted into a sequence of feature vectors ; Each feature vector Defined as: ; In the formula, This represents the u-axis displacement from the current point to the next point. This represents the v-axis displacement from the current point to the next point. Boundary point The curvature at that point.
4. The data processing method for drawing analysis according to claim 3, characterized in that, S4.3 specifically refers to: the feature vector sequence of the primitive sequence in the candidate primitive pair. and Create the cumulative distance matrix D and initialize it. , Where a and b are the row and column indices representing the current position being calculated; for each Calculate three possible path transitions: from the previous step (a) 1,b) are transferred from, plus the penalty term P(a,b,a) 1,b), from the previous step (a,b) 1) Transferred from, plus penalty term P(a,b,a,b) 1) From the previous step (a) 1,b 1) Transferred from, plus penalty term P(a,b,a) 1,b 1) Calculate the cumulative distance based on the cumulative distance formula of the improved dynamic time warping algorithm, and select the one with the smallest cumulative distance among the three, assigning it to... Traverse a=1 to m, b=1 to n, where m and n are sequences of eigenvectors. and The length of the primitive sequence in the candidate primitive pair is used to obtain the feature vector sequence. and final similarity .
5. A data processing method for drawing analysis according to claim 4, characterized in that, The structural change penalty term P is defined as follows: ; In the formula, and For the sequence of feature vectors The two index points indicate that from arrive The local direction, and For the sequence of feature vectors The two index points indicate that from arrive The local direction, For the sequence of feature vectors Zhong Cong point to The vector, For the sequence of feature vectors Zhong Cong point to The vector, where λ is the penalty coefficient.
6. The data processing method for drawing analysis according to claim 1, characterized in that, Specifically, S3 is: S3.1: Construct the binary image into a multi-scale Gaussian pyramid to obtain image representations at different resolutions; S3.2: Perform local feature extraction on each layer of the pyramid image to obtain multi-scale local feature vectors; S3.3: Map the local feature vectors to a discrete hash space to construct a hash table; S3.4: Perform multi-scale hash table fusion and collision resolution on hash tables of various scales to obtain a multi-scale geometric hash table.
7. A data processing method for drawing analysis according to claim 6, characterized in that, Specifically, S3.2 involves processing each pixel of each pyramid image layer. Extract a local window centered on it. In the local window Within the range, all edge points are detected, and their coordinate sets relative to the center point are recorded to form an edge point set. For each edge point set, its principal direction and geometric distance are calculated as local geometric features, wherein the principal direction... The geometric distance, obtained by calculating the eigenvectors of the covariance matrix of the edge point set, reflects the extension direction of the local structure. The geometric distance includes the normalized first-order moment in the x-direction. Normalized first moment in the y-direction Normalized second central moments in the x-direction Normalized second-order central moments in the y-direction Normalized cross second-order central moments ; The normalized first moment in the x-direction The average offset of the edge point set of the k-th pyramid image relative to the center point along the x-axis is represented by the normalized first moment in the y-direction. The average offset of the local edge point set of the k-th pyramid image relative to the center point along the y-axis is represented by the normalized second-order central moment in the x-direction. Describes the width or energy distribution of the edge point set of the k-th pyramid image along the x-axis, and the normalized second-order central moments along the y-axis. The normalized cross second-order central moments describe the height or energy distribution of the edge point set of the k-th layer pyramid image along the y-axis. The value reflects the correlation or tilt of the edge point set in the x and y directions of the k-th pyramid image. A non-zero value usually indicates that the edge point set is elliptical or diagonally distributed. The normalized first moment in the principal direction, the normalized first moment in the x-direction, the normalized second central moment in the x-direction, the normalized second central moment in the y-direction, and the normalized cross second central moment are combined to form the local feature vector at each scale. The expression is: 。 8. A data processing method for drawing analysis according to claim 7, characterized in that, Specifically, S3.3 is as follows: For local feature vectors at each scale k The components are discretized using quantiles; Concatenate the discrete indices of each component into a string hash key; The specific formula is as follows: ; In the formula, This is the index of the discrete interval to which the corresponding component belongs. For hash keys; Using the hash key as the key, the original binary image coordinates The value is the scale k, which is stored in the hash table of the k-th level. The specific formula is as follows: .
9. A data processing method for drawing analysis according to claim 8, characterized in that, In step S3.4, a global hash table is created as a multi-scale geometric hash table. The multi-scale geometric hash table The key is a scale-hash key combination The value is the set of coordinates of the corresponding original binary image, and the hash table for each scale k. Insert all its entries into the multi-scale geometric hash table. middle; If the same key If multiple coordinate points exist, clustering is performed based on the Euclidean distance of the local feature vectors. If the distance is less than a preset distance threshold, clustering is performed. Points are grouped into the same group. For each group of points, the coordinates of its center point and the average feature vector are calculated as the representative feature vector of the group. The representative feature vector and its corresponding primitive address are retained, and redundant points are discarded. The final formula for the multi-scale geometric hash table is: 。 10. A data processing system for drawing analysis, characterized in that, The system employs a data processing method for drawing analysis as described in any one of claims 1-9, and the system comprises: The drawing data acquisition module is used to parse and process the drawing files to obtain the drawing data; The drawing data preprocessing module is used to perform image preprocessing operations on the drawing data to obtain a binary image of the drawing data; A hash table construction module is used to perform primitive feature enhancement based on multi-scale geometric hashing on the binary image to obtain a multi-scale geometric hash table; The primitive clustering module is used to cluster similar primitives in the multi-scale geometric hash table based on an improved dynamic time warping algorithm; The feature extraction module is used to extract common features from the similar primitive clusters to achieve drawing analysis.