Method, device and equipment for determining part image segmentation threshold
Through the improved eel-grouper optimization algorithm combined with multiple strategies to optimize and iterate the image segmentation threshold, the problem of insufficient segmentation accuracy and efficiency in mechanical parts defect detection is solved, and higher segmentation accuracy and processing efficiency are achieved.
Patent Information
- Application Number
- CN202510672605.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-23
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2045-05-23
AI Technical Summary
The existing image segmentation methods have problems with insufficient segmentation accuracy and efficiency in mechanical parts defect detection, especially when multi-threshold image processing, it is easy to fall into local optimal solutions, and it is difficult to find the global optimal solutions.
The improved eel-grouper optimization algorithm is adopted, combining the exploration and optimization strategy of cosine fluctuation, the optimization strategy of the elimination optimization mechanism, and the exploration and development of dynamic balance optimization strategies, and the image segmentation threshold is optimized and iterated, the population is initialized through the preset conversion algorithm, and appropriate optimization strategies are selected at different iteration stages to improve search accuracy and range.
The accuracy and processing efficiency of multi-threshold image segmentation are improved, local optimal solutions are avoided, global optimal solutions are found, and image segmentation accuracy and calculation efficiency are improved.
Smart Images

Figure CN120198457B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer information processing, and in particular to a method, device and equipment for determining a part image segmentation threshold. Background Art
[0002] In modern manufacturing, the surface quality of mechanical parts directly impacts product performance and service life. Therefore, effective detection and diagnosis of surface defects on mechanical parts has become a critical research topic. Traditional inspection methods rely heavily on manual visual inspection, which is not only inefficient but also susceptible to human error, resulting in reduced accuracy and consistency in inspection results. Therefore, automated inspection using advanced image processing technologies has become a key approach to improving production efficiency and product quality. Image segmentation, a core technology in computer vision, aims to segment an image into regions with distinct features to facilitate analysis and processing of the target of interest. In the diagnosis of surface defects on mechanical parts, image segmentation can effectively extract defect regions from complex backgrounds, enabling automatic identification and classification of defects. With the continuous advancement of image processing technology, image segmentation methods based on optimization algorithms have gradually become mainstream. Their powerful capabilities in feature extraction and pattern recognition make them more adaptable to complex defect detection scenarios. Surface defects on mechanical parts vary widely, including scratches, dents, rust, and uneven coatings, which can severely impact the performance of the parts.
[0003] Therefore, it is particularly important to develop an efficient and accurate defect diagnosis method. The defect diagnosis system based on image segmentation technology can be trained for different types of defects to improve the accuracy of detection. At the same time, by locating and extracting features of defects, it can provide strong data support for subsequent quality control and improvement. Machine vision is an important manifestation of image processing technology in the industrial field. It obtains valuable information by capturing images and analyzing and processing them. In the production process of mechanical parts, machine vision can be used to achieve functions such as rapid inspection, dimensional measurement, and surface defect identification of components. Component images are acquired through high-resolution cameras and imaging devices, and then analyzed using image processing algorithms. This process not only improves the processing accuracy of parts, but also lays the foundation for the realization of intelligent production.
[0004] The basic principle of multi-threshold image segmentation is to divide the image's pixel value range into several intervals by setting multiple thresholds. Each interval corresponds to a specific image region, allowing for better analysis, feature extraction, and information recognition. In multi-threshold segmentation, Otsu's method and Kapur's method are two classic multi-threshold segmentation methods.
[0005] Among them, Otsu is the optimal algorithm for threshold selection in image segmentation. It is simple to calculate and is unaffected by image brightness and contrast, making it widely used in digital image processing. It divides the image into two parts, background and foreground, based on the image's grayscale characteristics. Because variance is a measure of the uniformity of grayscale distribution, the greater the inter-class variance between the background and foreground, the greater the difference between the two parts of the image. When part of the foreground is mistakenly classified as the background, or part of the background is mistakenly classified as the foreground, the difference between the two parts will decrease. Therefore, the segmentation that maximizes the inter-class variance means the lowest probability of misclassification. The advantage of Otsu's method is that it is an unsupervised segmentation method suitable for various types of image processing tasks, such as medical image analysis and object recognition.
[0006] The Eel and Grouper Optimization (EGO) algorithm, first proposed in 2024, simulates the symbiotic relationship and foraging behavior of eels and groupers in marine ecosystems. This metaheuristic optimization algorithm is based on the flexibility of eels and the aggressiveness of groupers, which lead to their shared foraging behavior. This algorithm selects high-quality individuals based on fitness for crossover, thereby rapidly identifying the optimal individual. While this algorithm has a fast search speed, its rapid convergence during the search process can lead to premature local optima and incomplete global search, resulting in a local optimal solution. This makes it difficult to accurately find the global optimal solution. Summary of the Invention
[0007] The technical problem to be solved by the present invention is to provide a method, device and equipment for determining the threshold value of part image segmentation, so as to improve the segmentation accuracy and processing efficiency during multi-threshold image processing.
[0008] To solve the above technical problems, an embodiment of the present invention provides a method for determining a part image segmentation threshold, comprising:
[0009] Acquire image data of a target part image;
[0010] Determine an original population according to the image data, wherein the original population includes a plurality of different individuals, each individual corresponding to a segmentation operator, and each segmentation operator corresponding to an original region value;
[0011] Initializing the original population according to a preset conversion algorithm to obtain an initialized population;
[0012] The positions of individuals in the initialized population are optimized iteratively according to a preset optimization algorithm to obtain a target segmentation threshold corresponding to the target area value of the target individual; the preset optimization algorithm is an improved eel-grouper optimization algorithm, and the preset optimization algorithm includes a preset sine and cosine fluctuation exploration optimization strategy, a preset elimination optimization mechanism optimization strategy, and a preset exploration and development dynamic balance optimization strategy. During the optimization iterative processing, the corresponding optimization strategy is determined according to the current number of iterations and the preset total number of iterations to perform optimization iterative processing on the initialized population.
[0013] In one embodiment, initializing the original population according to a preset conversion algorithm to obtain an initialized population includes:
[0014] The original region value corresponding to each individual in the original population is converted according to the preset conversion algorithm to obtain the initialized population.
[0015] In one embodiment, performing conversion processing on the original region value corresponding to each individual in the original population according to the preset conversion algorithm includes:
[0016] Convert the original value corresponding to each individual into a positive integer according to the following formula:
[0017] ;
[0018] in, Represents the initial region value corresponding to the i-th individual after transformation, Represents the original region value corresponding to the i-th individual before transformation, i=1, 2, 3, ..., N is a positive integer.
[0019] In one embodiment, performing an iterative optimization process on the individuals in the initialized population according to a preset optimization algorithm specifically includes the following steps:
[0020] When the current number of iterations is less than or equal to one third of the preset total number of iterations, performing an optimization iterative process on the initialized population according to a preset sine-cosine wave exploration optimization strategy to update the proxy position of each individual in the initialized population and obtain a first target population;
[0021] When one third of the preset total number of iterations is less than the current number of iterations and less than two thirds of the preset total number of iterations, performing iterative optimization processing on the first target population according to a preset elimination optimization mechanism optimization strategy to update the optimal proxy position of the optimal individual in the first target population and obtain a second target population, wherein the optimal individual is an individual in the first target population whose distance to the optimal region value is within a preset range;
[0022] When two-thirds of the preset total number of iterations < the current number of iterations ≤ the preset total number of iterations, the second target population is optimized iteratively according to the preset exploration and development dynamic balance optimization strategy until the number of iterations reaches the preset total number of iterations to obtain target individuals, each target individual corresponding to a target segmentation operator, and each target segmentation operator corresponding to a target area value.
[0023] In one embodiment, when the current number of iterations is less than or equal to one third of the preset total number of iterations, performing an optimization iterative process on the initialization population according to a preset sine-cosine wave exploration optimization strategy to update the proxy position of each individual in the initialization population and obtain a first target population, including:
[0024] Determine the volatility strategy parameters in the iterative optimization process based on the preset sine and cosine volatility functions;
[0025] The proxy position of each individual in the initialization population is iteratively updated according to the fluctuation strategy parameters to obtain a first target population after the individual proxy position is updated.
[0026] In one embodiment, when one third of the preset total number of iterations is less than the current number of iterations and less than two thirds of the preset total number of iterations, performing iterative optimization processing on the first target population according to a preset elimination optimization mechanism optimization strategy to update the optimal proxy position of the optimal individual in the first target population and obtain a second target population, including:
[0027] According to the formula: Iteratively updating the optimal proxy position of the optimal individual in the first target population;
[0028] in, represents the optimal proxy position after the update of the i-th optimal individual in the first target population corresponding to the current iterative process, represents the optimal proxy position of the i-th best individual in the first target population corresponding to the previous round of iterative processing, B represents the iterative progress of the algorithm, represents the perturbation coefficient, Best represents the proxy position of the excellent individual in the first target population, and Worst represents the proxy position of the inferior individual in the first target population;
[0029] According to the formula: Screening the population composed of the best individuals after the current updated optimal agent position, and obtaining the second target population;
[0030] in, represents the optimal proxy position of the best individual selected, Indicates the fitness value corresponding to the i-th optimal individual after the current iterative processing, It represents the fitness value of the individual closest to the global optimal segmentation threshold at the j-th dimension position after the current iterative processing.
[0031] In one embodiment, when two-thirds of the preset total number of iterations < the current number of iterations ≤ the preset total number of iterations, performing iterative optimization processing on the second target population according to a preset exploration and development dynamic balance optimization strategy to obtain the target segmentation threshold set includes:
[0032] According to the formula: Update the optimal proxy position of the selected optimal individual, where represents the optimal agent position after the optimal individual is screened out, 、 All represent the parameters of the preset exploration and development dynamic balance strategy, represents the optimal proxy position of the best individual selected, Indicates the proxy position of the best individual selected in the jth dimension;
[0033] According to the formula: The area value corresponding to the updated proxy position of the selected optimal individual is updated to obtain the target individual and the target area value corresponding to the target individual.
[0034] In one embodiment, the method for determining the part image segmentation threshold further includes:
[0035] Segmenting the target part image based on the target region value corresponding to the target individual to obtain a segmentation result;
[0036] Evaluate the segmentation result based on a preset evaluation algorithm to obtain an evaluation result;
[0037] According to the evaluation result, a target segmentation threshold corresponding to the target area value is determined.
[0038] An embodiment of the present invention further provides a device for determining a part image segmentation threshold, comprising:
[0039] An acquisition module, used for acquiring image data of a target part image;
[0040] A processing module is used to determine the original population based on the image data, wherein the original population includes a plurality of different individuals, each individual corresponds to a segmentation operator, and each segmentation operator corresponds to an original area value; the original population is initialized according to a preset conversion algorithm to obtain an initialized population; the positions of the individuals in the initialized population are optimized and iteratively processed according to a preset optimization algorithm to obtain a target segmentation threshold corresponding to the target area value of the target individual; the preset optimization algorithm is an improved eel-grouper optimization algorithm, and the preset optimization algorithm includes a preset sine and cosine fluctuation exploration optimization strategy, a preset elimination optimization mechanism optimization strategy, and a preset exploration and development dynamic balance optimization strategy. During the optimization iterative processing, the corresponding optimization strategy is determined according to the current number of iterations and the preset total number of iterations to perform optimization iterative processing on the initialized population. An embodiment of the present invention also provides a computing device, comprising:
[0041] a memory for storing one or more programs;
[0042] One or more processors are used to execute the one or more programs to implement the above-mentioned method.
[0043] The above solution of the present invention includes at least the following beneficial effects:
[0044] The above-mentioned solution of the present invention provides a method and device for determining a part image segmentation threshold, wherein the method comprises: acquiring image data of a target part image;
[0045] Determine an original population according to the image data, wherein the original population includes a plurality of different individuals, each individual corresponding to a segmentation operator, and each segmentation operator corresponding to an original region value;
[0046] The original population is initialized according to a preset conversion algorithm to obtain an initialized population; the positions of individuals in the initialized population are optimized iteratively according to a preset optimization algorithm to obtain a target segmentation threshold corresponding to the target area value of the target individual; the preset optimization algorithm is an improved eel-grouper optimization algorithm, and the preset optimization algorithm includes a preset sine and cosine fluctuation exploration optimization strategy, a preset elimination optimization mechanism optimization strategy, and a preset exploration and development dynamic balance optimization strategy. During the optimization iterative processing, the corresponding optimization strategy is determined according to the current number of iterations and the preset total number of iterations to perform optimization iterative processing on the initialized population, providing a more accurate segmentation threshold for multi-threshold image segmentation, thereby improving the accuracy and processing efficiency of multi-threshold image segmentation. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 is a flow chart of a method for determining a part image segmentation threshold value provided by an embodiment of the present invention;
[0048] Figure 2 This is a flow chart of a method for determining a part image segmentation threshold value provided by an optional embodiment of the present invention.
[0049] Figure 3 1 is a schematic block diagram of a module block of a device for determining a part image segmentation threshold value provided by an embodiment of the present invention;
[0050] Figure 4 is a schematic block diagram of an electronic device provided by an embodiment of the present invention;
[0051] Figure 5 is a schematic block diagram of a computing device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0052] Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0053] In the following description, for the purpose of illustrating the various disclosed embodiments, certain specific details are set forth in order to provide a thorough understanding of the various disclosed embodiments. However, those skilled in the relevant art will recognize that the embodiments may be practiced without one or more of these specific details. In other cases, well-known devices, structures, and techniques associated with this application may not be shown or described in detail to avoid unnecessarily obscuring the description of the embodiments.
[0054] Reference throughout this specification to "one embodiment" or "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment. Thus, the appearances of "in one embodiment" or "in an embodiment" in various places throughout this specification are not necessarily all referring to the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any manner in one or more embodiments.
[0055] In the following description, in order to clearly show the structure and working mode of the present invention, many directional words will be used for description, but words such as "front", "back", "left", "right", "outside", "inside", "outward", "inward", "up", and "down" should be understood as convenient terms and should not be understood as restrictive terms.
[0056] like Figure 1 As shown, an embodiment of the present invention provides a method for determining a part image segmentation threshold, comprising:
[0057] Step 11, obtaining image data of the target part image;
[0058] Step 12: Determine the original population based on the image data. The original population includes multiple different individuals. Each individual corresponds to a segmentation operator, and each segmentation operator corresponds to an original region value.
[0059] Step 13: Initialize the original population according to a preset conversion algorithm to obtain an initialized population;
[0060] Step 14, according to a preset optimization algorithm, the positions of individuals in the initialized population are optimized iteratively to obtain a target segmentation threshold corresponding to the target area value of the target individual; the preset optimization algorithm is an improved eel-grouper optimization algorithm, and the preset optimization algorithm includes a preset sine and cosine fluctuation exploration optimization strategy, a preset elimination optimization mechanism optimization strategy, and a preset exploration and development dynamic balance optimization strategy. During the optimization iterative processing, the corresponding optimization strategy is determined according to the current number of iterations and the preset total number of iterations to perform optimization iterative processing on the initialized population.
[0061] In this embodiment, the image data is specifically the pixel value of the image. For the image data of the target part image to be segmented, it includes multiple pixel values, and the value of each pixel represents its color or brightness information;
[0062] Here, based on the image data, multiple segmentation operators are generated to segment the pixel values of the target part image, and the population composed of the multiple segmentation operators is determined as the original population. Each segmentation operator represents an individual in the original population. Each individual corresponds to an initial position. After the initial position of the current individual is determined, the boundary area of the individual at that position on the target part image to be segmented is also determined. That is, each randomly generated individual corresponds to an original area value on the target part image to be segmented.
[0063] Furthermore, each individual in the original population is initialized using a preset conversion algorithm, that is, the original region value corresponding to the individual is processed to solve the problem of color selection range during image segmentation, ensuring the accuracy of subsequent optimization based on the initialized population, and thus ensuring the accuracy of image segmentation;
[0064] Furthermore, the initial population is iteratively optimized using an improved eel-grouper optimization algorithm. During this iterative optimization process, the entropy threshold of the target part image, represented by the segmentation threshold, serves as the objective function, also known as the fitness function. After each iteration, the position of the globally optimal agent (i.e., the optimal individual) and its corresponding fitness function value are recorded. This allows the optimal solution (optimal individual) to be output at the end of the iterative optimization process and serve as a reference for subsequent search processes. Specifically, the globally optimal agent is the agent with the best fitness function value among all searched agents. The fitness function value is a measure of the quality of an agent's solution to the problem, with higher fitness function values generally indicating better solutions. By continuously updating the position and fitness function value of the globally optimal agent, the optimal solution found during the current iteration is tracked and recorded throughout the search process.
[0065] When using the improved eel-grouper optimization algorithm to iteratively optimize the initialized population, different optimization strategies can be selected according to the stage of the current iterative optimization process to iteratively optimize the current population, which can effectively avoid local optimal solutions and improve the search range and search accuracy. Specifically, at different stages of the iterative optimization process, the optimization strategy is explored through cosine fluctuations to update the proxy position, thereby enhancing the algorithm's search range and improving the algorithm's search accuracy; the optimization strategy is optimized through a preset elimination optimization mechanism, and the proxy position is updated again to further improve the algorithm's convergence accuracy; the dynamic balance optimization strategy is explored and developed through a preset weighted proportional balance, thereby increasing the algorithm's search range and search capabilities; when the number of iterations reaches the preset maximum number of iterations, the iterative optimization process is exited and the final optimized target individual is output. Based on the target area value corresponding to the target individual, the target segmentation threshold corresponding to each target area value can be determined;
[0066] The method provided in the above embodiment demonstrates the advantages of good segmentation accuracy, strong convergence, high robustness, and low computational cost in the process of multi-threshold image segmentation, ensuring the segmentation accuracy and processing efficiency when performing image segmentation based on the segmentation threshold determined by this method.
[0067] In an optional embodiment of the present invention, the original position corresponding to each individual in the original population can be obtained by the following formula:
[0068]
[0069] ;
[0070] Among them, boundary represents the quantitative limit of the variable; represents the position of the i-th individual in the original population in the j-th dimension, i = 1, 2, 3, ..., N; N represents the size of the original population, j = 1, 2, 3, ..., dim; dim represents the dimension of the search space; ub and lb represent the upper and lower bounds of the search space when the number limit of the variables is equal to 1, respectively; and They represent the upper and lower bounds of the search space in the jth dimension respectively.
[0071] In an optional embodiment of the present invention, after each iterative optimization process, the fitness function value of each individual in the current population is calculated, and the optimal proxy position within the current iteration, the optimal position among all individuals in the population, and the optimal region value corresponding to the optimal proxy position are defined. The purpose of calculating the fitness function value is to convert each excellent proxy in the optimization algorithm into an excellent image segmentation operator for threshold segmentation. Here, the optimal region value can also be considered the optimal segmentation threshold.
[0072] In an implementable example, the fitness function value is calculated using the following formula:
[0073] ;
[0074] Among them, Iout represents the fitness function value; I represents the grayscale value range (0~255); thresh represents the optimal threshold number for image segmentation; i represents the i-th individual in the population; N represents the total number of populations.
[0075] In an optional embodiment of the present invention, the above step 13 may include:
[0076] Step 131 : transforming the original region value corresponding to each individual in the original population according to a preset transformation algorithm to obtain an initialized population.
[0077] Image channels are the different components of pixel data in an image, used to store information about color, brightness, or other image features. The RGB color model generates a variety of colors by varying the red, green, and blue color channels and superimposing them on each other. Each pixel is represented by three values, and its pixel value is represented by the superposition of red (0-255), green (0-255), and blue (0-255), resulting in more vivid colors. Each pixel value is three digits, representing one of the three primary colors. Here, each individual in the original population is transformed using a preset transformation algorithm. The original region value corresponding to each individual in the original population is converted into positive integer data to obtain a positive integer proxy. This avoids the color selection range problem that exists during image segmentation, ensures the accuracy of subsequent iterative optimization based on the initialized population, and thus ensures the accuracy of image segmentation.
[0078] In an optional embodiment of the present invention, the above step 131 may include:
[0079] 1311, convert the original area value corresponding to each individual into a positive integer according to the following formula:
[0080] ;
[0081] in, Represents the initial region value corresponding to the i-th individual after transformation, Represents the original region value corresponding to the i-th individual before transformation, i=1, 2, 3, ..., N is a positive integer.
[0082] like Figure 2 As shown, in an optional embodiment of the present invention, the above step 14 may include:
[0083] Step 141: When the current number of iterations is less than or equal to one third of the preset total number of iterations, the initialized population is optimized iteratively according to the preset sine-cosine wave exploration optimization strategy to update the proxy position of each individual in the initialized population and obtain the first target population;
[0084] Step 142: When one-third of the preset total number of iterations is less than the current number of iterations and less than two-thirds of the preset total number of iterations, the first target population is optimized iteratively according to the preset elimination optimization mechanism optimization strategy to update the optimal proxy position of the optimal individual in the first target population and obtain a second target population, where the optimal individual is the individual in the first target population whose distance to the optimal region value is within a preset range;
[0085] Step 143, when two-thirds of the preset total number of iterations < the current number of iterations ≤ the preset total number of iterations, the second target population is optimized iteratively according to the preset exploration and development dynamic balance optimization strategy until the number of iterations reaches the preset total number of iterations, so as to obtain target individuals, each target individual corresponding to a target segmentation operator, and each target segmentation operator corresponding to a target area value.
[0086] In this embodiment, in the initial stage of the optimization iteration, the initialized population is optimized iteratively using a preset sine-cosine wave exploration optimization strategy to update the proxy position of each individual in the initialized population. This optimization strategy, combined with the sine-cosine wave mechanism, enables the algorithm to more quickly escape from local optimal solutions during the exploration process, thereby increasing the accuracy and scope of the search and more accurately locating the global optimal solution.
[0087] Furthermore, in the middle stage of the optimization iteration, the first target population is optimized iteratively through the preset elimination optimization mechanism optimization strategy to update the optimal proxy position of the best individual in the first target population; here, the first target population is first screened to eliminate individuals that are far from the global optimal solution, thereby leaving the best individuals that are closer to the optimal solution, and the proxy position of the best individual is iteratively updated to improve the optimization performance of the algorithm;
[0088] Furthermore, in the final stage of the optimization iteration, the second target population is optimized and iteratively processed by a preset exploration and development dynamic equilibrium optimization strategy to improve the effectiveness and adaptability of the overall algorithm.
[0089] In an optional embodiment of the present invention, the above step 141 may include:
[0090] Step 1411, determining the fluctuation strategy parameters in the iterative optimization process according to the preset sine and cosine fluctuation functions;
[0091] Step 1412: Iteratively update the proxy position of each individual in the initialized population according to the fluctuation strategy parameters to obtain a first target population after the individual proxy positions are updated.
[0092] In this embodiment, the preset sine-cosine fluctuation exploration optimization strategy is proposed based on the inspiration of two different curve fluctuation functions: sine and cosine. Under the fluctuation amplitude of the hyperbolic function, the algorithm can escape from the local optimal solution more quickly during the exploration process, thereby increasing the accuracy and scope of the search and more accurately locating the global optimal solution.
[0093] Here, the volatility strategy parameters can be determined by the following formula:
[0094] ;
[0095] ;
[0096] ;
[0097] ;
[0098] in, represents the sinusoidal disturbance coefficient; represents the cosine perturbation coefficient; represents a sinusoidal wave function; Represents the cosine wave function; i represents the current search individual; N represents the total population; t represents the current number of iterations; Maxiter represents the preset maximum number of iterations;
[0099] Here, the sine and cosine function fluctuations are combined to obtain the fluctuation strategy parameters:
[0100] ;
[0101] in, is a random number between 0 and 1, Represents the parameters of the sine and cosine wave strategy;
[0102] During the global search process of the algorithm, some individuals fall into the local optimal trap within the search range due to their weak search ability. Through the fluctuation strategy parameter, the individuals trapped in the local optimal trap can be freed from the local optimal trap and further explore more ranges, expanding the search range of the search individuals, so that the algorithm can further explore the global optimal solution;
[0103] Furthermore, the introduction of the sine-cosine wave search strategy enables the individuals that were originally trapped in the local optimum to break away and move further towards the global optimum, thereby achieving the update of the individual agent position, as shown in the following formula:
[0104] ;
[0105] in, represents the updated proxy position of the i-th individual in the initial population (that is, the proxy position of the i-th individual in the first target population); represents the proxy position before the update (that is, the proxy position of the i-th individual in the initial population), Indicates the proxy position of the best individual in the current iteration.
[0106] In an optional embodiment of the present invention, the above step 142 may include:
[0107] Step 1421, according to the formula Iteratively update the optimal proxy position of the best individual in the first target population;
[0108] in, It represents the optimal proxy position after the update of the i-th optimal individual in the first target population corresponding to the current iterative process, represents the optimal proxy position of the i-th optimal individual in the first target population corresponding to the previous round of iterative processing, B represents the iterative progress of the algorithm, represents the disturbance coefficient, Best represents the proxy position of the excellent individual in the first target population, and Worst represents the proxy position of the inferior individual in the first target population;
[0109] Step 1422, according to the formula Screen the population composed of the best individuals after the current updated optimal agent position, and obtain the second target population;
[0110] in, represents the optimal proxy position of the best individual selected, Indicates the fitness value corresponding to the i-th optimal individual after the current iterative processing, It represents the fitness value of the individual closest to the global optimal segmentation threshold at the j-th dimension position after the current iterative processing.
[0111] here, ; ; ; ; ; Wherein, fit represents the optimal individual in the first target population.
[0112] In an optional embodiment of the present invention, the above step 143 may include:
[0113] Step 1431, according to the formula Update the optimal proxy position of the selected optimal individual, where represents the optimal agent position after the optimal individual is screened out, 、 Both represent the parameters of the preset exploration and development dynamic balance strategy. represents the optimal proxy position of the best individual selected, Indicates the proxy position of the best individual selected in the jth dimension;
[0114] Step 1432, according to the formula The area value corresponding to the updated proxy position of the selected optimal individual is updated to obtain the target individual and the target area value corresponding to the target individual.
[0115] In this embodiment, the development performance of the algorithm is first adjusted to redistribute the weight between review optimization and exploration to improve the effectiveness and adaptability of the overall algorithm. The specific formula is:
[0116] ; Where r2 represents a constant set to -2, and r1 is a random number between [0,1].
[0117] Furthermore, based on the adjusted preset exploration and development dynamic balance strategy and corresponding parameters, the individual agent positions and corresponding area values in the second target population are updated to improve the exploration performance of the algorithm, thereby obtaining the target individual and the target area value corresponding to the target individual; Here, Indicates the target area value corresponding to the target individual;
[0118] It should be noted that according to the formula After updating the optimal proxy position of the selected optimal individual, the optimal individual corresponding to the optimal proxy position is the target individual.
[0119] See Figure 2 In an optional embodiment of the present invention, it may also include performing boundary checks on the proxy positions corresponding to the individuals in the first target population obtained in step 1412, the proxy positions corresponding to the individuals in the second target population obtained in step 1422, and the proxy positions corresponding to the target individuals obtained in step 1432; through boundary checks, it can be ensured that the algorithm always produces solutions that meet the problem requirements during the search process, avoiding invalid solutions from negatively affecting the performance of the algorithm. Invalid solutions usually do not provide valuable information for the algorithm's search process, and may even cause the algorithm to fall into an infinite loop or produce the wrong search direction. Through boundary checks, these invalid solutions can be discovered and processed in a timely manner to avoid wasting computing resources;
[0120] Preferably, the boundary check can be performed by the following formula:
[0121] ;in, Indicates the proxy position corresponding to the individual obtained in the above steps.
[0122] In an optional embodiment of the present invention, based on step 1431 and step 1432, the following steps may also be included:
[0123] Step 1433, segmenting the target part image based on the target region value corresponding to the target individual to obtain a segmentation result;
[0124] Step 1434, evaluating the segmentation result based on a preset evaluation algorithm to obtain an evaluation result;
[0125] Step 1435: Determine the target segmentation threshold corresponding to the target region value based on the evaluation result.
[0126] In this embodiment, the preset evaluation algorithms include: FSIM (Feature Similarity Index Measure), SSIM (Structural Similarity), and PSNR (Peak Signal-to-Noise Ratio). PSNR quantifies image quality by comparing the difference between the original image and the processed image. A higher PSNR value indicates better image quality. SSIM evaluates the similarity between two images by comparing brightness, contrast, and structure, and is used to measure the similarity between images before and after distortion. FSIM is primarily based on the human visual system's (HVS) perception of low-level features, specifically the combination of phase congruency (PC) and gradient magnitude (GM).
[0127] When the specific value represented by each evaluation result is within the preset range, the target area value corresponding to the current target individual is determined to be the final segmentation area value, that is, the final target segmentation threshold.
[0128] Here, FSIM, SSIM, and PSNR are used to evaluate segmentation accuracy, which are defined as follows:
[0129] ;
[0130] ;
[0131] ;
[0132] ;
[0133] ;
[0134] ;
[0135] in, and They are images x and y The average value within the local window represents the brightness level of the image; and They are images x and y The variance within the local window represents the contrast of the image; is an image x and y The covariance within the local window indicates the structural similarity of the image; usually =0.01, =0.03, L is the dynamic range of pixel values; F1 and F2 are two constants about pixel values to avoid the denominator taking the value of 0; is the phase consistency function; is the similarity function of the gradient magnitude; and are two images; M and Q are the height and width of the image respectively; MSE represents the mean square error of the two compared images; and Represent the pixel values at the corresponding coordinates respectively; i and j are the position indexes of the pixels; MAX is the maximum possible pixel value in the image.
[0136] The method for determining the part image segmentation threshold provided by the above embodiment of the present invention is based on the eel-grouper optimization algorithm with three improved strategies, and uses FSIM, SSIM, and PSNR to evaluate segmentation accuracy, thereby improving the segmentation accuracy and algorithm convergence of the multi-threshold image segmentation technology. Specifically: through the sine and cosine wave exploration strategy, the algorithm's search range is enhanced and the algorithm's search accuracy is improved; through the elimination optimization mechanism strategy, the algorithm's convergence accuracy is further improved; through the exploration and development of a dynamic balance strategy, the weighted exploration and development ratio balance is achieved, thereby increasing the algorithm's search range and search capabilities. When the method for determining the part image segmentation threshold provided by the above embodiment of the present invention is applied to multi-threshold image segmentation, it can exhibit advantages such as good segmentation accuracy, strong convergence, high robustness, and low computational cost, thereby improving the accuracy and efficiency of multi-threshold image segmentation.
[0137] The following uses a dataset of real part images from a real factory to verify the beneficial effects of the present invention. The program experimental verification of the method of the present invention on a computer is specifically as follows:
[0138] 1. Experimental Setup
[0139] In this experiment, the maximum number of iterations was set to 100. To ensure fairness in the solution, 30 iterations were set, and the average of the final results was taken. Segmentation accuracy was evaluated using FSIM, SSIM, and PSNR. The evaluation metrics included average fitness value (Avgf) and standard deviation of fitness value (Stdf).
[0140] 2. Experimental subjects
[0141] The experimental objects are the improved eel grouper algorithm (EGO); two classic metaheuristic algorithms: Harris Hawk algorithm (HHO), improved grey wolf algorithm (EGWO) and sine-cosine algorithm (SCA); the novel algorithms in recent years: fishing algorithm (CFOA), sooty tern algorithm (STOA), rat swarm algorithm (RSO); and the original eel grouper algorithm (COA).
[0142] 3. Comparison of experimental results
[0143] In order to better display the data of experimental results comparison, the optimal results of average fitness and standard deviation of fitness values are bolded, as shown in Tables 1 and 2:
[0144] Table 1: FSIM, SSIM, and PSNR evaluation results of image segmentation of defective electromechanical parts:
[0145]
[0146] Table 2: FSIM, SSIM, and PSNR evaluation results of image segmentation of defective electromechanical parts:
[0147]
[0148] Table 3: FSIM, SSIM, and PSNR evaluation results of image segmentation of defective electromechanical parts:
[0149]
[0150] Table 4: FSIM, SSIM, and PSNR evaluation results of image segmentation of defective electromechanical parts:
[0151]
[0152] Judging from the results of the above experiments, the method provided by the present invention outperforms the seven algorithms compared in the above embodiments. For all electromechanical parts image data sets, the methods of the present invention almost all achieved the highest average fitness values. Judging from the comparison results between the improved eel grouper algorithm and the original eel grouper algorithm, the results of the improved algorithm are comprehensively ahead of the original algorithm, with significant improvements in fitness mean value, standard deviation, and segmentation accuracy. Finally, judging from the standard deviation of the fitness value, the standard deviation achieved by the improved eel grouper algorithm on the electromechanical parts image data set all ranked in the top three, verifying its robustness.
[0153] like Figure 3 As shown, an embodiment of the present invention further provides a device 30 for determining a part image segmentation threshold, comprising:
[0154] An acquisition module 31 is used to acquire image data of a target part image;
[0155] The processing module 32 is used to determine the original population based on the image data, where the original population includes multiple different individuals, each individual corresponds to a segmentation operator, and each segmentation operator corresponds to an original area value; the original population is initialized according to a preset conversion algorithm to obtain an initialized population; the positions of the individuals in the initialized population are optimized and iteratively processed according to a preset optimization algorithm to obtain a target segmentation threshold corresponding to the target area value of the target individual; the preset optimization algorithm is an improved eel-grouper optimization algorithm, and the preset optimization algorithm includes a preset sine and cosine fluctuation exploration optimization strategy, a preset elimination optimization mechanism optimization strategy, and a preset exploration and development dynamic balance optimization strategy. During the optimization iterative processing, the corresponding optimization strategy is determined according to the current number of iterations and the preset total number of iterations to perform optimization iterative processing on the initialized population.
[0156] It should be noted that this device is a device corresponding to the above-mentioned method for determining the part image segmentation threshold. All implementation methods in the above-mentioned method embodiment are applicable to this embodiment and can achieve the same technical effect.
[0157] like Figure 4 As shown, an embodiment of the present invention further provides an electronic device 50, comprising: a memory 51 for storing one or more computer programs; and one or more processors 52 for executing the one or more computer programs. When the computer programs are executed by the processors, the method for determining the part image segmentation threshold as described above is performed. All implementations in the above method embodiments are applicable to this embodiment and can achieve the same technical effects. The electronic device 50 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown in the present invention, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0158] like Figure 5As shown, electronic device 50 is a computing device or computer system that may include a CPU 501 (computing unit) that can perform various appropriate actions and processes based on a computer program stored in a ROM 502 (read-only memory) or a computer program loaded from a storage unit 508 into a random access RAM 503 (memory). RAM 503 may also store various programs and data required for the operation of device 500. CPU 501, ROM 502, and RAM 503 are interconnected via a bus 504. An I / O interface 505 (input / output interface) is also connected to bus 504.
[0159] Multiple components in the electronic device 500 are connected to the I / O interface 505, including an input unit 506, such as a keyboard, a mouse, etc.; an output unit 507, such as various types of displays, speakers, etc.; a storage unit 508, such as a magnetic disk, an optical disk, etc.; and a communication unit 509, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 509 allows the device 500 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0160] CPU 501 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of CPU 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. CPU 501 performs the various methods and processes described above. For example, in some embodiments, method 10 for determining a part image segmentation threshold can be implemented as a computer software program tangibly embodied in a computer-readable storage medium, such as storage unit 508. In some embodiments, part or all of the computer program can be loaded and / or installed onto device 500 via ROM 502 and / or communication unit 509. When the computer program is loaded into RAM 503 and executed by CPU 501, one or more steps of method 10 for determining a part image segmentation threshold described above can be performed. Alternatively, in other embodiments, CPU 501 can be configured to perform method 10 for determining a part image segmentation threshold by any other suitable means (e.g., via firmware).
[0161] An embodiment of the present invention further provides a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to execute the method 10 for determining a part image segmentation threshold as described above. All implementations in the above method embodiments are applicable to this embodiment and can achieve the same technical effects.
[0162] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present invention.
[0163] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0164] In the embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interface, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0165] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0166] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0167] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the existing technology, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the various embodiments of the method of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, ROM, RAM, disk or optical disk, etc. Various media that can store program code.
[0168] In addition, it should be pointed out that in the apparatus and method of the present invention, it is obvious that each component or each step can be decomposed and / or recombined. These decompositions and / or recombinations should be regarded as equivalent solutions of the present invention. Moreover, the steps of performing the above-mentioned series of processing can naturally be performed in chronological order according to the order of description, but they do not necessarily need to be performed in chronological order, and some steps can be performed in parallel or independently of each other. For those of ordinary skill in the art, it can be understood that all or any steps or components of the method and apparatus of the present invention can be implemented in hardware, firmware, software or a combination thereof in any computing device (including a processor, storage medium, etc.) or a network of computing devices. This can be achieved by those of ordinary skill in the art using their basic programming skills after reading the description of the present invention.
[0169] Therefore, the purpose of the present invention can also be achieved by running a program or a group of programs on any computing device. The computing device can be a well-known general-purpose device. Therefore, the purpose of the present invention can also be achieved simply by providing a program product containing program code for implementing the method or device. That is to say, such a program product also constitutes the present invention, and the storage medium storing such a program product also constitutes the present invention. Obviously, the storage medium can be any well-known storage medium or any storage medium developed in the future. It should also be pointed out that in the device and method of the present invention, it is obvious that each component or each step can be decomposed and / or recombined. These decompositions and / or recombinations should be regarded as equivalent schemes of the present invention. In addition, the steps of performing the above-mentioned series of processing can naturally be performed in chronological order according to the order of description, but do not necessarily need to be performed in chronological order. Certain steps can be performed in parallel or independently of each other.
[0170] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as within the scope of protection of the present invention.
Claims
1. A method for determining a part image segmentation threshold, characterized in that: include: Acquire image data of a target part image; Determine an original population according to the image data, wherein the original population includes a plurality of different individuals, each individual corresponding to a segmentation operator, and each segmentation operator corresponding to an original region value; Initializing the original population according to a preset conversion algorithm to obtain an initialized population; The positions of the individuals in the initialized population are optimized iteratively according to a preset optimization algorithm to obtain a target segmentation threshold corresponding to a target area value of the target individual; the preset optimization algorithm is an improved eel-grouper optimization algorithm, and the preset optimization algorithm includes a preset sine-cosine fluctuation exploration optimization strategy, a preset elimination optimization mechanism optimization strategy, and a preset exploration and development dynamic balance optimization strategy. During the optimization iterative processing, the corresponding optimization strategy is determined according to the current number of iterations and the preset total number of iterations to perform optimization iterative processing on the initialized population; wherein the optimization iterative processing specifically includes the following steps: When the current number of iterations is less than or equal to one third of the preset total number of iterations, performing an optimization iterative process on the initialized population according to a preset sine-cosine wave exploration optimization strategy to update the proxy position of each individual in the initialized population and obtain a first target population; When one third of the preset total number of iterations is less than the current number of iterations and less than two thirds of the preset total number of iterations, performing iterative optimization processing on the first target population according to a preset elimination optimization mechanism optimization strategy to update the optimal proxy position of the optimal individual in the first target population and obtain a second target population, wherein the optimal individual is an individual in the first target population whose distance to the optimal region value is within a preset range; When two-thirds of the preset total number of iterations < the current number of iterations ≤ the preset total number of iterations, the second target population is optimized iteratively according to the preset exploration and development dynamic balance optimization strategy until the number of iterations reaches the preset total number of iterations to obtain target individuals, each target individual corresponding to a target segmentation operator, and each target segmentation operator corresponding to a target area value.
2. The method for determining the part image segmentation threshold according to claim 1, characterized in that: Initializing the original population according to a preset conversion algorithm to obtain an initialized population, including: The original region value corresponding to each individual in the original population is converted according to the preset conversion algorithm to obtain the initialized population.
3. The method for determining the part image segmentation threshold according to claim 2, characterized in that: Performing a conversion process on the original region value corresponding to each individual in the original population according to the preset conversion algorithm includes: Convert the original value corresponding to each individual into a positive integer according to the following formula: ; in, Represents the initial region value corresponding to the i-th individual after transformation, Represents the original region value corresponding to the i-th individual before transformation, i=1, 2, 3, ..., N is a positive integer.
4. The method for determining the part image segmentation threshold according to claim 1, characterized in that: When the current number of iterations is less than or equal to one third of the preset total number of iterations, performing an optimization iterative process on the initialized population according to a preset sine-cosine wave exploration optimization strategy to update the proxy position of each individual in the initialized population and obtain a first target population, including: Determine the volatility strategy parameters in the iterative optimization process based on the preset sine and cosine volatility functions; The proxy position of each individual in the initialization population is iteratively updated according to the fluctuation strategy parameters to obtain a first target population after the individual proxy position is updated.
5. The method for determining the part image segmentation threshold according to claim 1, characterized in that: When one third of the preset total number of iterations is less than the current number of iterations and less than two thirds of the preset total number of iterations, performing iterative optimization processing on the first target population according to a preset elimination optimization mechanism optimization strategy to update the optimal proxy position of the optimal individual in the first target population and obtain a second target population, including: According to the formula: Iteratively updating the optimal proxy position of the optimal individual in the first target population; in, represents the optimal proxy position after the update of the i-th optimal individual in the first target population corresponding to the current iterative process, represents the optimal proxy position of the i-th optimal individual in the first target population corresponding to the last round of iterative processing, B represents the iterative progress of the algorithm, represents the disturbance coefficient, Best represents the proxy position of the excellent individual in the first target population, and Worst represents the proxy position of the inferior individual in the first target population; According to the formula: Screening the population composed of the best individuals after the current updated optimal agent position, and obtaining the second target population; in, represents the optimal proxy position of the best individual selected, Indicates the fitness value corresponding to the i-th optimal individual after the current iterative processing, It represents the fitness value of the individual closest to the global optimal segmentation threshold at the j-th dimension position after the current iterative processing.
6. The method for determining the part image segmentation threshold according to claim 1, characterized in that: When two-thirds of the preset total number of iterations < the current number of iterations ≤ the preset total number of iterations, performing iterative optimization processing on the second target population according to a preset exploration and development dynamic balance optimization strategy to obtain the target segmentation threshold set, including: According to the formula: Update the optimal proxy position of the selected optimal individual, where represents the optimal agent position after the optimal individual is screened out, 、 All represent parameters of the preset exploration and development dynamic balance optimization strategy, represents the optimal proxy position of the best individual selected, Indicates the proxy position of the best individual selected in the jth dimension; According to the formula: The area value corresponding to the updated proxy position of the selected optimal individual is updated to obtain the target individual and the target area value corresponding to the target individual.
7. The method for determining the part image segmentation threshold according to claim 6, characterized in that: Also includes: Segmenting the target part image based on the target region value corresponding to the target individual to obtain a segmentation result; Evaluate the segmentation result based on a preset evaluation algorithm to obtain an evaluation result; According to the evaluation result, a target segmentation threshold corresponding to the target area value is determined.
8. A device for determining a part image segmentation threshold, characterized in that: include: An acquisition module, used for acquiring image data of a target part image; A processing module is used to determine an original population based on the image data, wherein the original population includes multiple different individuals, each individual corresponds to a segmentation operator, and each segmentation operator corresponds to an original area value; the original population is initialized according to a preset conversion algorithm to obtain an initialized population; the positions of the individuals in the initialized population are optimized iteratively according to a preset optimization algorithm to obtain a target segmentation threshold corresponding to the target area value of the target individual; the preset optimization algorithm is an improved eel-grouper optimization algorithm, and the preset optimization algorithm includes a preset sine-cosine fluctuation exploration optimization strategy, a preset elimination optimization mechanism optimization strategy, and a preset exploration and development dynamic balance optimization strategy. During the optimization iterative processing, the corresponding optimization strategy is determined according to the current number of iterations and the preset total number of iterations to perform optimization iterative processing on the initialized population; wherein the optimization iterative processing specifically includes the following steps: When the current number of iterations is less than or equal to one third of the preset total number of iterations, performing an optimization iterative process on the initialized population according to a preset sine-cosine wave exploration optimization strategy to update the proxy position of each individual in the initialized population and obtain a first target population; When one third of the preset total number of iterations is less than the current number of iterations and less than two thirds of the preset total number of iterations, performing iterative optimization processing on the first target population according to a preset elimination optimization mechanism optimization strategy to update the optimal proxy position of the optimal individual in the first target population and obtain a second target population, wherein the optimal individual is an individual in the first target population whose distance to the optimal region value is within a preset range; When two-thirds of the preset total number of iterations < the current number of iterations ≤ the preset total number of iterations, the second target population is optimized iteratively according to the preset exploration and development dynamic balance optimization strategy until the number of iterations reaches the preset total number of iterations to obtain target individuals, each target individual corresponding to a target segmentation operator, and each target segmentation operator corresponding to a target area value.
9. A computing device, characterized in that include: a memory for storing one or more programs; One or more processors, configured to execute the one or more programs to implement the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Image segmentation method and device and electronic equipment
CN117952989A
Medical image segmentation threshold determination method and device, medium and equipment
CN119068011A