Obstacle segmentation method based on shared knowledge strategy particle swarm two-dimensional Ostu algorithm
By optimizing obstacle segmentation using the particle swarm optimization algorithm with a shared knowledge strategy, the problem of low computational efficiency of the two-dimensional Otsu method is solved, achieving efficient and fast obstacle segmentation results.
Patent Information
- Application Number
- CN202510988515.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-17
- Publication Date
- 2025-11-18
AI Technical Summary
The existing two-dimensional Otsu method has an overly complex method for selecting the segmentation threshold in image segmentation, resulting in excessively long algorithm running time and low computational efficiency, which cannot meet the requirements of real-time processing.
The two-dimensional Ostu algorithm based on a shared knowledge strategy particle swarm optimization is adopted. The image is preprocessed, a two-dimensional gray-level histogram is calculated, particle swarm parameters are initialized, the inter-class discrete matrix is calculated, the particle velocity and position are updated using the fitness function, the optimal segmentation threshold is found iteratively by combining the shared knowledge strategy, and morphological processing is performed to optimize obstacle segmentation.
It significantly improves computational efficiency and segmentation results, quickly finds the optimal segmentation threshold, solves the problem of insufficient population diversity when particle swarms search for the optimal solution, and achieves efficient obstacle segmentation.
Smart Images

