A fractal dimension calculation method, device, equipment and storage medium
By performing feature extraction and outlier processing on complex images, the problem of traditional box counting algorithms being insensitive to image edges and details is solved, and a more accurate and stable fractal dimension calculation is achieved.
Patent Information
- Application Number
- CN202410990963.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-23
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2044-07-23
AI Technical Summary
Traditional box counting algorithms are insensitive to image edges and details when processing complex images, resulting in fractal dimension calculations that misjudgment of image properties or other data features.
By extracting the data to be analyzed, a three-dimensional feature map is obtained and converted into a feature matrix. The feature matrix is outlier, noise and outlier, and then input the processed matrix to the box algorithm to calculate the fractal dimension.
The accuracy and robustness of the Box-Counting algorithm are improved, so that fractal dimension calculation can be performed stably in complex environments, reducing the possibility of misjudgment.
Smart Images

Figure CN118781274B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of fractal dimension calculation, and in particular to a fractal dimension calculation method, device, equipment and storage medium. Background Art
[0002] Fractal dimension (FD), as a measure of self-similarity of graphics or objects, characterizes the index of fractal patterns or sets by quantifying the complexity of graphics or objects as the ratio of detail changes to scale changes. It plays an important role in image analysis, texture recognition and pattern recognition.
[0003] The box counting method is a method commonly used for fractal dimension calculation. The basic idea is to use boxes of different sizes to cover the image and calculate how many boxes are needed to completely cover the objects in the image. As the box size changes, a relationship between the number and size of boxes can be obtained, thereby estimating the fractal dimension.
[0004] However, for more complex images or data, they contain more outliers, and their edges and details contain more features. Traditional box counting algorithms cannot eliminate outliers and are insensitive to image edges and details. They perform poorly in processing, causing the calculated FD to misjudge image properties or other data features. Summary of the invention
[0005] The present invention provides a fractal dimension calculation method, device, equipment and storage medium, which solves the problem that the traditional box counting algorithm is insensitive to image edges and details when processing complex images, has poor processing performance, and causes the calculated FD to misjudge image properties or other data features.
[0006] The present invention provides a fractal dimension calculation method, comprising the following steps:
[0007] Acquiring data to be analyzed, wherein the data to be analyzed includes image data and data having fractal geometric features;
[0008] Extract features from the data to be analyzed to obtain a three-dimensional feature map, and convert the three-dimensional feature map into a feature matrix;
[0009] Perform outlier processing on the feature matrix to obtain the image matrix;
[0010] Input the image matrix into the box algorithm to obtain the fractal dimension of the data to be analyzed;
[0011] The process of performing outlier processing on the feature matrix to obtain an image matrix includes:
[0012] Create an all-zero image matrix of the same size as the feature matrix;
[0013] For each non-zero element in the feature matrix, count the number of elements around it whose value is 0;
[0014] If the number of elements with a value of 0 around the current non-zero element is greater than 5, the value of the position corresponding to the current non-zero element in the all-zero image matrix is set to 0, otherwise it is set to 1;
[0015] Traverse each non-zero element in the feature matrix based on rows and columns to obtain the corresponding image matrix.
[0016] Preferably, converting the three-dimensional feature map into a feature matrix comprises the following steps:
[0017] Convert the three-dimensional feature map into a two-dimensional feature matrix;
[0018] The two-dimensional feature matrix is binarized to obtain the feature matrix.
[0019] Preferably, the image matrix is input into the box algorithm to obtain the fractal dimension of the image to be analyzed, comprising the following steps:
[0020] Generate boxes of different sizes to decompose the image matrix into sub-matrices;
[0021] For each size of box, get the number of boxes required to completely cover the image matrix;
[0022] The linear fitting curve between the number of boxes of different sizes and the corresponding sizes was drawn by the least squares method;
[0023] The fractal dimension is obtained according to the slope of the fitting curve.
[0024] Preferably, the fractal dimension is obtained according to the slope of the fitting curve as shown in the following formula:
[0025]
[0026] Where D is the fractal dimension, ε is the box size, N(ε) is the size ε The number of boxes required to completely cover the image matrix.
[0027] Preferably, feature extraction is performed on the data to be analyzed through a deep learning model.
[0028] A fractal dimension calculation device, comprising:
[0029] An acquisition module, used for acquiring data to be analyzed, wherein the data to be analyzed includes image data and data having fractal geometry characteristics;
[0030] An extraction module is used to extract features from the data to be analyzed, obtain a three-dimensional feature map, and convert the three-dimensional feature map into a feature matrix;
[0031] A processing module, used for performing outlier processing on the feature matrix to obtain an image matrix;
[0032] A calculation module, used to input the image matrix into the box algorithm to obtain the fractal dimension of the data to be analyzed;
[0033] The processing module comprises:
[0034] Create a module to create an all-zero image matrix of the same size as the feature matrix;
[0035] The statistical module is used to count the number of zeros around each non-zero element in the feature matrix;
[0036] A judgment module, used for setting the value of the position corresponding to the current non-zero element in the all-zero image matrix to 0 if the number of elements with element values of 0 around the current non-zero element is greater than 5, otherwise setting it to 1;
[0037] The traversal module is used to traverse each non-zero element in the feature matrix based on rows and columns to obtain the corresponding image matrix.
[0038] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned fractal dimension calculation method when executing the program.
[0039] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the fractal dimension calculation method is implemented.
[0040] Compared with the prior art, the present invention has the following beneficial effects:
[0041] The present invention first extracts features from the data to be analyzed to obtain a three-dimensional feature map, which can more effectively capture the feature information of edges and details in the data to be analyzed, and then converts the three-dimensional feature map into a feature matrix, performs outlier processing on the feature matrix to obtain an image matrix, and inputs the image matrix into the box algorithm to obtain the fractal dimension of the image to be analyzed. The present invention processes the outliers in the feature matrix, so that the analysis dimension calculated by the box algorithm is more accurate, and the fractal dimension calculation can be stably performed in a complex environment. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0043] Figure 1 A flow chart of a fractal dimension calculation method of the present invention;
[0044] Figure 2 This is a diagram of the device for the simulation experiment of the resonance tank internal partition sway reduction according to Example 1 of the present invention;
[0045] Figure 3 It is a schematic diagram of the time series of the free liquid surface obtained from the simulation experiment of sway reduction of partitions at different heights in the resonance liquid tank of Example 1 of the present invention;
[0046] in, Figure 3 (a): 5cm partition, Figure 3 (b): 7cm partition, Figure 3 (c): 9cm partition, Figure 3 (d): 11 cm partition;
[0047] Figure 4 Part of the typhoon images required for typhoon intensity prediction in Embodiment 2 of the present invention;
[0048] Figure 5 This is a variation curve of the FD value obtained by the typhoon intensity prediction in Example 2 of the present invention. DETAILED DESCRIPTION
[0049] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0050] The present invention provides a method for calculating fractal dimension, which obtains feature maps through deep learning models such as CNN, and combines image processing technology to preprocess and process outliers on the feature maps, thereby improving the accuracy and robustness of the Box-Counting algorithm. The method specifically includes the following steps:
[0051] The first step is to obtain the data to be analyzed, which includes image data and data with fractal geometric features.
[0052] Step 2: Use the deep learning model to extract features of the data to be analyzed, obtain a three-dimensional feature map, and convert the three-dimensional feature map into a feature matrix.
[0053] The deep learning model is used to extract features from the data to be analyzed. Taking the CNN model as an example, the fully connected layer and softmax layer used for classification in the CNN are discarded, and the high-level features in the data can be effectively extracted through multi-layer convolution and pooling operations.
[0054] Input the data to be analyzed into the CNN model, and use the automatic learning ability of CNN to automatically obtain and output the 3D feature map from the convolution layer and pooling layer. The details are as follows: In the compilation software, you can use the pre-trained CNN model and select a network layer for feature extraction to output the 3D feature map (usually select the convolution layer close to the output layer, because the feature representation of these layers is more abstract and advanced).
[0055] The three-dimensional feature map extracted from the CNN model is converted into a two-dimensional feature map FeatureMatrix, and the two-dimensional feature map is binarized to obtain the final feature matrix FeatureMatrix. The purpose is to convert image features into a data format that can be processed later while retaining the key information in the image. The feature map is adjusted from a three-dimensional tensor to a two-dimensional tensor for subsequent analysis and processing. Usually, the spatial dimension is expanded into one dimension to form a two-dimensional image.
[0056] In MATLAB or other compiled software, there is a built-in function to convert images into matrices, which can reshape images into feature matrices without losing features.
[0057] Step 3: Perform outlier processing on the feature matrix to obtain the image matrix.
[0058] Perform outlier processing on the feature matrix to eliminate noise and outliers in the feature matrix. The specific process is to traverse each element of the feature matrix by row and column. When an element is not 0, check whether there are more than 5 consecutive 0s around the element. If so, set the element to 0, otherwise, keep it unchanged. Convert the processed feature matrix to the final image matrix. The specific operations are as follows:
[0059] (1): Create an all-zero image matrix ImageMatrix = zero(FeatureMatrix) of the same size as the original feature matrix to store the processed features; initialize a counter count_zeros = 0 to count the number of surrounding zero elements.
[0060] (2): Loop through the rows and columns of the feature matrix.
[0061] fori=1:size(FeatureMatrix,1);
[0062] forj=1:size(FeatureMatrix,2)
[0063] The first line of code calculates the number of rows of the feature matrix, and the second line of code calculates the number of columns of the feature matrix.
[0064] (3): Check whether the current element is zero and ensure that the index of the adjacent elements does not exceed the range of the image matrix.
[0065] Traversing by row checks left and right, and traversing by column checks top and bottom. Assuming the feature matrix size is m rows and n columns, when traversing to a matrix element in the m-4th row, there are only 4 elements left on its right, which does not meet the condition of whether there are more than 5 consecutive zeros, and this round of traversal ends. It is not possible to break the limit of m rows of the matrix and add to the m+1 row in order to get 5 elements to the right of the matrix element, that is, the index cannot exceed the range of the image matrix.
[0066] (4): If the current element is 0, count_zeros is increased by 1 until count_zeros is greater than 5, and the value of the image matrix at the corresponding position is set to zero; otherwise, it is set to 1.
[0067] (5): After the loop ends, ImageMatrix stores the feature matrix updated according to the number of surrounding zero elements.
[0068] Step 4: Input the image matrix into the box algorithm to obtain the fractal dimension of the image to be analyzed.
[0069] The image matrix after outlier processing is used as the input of the Box-Counting algorithm and its FD is calculated. The specific calculation steps include: first, a set of box sizes ε for laying grids on the image is generated using a sampling method, and each grid constitutes a box of size ε×ε; then, for each ε, the number of boxes N(ε) required to completely cover the image is calculated; then, the least squares method is applied to draw a linear fitting curve between N(ε) and ε; finally, the slope of the fitting curve is calculated to obtain FD:
[0070]
[0071] Example 1
[0072] In order to intuitively evaluate the effect of the baffle in the resonant tank on reducing sway, an experimental model tank for fluidized ore swaying was constructed on a vibration platform of a certain university, and the basic data of fluidized ore swaying was obtained in combination with a numerical simulation platform. The tank is designed to be prismatic with a square base, with a length of 0.6m, a width of 0.6cm, a height of 0.6cm, and a filling water depth of 0.3m. The baffle required for sway reduction has a height of 0.6cm and a thickness of 0.01cm, and its width can be adjusted from 0.05m to 0.11m. The schematic diagram of the device is shown in the figure. Figure 2 shown.
[0073] In the simulation experiment of vibration reduction of the partition in the resonant tank, the vibration law of the free liquid surface was tested according to the order of different partition widths of 0.05m, 0.07m, 0.09m and 0.11m, and the corresponding time series of free liquid surface sloshing height were recorded (see Figure 3 ). Next, the present invention is used to identify and determine the sloshing reduction effect of different baffle thicknesses on the liquid surface on the left side of the tank. The specific steps are as follows:
[0074] S1: The deep learning model is used to capture the time series features of the free liquid surface sloshing height at different baffle distances (such as edges, peaks, changing trends, etc.) and obtain the corresponding three-dimensional feature map.
[0075] S2: Convert the three-dimensional feature map into a two-dimensional feature map. Figure 2 After the value processing, the feature matrix is obtained, and then the feature matrix is converted into the final image matrix.
[0076] S3: Perform outlier processing on the feature matrix to eliminate noise and outliers in the image. The specific process is to traverse each element of the feature matrix row by row and column. When an element is not 0, check whether there are more than 5 consecutive 0s around the element. If so, set the element to 0, otherwise, keep it unchanged. Convert the processed matrix into the final image matrix.
[0077] S4: According to the formula of Box-Counting algorithm Calculate FD when the partition thickness is 0.05m, 0.07m, 0.09m and 0.11m respectively. The results are FD 1 =1.7364, FD 2 =1.7539, FD 3 =1.7695, FD 4 =1.7800.
[0078] From the above calculation results, it can be seen that when the baffle thickness is 0.05m, the sloshing behavior of the free liquid surface is relatively unstable and the sloshing reduction effect is not good. On the contrary, when the baffle thickness is 0.09m and 0.11cm, the baffle sloshing reduction effect is better. According to the FD range calculated by the present invention, it can be judged that when the baffle thickness range is 0.09-0.11m, the liquid surface of the resonant liquid tank can be effectively reduced. At the same time, the numerical variation law of FD conforms to the sloshing reduction law of the resonant liquid tank with different thickness baffles. Therefore, according to the present invention, the appropriate baffle thickness can be quickly and accurately selected to achieve the ideal sloshing reduction effect.
[0079] Example 2
[0080] The status images of a certain typhoon at three different times of the day from August 5, 2015 to August 9, 2015 were obtained from the Meteorological Bureau Center (the typhoon image at a certain time is as follows: Figure 4 Through the study of historical data, it is found that the typhoon showed a trend of gradually strengthening and then gradually weakening during this period.
[0081] Typhoons in different periods present different motion states, including wind speed, wind direction and intensity, so the fractal dimension FD used to measure the complexity and self-similarity of typhoons will also be different. Next, the present invention is used to identify and determine the nature of this typhoon. The specific steps are as follows:
[0082] S5: Use the deep learning model to extract features from the typhoon images at different periods.
[0083] S6: The three-dimensional feature map extracted from the deep learning model is converted into a two-dimensional feature map and binarized, aiming to convert the typhoon image features into a data format that can be used for subsequent processing while retaining the key information in the image.
[0084] S7: Perform outlier processing on the feature matrix to eliminate noise and outliers in the image. The specific process is to traverse each element of the feature matrix row by row and column. When an element is not 0, check whether there are more than 5 consecutive 0s around the element. If so, set the element to 0, otherwise, keep it unchanged. Convert the processed matrix into the final image matrix.
[0085] S8: Formula using Box-Counting algorithm Calculate the FD of typhoons in different periods. The specific results are as follows Figure 4 shown.
[0086] According to the above calculation results, it can be known that the typhoon state on August 7 has the largest fractal dimension, and it drops to the minimum on August 9. The change trend of this fractal dimension is consistent with the change trend of the typhoon state. This shows that the FD calculation method proposed in the present invention can be used as an important tool for understanding typhoon dynamics and helps to more accurately predict the path and intensity of typhoons.
[0087] Based on the same concept, the present invention also provides a fractal dimension calculation device, including an acquisition module, an extraction module, a processing module and a calculation module.
[0088] The acquisition module is used to acquire the data to be analyzed, and the data to be analyzed includes image data and data with fractal geometric features.
[0089] The extraction module is used to extract features from the data to be analyzed, obtain a three-dimensional feature map, and convert the three-dimensional feature map into a feature matrix.
[0090] The processing module is used to process the outliers of the feature matrix to obtain the image matrix.
[0091] The calculation module is used to input the image matrix into the box algorithm to obtain the fractal dimension of the data to be analyzed.
[0092] The processing module includes a creation module, a statistics module, a judgment module and a traversal module.
[0093] The creation module is used to create an all-zero image matrix of the same size as the feature matrix.
[0094] The statistics module is used to count the number of zeros around each non-zero element in the feature matrix.
[0095] The judgment module is used to set the value of the position corresponding to the current non-zero element in the all-zero image matrix to 0 if the number of elements with element values of 0 around the current non-zero element is greater than 5, otherwise it is set to 1.
[0096] The traversal module is used to traverse each non-zero element in the feature matrix based on rows and columns to obtain the corresponding image matrix.
[0097] The present invention also provides a computer device, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the above-mentioned fractal dimension calculation method is implemented when the processor executes the program.
[0098] The present invention also provides a computer-readable storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned fractal dimension calculation method is implemented.
[0099] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0100] Obviously, those skilled in the art may make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A method for calculating fractal dimension, characterized in that: The following steps are involved: Acquiring data to be analyzed, wherein the data to be analyzed includes image data and data having fractal geometric features; Extract features from the data to be analyzed to obtain a three-dimensional feature map, and convert the three-dimensional feature map into a feature matrix; Perform outlier processing on the feature matrix to obtain the image matrix; Input the image matrix into the box algorithm to obtain the fractal dimension of the data to be analyzed; The process of performing outlier processing on the feature matrix to obtain an image matrix includes: Create an all-zero image matrix of the same size as the feature matrix; For each non-zero element in the feature matrix, count the number of consecutive 0 elements around it; If the number of consecutive zero elements around the current non-zero element is greater than 5, the value of the position corresponding to the current non-zero element in the all-zero image matrix is set to 0, otherwise it is set to 1; Traverse each non-zero element in the feature matrix based on rows and columns to obtain the corresponding image matrix.
2. A fractal dimension calculation method as claimed in claim 1, characterized in that: Converting the three-dimensional feature map into a feature matrix includes the following steps: Convert a three-dimensional feature map into a two-dimensional feature map; The two-dimensional feature map is binarized to obtain a feature matrix.
3. A fractal dimension calculation method as claimed in claim 1, characterized in that: The image matrix is input into the box algorithm to obtain the fractal dimension of the image to be analyzed, which includes the following steps: Generate boxes of different sizes; For each size of box, get the number of boxes required to completely cover the image matrix; The linear fitting curve between the number of boxes of different sizes and the corresponding sizes was drawn by the least squares method; The fractal dimension is obtained according to the slope of the fitting curve.
4. A fractal dimension calculation method as claimed in claim 3, characterized in that: The fractal dimension is obtained according to the slope of the fitting curve as shown below: Where D is the fractal dimension, ε is the box size, N(ε) is the size ε The number of boxes required to completely cover the image matrix.
5. A fractal dimension calculation method as claimed in claim 1, characterized in that: The deep learning model is used to extract features from the data to be analyzed.
6. A fractal dimension calculation device, characterized in that: include: An acquisition module, used for acquiring data to be analyzed, wherein the data to be analyzed includes image data and data having fractal geometry characteristics; An extraction module is used to extract features from the data to be analyzed, obtain a three-dimensional feature map, and convert the three-dimensional feature map into a feature matrix; A processing module, used for performing outlier processing on the feature matrix to obtain an image matrix; A calculation module, used to input the image matrix into the box algorithm to obtain the fractal dimension of the data to be analyzed; The processing module comprises: Create a module to create an all-zero image matrix of the same size as the feature matrix; The statistical module is used to count the number of consecutive 0 elements around each non-zero element in the feature matrix; A judgment module, used for setting the value of the position corresponding to the current non-zero element in the all-zero image matrix to 0 if the number of consecutive zero elements around the current non-zero element is greater than 5, otherwise setting it to 1; The traversal module is used to traverse each non-zero element in the feature matrix based on rows and columns to obtain the corresponding image matrix.
7. A computer device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method for calculating the fractal dimension described in any one of claims 1 to 5 is implemented.
8. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the fractal dimension calculation method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Structure model 3D printing method based on rasterizing and sparse compression treatment
CN109955486A
Pump fault diagnosis method and device based on fractal dimension and neural network
CN113092083A