Method and apparatus for extracting contour feature, and electronic device, medium and program product
By calculating the skew angle distribution function of target points on the contour and performing Fourier transform, the instability problem of contour feature extraction in existing technologies under affine transformation and slight deformation is solved, achieving higher feature extraction stability and accuracy.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2026-03-05
AI Technical Summary
Existing contour feature extraction methods struggle to maintain stability and invariance when faced with affine transformations and slight deformations, affecting the accuracy and stability of feature extraction.
By calculating the distribution function of the deviation angle of each target point on the contour as a function of the contour line, and performing Fourier transform, contour features are extracted. The influence of affine transformation and slight deformation is reduced by utilizing the local geometric features of the deviation angle and the frequency domain processing of Fourier transform.
It improves the stability and accuracy of contour feature extraction, enhances the adaptability to various deformations, and ensures the invariance and robustness of feature extraction.
Smart Images

Figure CN2024114439_05032026_PF_FP_ABST
Abstract
Description
Methods, apparatuses, electronic devices, media, and program products for extracting contour features Technical Field
[0001] This invention relates to the field of computer vision technology, and in particular to a method for extracting contour features, as well as an apparatus, electronic device, non-volatile readable storage medium, and computer program product for extracting contour features. Background Technology
[0002] In image processing and computer vision, contour feature extraction is a crucial step in shape recognition and object detection. Existing contour feature extraction methods mainly include Fourier descriptors and Hu moments. These methods utilize different mathematical techniques to describe shape features, thereby aiding image classification and recognition. Fourier descriptors use the Fourier transform of object boundary information to describe shape features, transforming contour features from the spatial domain to the frequency domain and extracting frequency domain information as the image's feature vector. Hu moments, on the other hand, are based on the image's moment features, extracting shape features by calculating the image's central moment. Hu moments can, to a certain extent, maintain invariance to image rotation, translation, and scaling.
[0003] However, these methods often struggle to maintain stability and invariance when faced with more complex affine transformations (such as shearing) and slight deformations. This limits their effectiveness in practical applications, especially in scenarios requiring high-precision shape recognition and matching.
[0004] Summary of the Invention
[0005] The present invention aims to at least solve one of the technical problems existing in the prior art. Therefore, one object of the present invention is to propose a method for extracting contour features that maintains strong invariance under affine transformations and slight deformations, reducing the influence of affine transformations and slight deformations, thereby improving the stability and accuracy of feature extraction.
[0006] The second objective of this invention is to provide an apparatus for extracting contour features.
[0007] The third objective of this invention is to provide an electronic device.
[0008] The fourth objective of this invention is to provide a non-volatile readable storage medium.
[0009] The fifth objective of this invention is to provide a computer program product.
[0010] To achieve the above objective, a method for extracting contour features according to a first aspect of the present invention includes: acquiring the contour of a target graphic; traversing target points on the contour in a preset order to obtain a distribution function of the bias angle of each target point on the contour as a function of the contour line, wherein the bias angle is the angle between a first vector of the current target point and a second vector of the current target point, the first vector is the vector from the previous target point to the current target point, and the second vector is the vector from the current target point to the next target point; and performing a Fourier transform on the distribution function of the bias angle as a function of the contour line to obtain contour features.
[0011] The method for extracting contour features according to embodiments of the present invention captures the relative angle changes between adjacent target points by calculating the distribution function of the skew angle of each target point on the contour as a function of the contour line. This information reflects the local geometric features of the contour, thus accurately describing the detailed structure of the contour. Since affine transformations primarily affect the absolute position, scale, and shape of the contour but do not change the relative angular relationships between target points on the contour, this method exhibits strong invariance to affine transformations. By performing a Fourier transform on the distribution function of the skew angle as a function of the contour line, the local geometric features of the contour can be transformed into frequency domain features, which are more robust to small-scale local deformations. Even if the contour undergoes slight local changes, the Fourier-transformed features can still effectively describe the main features of the shape. Therefore, by utilizing the distribution function of the skew angle as a function of the contour line combined with the frequency domain processing of the Fourier transform, the adaptability to various deformations can be improved, the influence of affine transformations and slight deformations can be reduced, thereby enhancing the stability and accuracy of feature extraction.
[0012] In some embodiments, the bias angle distribution function with respect to the contour line is expressed as the bias angle of each target point on the contour and the contour distance from the target point to the starting point.
[0013] In some embodiments, the contour distance is a normalized contour distance value.
[0014] In some embodiments, the starting point is any one of the target points on the contour line.
[0015] In some embodiments, the preset order includes a clockwise order or a counterclockwise order.
[0016] In some embodiments, performing a Fourier transform on the distribution function of the bias angle with respect to the contour line to obtain contour features includes: performing a discrete Fourier transform on the distribution function of the bias angle with respect to the contour line; and correcting the phase angle sequence of the discrete Fourier transform; the contour features include the amplitude of the discrete Fourier transform corresponding to each target point on the contour line and the corrected phase angle.
[0017] In some embodiments, the correction processing of the phase angle sequence of the discrete Fourier transform includes: obtaining the nth phase angle subsequence, where n≥2; the nth phase angle subsequence is obtained by calculating the phase angle difference between two adjacent phase angles in reverse order of the (n-1)th phase angle subsequence; wherein, the first phase angle subsequence is obtained by calculating the phase angle difference between two adjacent phase angles in reverse order of the phase angle sequence, and the phase angle difference between the first and last phase angles in the phase angle sequence is the first phase angle difference in the first phase angle subsequence.
[0018] In some embodiments, n = 2.
[0019] In some embodiments, the correction processing of the phase angle sequence of the discrete Fourier transform further includes: normalizing the phase angle of the nth phase angle subsequence.
[0020] To achieve the above objective, a device for extracting contour features according to a second aspect of the present invention includes: a contour acquisition module configured to acquire the contour of a target graphic; a distribution function acquisition module configured to traverse target points on the contour in a preset order to obtain a distribution function of the deviation angle of each target point on the contour as a function of the contour line, wherein the deviation angle is the angle between a first vector of the current target point and a second vector of the current target point, the first vector being the vector from the previous target point to the current target point, and the second vector being the vector from the current target point to the next target point; and a Fourier transform module configured to perform a Fourier transform on the distribution function of the deviation angle as a function of the contour line to obtain contour features.
[0021] According to an embodiment of the present invention, the apparatus for extracting contour features includes a distribution function acquisition module that traverses target points on the contour in a preset order and calculates the distribution function of the deviation angle of each target point as a function of the contour line. The deviation angle reflects the relative angular change between adjacent target points on the contour, and this local geometric feature can accurately describe the detailed structure of the contour. Since affine transformation mainly affects the absolute position, scale, and shape of the contour, but does not change the relative angular relationship between target points, this allows the apparatus to maintain strong invariance under affine transformation and slight deformation. The Fourier transform module performs a Fourier transform on the distribution function of the deviation angle as a function of the contour line, transforming the local geometric features of the contour into frequency domain features. Frequency domain features are more robust to small-scale local deformations; even if the contour undergoes slight local changes, the features after Fourier transform can still effectively describe the main features of the shape. Therefore, by using the distribution function of the deviation angle as a function of the contour line combined with the frequency domain processing of Fourier transform, the adaptability to various deformations can be improved, the influence of affine transformation and slight deformation can be reduced, thereby improving the stability and accuracy of feature extraction.
[0022] To achieve the above objectives, an electronic device according to a third aspect of the present invention includes: at least one processor; a memory communicatively connected to the processor; wherein the memory stores a computer program executable by the at least one processor, and the at least one processor executes the computer program to implement the method for extracting contour features as described in the above embodiments.
[0023] According to embodiments of the present invention, an electronic device employs the contour feature extraction method described in the above embodiments. By calculating the distribution function of the skew angle of each target point on the contour as a function of the contour line, the relative angle changes between adjacent target points can be captured. This information on relative angle changes reflects the local geometric features of the contour, thereby accurately describing the detailed structure of the contour. Since affine transformations mainly affect the absolute position, scale, and shape of the contour but do not change the relative angle relationships between target points on the contour, this method exhibits strong invariance to affine transformations. By performing a Fourier transform on the distribution function of the skew angle as a function of the contour line, the local geometric features of the contour can be transformed into frequency domain features. Frequency domain features are more robust to small-scale local deformations. Even if the contour undergoes slight local changes, the features after the Fourier transform can still effectively describe the main features of the shape. Therefore, by utilizing the distribution function of the skew angle as a function of the contour line combined with the frequency domain processing of the Fourier transform, the adaptability to various deformations can be improved, the influence of affine transformations and slight deformations can be reduced, thereby enhancing the stability and accuracy of feature extraction.
[0024] To achieve the above objectives, a non-volatile readable storage medium according to a fourth aspect of the present invention stores a computer program thereon, which, when executed by a processor, implements the method for extracting contour features as described in the above embodiments.
[0025] According to the embodiments of the present invention, the non-volatile readable storage medium, by executing a computer program that implements the method for extracting contour features as described in the above embodiments, can maintain strong invariance under affine transformations and slight deformations, reducing the influence of affine transformations and slight deformations, thereby improving the stability and accuracy of feature extraction.
[0026] To achieve the above objectives, a computer program product according to a fifth aspect of the present invention includes a computer program stored on a computer-readable storage medium, the computer program including program instructions that, when executed by a computer, cause the computer to perform the method for extracting contour features as described in the above embodiments.
[0027] According to the computer program product of the present invention, by executing the program instructions of the method for extracting contour features as described in the above embodiments, the relative angle changes between adjacent target points can be captured by calculating the distribution function of the skew angle of each target point on the contour as a function of the contour line. This information on relative angle changes reflects the local geometric features of the contour, thereby accurately describing the detailed structure of the contour. Since affine transformations mainly affect the absolute position, scale, and shape of the contour, but do not change the relative angular relationships between target points on the contour, this method has strong invariance to affine transformations. By performing a Fourier transform on the distribution function of the skew angle as a function of the contour line, the local geometric features of the contour can be transformed into frequency domain features, which are more robust to small-scale local deformations. Even if the contour undergoes slight local changes, the features after the Fourier transform can still effectively describe the main features of the shape. Therefore, by combining the distribution function of the skew angle as a function of the contour line with the frequency domain processing of the Fourier transform, the adaptability to various deformations can be improved, the influence of affine transformations and slight deformations can be reduced, thereby improving the stability and accuracy of feature extraction.
[0028] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0029] The above and / or additional aspects and advantages of the present invention will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which:
[0030] Figure 1 is a flowchart of a method for extracting contour features according to an embodiment of the present invention;
[0031] Figure 2 is a schematic diagram of the contour distance and deflection angle according to an embodiment of the present invention;
[0032] Figure 3 is a schematic diagram of normalizing the contour distance according to an embodiment of the present invention;
[0033] Figure 4 is a graph showing the changes in amplitude and phase angle of different patterns and characteristic values of different patterns with frequency according to an embodiment of the present invention.
[0034] Figure 5 shows the amplitude of different patterns in the prior art and the curves of the characteristic values of different patterns after Fourier descriptor processing as a function of frequency.
[0035] Figure 6 is a schematic diagram comparing the similarity of feature values of different graphics according to an embodiment of the present invention;
[0036] Figure 7 is a comparative diagram of the similarity of feature values of different graphics processed using Fourier descriptors in the prior art;
[0037] Figure 8 is a block diagram of an apparatus for extracting contour features according to an embodiment of the present invention;
[0038] Figure 9 is a block diagram of an electronic device according to an embodiment of the present invention.
[0039] Reference numerals: Device for extracting contour features 100; Contour acquisition module 1; Distribution function acquisition module 2; Fourier transform module 3; Electronic device 110; Processor 111; Memory 112. Detailed Implementation
[0040] The embodiments of the present invention are described in detail below. The embodiments described with reference to the accompanying drawings are exemplary. The embodiments of the present invention are described in detail below.
[0041] In existing technologies, contour feature extraction methods mainly include Fourier descriptors and Hu moments. These methods utilize different mathematical techniques to describe shape features, thereby assisting in image classification and recognition.
[0042] The Fourier descriptor is a classic contour feature extraction method that obtains a frequency domain representation of the shape by performing a Fourier transform on the coordinates of the contour's boundary points. While the Fourier descriptor provides some shape invariance, its robustness to affine transformations is limited. Specifically, the Fourier descriptor is robust to contour translation, scaling, and rotation, but it is quite sensitive to affine transformations, especially nonlinear deformations. This is mainly because the Fourier descriptor does not maintain feature invariance well when handling affine transformations, especially when the contour undergoes significant deformation, the frequency domain coefficients of the Fourier descriptor may be significantly affected, leading to inaccurate feature matching.
[0043] Hu moments are another commonly used contour feature extraction method. Based on the moment features of an image, Hu moments extract shape features by calculating the central moment of the image. Hu moments can maintain invariance to shape rotation, translation, and scaling to a certain extent. However, Hu moments remain sensitive to complex affine transformations and slight deformations (such as local shape distortion). This is because Hu moments are primarily based on the global characteristics of the image; when dealing with more complex affine transformations or local deformations, they are prone to losing important information, leading to a decrease in the accuracy of feature extraction and thus affecting the final shape recognition performance.
[0044] Therefore, these methods often struggle to maintain stability and invariance when faced with more complex affine transformations (such as shearing) and slight deformations.
[0045] To address the above problems, this invention proposes a method for extracting contour features. This method maintains strong invariance under affine transformations and slight deformations, reducing the impact of affine transformations and slight deformations, thereby improving the stability and accuracy of feature extraction.
[0046] The method for extracting contour features according to an embodiment of the present invention is described below with reference to FIG1.
[0047] Figure 1 is a flowchart of a method for extracting contour features according to an embodiment of the present invention. The method for extracting contour features includes at least steps S1-S3, as follows:
[0048] S1, obtain the outline of the target graphic.
[0049] In some embodiments, the target graphic refers to an image or shape that needs to be feature extracted and analyzed. It can be any two-dimensional graphic with a clear boundary, such as geometric figures, objects, text, symbols, engineering drawings (such as architectural floor plans, mechanical parts drawings), etc.
[0050] In some embodiments, a contour can refer to the boundary line or edge line of a target graphic, a coherent path formed by the boundaries of the graphic. It represents the shape contour of the graphic and serves as the boundary between the inside and outside of the graphic. The contour provides geometric shape information of the graphic, which is crucial for shape recognition and analysis. In target detection tasks, contour information can help determine the location and shape of the target, supporting subsequent recognition and classification tasks. For example, in medical image analysis, obtaining the contour of a tumor helps determine its shape and size. Furthermore, in autonomous driving systems, the contours of obstacles around the vehicle can be used for obstacle detection and path planning.
[0051] In some embodiments, the contour of a target graphic can be obtained using edge detection algorithms and contour tracking algorithms. Edge detection algorithms (such as Canny edge detection and the Sobel operator) are used to detect edges in an image. These algorithms identify areas where pixel values change drastically by calculating the gradients of pixels in the image, thus finding the edges. The Canny edge detection algorithm accurately detects edges through a series of steps (such as Gaussian filtering, gradient calculation, non-maximum suppression, and double thresholding); the Sobel operator detects edges by calculating the gradient values in the horizontal and vertical directions of the image. Contour tracking algorithms (such as the findContours function in OpenCV) are used to extract contours from the edge detection results. This algorithm connects edge points into continuous lines, forming closed or open contours, providing boundary information of the target graphic.
[0052] S2, traverse the target points on the contour in a preset order to obtain the distribution function of the deviation angle of each target point on the contour as a function of the contour line.
[0053] In some embodiments, target points on a contour can be discrete points sampled on the contour or every point on the contour. These points represent the shape of the contour and can describe its geometric features. The contour obtained through edge detection and contour tracking algorithms can provide the positions of these target points. Each target point is a sample point of the contour, which can be a pixel on an edge or a calculated interpolated point.
[0054] In some embodiments, the preset order includes a clockwise or counterclockwise order, meaning that when traversing target points on the contour, a clockwise or counterclockwise order can be selected. The choice of this order can depend on the specific application requirements or the algorithm design.
[0055] In some embodiments, the bias angle is the angle between the first vector of the current target point and the second vector of the current target point, where the first vector is the vector from the previous target point to the current target point, and the second vector is the vector from the current target point to the next target point.
[0056] In some embodiments, using the distribution function of the bias angle with respect to the contour line can maintain strong invariance under affine transformations and slight deformations, reducing the impact of affine transformations and slight deformations.
[0057] Affine transformation, a common transformation model in image processing and computer vision, primarily describes linear transformations between two-dimensional coordinate points. It preserves the "straightness" (i.e., straight lines remain straight lines after transformation) and "parallelism" (i.e., parallel lines remain parallel lines after transformation) of two-dimensional graphics. Affine transformations can be achieved through a combination of a series of atomic transformations, including translation, scaling, flipping, rotation, and shearing.
[0058] In some embodiments, affine transformations include operations such as translation, rotation, scaling, and shearing. These operations change the absolute position and orientation of each target point in the image, but do not change the relative angles between target points. Specifically: translation does not change the relative angles and distances between target points, but only changes the position of all target points. Rotation changes the orientation of target points, but the relative angles remain unchanged. Scaling changes the distances between target points, but the relative angles remain unchanged. Shearing changes the shape of the contour, but does not change the local relative angles between target points.
[0059] The skew angle describes the relative direction between each target point on the contour and its neighbors. Calculating the skew angle of each target point on the contour and plotting its distribution function along the contour line captures local geometric changes in the contour at various locations. This method focuses on local features rather than global features, making it insensitive to global affine transformations. Even if the contour undergoes a global affine transformation or slight deformation, the skew angle, as a local angular information, remains unchanged after the affine transformation because it does not alter local angular relationships. Therefore, features constructed based on the skew angle exhibit strong invariance to affine transformations.
[0060] S3, perform a Fourier transform on the distribution function of the bias angle with respect to the contour line to obtain the contour features.
[0061] In some embodiments, the Fourier transform is a mathematical transformation that converts signals in the time or spatial domain into signals in the frequency domain, thereby extracting the frequency components of the signal. By performing a Fourier transform on the distribution function of the skew angle as a function of the contour line, local geometric features can be transformed into frequency domain features (i.e., contour features). Frequency domain features are more robust to small-scale local deformations. Even with slight changes in the contour, the features after the Fourier transform can still effectively describe the main features of the shape.
[0062] In some embodiments, contour features are attributes used to describe the shape of a target graphic's contour. In the frequency domain, contour features can be represented as a set of frequency components and their corresponding amplitudes and phase angles, which reflect the shape information of the contour. Contour features can not only be used to determine similarity but also help identify and classify different shapes in image recognition. By comparing the contour features of different graphics, their similarities and differences can be effectively determined.
[0063] The method for extracting contour features according to embodiments of the present invention captures the relative angle changes between adjacent target points by calculating the distribution function of the skew angle of each target point on the contour as a function of the contour line. This information reflects the local geometric features of the contour, thus accurately describing the detailed structure of the contour. Since affine transformations primarily affect the absolute position, scale, and shape of the contour but do not change the relative angular relationships between target points on the contour, this method exhibits strong invariance to affine transformations. By performing a Fourier transform on the distribution function of the skew angle as a function of the contour line, the local geometric features of the contour can be transformed into frequency domain features, which are more robust to small-scale local deformations. Even if the contour undergoes slight local changes, the Fourier-transformed features can still effectively describe the main features of the shape. Therefore, by utilizing the distribution function of the skew angle as a function of the contour line combined with the frequency domain processing of the Fourier transform, the adaptability to various deformations can be improved, the influence of affine transformations and slight deformations can be reduced, thereby enhancing the stability and accuracy of feature extraction.
[0064] In some embodiments, the distribution function of the bias angle with respect to the contour line is represented as the bias angle of each target point on the contour and the contour distance from the target point to the starting point. The distribution function of the bias angle with respect to the contour line can be a mathematical expression used to describe the geometric characteristics of each target point on the contour line. Specifically, it is based on the target point and considers the bias angle of each target point and the contour distance of that point relative to the starting point of the contour.
[0065] In some embodiments, the distribution function of the deviation angle with respect to the contour line can be represented by a formula or a set of data, including two variables: the deviation angle of the target point and the contour distance from the target point to the starting point. This function can be expressed as f(x i ,y i ), where x i y represents the contour distance from the i-th target point to the starting point. i This represents the deflection angle of the i-th target point.
[0066] The bias angle of each target point serves to capture local geometric changes in the contour. The contour distance provides global positional information for the target points on the contour. It represents the relative position of each target point on the contour and helps determine the point's positional order within the entire contour. Combining the bias angle of each target point with the contour distance from that target point to the starting point reflects both the local details and the global structure of the contour, providing a more comprehensive description of its shape. This approach exhibits stronger invariance to affine transformations (such as translation, scaling, rotation, and shearing) because these transformations do not alter the angular relationships between target points. Therefore, using this distribution function reduces the impact of affine transformations and minor deformations, especially in applications such as image comparison and pattern recognition.
[0067] In some embodiments, the starting point can be any target point on the contour line. That is, there are no fixed requirements for choosing the starting point; it can be flexibly set according to specific needs or algorithm design. Since the contour is a closed curve, the arbitrary choice of the starting point ensures the algorithm's cyclic invariance to contour traversal. This means that calculating the bias angle distribution from different starting points will not affect the final feature result, enhancing the algorithm's robustness to rotation and starting point selection. This flexibility allows the method to adapt to various complex scenarios and application requirements, ensuring stable extraction of effective features under different conditions.
[0068] Figure 2 is a schematic diagram of the contour distance and deflection angle according to an embodiment of the present invention. As shown in Figure 2, an arbitrary target point is selected from the contour as the starting point, that is, target point P0 is selected as the starting point. Starting from the starting point P0, each target point on the contour is traversed sequentially in a clockwise (or counterclockwise) direction, and the deflection angle and contour distance from the target point to the starting point are calculated for each target point.
[0069] Further, as shown in Figure 2, the contour distance from target point P1 to target point P0 is L1, the contour distance from target point P2 to target point P1 is L2, and the angle between the vector from target point P0 to target point P1 and the vector from target point P1 to target point P2 is denoted as the bias angle a1. Therefore, the eigenvalue corresponding to target point P1 is (L1, a1), the eigenvalue corresponding to target point P2 is (L1+L2, a2), and so on. The eigenvalue of each target point is calculated sequentially along the contour line until the contours are joined end-to-end.
[0070] Furthermore, by calculating the feature values of all target points on the contour through the above steps, a distribution function describing the shape of the contour is generated, namely the distribution function of the deviation angle with respect to the contour line, denoted as f(x i ,y i ), where x i y represents the contour distance from the i-th target point to the starting point. i This represents the deflection angle of the i-th target point.
[0071] In some embodiments, the contour distance is a normalized contour distance value. Normalization can be achieved by mapping the contour distance to a standardized range, such as [0,1]. The purpose is to eliminate differences in graphic size, reduce comparison errors caused by different graphic dimensions, and ensure that graphics of different sizes are compared on the same scale, thereby improving comparison accuracy.
[0072] Specifically, in the unnormalized state, the contour distance is an absolute distance based on the actual size of the graphic. When comparing graphics of different sizes, the absolute distance can introduce significant errors due to size differences. Normalization converts the contour distance into a relative distance (typically between 0 and 1), eliminating comparison errors caused by differences in graphic size. Therefore, the normalized contour distance and skew angle provide a unified scale at which graphics of different sizes can be feature-extracted and compared using the same standard, thus avoiding inconsistencies caused by size differences. Normalization adjusts the features of different graphics to a uniform scale, facilitating direct comparison. For example, after normalization, the features of two circles of different sizes become standardized, making them easier to compare through similarity measurements.
[0073] Figure 3 is a schematic diagram of normalizing the contour distance according to an embodiment of the present invention. As shown in Figure 3, by normalizing the contour distance from different target points to the starting point to the range of 0 to 1, the analysis can be performed on a uniform scale regardless of the actual length of the contour distance. This helps to compare graphic contours of different sizes or scales, reduce numerical deviations caused by size differences, and thus improve the accuracy of the comparison.
[0074] In some embodiments, performing a Fourier transform on the distribution function of the bias angle with respect to the contour line to obtain contour features includes: performing a discrete Fourier transform on the distribution function of the bias angle with respect to the contour line, and performing a correction process on the phase angle sequence of the discrete Fourier transform.
[0075] The Fourier transform is a mathematical transformation that converts signals in the time or spatial domain into signals in the frequency domain. For discrete signals, the Discrete Fourier Transform (DFT) can be used to analyze the frequency components. In this embodiment of the invention, the input signal can be a distribution function of the bias angle as a function of a contour line. This function describes the local geometric features of each target point on the contour. By applying the Discrete Fourier Transform to this distribution function, the change in bias angle in the time domain is transformed into frequency domain information. The frequency domain information includes the amplitude and phase angle of the signal.
[0076] In some embodiments, the Discrete Fourier Transform (DFT) can decompose the original signal into sine waves of different frequencies, which helps in analyzing the frequency characteristics of the signal. Through the DFT, complex time-domain signals are transformed into frequency components, making signal processing and analysis simpler.
[0077] In some embodiments, the distribution function f(x) of the bias angle with respect to the contour line i ,y i The Discrete Fourier Transform is performed using the following formula:
[0078] Where k is the frequency index or the number of the frequency component in the Fourier transform, w s The frequency step size, w, is expressed as the discrete Fourier transform frequency step size. s The value of is from 0 to π, representing the frequency range calculated in the Fourier transform. This range covers all possible frequencies in the Fourier transform. i is a weak unit, from x1 to x... n and y1 to y n The distribution functions f(x) are respectively i ,y i The point in ).
[0079] Therefore, through this discrete Fourier transform, the bias angle is expressed as a function of the contour line distribution f(x). i ,y i The signal is converted into a function F(k) in the frequency domain to capture the characteristics of the signal at different frequencies.
[0080] In some embodiments, the phase angle is the initial phase of each frequency component in the signal, which can be represented as the angle of the frequency component in the complex plane. Phase information obtained by directly applying the Discrete Fourier Transform (DFT) may be affected by noise or computational errors, leading to a shift in the phase angle. Therefore, phase angle correction is necessary to improve the accuracy and consistency of the feature information after the Fourier Transform. This correction helps reduce the bias introduced by noise or transform errors, making the features more reliable.
[0081] In some embodiments, the contour features include the amplitude of the discrete Fourier transform corresponding to each target point on the contour line and the corrected phase angle. By combining the amplitude and corrected phase angle of each target point, a complete contour feature can be formed. These features not only reflect the overall shape change of the signal (through amplitude) but also preserve the local details of the signal (through phase angle). This enhances the discriminative power of the features, making them more accurate and detailed in describing and distinguishing different contours.
[0082] In some embodiments, the phase angle sequence of the discrete Fourier transform is corrected by: obtaining the nth phase angle subsequence, where n≥2. The nth phase angle subsequence is obtained by calculating the phase angle difference between two adjacent phase angles in reverse order of the (n-1)th phase angle subsequence. The first phase angle subsequence is obtained by calculating the phase angle difference between two adjacent phase angles in reverse order of the phase angle sequence. The phase angle difference between the first and last phase angles in the phase angle sequence is the first phase angle difference in the first phase angle subsequence. The specific formula is as follows: Δa i =a i+1 -a i ;
[0083] Where, Δai a is the phase angle difference between two adjacent phase angles. i and a i+1 These are two adjacent phase angles.
[0084] For example, suppose the phase angle sequence obtained after discrete Fourier transform is [30°, 45°, 60°, 90°]. To perform correction, we can first calculate the first phase angle subsequence. The initial phase angle sequence, arranged in reverse order, is [90°, 60°, 45°, 30°]. Then, we calculate the difference between two adjacent phase angles: 90°-60° = 30°, 60°-45° = 15°, 45°-30° = 15°, and 30°-90° = -60°, thus obtaining the first phase angle subsequence as [-60°, 30°, 15°, 15°].
[0085] Furthermore, the second phase angle subsequence is calculated by reversing the first phase angle subsequence to obtain [15°, 15°, 30°, -60°]. Then, the difference between two adjacent phase angles is calculated, namely 15°-15°=0°, 15°-30°=-15°, 30°-(-60°)=90°, and -60°-15°=-75°, thus obtaining the second phase angle subsequence as [-75°, 0°, -15°, 90°].
[0086] Therefore, by performing multiple difference calculations on the phase angle, the phase change caused by rotation can be eliminated, making the features unaffected by rotation. Thus, regardless of the rotation angle of the contour graphic, the feature information remains consistent after multiple difference processing, thereby improving the robustness of the features.
[0087] In some embodiments, when n=2, it can represent performing two difference calculations on the phase angle sequence of the discrete Fourier transform to obtain the corrected phase angle subsequence. Through this double difference processing, the influence of image rotation can be effectively reduced, making the phase angle features less sensitive to rotation, thereby improving the stability and consistency of the features.
[0088] In some embodiments, the correction processing of the phase angle sequence of the discrete Fourier transform further includes: normalizing the phase angles of the nth phase angle subsequence. The purpose of the normalization processing is to adjust all phase angles to a uniform range, avoid comparison errors caused by the difference between positive and negative phase angles, and ensure that the feature values are consistent and comparable across different images.
[0089] In some embodiments, normalization can be performed using various methods, such as transformation using trigonometric functions (e.g., sine or cosine functions), or by using other mathematical methods to standardize the phase angle to a specified range. Specific normalization methods are not limited here, allowing for flexibility to adapt to different application requirements.
[0090] Figure 4 is a graph showing the amplitude and phase angle of different patterns and characteristic values of different patterns as a function of frequency according to an embodiment of the present invention. As shown in Figure 4, based on when w s With a value of 1, k = 40, and the phase angle normalized using a sine function, Figure 4(a) shows the original rectangular shape, (a') shows the amplitude of the eigenvalues of the original rectangular shape as a function of frequency, and (a”) shows the phase angle of the eigenvalues of the original rectangular shape as a function of frequency. Figure 4(b) shows the shape after rotation, scaling, and translation, (b') shows the amplitude of the eigenvalues of the shape after rotation, scaling, and translation as a function of frequency, and (b”) shows the phase angle of the eigenvalues of the shape after rotation, scaling, and translation as a function of frequency. Figure 4(c) shows the shape after affine transformation, (c') shows the amplitude of the eigenvalues of the shape after affine transformation as a function of frequency, and (c”) shows the phase angle of the eigenvalues of the shape after affine transformation as a function of frequency. Figure 4(d) shows another shape (circle), (d') shows the amplitude of the eigenvalues of the circular shape as a function of frequency, and (d”) shows the phase angle of the eigenvalues of the circular shape as a function of frequency.
[0091] Analysis of Figure 4 shows that (a') and (a”), (b') and (b”), and (c) and (c”) are insensitive to rotation, translation, scaling, and affine transformations of the graph, indicating that the eigenvalues have strong robustness. Even after these transformations, the distribution of amplitude and phase angles remains unchanged. Furthermore, Figures (d') and (d”) show that both amplitude and phase angle can be used to distinguish different graphs.
[0092] Furthermore, as shown in Figure 4, the first 10 feature values of different graphics are similar. Therefore, these similar feature values need to be removed when comparing similarity to avoid errors. Specifically, these first 10 feature values may be highly sensitive to the main contour features of the graphics, but have a weak ability to distinguish detailed features. Therefore, these similar feature values need to be removed, and subsequent feature values should be retained for comparison.
[0093] Figure 5 shows the amplitude of different shapes in the prior art and the curves of the characteristic values of different shapes processed by the Fourier descriptor as a function of frequency. As shown in Figure 5, (e) is the original rectangular shape, and (e') is the curve of the amplitude of the characteristic values of the original rectangular shape processed by the Fourier descriptor as a function of frequency. Figure 5 shows (f) a shape processed by rotation, scaling, and translation, and (f') is the curve of the amplitude of the characteristic values of the shape processed by rotation, scaling, and translation, processed by the Fourier descriptor as a function of frequency. Figure 4 shows (g) a shape processed by affine transformation, and (g') is the curve of the amplitude of the characteristic values of the shape processed by the affine transformation, processed by the Fourier descriptor, as a function of frequency. Figure 4 shows (h) a shape of another shape (circle), and (h') is the curve of the amplitude of the characteristic values of the circular shape processed by the Fourier descriptor as a function of frequency.
[0094] Analysis of Figure 5 shows that, comparing (e'), (f'), and (g') in Figure 5, the third and fifth eigenvalues change significantly after the affine transformation. Furthermore, it can be seen from (e'), (f'), (g'), and (h') in Figure 5 that the eigenvalues processed by the Fourier descriptor are concentrated in the first 10.
[0095] Furthermore, as can be seen from Figure 5 (e'), (f'), (g') and (h'), the magnitude of the first eigenvalue is 1.0. Therefore, it needs to be removed when comparing similarity.
[0096] In some embodiments, if the Euclidean distance between two vectors divided by the sum of their magnitudes is used as a similarity measure, the similarity comparison of feature values of different graphics using the contour feature extraction method of this embodiment can be shown in Figure 6 for the different graphics in Figures 4 and 5 above. In Figure 6, the graphics in the first row from left to right and the graphics in the first column from top to bottom are identical: the original rectangle, the graphic after translation, rotation, and scaling of the original graphic, the graphic after affine transformation of the original graphic, and the circular graphic. As can be seen from Figure 6, the graphics after translation, rotation, and scaling of the original graphic and the graphic after affine transformation of the original graphic have a very high similarity to the original rectangle. Therefore, the contour feature extraction method of this embodiment can maintain strong invariance under affine transformation and slight deformation, reducing the influence of affine transformation and slight deformation, thereby improving the stability and accuracy of feature extraction.
[0097] In some embodiments, the similarity comparison of feature values of different graphics processed using the Fourier descriptor in the prior art can be shown in Figure 7. The graphics in the first row of Figure 7 correspond identically from left to right and from top to bottom to the graphics in the first column: the original rectangle, a graphic obtained by translation, rotation, and scaling of the original graphic, a graphic obtained by affine transformation of the original graphic, and a circle. As can be seen from the data in the third column of Figure 7, the invariance of the Fourier descriptor to affine transformations is weaker than the contour feature extraction method of this embodiment. Furthermore, as can be seen from the data in the fourth column of Figure 7, the discriminative power of the Fourier descriptor for different graphics is weaker than the contour feature extraction method of this embodiment.
[0098] The apparatus for extracting contour features according to an embodiment of the present invention is described below with reference to FIG8.
[0099] Figure 8 is a block diagram of an apparatus for extracting contour features according to an embodiment of the present invention. As shown in Figure 8, the apparatus 100 for extracting contour features includes: a contour acquisition module 1, a distribution function acquisition module 2, and a Fourier transform module 3.
[0100] In some embodiments, the contour acquisition module 1 can be configured to acquire the contour of the target graphic. Specifically, the contour acquisition module 1 can extract edges in the image using image processing techniques, such as edge detection algorithms (Canny edge detection, Sobel operator, etc.), and connect the detected edge points into continuous contour lines using a contour tracking algorithm (the findContours function in OpenCV). The output of this module is the contour of the target graphic, which lays the foundation for subsequent feature extraction.
[0101] In some embodiments, the distribution function acquisition module 2 can be configured to traverse the target points on the contour in a preset order to obtain the distribution function of the bias angle of each target point on the contour line, wherein the bias angle is the angle between the first vector of the current target point and the second vector of the current target point, the first vector is the vector from the previous target point to the current target point, and the second vector is the vector from the current target point to the next target point.
[0102] The deviation angle distribution function of the contour line represents the deviation angle of each target point on the contour and the contour distance from the target point to the starting point. The contour distance is the normalized contour distance value. Normalization can be performed by mapping the contour distance to a standardized range, such as [0,1]. Its purpose is to eliminate differences in graphic size, reduce comparison errors caused by different graphic dimensions, and ensure that graphics of different sizes are compared on the same scale, thereby improving the accuracy of the comparison.
[0103] In some embodiments, the distribution function acquisition module 2 can be configured with a preset order of clockwise or counterclockwise, the choice of which can depend on the specific application requirements or algorithm design. Furthermore, the starting point can be any target point on the contour line, which can also be flexibly set according to specific needs or algorithm design.
[0104] In some embodiments, the Fourier transform module 3 can be configured to perform a Fourier transform on the distribution function of the bias angle as a function of the contour line to obtain contour features. Specifically, a discrete Fourier transform can be performed on the distribution function of the bias angle as a function of the contour line, and the distribution function f(x) of the bias angle as a function of the contour line can be transformed to obtain contour features. i ,y i The signal is converted into a function F(k) in the frequency domain to capture the characteristics of the signal at different frequencies.
[0105] Furthermore, the phase angle sequence of the Discrete Fourier Transform (DFT) can be corrected. This correction process can include performing multiple difference calculations on the phase angle sequence of the DFT to eliminate phase changes caused by rotation, ensuring that the features are unaffected by rotation. Additionally, the phase angles of the nth phase angle subsequence can be normalized. The purpose of normalization is to adjust all phase angles to a uniform range, avoiding comparison errors caused by differences in the positive and negative values of the phase angles, and ensuring consistency and comparability of feature values across different images.
[0106] In some embodiments, the contour features include the amplitude of the discrete Fourier transform corresponding to each target point on the contour line and the corrected phase angle. By combining the amplitude and corrected phase angle of each target point, a complete contour feature can be formed. These features not only reflect the overall shape change of the signal (through amplitude) but also preserve the local details of the signal (through phase angle). This enhances the discriminative power of the features, making them more accurate and detailed in describing and distinguishing different contours.
[0107] According to an embodiment of the present invention, the device 100 for extracting contour features includes a distribution function acquisition module 2 that traverses the target points on the contour in a preset order and calculates the distribution function of the deviation angle of each target point as a function of the contour line. The deviation angle reflects the relative angular change between adjacent target points on the contour, and this local geometric feature can accurately describe the detailed structure of the contour. Since affine transformation mainly affects the absolute position, scale, and shape of the contour, but does not change the relative angular relationship between target points, this device can maintain strong invariance under affine transformation and slight deformation. The Fourier transform module 3 performs a Fourier transform on the distribution function of the deviation angle as a function of the contour line, transforming the local geometric features of the contour into frequency domain features. Frequency domain features are more robust to small-scale local deformations; even if the contour undergoes slight local changes, the features after Fourier transform can still effectively describe the main features of the shape. Therefore, by using the distribution function of the deviation angle as a function of the contour line combined with the frequency domain processing of Fourier transform, the adaptability to various deformations can be improved, the influence of affine transformation and slight deformation can be reduced, thereby improving the stability and accuracy of feature extraction.
[0108] The electronic device according to an embodiment of the present invention is described below with reference to FIG9.
[0109] FIG9 is a block diagram of an electronic device according to an embodiment of the present invention. As shown in FIG9, the electronic device 110 includes a memory 112 and at least one processor 111.
[0110] The processor 111 can be one processor 111, or it can be two processors 111, three processors 111, five processors 111, eight processors 111, ten processors 111, or more processors 111. These processors 111 can be general-purpose processors or special-purpose chips, depending on the design and purpose of the electronic device 110.
[0111] In some embodiments, memory 112 may be used to store computer programs and other necessary data. This memory 112 may include RAM (random access memory) and ROM (read-only memory), etc. The computer program is stored in memory 112 and awaits execution by processor 111.
[0112] In some embodiments, the memory 112 is communicatively connected to at least one processor 111, and the memory 112 stores a computer program that can be executed by at least one processor 111. When the at least one processor 111 executes the computer program, it implements the method for extracting contour features as described in the above embodiments.
[0113] In some embodiments, electronic device 110 refers to a hardware device capable of performing calculations, storing, and processing information. Electronic devices can be image processing devices, computer devices, and home appliances, etc. Image processing devices are specifically designed for processing and analyzing image data, such as cameras, scanners, and industrial cameras. Computer devices refer to general-purpose computing devices, such as desktop computers, laptops, and servers. Home appliances refer to electronic devices used in the home, such as televisions, smart speakers, and home robots. These devices can all perform contour feature extraction and other image processing functions by executing specific software programs.
[0114] According to the electronic device 110 of the present invention, by employing the contour feature extraction method described in the above embodiment, the relative angle changes between adjacent target points can be captured by calculating the distribution function of the skew angle of each target point on the contour as a function of the contour line. This information on relative angle changes reflects the local geometric features of the contour, thereby accurately describing the detailed structure of the contour. Since affine transformations mainly affect the absolute position, scale, and shape of the contour, but do not change the relative angle relationships between target points on the contour, this method exhibits strong invariance to affine transformations. By performing a Fourier transform on the distribution function of the skew angle as a function of the contour line, the local geometric features of the contour can be transformed into frequency domain features, which are more robust to small-scale local deformations. Even if the contour undergoes slight local changes, the features after the Fourier transform can still effectively describe the main features of the shape. Therefore, by utilizing the distribution function of the skew angle as a function of the contour line combined with the frequency domain processing of the Fourier transform, the adaptability to various deformations can be improved, the influence of affine transformations and slight deformations can be reduced, thereby enhancing the stability and accuracy of feature extraction.
[0115] This invention also proposes a non-volatile readable storage medium storing a computer program. When the computer program is executed by the processor 111, it implements the contour feature extraction method described in the above embodiments. The specific implementation process of the contour feature extraction method can be referred to the description in the above embodiments.
[0116] The computer-readable storage medium in the embodiments of the present invention may include, but is not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other optical and magnetic storage media, which will not be described in detail here.
[0117] According to the embodiments of the present invention, the non-volatile readable storage medium, by executing a computer program that implements the method for extracting contour features as described in the above embodiments, can maintain strong invariance under affine transformations and slight deformations, reducing the influence of affine transformations and slight deformations, thereby improving the stability and accuracy of feature extraction.
[0118] This invention also proposes a computer program product, which includes a computer program stored on a computer-readable storage medium. The computer program includes program instructions, which, when executed by a computer, cause the computer to perform the method for extracting contour features as described in the above embodiments.
[0119] According to the computer program product of the present invention, by executing the program instructions of the method for extracting contour features as described in the above embodiments, the relative angle changes between adjacent target points can be captured by calculating the distribution function of the skew angle of each target point on the contour as a function of the contour line. This information on relative angle changes reflects the local geometric features of the contour, thereby accurately describing the detailed structure of the contour. Since affine transformations mainly affect the absolute position, scale, and shape of the contour, but do not change the relative angular relationships between target points on the contour, this method has strong invariance to affine transformations. By performing a Fourier transform on the distribution function of the skew angle as a function of the contour line, the local geometric features of the contour can be transformed into frequency domain features, which are more robust to small-scale local deformations. Even if the contour undergoes slight local changes, the features after the Fourier transform can still effectively describe the main features of the shape. Therefore, by combining the distribution function of the skew angle as a function of the contour line with the frequency domain processing of the Fourier transform, the adaptability to various deformations can be improved, the influence of affine transformations and slight deformations can be reduced, thereby improving the stability and accuracy of feature extraction.
[0120] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "illustrative embodiment," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example.
[0121] Although embodiments of the invention have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the claims and their equivalents.
Claims
1. A method for extracting contour features, characterized in that, include: Obtain the outline of the target graphic; The target points on the contour are traversed in a preset order to obtain the distribution function of the bias angle of each target point on the contour as a function of the contour line. The bias angle is the angle between the first vector of the current target point and the second vector of the current target point. The first vector is the vector from the previous target point to the current target point, and the second vector is the vector from the current target point to the next target point. The Fourier transform of the deviation angle as a function of the contour line is performed to obtain the contour features.
2. The method according to claim 1, characterized in that, The distribution function of the deviation angle with respect to the contour line is expressed as the deviation angle of each target point on the contour and the contour distance from the target point to the starting point.
3. The method according to claim 2, characterized in that, The contour distance is the normalized contour distance value.
4. The method according to claim 2, characterized in that, The starting point is any one of the target points on the contour line.
5. The method according to claim 1, characterized in that, The preset order includes either clockwise or counterclockwise order.
6. The method according to any one of claims 1-5, characterized in that, The step of performing a Fourier transform on the distribution function of the deviation angle as a function of the contour line to obtain contour features includes: Perform a discrete Fourier transform on the distribution function of the deviation angle as a function of the contour line; Correction processing is performed on the phase angle sequence of the discrete Fourier transform; The contour features include the amplitude of the discrete Fourier transform corresponding to each target point on the contour line and the phase angle after correction.
7. The method according to claim 6, characterized in that, The correction process for the phase angle sequence of the discrete Fourier transform includes: Obtain the phase angle subsequence of the nth iteration, where n≥2; The nth phase angle subsequence is obtained by calculating the phase angle difference between two adjacent phase angles in reverse order of the (n-1)th phase angle subsequence; The first phase angle subsequence is obtained by calculating the phase angle difference between two adjacent phase angles in reverse order of the phase angle sequence. The phase angle difference between the first and last phase angles in the phase angle sequence is... The difference is the first phase angle difference in the first phase angle subsequence.
8. The method according to claim 7, characterized in that, The n=2.
9. The method according to claim 7, characterized in that, The step of correcting the phase angle sequence of the discrete Fourier transform further includes: normalizing the phase angle of the nth phase angle subsequence.
10. An apparatus for extracting contour features, characterized in that, include: The contour acquisition module is configured to acquire the contour of the target graphic. The distribution function acquisition module is configured to traverse the target points on the contour in a preset order to obtain the distribution function of the bias angle of each target point on the contour as a function of the contour line, wherein the bias angle is the angle between the first vector of the current target point and the second vector of the current target point, the first vector is the vector from the previous target point to the current target point, and the second vector is the vector from the current target point to the next target point; The Fourier transform module is configured to perform a Fourier transform on the distribution function of the deviation angle with respect to the contour line to obtain contour features.
11. An electronic device, characterized in that, include: At least one processor; The memory is communicatively connected to the processor; The memory stores a computer program that can be executed by the at least one processor, and when the at least one processor executes the computer program, it implements the method for extracting contour features as described in any one of claims 1-9.
12. A non-volatile readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the method for extracting contour features as described in any one of claims 1-9.
13. A computer program product, characterized in that, The computer program product includes a computer program stored on a computer-readable storage medium, the computer program including program instructions that, when executed by a computer, cause the computer to perform the method for extracting contour features as described in any one of claims 1-9.
Citation Information
Patent Citations
View-based space shape recognition method and device, equipment and storage medium
CN115272689A
Contour detection method based on machine vision
CN117237391A
System and method for dynamically projecting information from a motor vehicle
US9827901B1