Figure CN120976252A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to obstacle segmentation methods, specifically to an obstacle segmentation method based on the two-dimensional Ostu algorithm of particle swarm optimization with a shared knowledge strategy. Background Technology
[0002] Deep space exploration is a hot topic in 21st-century global space activities, and unmanned rovers are currently the most effective means of planetary exploration. To enable long-term exploration in unknown environments, safely avoiding various obstacles and craters is a fundamental guarantee for completing planned scientific exploration missions. Under certain lighting conditions, terrain undulations will appear in images as variations in brightness. Darker areas in images are usually concentrated on the shaded sides of impact craters, the shaded sides of steep slopes, or the shadows of rocks, while brighter areas are usually the sunlit sides of obstacles reflecting strong sunlight. Therefore, by identifying excessively bright or dark areas and combining this with regional texture information analysis, obstacles can be detected.
[0003] Based on the grayscale distribution of the image, overly bright and overly dark regions representing obstacles are obtained, and thresholding is used to separate the obstacles from the background. Common thresholding methods include K-means clustering, maximum entropy thresholding, and the two-dimensional Otsu's method, but these methods are not ideal for segmenting planetary scenes. In contrast, the two-dimensional Otsu's method improves the image segmentation effect, but its method of selecting the segmentation threshold is too complex, resulting in an excessively long algorithm runtime, which cannot meet the requirements of real-time image processing and has low computational efficiency. Summary of the Invention
[0004] The purpose of this invention is to address the technical problem of the two-dimensional Otsu algorithm in common threshold segmentation methods for image processing, where the method of selecting the segmentation threshold is too complicated, resulting in excessively long algorithm running time and low computational efficiency. Instead, this invention provides an obstacle segmentation method based on the two-dimensional Otsu algorithm of particle swarm optimization with a shared knowledge strategy.
[0005] To achieve the above objectives, the technical solution adopted by the present invention is as follows:
[0006] An obstacle segmentation method based on the two-dimensional Ostu algorithm of particle swarm optimization with a shared knowledge strategy is characterized by the following steps:
[0007] Step 1: Obtain the image to be processed, and perform wavelet transform denoising and smoothing and histogram equalization enhancement preprocessing on the image to be processed to obtain the preprocessed image I(x,y);
[0008] Step 2: Divide the preprocessed image I(x, y) into N equal pixels. Calculate the gray value f(x, y) of each pixel and the average gray value g(x, y) of its neighboring pixel set, where x is the horizontal position of the pixel and y is the vertical position of the pixel, and N≥3. Define f(x, y) = i and g(x, y) = j to obtain N two-dimensional arrays (i, j).
[0009] Step 3: Count the number of times the same two-dimensional array (i, j) appears in the N two-dimensional arrays. ij And calculate the probability density P corresponding to the same two-dimensional array. ij The calculation formula is as follows:
[0010] Where N is the number of pixels;
[0011] With i and j as independent variables, P ij Using the dependent variable, a two-dimensional grayscale histogram of the preprocessed image I(x,y) is obtained;
[0012] Step 4: In the two-dimensional solution space, randomly generate N two-dimensional particles and calculate N particle arrays. Match the N particle arrays with the N two-dimensional arrays (i, j) obtained in Step 2 to obtain the corresponding particle arrays and two-dimensional arrays.
[0013] Step 5: Use the N particle arrays from Step 4 as segmentation threshold arrays, and calculate the inter-class discrete matrix of each particle array based on the two-dimensional gray-level histogram obtained in Step 3 to obtain N inter-class discrete matrices.
[0014] Step 6: Based on the N inter-class discrete matrices obtained in Step 5, calculate the fitness function of the positions of the N particle arrays;
[0015] Step 7: Based on the fitness function obtained in Step 6, determine the local extremum pBesti of each of the N particle arrays and the global extremum gBest of the N particle arrays, and obtain the N local extremum pBesti and the global extremum gBest.
[0016] Step 8: Update the velocity of each two-dimensional particle in Step 4 based on the N local extrema pBesti and one global extrema gBest obtained in Step 7. Calculate the fitness of the N particle arrays used as the segmentation threshold array in Step 5 using the fitness function obtained in Step 6. Sort the fitness of the N particle arrays in descending order. Update the position of each two-dimensional particle in the N particle arrays after descending order according to the shared knowledge strategy to obtain N particle arrays with updated velocity and position.
[0017] Step 9: Return to Step 5, and use the N particle arrays with updated velocities and positions obtained in Step 8 as the separation threshold arrays to obtain N particle arrays with updated velocities and positions again, until the preset number of iterations is completed, resulting in N particle arrays with final velocities and positions; among the N particle arrays with final velocities and positions, select the particle array with the highest corresponding fitness to obtain the optimal particle array;
[0018] Step 10: According to the correspondence between the particle array and the two-dimensional array obtained in Step 4, define the two-dimensional array corresponding to the optimal particle array obtained in Step 9 as the optimal two-dimensional array. Use the optimal two-dimensional array as the optimal segmentation threshold array and use the optimal segmentation threshold array to divide the preprocessed image into obstacle region and background region.
[0019] Step 11: Perform morphological processing on the obstacle region segmented in Step 10. After opening operations of erosion and dilation, perform morphological closing operations on the edge image using structuring elements to obtain the obstacle segmentation map.
[0020] Furthermore, step 4 is detailed below:
[0021] Step 4.1: In the two-dimensional solution space, randomly generate N two-dimensional particles g, each with a position X. gm And a velocity V gm Where m = 1, 2, ..., N;
[0022] Step 4.2: Combine the position and velocity of each two-dimensional particle into a particle array (X). gm V gm ), resulting in an array of N particles (X gm V gm );
[0023] Step 4.3: Array N particles (X) gm V gm The corresponding particle array and the two-dimensional array are obtained one-to-one with the N two-dimensional arrays (i, j) obtained in step 2.
[0024] Furthermore, step 5 is detailed below:
[0025] Step 5.1: Randomly select one particle array from the N particle arrays in step 4, and use the corresponding two-dimensional array (s, t) as the segmentation threshold array to divide the image I(x, y) into four parts: boundary, background, target, and noise; where s∈i, t∈j;
[0026] Step 5.2: Define a segmentation threshold array. The background portion of the image is defined as C0, with a probability of w0, and the target portion as C1, with a probability of w1. The probabilities w0 and w1 of the background and target portions are then calculated using the following formulas:
[0027]
[0028] Where L represents the gray level of the image and the average gray level of the image's neighborhood set;
[0029] Step 5.3: Based on the probability w0 of the background and the probability w1 of the target, calculate the mean vector u0 corresponding to the background, the mean vector u1 corresponding to the target, and the overall mean vector u of the image. The calculation formula is as follows:
[0030]
[0031] Among them, u 0i and u 0j The mean vector corresponding to the two-dimensional array (i, j) of the background part;
[0032] u 1i and u 1j The mean vector corresponding to the two-dimensional array (i, j) of the target part;
[0033] u i and u j Let (i, j) be the total mean vector corresponding to the two-dimensional array (i, j);
[0034] Step 5.4: Based on the probability w0 of the background appearing part, the mean vector u0 corresponding to the background part, the probability w1 of the target part appearing part, the mean vector u1 corresponding to the target part, and the overall mean vector u of the image, the inter-class discrete matrix Q(s,t) of the particle array is obtained, as shown below:
[0035] Q(s,t)=w0(u0-u) 2 +w1(u1-u) 2
[0036] Step 5.5: Repeat steps 5.1-5.4 to obtain the inter-class discrete matrices of the remaining N-1 particle arrays, resulting in N inter-class discrete matrices.
[0037] Furthermore, step 6 is detailed below:
[0038] Step 6.1: Calculate the trace R of the N discrete matrices obtained in Step 5. trace Q(s,t);
[0039] Step 6.2: Take the trace R of the N discrete matrices obtained in Step 6.1.trace Q(s,t) serves as the inter-class discreteness measure for the background component C0 and the target component C1. Using this discreteness measure as the fitness function fun(s,t), we obtain the fitness function for the positions of the N particle arrays, expressed as follows:
[0040]
[0041] Furthermore, step 8 is detailed below:
[0042] Step 8.1: Update the velocity of each two-dimensional particle in Step 4 based on the N local extrema pBesti and one global extrema gBest obtained in Step 7, as follows:
[0043]
[0044] in, The current particle velocity;
[0045] The updated particle velocity is the particle velocity of the current particle.
[0046] n is the number of iterations;
[0047] This represents the local extremum of the current particle.
[0048] gBest n This represents the current global extremum of the particle.
[0049] This represents the current position in the particle array.
[0050] ω represents the inertia weight;
[0051] c1 and c2 are learning factors;
[0052] r1 and r2 are random numbers distributed in [0, 1];
[0053] We obtain the two-dimensional particles with updated velocity;
[0054] Step 8.2 While executing Step 8.1, the fitness of the N particle arrays in Step 4 is calculated using the fitness function obtained in Step 6. The fitness of the N particle arrays is sorted in descending order, and the two-dimensional particle positions are updated according to the shared knowledge strategy, thereby obtaining N particle arrays with updated velocity and position.
[0055] Furthermore, step 8.2 is detailed as follows:
[0056] Step 8.2.1: Initial shared knowledge stage position update, obtaining the initial stage update position of the particle array.
[0057] The fitness of the N particle arrays used as the segmentation threshold array in step 5 is calculated using the fitness function obtained in step 6. The N particle arrays are then sorted in descending order of fitness. One of these particle arrays is selected as the current particle array, and the remaining N-1 particle arrays are treated as random particle arrays. The two particle arrays with the closest fitness to the current particle array are selected, and the position difference between these two particle arrays, as well as the position difference between the random particle array and the current particle array, are calculated. The position of the current particle array is then updated. The particle array position update method in the initial stage is as follows:
[0058]
[0059] in, This represents the current position in the particle array.
[0060] To be better than the current particle array position;
[0061] It is below the current particle array position;
[0062] For random particle array positions;
[0063] This refers to the updated particle array positions;
[0064] α is the distance factor;
[0065] If the fitness of the random particle array is less than the fitness of the current particle array, the random particle array is moved as a whole to the position of the current particle array.
[0066] If the fitness of the random particle array is greater than or equal to the fitness of the current particle array, then the current particle array moves to the position of the random particle array.
[0067] Step 8.2.2 Advanced Knowledge Sharing Phase Location Update
[0068] Based on fitness, the N particle arrays after the initial shared knowledge phase position update are sorted in descending order. The top 10% of particle arrays are selected as the better particle arrays, the middle 80% as the medium particle arrays, and the bottom 10% as the worse particle arrays. Advanced phase position updates are then performed based on the random distance between the better and worse particle arrays, and the distance difference between the medium particle array and the current particle array. The update method is as follows:
[0069]
[0070] Among them, X rbest This refers to a randomly selected position in the optimal particle array.
[0071] X rm This is a randomly selected position in the medium particle array;
[0072] X rworst A random position in the particle array from the poor particle array;
[0073] Randomly select a particle array from the medium particle array. If the fitness of the medium particle array is less than that of the current particle array, then N-1 particle arrays move to the position of the current particle array.
[0074] If the fitness of the medium particle array is greater than or equal to the fitness of the current particle array, then N-1 particle arrays move to the position of the medium particle array.
[0075] 8.2.3 After steps 8.2.1 and 8.2.2, the new position and velocity of each particle array are obtained, thus obtaining N particle arrays with updated velocity and position.
[0076] Furthermore, step 10 is detailed as follows:
[0077] Based on the correspondence between the particle array and the two-dimensional array in step 4, the optimal two-dimensional array in step 9 is defined as (x, v). Let the optimal two-dimensional array (x, v) be the optimal segmentation threshold array. The preprocessed image is divided into obstacle region and background region using the optimal segmentation threshold array. The calculation method is as follows:
[0078]
[0079] Compared with the prior art, the present invention has the following beneficial technical effects:
[0080] 1. This invention presents an obstacle segmentation method based on a shared knowledge strategy particle swarm optimization (PSO) 2D Ostu algorithm. The method preprocesses the acquired image, calculates the 2D grayscale histogram of the preprocessed image, initializes the particle swarm parameters, calculates the inter-class discrete matrix of all particles, calculates the fitness function values of all particles according to the set fitness function, updates the local extrema and global extrema of the particles based on the function values, and updates the particle velocity and position based on the extrema. Simultaneously, by combining a shared knowledge strategy, the method iteratively searches for the optimal solution, outputting it as the optimal segmentation threshold for obstacle segmentation. The segmented image is then morphologically optimized to output the final obstacle segmentation map. This method exhibits high computational efficiency and significant enhancement effects.
[0081] 2. This invention presents an obstacle segmentation method based on the shared knowledge strategy particle swarm optimization (PSO) two-dimensional Ostu algorithm. By introducing a particle swarm optimization optimal threshold search strategy into the two-dimensional Ostu segmentation, the optimal segmentation threshold is quickly found, achieving optimal segmentation and demonstrating a significant improvement in segmentation performance.
[0082] 3. The present invention provides an obstacle segmentation method based on the two-dimensional Ostu algorithm of particle swarm optimization with a shared knowledge strategy. By introducing a shared knowledge strategy into the optimal segmentation threshold search strategy of particle swarm optimization, which is divided into primary and advanced stages, it is beneficial for the population to explore more unknown regions and find the global optimal region within the number of iterations, thus solving the problem of insufficient population diversity when particle swarm optimization searches for the optimal solution. Attached Figure Description
[0083] Figure 1 This is a schematic diagram of the obstacle segmentation method based on the two-dimensional Ostu algorithm of particle swarm optimization with shared knowledge strategy according to the present invention.
[0084] Figure 2 This is a diagram illustrating the entire process of obstacle segmentation in an embodiment of the obstacle segmentation method based on the shared knowledge strategy particle swarm optimization 2D Ostu algorithm of the present invention. Detailed Implementation
[0085] To make the objectives, advantages, and features of this invention clearer, the obstacle segmentation method based on the two-dimensional Ostu algorithm of particle swarm optimization with a shared knowledge strategy proposed in this invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. Those skilled in the art should understand that these embodiments are merely used to explain the technical principles of this invention and are not intended to limit the scope of protection of this invention.
[0086] like Figure 1-2 As shown, an obstacle segmentation method based on the two-dimensional Ostu algorithm of particle swarm optimization with a shared knowledge strategy includes the following steps:
[0087] Step 1: Obtain a 640*480 image to be processed, and perform wavelet transform denoising and smoothing and histogram equalization enhancement preprocessing on the image to be processed to obtain the preprocessed image I(x,y);
[0088] Step 2: Divide the preprocessed image I(x, y) into N equal pixels. Calculate the gray value f(x, y) of each pixel and the average gray value g(x, y) of its neighboring pixel set, where x is the horizontal position of the pixel and y is the vertical position of the pixel, and N≥3. Define: f(x, y)=i, g(x, y)=j, and the image gray level and the average gray level of the neighboring pixels are both L levels, thus obtaining N two-dimensional arrays (i, j).
[0089] Step 3: Count the number of times the same two-dimensional array (i, j) appears in the N two-dimensional arrays.ij And calculate the probability density P corresponding to the same two-dimensional array. ij The calculation formula is as follows:
[0090] Where N is the number of pixels;
[0091] With i and j as independent variables, P ij Using the dependent variable, a two-dimensional grayscale histogram of the preprocessed image I(x,y) is obtained;
[0092] Step 4: In the two-dimensional solution space, randomly generate N two-dimensional particles and calculate N particle arrays. Match the N particle arrays with the N two-dimensional arrays (i, j) obtained in Step 2 to obtain the corresponding particle arrays and two-dimensional arrays, as follows:
[0093] Step 4.1: In the two-dimensional solution space, randomly generate N two-dimensional particles g, each with a position X. gm And a velocity V gm Where m = 1, 2, ..., N;
[0094] Step 4.2: Combine the position and velocity of each two-dimensional particle into a particle array (X). gm V gm ), resulting in an array of N particles (X gm V gm );
[0095] Step 4.3: Array N particles (X) gm V gm The corresponding particle array and the two-dimensional array are obtained one-to-one with the N two-dimensional arrays (i, j) obtained in step 2.
[0096] Step 5: Using the N particle arrays from Step 4 as segmentation threshold arrays, calculate the inter-class discrete matrix for each particle array based on the two-dimensional gray-level histogram obtained in Step 3, resulting in N inter-class discrete matrices, as follows:
[0097] Step 5.1: Randomly select one particle array from the N particle arrays in step 4, and use the corresponding two-dimensional array (s, t) as the segmentation threshold array to divide the image I(x, y) into four parts: boundary, background, target, and noise; where s∈i, t∈j;
[0098] Step 5.2: Define a segmentation threshold array. The background portion of the image is defined as C0, with a probability of w0, and the target portion as C1, with a probability of w1. The probabilities w0 and w1 of the background and target portions are then calculated using the following formulas:
[0099]
[0100] Step 5.3: Based on the probability w0 of the background and the probability w1 of the target, calculate the mean vector u0 corresponding to the background, the mean vector u1 corresponding to the target, and the overall mean vector u of the image. The calculation formula is as follows:
[0101]
[0102] Among them, u 0i and u 0j The mean vector corresponding to the two-dimensional array (i, j) of the background part;
[0103] u 1i and u 1j The mean vector corresponding to the two-dimensional array (i, j) of the target part;
[0104] u i and u j Let (i, j) be the total mean vector corresponding to the two-dimensional array (i, j);
[0105] Step 5.4: Based on the probability w0 of the background appearing part, the mean vector u0 corresponding to the background part, the probability w1 of the target part appearing part, the mean vector u1 corresponding to the target part, and the overall mean vector u of the image, the inter-class discrete matrix Q(s,t) of the particle array is obtained, as shown below:
[0106] Q(s,t)=w0(u0-u) 2 +w1(u1-u) 2 ;
[0107] Step 5.5: Repeat steps 5.1-5.4 to obtain the inter-class discrete matrices of the remaining N-1 particle arrays, resulting in N inter-class discrete matrices.
[0108] Step 6: Based on the N inter-class discrete matrices obtained in Step 5, calculate the fitness function for the positions of the N particle arrays, as follows:
[0109] Step 6.1: Calculate the trace R of the N discrete matrices obtained in Step 5. trace Q(s,t);
[0110] Step 6.2: Take the trace R of the N discrete matrices obtained in Step 6.1. trace Q(s,t) serves as the inter-class discreteness measure for the background component C0 and the target component C1. Using this discreteness measure as the fitness function fun(s,t), we obtain the fitness function for the positions of the N particle arrays, expressed as follows:
[0111]
[0112] Step 7: Based on the fitness function obtained in Step 6, determine the local extremum pBesti of each of the N particle arrays and the global extremum gBest of the N particle arrays, and obtain the N local extrema pBesti and the global extremum gBest.
[0113] Step 8: Update the velocity of each 2D particle in Step 4 based on the N local extrema pBesti and one global extrema gBest obtained in Step 7. Calculate the fitness of the N particle arrays used as the segmentation threshold array in Step 5 using the fitness function obtained in Step 6. Sort the fitness of the N particle arrays in descending order. Update the position of each 2D particle in the N sorted N particle arrays according to the shared knowledge strategy to obtain N particle arrays with updated velocity and position, as follows:
[0114] Step 8.1: Update the velocity of each two-dimensional particle in Step 4 based on the N local extrema pBesti and one global extrema gBest obtained in Step 7, as follows:
[0115]
[0116] in, The current particle velocity;
[0117] The updated particle velocity is the particle velocity of the current particle.
[0118] n is the number of iterations;
[0119] This represents the local extremum of the current particle.
[0120] gBest n This represents the current global extremum of the particle.
[0121] This represents the current position in the particle array.
[0122] ω represents the inertia weight;
[0123] c1 and c2 are learning factors;
[0124] r1 and r2 are both random numbers distributed in [0, 1], and in this embodiment, the value is 0.5;
[0125] We obtain the two-dimensional particles with updated velocity;
[0126] Step 8.2 While executing Step 8.1, the fitness of the N particle arrays in Step 4 is calculated using the fitness function obtained in Step 6. The fitness of the N particle arrays is then sorted in descending order. The two-dimensional particle positions are updated according to the shared knowledge strategy, resulting in N particle arrays with updated velocity and position, as detailed below:
[0127] Step 8.2.1: Initial shared knowledge stage position update, obtaining the initial stage update position of the particle array.
[0128] The fitness of the N particle arrays used as the segmentation threshold array in step 5 is calculated using the fitness function obtained in step 6. The N particle arrays are then sorted in descending order of fitness. One of the particle arrays is selected as the current particle array, and the remaining N-1 particle arrays are treated as random particle arrays. The two particle arrays with the closest fitness to the current particle array are selected, and the position difference between these two particle arrays is calculated. This position difference, along with the position difference between the random particle array and the current particle array, is used to update the position of the current particle array. The initial stage particle array position update method is as follows:
[0129]
[0130] in, This represents the current position in the particle array.
[0131] To be better than the current particle array position;
[0132] It is below the current particle array position;
[0133] For random particle array positions;
[0134] This refers to the updated particle array positions;
[0135] α is the distance factor;
[0136] If the fitness of the random particle array is less than the fitness of the current particle array, the random particle array is moved as a whole to the position of the current particle array.
[0137] If the fitness of the random particle array is greater than or equal to the fitness of the current particle array, then the current particle array moves to the position of the random particle array.
[0138] Step 8.2.2 Advanced Knowledge Sharing Phase Location Update
[0139] Based on fitness, the N particle arrays after the initial shared knowledge phase position update are sorted in descending order. The top 10% of particle arrays are selected as the better particle arrays, the middle 80% as the medium particle arrays, and the bottom 10% as the worse particle arrays. Advanced phase position updates are then performed based on the random distance between the better and worse particle arrays, and the distance difference between the medium particle array and the current particle array. The update method is as follows:
[0140]
[0141] Among them, X rbest This refers to a randomly selected position in the optimal particle array.
[0142] X rm This is a randomly selected position in the medium particle array;
[0143] X rworst A random position in the particle array from the poor particle array;
[0144] Randomly select a particle array from the medium particle array. If the fitness of the medium particle array is less than that of the current particle array, then N-1 particle arrays move to the position of the current particle array.
[0145] If the fitness of the medium particle array is greater than or equal to the fitness of the current particle array, then N-1 particle arrays move to the position of the medium particle array.
[0146] 8.2.3 After steps 8.2.1 and 8.2.2, the new position and velocity of each particle array are obtained, thus obtaining N particle arrays with updated velocity and position.
[0147] Step 9: Return to Step 5, and use the N particle arrays with updated velocities and positions obtained in Step 8 as the separation threshold arrays to obtain N particle arrays with updated velocities and positions again, until 50 iterations are completed, resulting in N particle arrays with final velocities and positions; among the N particle arrays with final velocities and positions, select the particle array with the highest corresponding fitness to obtain the optimal particle array.
[0148] Step 10: Based on the correspondence between the particle array and the two-dimensional array obtained in Step 4, define the two-dimensional array corresponding to the optimal particle array obtained in Step 9 as the optimal two-dimensional array. Use the optimal two-dimensional array as the optimal segmentation threshold array, and use the optimal segmentation threshold array to divide the preprocessed image into obstacle regions and background regions. The calculation method is as follows:
[0149]
[0150] Step 11: Perform morphological processing on the obstacle region segmented in Step 10. After opening operations of erosion and dilation, perform morphological closing operations on the edge image using structuring elements to obtain the obstacle segmentation map.
[0151] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the present invention.
Claims
1. An obstacle segmentation method based on the two-dimensional Ostu algorithm of particle swarm optimization with a shared knowledge strategy, characterized in that, Includes the following steps: Step 1: Obtain the image to be processed, and perform wavelet transform denoising and smoothing and histogram equalization enhancement preprocessing on the image to be processed to obtain the preprocessed image I(x,y); Step 2: Divide the preprocessed image I(x, y) into N equal pixels. Calculate the gray value f(x, y) of each pixel and the average gray value g(x, y) of its neighboring pixel set, where x is the horizontal position of the pixel and y is the vertical position of the pixel, and N≥3. Define f(x, y) = i and g(x, y) = j to obtain N two-dimensional arrays (i, j). Step 3: Count the number of times the same two-dimensional array (i, j) appears in the N two-dimensional arrays. ij And calculate the probability density P corresponding to the same two-dimensional array. ij The calculation formula is as follows: Where N is the number of pixels; With i and j as independent variables, P ij Using the dependent variable, a two-dimensional grayscale histogram of the preprocessed image I(x,y) is obtained; Step 4: In the two-dimensional solution space, randomly generate N two-dimensional particles and calculate N particle arrays. Match the N particle arrays with the N two-dimensional arrays (i, j) obtained in Step 2 to obtain the corresponding particle arrays and two-dimensional arrays. Step 5: Use the N particle arrays from Step 4 as segmentation threshold arrays, and calculate the inter-class discrete matrix of each particle array based on the two-dimensional gray-level histogram obtained in Step 3 to obtain N inter-class discrete matrices. Step 6: Based on the N inter-class discrete matrices obtained in Step 5, calculate the fitness function of the positions of the N particle arrays; Step 7: Based on the fitness function obtained in Step 6, determine the local extremum pBesti of each of the N particle arrays and the global extremum gBest of the N particle arrays, and obtain the N local extremum pBesti and the global extremum gBest. Step 8: Update the velocity of each two-dimensional particle in Step 4 based on the N local extrema pBesti and one global extrema gBest obtained in Step 7. Calculate the fitness of the N particle arrays used as the segmentation threshold array in Step 5 using the fitness function obtained in Step 6. Sort the fitness of the N particle arrays in descending order. Update the position of each two-dimensional particle in the N particle arrays after descending order according to the shared knowledge strategy to obtain N particle arrays with updated velocity and position. Step 9: Return to Step 5, and use the N particle arrays with updated velocities and positions obtained in Step 8 as the separation threshold arrays to obtain N particle arrays with updated velocities and positions again, until the preset number of iterations is completed, resulting in N particle arrays with final velocities and positions; among the N particle arrays with final velocities and positions, select the particle array with the highest corresponding fitness to obtain the optimal particle array; Step 10: According to the correspondence between the particle array and the two-dimensional array obtained in Step 4, define the two-dimensional array corresponding to the optimal particle array obtained in Step 9 as the optimal two-dimensional array. Use the optimal two-dimensional array as the optimal segmentation threshold array and use the optimal segmentation threshold array to divide the preprocessed image into obstacle region and background region. Step 11: Perform morphological processing on the obstacle region segmented in Step 10. After opening operations of erosion and dilation, perform morphological closing operations on the edge image using structuring elements to obtain the obstacle segmentation map.
2. The obstacle segmentation method based on the two-dimensional Ostu algorithm of particle swarm optimization with shared knowledge strategy as described in claim 1, characterized in that, Step 4 is as follows: Step 4.1: In the two-dimensional solution space, randomly generate N two-dimensional particles g, each with a position X. gm And a velocity V gm Where m = 1, 2, ..., N; Step 4.2: Combine the position and velocity of each two-dimensional particle into a particle array (X). gm V gm ), resulting in an array of N particles (X gm V gm ); Step 4.3: Array N particles (X) gm V gm The corresponding particle array and the two-dimensional array are obtained one-to-one with the N two-dimensional arrays (i, j) obtained in step 2.
3. The obstacle segmentation method based on the two-dimensional Ostu algorithm of particle swarm optimization with shared knowledge strategy as described in claim 2, characterized in that, Step 5 is as follows: Step 5.1: Randomly select one particle array from the N particle arrays in step 4, and use the corresponding two-dimensional array (s, t) as the segmentation threshold array to divide the image I(x, y) into four parts: boundary, background, target, and noise; where s∈i, t∈j; Step 5.2: Define a segmentation threshold array. The background portion of the image is defined as C0, with a probability of w0, and the target portion as C1, with a probability of w1. The probabilities w0 and w1 of the background and target portions are then calculated using the following formulas: Where L represents the gray level of the image and the average gray level of the image's neighborhood set; Step 5.3: Based on the probability w0 of the background and the probability w1 of the target, calculate the mean vector u0 corresponding to the background, the mean vector u1 corresponding to the target, and the overall mean vector u of the image. The calculation formula is as follows: Among them, u 0i and u 0j The mean vector corresponding to the two-dimensional array (i, j) of the background part; u 1i and u 1j The mean vector corresponding to the two-dimensional array (i, j) of the target part; u i and u j Let (i, j) be the total mean vector corresponding to the two-dimensional array (i, j); Step 5.4: Based on the probability w0 of the background appearing part, the mean vector u0 corresponding to the background part, the probability w1 of the target part appearing part, the mean vector u1 corresponding to the target part, and the overall mean vector u of the image, the inter-class discrete matrix Q(s,t) of the particle array is obtained, as shown below: Q(s,t)=w0(u0-u) 2 +w1(u1-u) 2 ; Step 5.5: Repeat steps 5.1-5.4 to obtain the inter-class discrete matrices of the remaining N-1 particle arrays, resulting in N inter-class discrete matrices.
4. The obstacle segmentation method based on the two-dimensional Ostu algorithm of particle swarm optimization with shared knowledge strategy according to claim 3, characterized in that, Step 6 is as follows: Step 6.1: Calculate the trace R of the N discrete matrices obtained in Step 5. trace Q(s,t); Step 6.2: Take the trace R of the N discrete matrices obtained in Step 6.
1. trace Q(s,t) serves as the inter-class discreteness measure for the background component C0 and the target component C1. Using this discreteness measure as the fitness function fun(s,t), we obtain the fitness function for the positions of the N particle arrays, expressed as follows:
5. The obstacle segmentation method based on the two-dimensional Ostu algorithm of particle swarm optimization with shared knowledge strategy as described in claim 4, characterized in that, Step 8 is as follows: Step 8.1: Update the velocity of each two-dimensional particle in Step 4 based on the N local extrema pBesti and one global extrema gBest obtained in Step 7, as follows: in, The current particle velocity; The updated particle velocity is the particle velocity of the current particle. n is the number of iterations; This represents the local extremum of the current particle. gBest n This represents the current global extremum of the particle. This represents the current position in the particle array. ω represents the inertia weight; c1 and c2 are learning factors; r1 and r2 are random numbers distributed in [0, 1]; We obtain the two-dimensional particles with updated velocity; Step 8.2: While executing step 8.1, calculate the fitness of the N particle arrays in step 4 using the fitness function obtained in step 6, sort the fitness of the N particle arrays in descending order, and perform two-dimensional particle position updates according to the shared knowledge strategy to obtain N particle arrays with updated velocity and position.
6. The obstacle segmentation method based on the two-dimensional Ostu algorithm of particle swarm optimization with shared knowledge strategy as described in claim 5, characterized in that, Step 8.2 is as follows: Step 8.2.1: Initial Shared Knowledge Stage Position Update. The initial stage particle array position is updated by calculating the fitness of the N particle arrays used as the segmentation threshold array in Step 5 using the fitness function obtained in Step 6. The N particle arrays are sorted in descending order of fitness. One particle array is selected as the current particle array, and the remaining N-1 particle arrays are random particle arrays. The two particle arrays with the closest fitness to the current particle array are selected, and the position difference between these two particle arrays is calculated. This position difference, along with the position difference between the random particle array and the current particle array, is used to update the position of the current particle array. The initial stage particle array position update method is as follows: in, This represents the current position in the particle array. To be better than the current particle array position; It is below the current particle array position; For random particle array positions; This refers to the updated particle array positions; α is the distance factor; If the fitness of the random particle array is less than the fitness of the current particle array, the random particle array is moved as a whole to the position of the current particle array. If the fitness of the random particle array is greater than or equal to the fitness of the current particle array, then the current particle array moves to the position of the random particle array. Step 8.2.2 Advanced Knowledge Sharing Phase Location Update Based on fitness, the N particle arrays after the initial shared knowledge phase position update are sorted in descending order. The top 10% of particle arrays are selected as the better particle arrays, the middle 80% as the medium particle arrays, and the bottom 10% as the worse particle arrays. Advanced phase position updates are then performed based on the random distance between the better and worse particle arrays, and the distance difference between the medium particle array and the current particle array. The update method is as follows: Among them, X rbest This refers to a randomly selected position in the optimal particle array. X rm This is a randomly selected position in the particle array within the medium particle array. X rworst A random position in the particle array from the poor particle array; Randomly select a particle array from the medium particle array. If the fitness of the medium particle array is less than that of the current particle array, then N-1 particle arrays move to the position of the current particle array. If the fitness of the medium particle array is greater than or equal to the fitness of the current particle array, then N-1 particle arrays move to the position of the medium particle array. 8.2.3 After steps 8.2.1 and 8.2.2, the new position and velocity of each particle array are obtained, thus obtaining N particle arrays with updated velocity and position.
7. The obstacle segmentation method based on the two-dimensional Ostu algorithm of particle swarm optimization with shared knowledge strategy as described in claim 6, characterized in that, Step 10 is as follows: Based on the correspondence between the particle array and the two-dimensional array in step 4, the optimal two-dimensional array in step 9 is defined as (x, v). Let the optimal two-dimensional array (x, v) be the optimal segmentation threshold array. The preprocessed image is divided into obstacle region and background region using the optimal segmentation threshold array. The calculation method is as follows: