Image edge detection method based on improved ant colony algorithm
The improved ant colony algorithm addresses noise sensitivity and path selection issues in traditional edge detection by using non-uniform initial information distribution and adaptive updates, resulting in enhanced edge detection accuracy and efficiency.
Patent Information
- Application Number
- CN202411791156.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-06
- Publication Date
- 2025-03-14
AI Technical Summary
Traditional image edge detection algorithms, including those using the ant colony algorithm, are sensitive to noise and often suffer from path selection difficulties and the issue of retracing paths, leading to reduced accuracy and efficiency due to the influence of residual information from suboptimal solutions in the information update process.
An improved ant colony algorithm for image edge detection that involves non-uniform initial information distribution based on the target direction, adaptive adjustment of the heuristic function, and dynamic information update rules to guide ants towards edges more effectively, ensuring better convergence and noise resistance.
The improved algorithm enhances edge detection accuracy and efficiency by reducing search inefficiencies and preventing the algorithm from getting stuck in local optima, while maintaining clear and complete edge information and improved noise resistance.
Smart Images

Figure CN119625009A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of image detection, and in particular to an image edge detection method of an improved ant colony algorithm. Background Art
[0002] In image processing and machine vision, image edge detection plays a very important role. Image edges are key visual information. Edge detection can extract the contours of target objects and feature information of different regions. Through feature extraction, image simplification and structural analysis of edge detection processing, it provides a basis for subsequent target recognition, tracking and image segmentation. Classic image edge detection can be roughly divided into two categories: algorithms based on first-order derivatives and algorithms based on second-order derivatives. These traditional classic image edge detections are sensitive to noise, and processing may result in serious distortion of complex images.
[0003] In recent years, with the continuous development of artificial intelligence models, video intelligent monitoring and practical applications of mathematics, various new edge detection algorithms or improved methods have been applied to image edge detection. The ant colony algorithm was first proposed by Italian scholars. MacroDorigo It was proposed by et al. and is a population-based simulated evolutionary algorithm inspired by the foraging behavior of ant colonies in nature. It was originally a probabilistic algorithm used to find the optimal path in a graph. CN 116152282 A The ant colony algorithm is used to detect image edges. Specifically, the independent variable of the heuristic function in the traditional ant colony algorithm is added with corresponding weights for information fusion based on the change of image pixel intensity of local pixels. The grayscale value of the local pixel with the added weight is used as the independent variable of the new heuristic function. The local statistics are obtained according to the new heuristic function, and the heuristic information is obtained according to the local statistics to achieve the purpose of better guiding ants to move to the edge, thereby improving the detection rate.
[0004] However, the above scheme adopts the pheromone equal distribution method, which makes it easy to have difficulty in selecting some paths and the phenomenon of going back and forth. In addition, during the iterative update of pheromones, the traditional ant colony algorithm is often affected by the residual pheromones of the previously searched suboptimal solution on the path, which will cause the directionality of the optimal solution to be reduced, thereby affecting the edge detection accuracy and efficiency of the algorithm.
[0005] In order to solve the above problems, people have been seeking an ideal technical solution. Summary of the invention
[0006] Based on this, it is necessary to provide an image edge detection method based on an improved ant colony algorithm to address the above technical problems. The method has good performance in image edge detection processing, can not only clearly and completely retain the image edge information, but also has good noise resistance.
[0007] In order to achieve the above object, the first aspect of the present invention provides an image edge detection method using an improved ant colony algorithm, comprising the following steps: Get the pixel size L * W The image to be detected by edge is randomly placed on the image to be detected by edge m Ants, among them, m ≤ L * W ; In the initial path search process, different initial pheromones are assigned to different paths by utilizing the inductiveness of the destination target direction, thus obtaining the initial pheromone matrix. The adaptive coefficient is introduced into the heuristic function to adjust the weight of the heuristic function in the state transition probability; The ant colony path is constructed based on the initial pheromone matrix and heuristic function, and the ants perform a local pheromone update every step; After all ants have completed an iterative cycle, the optimal path is found and the global pheromone is updated; Until the ant colony completes all iterations and obtains the final pheromone matrix; According to the final pheromone matrix, it is determined whether each pixel position is an edge pixel.
[0008] Furthermore, the formula for the initial pheromone is:
[0009] Where: τ ij (0) is the current ant k Slave Node i To Node j The initial local pheromone, d sg As a starting point s To the end g The Euclidean distance of L si For the current ant k From the starting point s To point i Length traveled; d ig For Node i To Node j The Euclidean distance of d jg For Node j To the destinationg The Euclidean distance of allow k Indicates the current ant k A collection of next target points that can be selected.
[0010] Among them, the update of pheromone is performed: Ants perform a local pheromone update every time they take a step; Wherein, when the iteration number value is lower than the set continuous iteration number value, the pheromone volatility rate of the local pheromone is set to a first value; When the optimal solution does not appear in the set number of consecutive iterations, the pheromone volatility of the local pheromone is set to a second value; wherein the second value is greater than the first value; After all ants have completed an iterative cycle, the optimal path is found and the global pheromone is updated.
[0011] Furthermore, when the global pheromone is updated, the pheromone of the path with the maximum concentration found by the ant colony algorithm is updated, and the pheromone of other paths remains unchanged.
[0012] In order to achieve the above object, the second aspect of the present invention provides an image edge detection device using an improved ant colony algorithm, comprising: Initialization module, used to obtain the pixel size L * W The image to be detected by edge is randomly placed on the image to be detected by edge m Ants, among them, m ≤ L * W ; The initial pheromone matrix acquisition module is used to allocate different initial pheromones to different paths by utilizing the inductiveness of the end target direction during the initial path search process to obtain the initial pheromone matrix; A heuristic function improvement module is used to introduce an adaptive coefficient into the heuristic function to adjust the proportion of the heuristic function in the state transition probability; Ant colony path construction module, used to construct ant colony paths based on the initial pheromone matrix and heuristic function; The local pheromone update module is used to update the local pheromone every time the ant takes a step; The global pheromone update module is used to find the optimal path after completing an iterative cycle, update the global pheromone, and perform a second update on the updated pheromone matrix according to the paths passed by all ants until the final pheromone matrix is obtained after the ant colony completes all iterations; The edge pixel point judgment module is used to judge whether each pixel position is an edge pixel point according to the final pheromone matrix.
[0013] In order to achieve the above-mentioned purpose, the third aspect of the present invention provides a computer device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; the memory is used to store computer programs; the processor is used to implement the steps of the method proposed in the first aspect when executing the program stored in the memory.
[0014] In order to achieve the above-mentioned purpose, the fourth aspect of the present invention provides a computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, enables the processors to perform the steps of the method proposed in the first aspect.
[0015] In order to achieve the above-mentioned objective, the fifth aspect of the present invention provides a computer program product, comprising a computer program, which implements the steps of the method proposed in the first aspect when executed by a processor.
[0016] The beneficial effects of the present invention are: The present invention improves the initial pheromone distribution method, utilizes the inductiveness of the end target direction, and adopts an uneven distribution method to reduce the inefficiency and blindness of the ant colony search that occurs during the initial path search process, thereby increasing the convergence speed of the algorithm. Improve the heuristic function with heuristic and adaptive features. In the early stage, the concentration difference of pheromone between nodes is small, which can enhance local visibility and guide ants to quickly reach the nearest target node. In the later stage of image detection search, the convergence speed of the algorithm is improved by reducing the proportion of heuristic function in the state transition probability. Furthermore, the volatility of local pheromones is dynamically adjusted to prevent the algorithm from falling into the local optimum due to the improvement of local pheromones; After the ant colony completes a round of optimization, the pheromone of the path with the highest concentration found by the ant colony algorithm is updated, and the pheromone of other paths remains unchanged. Through experimental analysis and verification, the improved pheromone update rule can improve the search efficiency of the algorithm and accelerate the convergence speed of the algorithm. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 It is a flow chart of the image edge detection method of the improved ant colony algorithm of the present invention; Figure 2 It is a structural schematic diagram of an image edge detection system of an improved ant colony algorithm of the present invention; Figure 3 It is a structural diagram of an implementation of the computer device of the present invention. DETAILED DESCRIPTION
[0018] The ant colony algorithm was originally used in path planning. It can also be applied to image edge detection by judging the pheromone threshold. However, it has some shortcomings. The parameters such as pheromone concentration influencing factor, heuristic function, pheromone volatility, state transition parameter and number of ants will have a great impact on the detection. The main problems include: (1) In the traditional ant colony algorithm, unreasonable initial parameter settings will result in a positive feedback mechanism that cannot be formed in a short period of time, resulting in slow convergence or even no convergence. It will also cause the ant colony search to fall into a local optimum.
[0019] (2) In the traditional ant colony algorithm, ants detect edges by measuring the concentration of pheromones on the path. The pheromone equalization method is prone to causing difficulty in selecting some paths and the occurrence of loops.
[0020] (3) During the iterative update of pheromones, the traditional ant colony algorithm is often affected by the residual pheromones on the path of the previously searched suboptimal solution, which will reduce the directionality of the optimal solution and further affect the edge detection accuracy and efficiency of the algorithm.
[0021] In view of the above problems existing in the traditional ant colony algorithm, the present invention makes comprehensive improvements to the algorithm in three aspects: uneven initial pheromone distribution, improved heuristic function and improved pheromone update rules. This makes the algorithm have good performance in edge detection processing of images, which can not only clearly and completely retain the edge information of the image, but also has good noise resistance.
[0022] The technical solution of the present invention is further described in detail below through specific implementation methods.
[0023] Example 1 This embodiment provides an image edge detection method using an improved ant colony algorithm. Figure 1 As shown, the following steps are included: (1) Initialization process Get the pixel size L * W The image to be detected by edge is randomly placed on the image to be detected by edge m Ants, among them, m ≤ L * W ; The edge points in the image are the "food" that the ants are looking for.
[0024] Ant colonies rely on the pheromones they release to transmit information to each other. In traditional ant colony algorithms, the initial pheromones are evenly distributed, which can cause the ants to go back and forth during the initial path search. In order to reduce the inefficiency and blindness of the ant colony search during the initial path search, it is necessary to improve the initial pheromone distribution method.
[0025] Therefore, in the initial path search process, this embodiment uses the inductiveness of the destination target direction to allocate different initial pheromones to different paths to obtain an initial pheromone matrix.
[0026] In one embodiment, the formula of the initial pheromone is:
[0027] Where: τ ij (0) is the current ant k Slave Node i To Node j The initial local pheromone, d sg As a starting point s To the end g The Euclidean distance of L si For the current ant k From the starting point s To point i Length traveled; d ij For Node i To Node j The Euclidean distance of d jg For Node j To the destination g The Euclidean distance of allow k Indicates the current ant k A collection of next target points that can be selected.
[0028] By utilizing the inductive nature of the end-point target direction and assigning different initial pheromones to different paths, the efficiency of the ant colony in exploring the optimal path can be accelerated and the convergence speed of the algorithm can be improved.
[0029] The heuristic function of the traditional ant colony algorithm is ,in, d ij express i and j The Euclidean distance between points, allow k Indicates the current ant kThe set of next target points that can be selected. It can be seen that the heuristic function value is inversely proportional to the distance between the next optional node and the target node. Therefore, the ant will choose to move to a node closer to the target node. However, in actual image edge detection, the distance difference between adjacent nodes and the target node is very close, resulting in the heuristic function values of adjacent nodes being basically the same, and falling into a local optimum. In addition, the grayscale gradient value on the edge pixel point of the image and the grayscale gradient value of the noise point are very large. The traditional heuristic function lacks adaptability and has a low noise suppression effect, which will affect the image edge detection accuracy. Therefore, this embodiment improves the heuristic function in terms of heuristics and adaptability. In the early stage, the concentration difference of pheromones between nodes is small, which can enhance local visibility and guide ants to quickly reach the nearest target node. In the later stage of image detection search, the convergence speed of the algorithm is improved by reducing the proportion of the heuristic function in the state transition probability.
[0030] Specifically, an adaptive coefficient is introduced into the heuristic function to adjust the proportion of the heuristic function in the state transition probability.
[0031] The improved heuristic function is:
[0032] Where: d ij For Node i To Node j The distance ; d jg For Node j To the end g The distance ; d ig For Node i To the end g The distance ; λ is a constant greater than zero; ε is the adaptive coefficient, and its expression is: , N is the current iteration number, N max is the maximum number of iterations.
[0033] By improving the heuristic function and introducing the adaptive coefficient ε, a larger ε value is used in the early stage of image edge detection of the ant colony algorithm to increase the proportion of the heuristic function in the state transition probability, avoid falling into the local optimal solution, and improve the local search ability of the algorithm; in the continuous iterative processing of the algorithm, the ε value is reduced, the influence of the heuristic function in the state transition probability is reduced, and the convergence speed of the ant colony algorithm is improved.
[0034] (2) Select a path Construct ant colony paths based on the initial pheromone matrix and heuristic function; Specifically, in t Moment, Ant k From a node i Move to another node j The state transition probability It can be calculated as shown below:
[0035] in: α、β is a constant, α is the input pheromone heuristic factor, which generally ranges from [1-4]; β is the expected heuristic factor, which generally ranges from [0-5]; τ ij (t) express t Moment ants from point i To point j pheromone concentration; allow k is the set of points that the ant is allowed to choose in the next step; η ij (t) is the heuristic function.
[0036] (3) Pheromone update The updating of pheromones consists of two steps: local pheromones and global pheromones.
[0037] Specifically, the pheromone update is performed: Ants perform a local pheromone update every time they take a step; After all ants have completed an iterative cycle, the optimal path is found and the global pheromone is updated; Wherein, when the local pheromone is updated, if the number of iterations is lower than the set number of continuous iterations, the local pheromone volatility is set to the first value; If no optimal solution is found within the set number of consecutive iterations, the pheromone volatility is set to a second value; wherein the second value is greater than the first value; Specifically, the update formula of pheromone volatilization rate is:
[0038] Among them, the first value is a constant ρ 0 , the second value is γρ 0 , γ is ρ 0 The adjustment coefficient is in the range of (1,10];N is the number of iterations; N ρ It is the number of iterations that are set without an optimal solution.
[0039] Specifically, in this embodiment, after the optimal path is found after completing one iteration cycle, the pheromone is updated only for the path with the maximum concentration found by the ant colony algorithm, and the pheromone for other paths remains unchanged.
[0040] Through the update of pheromones, the path walked by the ants will leave pheromones when the ants pass through. Through the two-step pheromone update, the calculation results can be better converged to the real edge position of the image, thereby determining the edge points of the image.
[0041] Specifically, the traditional local pheromone update formula is:
[0042] in: ρ is the pheromone volatilization rate; For the increase of pheromone; I ij For point ( i , j )’s grayscale gradient value.
[0043] Pheromone Volatilization Rate ρ In order to avoid the endless accumulation of pheromones, the pheromone volatilization rate is used ρ To control the volatilization rate of pheromones. ρ It can improve the search efficiency of the ant colony algorithm and avoid falling into local optimality.
[0044] Furthermore, in order to prevent the algorithm from falling into the local optimum due to the improvement of pheromone, the recovery rate of pheromone is dynamically adjusted, and the local pheromone update formula is:
[0045] Among them, τ ij ( t ) for ants k Slave Node i Move to another node j The local pheromone, ρ( n ) is the pheromone volatilization rate, and its value is between (0,1); For the increase of pheromone; I ij For point ( i , j )’s grayscale gradient value.
[0046] When the ant colony algorithm first starts to optimize, by setting a small ρvalue to increase the influence of pheromone on the path selection of the ant colony algorithm. When the optimal solution does not appear, increase the pheromone recovery rate ρ value to avoid the algorithm falling into the local optimal solution and then obtain the global optimal solution.
[0047] (4) Determine edge points Finally, the final pheromone matrix is used to determine whether each pixel position is an edge pixel.
[0048] Specifically, after completing the rectification iteration cycle, the pheromone intensity comparison is performed by setting a threshold value, and the threshold value is set to T ,when When , the output is 1, it is determined to be an edge point, otherwise it is a non-edge point. The calculation formula is: Among them, 0 represents a non-edge point and 1 represents an edge point.
[0049] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0050] Example 2 Based on the same inventive concept, the embodiment of the present application also provides an image edge detection device for implementing the image edge detection method involved above. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above method, so the specific limitations in one or more image edge detection device embodiments provided below can refer to the limitations of the image edge detection method above, and will not be repeated here.
[0051] like Figure 2 As shown, the image edge detection device of the improved ant colony algorithm is characterized by comprising: Initialization module, used to obtain the pixel size L * W The image to be detected by edge is randomly placed on the image to be detected by edge m Ants, among them, m ≤ L* W ; The initial pheromone matrix acquisition module is used to allocate different initial pheromones to different paths by utilizing the inductiveness of the end target direction during the initial path search process to obtain the initial pheromone matrix; A heuristic function improvement module is used to introduce an adaptive coefficient into the heuristic function to adjust the proportion of the heuristic function in the state transition probability; Ant colony path construction module, used to construct ant colony paths based on the initial pheromone matrix and heuristic function; The local pheromone update module is used to update the local pheromone every time the ant takes a step; The global pheromone update module is used to find the optimal path after completing an iterative cycle, update the global pheromone, and perform a second update on the updated pheromone matrix according to the paths passed by all ants until the final pheromone matrix is obtained after the ant colony completes all iterations; The edge pixel point judgment module is used to judge whether each pixel position is an edge pixel point according to the final pheromone matrix.
[0052] Example 3 A computer device, which may be a terminal, may have an internal structure as shown in Figure 3 As shown, the terminal can communicate with the laser stripping equipment to control the normal operation of the laser stripping equipment. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner. The wireless method can be achieved through WIFI , mobile cellular networks, NFC(near field communication) or other technologies. When the computer program is executed by the processor, the image edge detection method described in Example 1 is implemented. The display unit of the computer device is used to form a visually visible picture, and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a button, trackball or touchpad provided on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0053] Those skilled in the art will understand that Figure 3 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0054] Example 4 On the basis of the above embodiments, this embodiment provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the method described in Embodiment 1 are implemented.
[0055] Example 5 On the basis of the above embodiments, this embodiment provides a computer program product, including a computer program. When the computer program is executed by a processor, the steps of the method described in Embodiment 1 are implemented.
[0056] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to a memory, a database or other medium used in the embodiments provided in this application can include at least one of a non-volatile and a volatile memory. A non-volatile memory can include a read-only memory ( Read - OnlyMemory , ROM ), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive random access memory ( ReRAM )、Magnetic variable memory( Magnetoresistive Random Access Memory , MRAM )、Ferroelectric Memory( Ferroelectric Random Access Memory , FRAM )、phase change memory( Phase Change Memory , PCM ), graphene memory, etc. Volatile memory may include random access memory ( Random Access Memory, RAM ) or external cache memory, etc. By way of illustration and not limitation, RAM Can be in many forms, such as static random access memory ( Static Random Access Memory , SRAM ) or dynamic random access memory ( Dynamic Random Access Memory , DRAM ) and the like. The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. The non-relational database may include a distributed database based on blockchain, etc., but is not limited thereto. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, etc., but is not limited thereto.
[0057] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0058] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
[0059] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, ordinary technicians in the field should understand that the specific implementation methods of the present invention can still be modified or some technical features can be replaced by equivalents without departing from the spirit of the technical solution of the present invention, which should be included in the scope of the technical solution for protection of the present invention.
Claims
1. An image edge detection method based on an improved ant colony algorithm, characterized in that: Get the pixel size L * W The image to be detected by edge is randomly placed on the image to be detected by edge m Ants, among them, m ≤ L * W ; In the initial path search process, different initial pheromones are assigned to different paths by utilizing the inductiveness of the destination target direction, thus obtaining the initial pheromone matrix. The adaptive coefficient is introduced into the heuristic function to adjust the weight of the heuristic function in the state transition probability; Construct the ant colony path based on the initial pheromone matrix and heuristic function, and update the pheromone; Until the ant colony completes all iterations and obtains the final pheromone matrix; According to the final pheromone matrix, it is determined whether each pixel position is an edge pixel.
2. The image edge detection method based on the improved ant colony algorithm according to claim 1, characterized in that: The formula for the initial pheromone is: Where: τ ij (0) is the current ant k Slave Node i To Node j The initial local pheromone, d sg Starting point s To the end g The Euclidean distance of L si For the current ant k From the starting point s To point i Length traveled; d ig For Node i To Node j The Euclidean distance of d jg For Node j To the destination g The Euclidean distance of allow k Indicates the current ant k A collection of next target points that can be selected.
3. The image edge detection method according to claim 1 or 2, characterized in that: Update execution of pheromone: Ants perform a local pheromone update every time they take a step; Wherein, when the iteration number value is lower than the set continuous iteration number value, the pheromone volatility rate of the local pheromone is set to a first value; When the optimal solution does not appear in the set number of consecutive iterations, the pheromone volatility of the local pheromone is set to a second value; wherein the second value is greater than the first value; After all ants have completed an iterative cycle, the optimal path is found and the global pheromone is updated.
4. The image edge detection method based on the improved ant colony algorithm according to claim 3 is characterized by: The update formula of pheromone volatilization rate is: Among them, the first value is a constant ρ 0 , the second value is γρ 0 , γ is ρ 0 The adjustment coefficient is in the range of (1,10]; N is the number of iterations; N ρ It is the number of iterations that are set without an optimal solution.
5. The image edge detection method according to claim 1, 2 or 4, characterized in that: The improved heuristic function is: Where: t is the current time, d ij For Node i To Node j distance; d jg For Node j To the end g distance; d ig For Node i To the end g distance; λ is a constant greater than zero; ε is the adaptive coefficient, and its expression is: , N is the current iteration number, N max is the maximum number of iterations.
6. The image edge detection method according to claim 1, 2 or 4, characterized in that: The local pheromone update formula is: Among them, τ ij ( t ) for ants k Slave Node i Move to another node j Local pheromones ,ρ(n) is the pheromone volatilization rate, with a value between (0,1); is the pheromone increment; I ij For point ( i , j )’s grayscale gradient value; The global pheromone update formula is: in, τ 0 represents the initial value of the pheromone, μ represents the global pheromone decay rate, and its value is between (0,1).
7. An image edge detection device based on an improved ant colony algorithm, characterized in that: include: Initialization module, used to obtain the pixel size L * W The image to be detected by edge is randomly placed on the image to be detected by edge m Ants, among them, m ≤ L * W ; The initial pheromone matrix acquisition module is used to allocate different initial pheromones to different paths by utilizing the inductiveness of the end target direction during the initial path search process to obtain the initial pheromone matrix; A heuristic function improvement module is used to introduce an adaptive coefficient into the heuristic function to adjust the proportion of the heuristic function in the state transition probability; Ant colony path construction module, used to construct ant colony paths based on the initial pheromone matrix and heuristic function; The local pheromone update module is used to update the local pheromone every time the ant takes a step; The global pheromone update module is used to find the optimal path after completing an iterative cycle, update the global pheromone, and perform a second update on the updated pheromone matrix according to the paths passed by all ants until the final pheromone matrix is obtained after the ant colony completes all iterations; The edge pixel point judgment module is used to judge whether each pixel position is an edge pixel point according to the final pheromone matrix.
8. A computer device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory, used to store computer programs; A processor, configured to implement the steps of the method according to any one of claims 1 to 6 when executing a program stored in a memory.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Image edge detection method based on improved ant colony algorithm
CN116152282A