CN113870297B - Image edge detection method and device and storage medium - Google Patents
Image edge detection method and device and storage medium Download PDFInfo
- Publication number
- CN113870297B CN113870297B CN202111457160.5A CN202111457160A CN113870297B CN 113870297 B CN113870297 B CN 113870297B CN 202111457160 A CN202111457160 A CN 202111457160A CN 113870297 B CN113870297 B CN 113870297B
- Authority
- CN
- China
- Prior art keywords
- edge
- gray
- derivative
- sample
- image
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/13—Edge detection
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/004—Artificial life, i.e. computing arrangements simulating life
- G06N3/006—Artificial life, i.e. computing arrangements simulating life based on simulated virtual individual or collective life forms, e.g. social simulations or particle swarm optimisation [PSO]
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/20—Special algorithmic details
- G06T2207/20081—Training; Learning
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/20—Special algorithmic details
- G06T2207/20172—Image enhancement details
- G06T2207/20192—Edge enhancement; Edge preservation
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- General Health & Medical Sciences (AREA)
- Molecular Biology (AREA)
- Biophysics (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Evolutionary Computation (AREA)
- Artificial Intelligence (AREA)
- Biomedical Technology (AREA)
- Computing Systems (AREA)
- General Engineering & Computer Science (AREA)
- Life Sciences & Earth Sciences (AREA)
- Mathematical Physics (AREA)
- Software Systems (AREA)
- Health & Medical Sciences (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Image Analysis (AREA)
Abstract
The invention discloses an image edge detection method, a device and a storage medium, comprising the following steps: converting an image to be detected into a gray image; carrying out weighted average processing on the gray derivative of each candidate edge direction to determine the gray derivative of each pixel in the gray image in the candidate edge direction; taking the maximum gray derivative of the candidate edge direction as the gray derivative of the target pixel, and establishing an edge point judgment matrix, an edge intensity matrix and an average edge intensity matrix according to a gray derivative threshold; initializing population scale and problem dimension, and randomly generating a population sample; constructing a fitness function and determining the cycle number; determining boundary points by adopting a teacher student learning method according to the population samples, the fitness function and the cycle times; and randomly selecting a candidate sample from the neighborhood range of the boundary point to replace the boundary point, and outputting an edge detection result. The invention has high precision and high convergence speed, and can be widely applied to the technical field of image processing.
Description
Technical Field
The present invention relates to the field of image processing technologies, and in particular, to a method and an apparatus for detecting an image edge, and a storage medium.
Background
The edge is a basic feature of an image, mainly exists between an object and a background, and between areas, carries the most important outline information of an image, is the basis of further image processing such as image segmentation, feature extraction, image recognition and the like, is directly related to the quality of subsequent image processing, is a very important research topic, and is widely applied to engineering.
Because projection, mixing, distortion and noise are often generated in the imaging process, images can present certain blurring and deformation, and edge detection becomes difficult, people are always dedicated to constructing edge detection operators with good properties. The edge appears at the boundary of the region with the sharp change of the gray level in the image, and differential operation is the main means of traditional edge detection and extraction, such as Robert operator, Sobel operator, Prewitt and the like based on the image gray level distribution gradient. These operators are simple to compute and easy to implement, but due to the complexity of the edges themselves, these operators are not ideal enough in terms of noise immunity. With the extensive research and application of new theoretical tools in image edge detection, people also propose an edge detection technology based on morphology, a detection technology based on a neural network, a detection technology based on a fuzzy theory, a detection technology based on a genetic algorithm, an edge detection technology based on fractal characteristics and the like.
The swarm intelligence optimization does not depend on function derivatives, the swarm presents evolution diversity and behavior directivity by simulating the behavior of the swarm and individuals such as insects, birds, fishes and the like, the swarm intelligence optimization is a swarm-based random search algorithm, can be used for approximately solving some optimization problems which are difficult to directly solve, and is widely applied to the optimization design of products or systems in recent years. The teaching and learning-based group intelligent optimization algorithm is inspired from the teaching process of teachers and students, the optimization process is divided into two stages of learning from teachers and mutual learning among students, no algorithm specific parameter is needed, the algorithm precision is high, and the convergence speed is high.
Therefore, the teaching and learning group intelligent optimization algorithm is applied to image edge detection, reasonable optimization targets for determining edge pixel points are defined, a set of new edge detection method with good anti-noise performance is constructed, and the method is of great significance in well adapting to complex edges.
Disclosure of Invention
In view of the above, embodiments of the present invention provide an image edge detection method, an image edge detection apparatus, and a storage medium with high accuracy and high convergence rate.
One aspect of the present invention provides an image edge detection method, including:
converting an image to be detected into a gray image;
carrying out weighted average processing on the gray derivative of each candidate edge direction to determine the gray derivative of each pixel in the gray image in the candidate edge direction;
taking the maximum gray derivative of the candidate edge direction as the gray derivative of the target pixel, and establishing an edge point judgment matrix, an edge intensity matrix and an average edge intensity matrix according to a gray derivative threshold;
initializing population scale and problem dimension, and randomly generating a population sample;
constructing a fitness function according to the edge strength and the threshold value of the critical edge strength, and determining the cycle number;
determining boundary points by adopting a teacher student learning method according to the population samples, the fitness function and the cycle times;
and randomly selecting a candidate sample from the neighborhood range of the boundary point to replace the boundary point, and outputting an edge detection result.
Optionally, the performing a weighted average process on the gray derivative of each candidate edge direction to determine the gray derivative of each pixel in the gray image in the candidate edge direction includes:
defining eight candidate edge directions;
taking three pixels of any position in the gray-scale image along any candidate edge direction, and calculating gray-scale derivatives of the three pixels in four vertical directions;
and after sequencing the gray derivative, calculating corresponding weight and a weighted average value of the gray derivative.
Optionally, the step of taking the maximum gray derivative of the candidate edge directions as the gray derivative of the target pixel, and establishing an edge point determination matrix, an edge intensity matrix, and an average edge intensity matrix according to a gray derivative threshold includes:
taking the maximum value in the corresponding gray derivative in different vertical directions as the gray derivative of each pixel;
selecting a gray derivative threshold value;
filtering non-edge noise pixel points in the gray level image according to the gray level derivative threshold value;
establishing an edge point judgment matrix;
according to the edge point judgment matrix, after the neighborhood width of a pixel point is selected, the sum of non-zero elements in the neighborhood width range around the elements is calculated, and an edge intensity matrix is determined;
and calculating an average edge intensity matrix according to the edge intensity matrix.
Optionally, the method further comprises:
calculating a fitness value vector of a population matrix sample containing a plurality of elements according to the fitness function;
and taking the sample with the largest fitness value vector as a teacher, and calculating the average value vector and the average fitness value of the population.
Optionally, the determining the boundary point by using a teacher-student learning method according to the population sample, the fitness function, and the cycle number includes:
in a stage of learning from a teacher, determining a new candidate sample according to any first sample in the population;
in a student mutual learning stage, randomly selecting a second sample different from a first sample in a population according to any first sample in the population, calculating a fitness value between the first sample and the second sample, and determining a new candidate sample according to the fitness value;
determining the boundary point from the new candidate sample.
Optionally, the determining the boundary point by using a teacher-student learning method according to the population sample, the fitness function, and the cycle number further includes:
taking the sample with the largest fitness value as a new teacher, and calculating the average value vector and the average fitness value of the population according to the new teacher;
judging whether the edge intensity value of any sample in the population is greater than N times of the critical edge intensity, and if so, marking the pixel at the corresponding position of the current sample as a boundary point, wherein the average edge intensity is greater than an edge intensity threshold value;
and selecting a new candidate sample to replace the sample in the population corresponding to the boundary point.
An embodiment of the present invention further provides an image edge detection apparatus, including:
the first module is used for converting an image to be detected into a gray image;
the second module is used for carrying out weighted average processing on the gray derivative of each candidate edge direction and determining the gray derivative of each pixel in the gray image in the candidate edge direction;
a third module, configured to use the maximum grayscale derivative of the candidate edge direction as a grayscale derivative of the target pixel, and establish an edge point determination matrix, an edge intensity matrix, and an average edge intensity matrix according to a grayscale derivative threshold;
the fourth module is used for initializing population scale and problem dimension and randomly generating population samples;
a fifth module, configured to construct a fitness function according to the edge strength and the threshold of the critical edge strength, and determine a cycle number;
a sixth module, configured to determine a boundary point by using a teacher-student learning method according to the population sample, the fitness function, and the cycle number;
and the seventh module is used for randomly selecting a candidate sample from the neighborhood range of the boundary point to replace the boundary point and then outputting an edge detection result.
The embodiment of the invention also provides the electronic equipment, which comprises a processor and a memory;
the memory is used for storing programs;
the processor executes the program to implement the method as described above.
An embodiment of the present invention further provides a computer-readable storage medium, where the storage medium stores a program, and the program is executed by a processor to implement the method described above.
Embodiments of the present invention also provide a computer program product, which includes a computer program, and when the computer program is executed by a processor, the computer program implements the method as described above.
The embodiment of the invention converts the image to be detected into a gray image; carrying out weighted average processing on the gray derivative of each candidate edge direction to determine the gray derivative of each pixel in the gray image in the candidate edge direction; taking the maximum gray derivative of the candidate edge direction as the gray derivative of the target pixel, and establishing an edge point judgment matrix, an edge intensity matrix and an average edge intensity matrix according to a gray derivative threshold; initializing population scale and problem dimension, and randomly generating a population sample; constructing a fitness function according to the edge strength and the threshold value of the critical edge strength, and determining the cycle number; determining boundary points by adopting a teacher student learning method according to the population samples, the fitness function and the cycle times; and randomly selecting a candidate sample from the neighborhood range of the boundary point to replace the boundary point, and outputting an edge detection result. The invention has high precision and high convergence speed.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a flowchart illustrating the overall steps provided by an embodiment of the present invention;
FIG. 2 is a neighborhood template used in calculating a derivative of gray scale according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of an original image and a detection result processed by different methods according to an embodiment of the present invention;
fig. 4 is a schematic diagram of a result obtained by using a conventional classical edge detection method according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
In order to overcome the defects in the prior art, the embodiment of the invention provides an image edge detection method based on a teaching and learning group intelligent optimization algorithm, and the method has better adaptability and can provide a good edge detection result. Based on the grayscale derivatives of 8 directions, an image edge intensity matrix is established. In the imitation teaching process, students learn from teachers and learn among students, pixel points with larger edge strength defined on the basis of gray derivative are searched and positioned, and the pixel points are marked as edge pixel points. The method does not depend on the filter noise reduction technology used by some traditional image detection methods, provides a new idea of image edge detection, and is an extension of the existing image edge detection method.
Specifically, an embodiment of the present invention provides an image edge detection method, including:
converting an image to be detected into a gray image;
carrying out weighted average processing on the gray derivative of each candidate edge direction to determine the gray derivative of each pixel in the gray image in the candidate edge direction;
taking the maximum gray derivative of the candidate edge direction as the gray derivative of the target pixel, and establishing an edge point judgment matrix, an edge intensity matrix and an average edge intensity matrix according to a gray derivative threshold;
initializing population scale and problem dimension, and randomly generating a population sample;
constructing a fitness function according to the edge strength and the threshold value of the critical edge strength, and determining the cycle number;
determining boundary points by adopting a teacher student learning method according to the population samples, the fitness function and the cycle times;
and randomly selecting a candidate sample from the neighborhood range of the boundary point to replace the boundary point, and outputting an edge detection result.
Optionally, the performing a weighted average process on the gray derivative of each candidate edge direction to determine the gray derivative of each pixel in the gray image in the candidate edge direction includes:
defining eight candidate edge directions;
taking three pixels of any position in the gray-scale image along any candidate edge direction, and calculating gray-scale derivatives of the three pixels in four vertical directions;
and after sequencing the gray derivative, calculating corresponding weight and a weighted average value of the gray derivative.
Optionally, the step of taking the maximum gray derivative of the candidate edge directions as the gray derivative of the target pixel, and establishing an edge point determination matrix, an edge intensity matrix, and an average edge intensity matrix according to a gray derivative threshold includes:
taking the maximum value in the corresponding gray derivative in different vertical directions as the gray derivative of each pixel;
selecting a gray derivative threshold value;
filtering non-edge noise pixel points in the gray level image according to the gray level derivative threshold value;
establishing an edge point judgment matrix;
according to the edge point judgment matrix, after the neighborhood width of a pixel point is selected, the sum of non-zero elements in the neighborhood width range around the elements is calculated, and an edge intensity matrix is determined;
and calculating an average edge intensity matrix according to the edge intensity matrix.
Optionally, the method further comprises:
calculating a fitness value vector of a population matrix sample containing a plurality of elements according to the fitness function;
and taking the sample with the largest fitness value vector as a teacher, and calculating the average value vector and the average fitness value of the population.
Optionally, the determining the boundary point by using a teacher-student learning method according to the population sample, the fitness function, and the cycle number includes:
in a stage of learning from a teacher, determining a new candidate sample according to any first sample in the population;
in a student mutual learning stage, randomly selecting a second sample different from a first sample in a population according to any first sample in the population, calculating a fitness value between the first sample and the second sample, and determining a new candidate sample according to the fitness value;
determining the boundary point from the new candidate sample.
Optionally, the determining the boundary point by using a teacher-student learning method according to the population sample, the fitness function, and the cycle number further includes:
taking the sample with the largest fitness value as a new teacher, and calculating the average value vector and the average fitness value of the population according to the new teacher;
judging whether the edge intensity value of any sample in the population is greater than N times of the critical edge intensity, and if so, marking the pixel at the corresponding position of the current sample as a boundary point, wherein the average edge intensity is greater than an edge intensity threshold value;
and selecting a new candidate sample to replace the sample in the population corresponding to the boundary point.
An embodiment of the present invention further provides an image edge detection apparatus, including:
the first module is used for converting an image to be detected into a gray image;
the second module is used for carrying out weighted average processing on the gray derivative of each candidate edge direction and determining the gray derivative of each pixel in the gray image in the candidate edge direction;
a third module, configured to use the maximum grayscale derivative of the candidate edge direction as a grayscale derivative of the target pixel, and establish an edge point determination matrix, an edge intensity matrix, and an average edge intensity matrix according to a grayscale derivative threshold;
the fourth module is used for initializing population scale and problem dimension and randomly generating population samples;
a fifth module, configured to construct a fitness function according to the edge strength and the threshold of the critical edge strength, and determine a cycle number;
a sixth module, configured to determine a boundary point by using a teacher-student learning method according to the population sample, the fitness function, and the cycle number;
and the seventh module is used for randomly selecting a candidate sample from the neighborhood range of the boundary point to replace the boundary point and then outputting an edge detection result.
The embodiment of the invention also provides the electronic equipment, which comprises a processor and a memory;
the memory is used for storing programs;
the processor executes the program to implement the method as described above.
An embodiment of the present invention further provides a computer-readable storage medium, where the storage medium stores a program, and the program is executed by a processor to implement the method described above.
Embodiments of the present invention also provide a computer program product, which includes a computer program, and when the computer program is executed by a processor, the computer program implements the method as described above.
The following detailed description of the specific implementation principles of the present invention is made with reference to the accompanying drawings:
as shown in fig. 1, the image edge detection method of the present invention includes the following steps:
s1, importing the image to be detected, converting the image to be detected into a gray scale image, and processing the gray scale imageRepresenting the digital gray scale image with an image size of,Is composed ofAt the pixel gray value. Wherein the field to be analyzed comprises image processing and computer vision;
s2, defining edgeIn 8 directions, as shown in figure 2,the derivative of the pixel gray can be used to further identify the structural features of the edge, for example, the derivative of the gray in the N direction is:
s3, gettingAt three pixels along a certain direction, the derivative of the gray scale in the vertical direction is calculated to eliminate possible noise effects in edge recognition. To be provided withIn a direction ofTaking the pixel at three positions as an example (see FIG. 2), the gray derivatives corresponding to the NE direction are calculated as、、:
S5, calculating the weighted average of the gray derivative in SW directionWill beThe derivative of the gray scale of the pixel in the NW-SE direction is taken asAndgreater value of, i.e.
S6, calculate other 3 directions in the same way: derivatives of gray scale in the vertical direction of W-E, NE-SW and N-S,Andand taking the maximum of the four as the derivative of the gray level of each pixel, forAt pixel point, gray derivative matrixCorresponding elementComprises the following steps:
s7, selecting a gray derivative threshold valuePreliminarily filtering out smaller pixel points which are not edge noise, simultaneously avoiding that the gray derivative of the edge points has too large difference and the pixel points with smaller gray derivative are judged as non-edge pixel points by mistake, and establishing an edge point judgment matrix J, wherein for matrix elementsIf, ifThen, thenOtherwise;
S8, judging the matrix J according to the edge points, selecting the width d of the neighborhood of the pixel point, and calculating the elementThe sum of non-zero elements in the neighborhood of the surrounding width d is taken asEdge strength of pixel pointObtaining an edge strength matrix NJ; within the same width d neighborhood, with edge strengthBased on the NJ matrix, calculating by statistical average methodAverage edge strength of pixelObtaining an average edge strength matrix。
S9, determining edge pixel points by a teaching and learning algorithm;
and S10, outputting an image edge detection result.
Further, the determining of the edge pixel point by the teaching and learning algorithm in the step S9 includes the following steps:
s9-1, initializing population scaleDimension of problemIs randomly generatedAn initial population sample matrix X, wherein each row represents a sample, a coordinate of an image pixel;
Wherein the content of the first and second substances,setting an edge intensity threshold for a step functionMean edge intensity thresholdInner cycle number NC, outer cycle number maxCycle;
s9-3, according to the fitness functionThe calculation includesThe fitness value vector Y of the population matrix sample X of each element;
s9-4, recording the sample with the maximum fitness value as the teacher, and calculating the average vector of the population XAnd average fitness value;
S9-5, and steps S9-6-S9-9 are repeated maxCycle times;
s9-6, learning to the teacher: for populationAny one of (1) toA sampleI.e. population sample matrixTo (1) aLine, generate new candidate samples in the following manner:
Wherein、Is composed ofThe number of 2 components of (a) is,round () is a rounding function, and rand () is a function for generating random numbers between 0 and 1; computing candidate samplesOf the fitness value ofIf the fitness value is larger, the method is usedReplacement of;
S9-7, student mutual learning stage: for populationAny one of (1) toA sampleRandomly selecting a populationAny other thanOf (2) a sample. ComputingAndis a fitness value ofIf the corresponding fitness value is larger, a new candidate sample is generated as follows:
S9-8, recording the sample with the maximum fitness value again as the teacher, and calculating the populationVector of mean value ofAnd average fitness value;
S9-9, S9-6~ S9-8 cycle NC times, for the populationAny one of (1) toA sampleIf the edge intensity value is larger than the critical edge intensity timesAnd average edge strengthGreater than a threshold valueThen will beThe pixels at the corresponding positions are marked as boundary points, and a new candidate sample is randomly selected within the range with the width of d to replace the pixels in the population。
The invention is further illustrated below with an example of an edge detection application of a classical lena image (as shown in fig. 3 (a)). The invention discloses an image edge detection method based on a teaching and learning optimization algorithm, which comprises the following steps of:
s1, leadInputting the image to be detected, converting it into gray image, andrepresenting the digital gray scale image, the image size is 512 x 512,is composed ofAt the pixel gray value. Wherein the field to be analyzed comprises image processing and computer vision;
s2, defining edge8 directionsProcessing the derivative of the pixel gray scale to further confirm the structural characteristics of the edge;
s3, gettingCalculating a vertical gray derivative of three pixels along a certain direction to eliminate possible noise influence in edge identification;
s4, sorting the 3 gray derivative coefficients, and calculating the weight and the weighted average of the gray derivative coefficients;
s5, calculating the weighted average of the grayscale derivatives in the other vertical direction according to the same methodTaking the larger value of the derivative of the gray scale of the pixel along the direction;
s6, calculating the gray derivative of other 3 vertical directions according to the same method, and taking the maximum value of the four as the gray derivative of each pixel;
s7, selecting a gray derivative threshold valuePreliminarily filtering out smaller pixel points which are not edge noise, simultaneously avoiding that the gray derivative of the edge points has too large difference and the pixel points with smaller gray derivative are judged as non-edge pixel points by mistake, and establishing an edge point judgment matrix J, wherein for matrix elementsIf, ifThen, thenOtherwise;
S8, judging the matrix J according to the edge points, selecting the pixel point neighborhood width d =1, and calculating the elementsThe sum of non-zero elements in the neighborhood of the surrounding width d is taken asEdge strength of pixel pointObtaining an edge strength matrix NJ; in the same width d neighborhood range, based on the edge strength matrix NJ, the statistical average method is used for calculationAverage edge strength of pixelObtaining an average edge strength matrix。
S9, determining edge pixel points by a teaching and learning algorithm;
and S10, outputting an image edge detection result.
Wherein, the step of determining the edge pixel points by the teaching and learning optimization algorithm in the step S9 includes the following steps:
s9-1, initializing population scaleDimension of problemIs randomly generatedInitial population sample matrixWherein each row represents a sample, a coordinate of an image pixel;
Wherein the content of the first and second substances,setting an edge intensity threshold for a step functionMean edge intensity thresholdInternal circulation ofLoop number NC =5, outer loop number maxCycle = 200;
s9-3, according to the fitness functionThe calculation includesPopulation matrix sample of individual elementsVector of fitness value;
S9-4, recording the sample with the maximum fitness value as the teacher, and calculating the populationVector of mean value ofAnd average fitness value;
S9-5, and steps S9-6-S9-9 are repeated maxCycle times;
s9-6, learning to the teacher: for populationAny one of (1) toA sampleI.e. population sample matrixTo (1) aLine, generate new candidate samples in the following manner:
Wherein、Is composed ofThe number of 2 components of (a) is,round () is a rounding function, and rand () is a function for generating random numbers between 0 and 1; computing candidate samplesOf the fitness value ofIf the fitness value is larger, the method is usedReplacement of;
S9-7, student mutual learning stage: for populationAny one of (1) toA sampleRandomly selecting a populationAny other thanOf (2) a sample. ComputingAndis a fitness value ofIf the corresponding fitness value is larger, a new candidate sample is generated as follows:
S9-8, recording the sample with the maximum fitness value again as the teacher, and calculating the populationVector of mean value ofAnd average fitness value;
S9-9, S9-6~ S9-8 cycle NC times, for the populationAny one of (1) toA sampleIf the edge intensity value is larger than the critical edge intensity timesAnd average edge strengthGreater than a threshold valueThen will beThe pixels at the corresponding positions are marked as boundary points and have a width ofRandomly selecting a new candidate sample to replace the population。
The results obtained by the edge detection method based on the teaching and learning optimization algorithm disclosed in this embodiment 1 and other classical edge detection methods are shown in fig. 3 (c) and fig. 4, and fig. 3 (b) is an edge detection result directly filtered by a threshold without using the teaching and learning optimization algorithm, and as can be seen from fig. 3 and fig. 4, the disclosed edge detection method based on the teaching and learning optimization algorithm can effectively filter more background noise, has an edge detection effect slightly inferior to Canny, achieves or even exceeds the edge detection effects of other methods such as Sobol, Roberts, Prewitt, and the like, and provides a new approach for image edge detection.
In summary, compared with the prior art, the invention has the following advantages and effects:
(1) the invention establishes the intelligent optimization algorithm of teaching and learning groups, and the search of the edge pixel points does not need to set any algorithm parameter, thus being simple to realize.
(2) The method establishes the image edge intensity matrix based on the gray derivative in 8 directions, combines small-scale local search and a large amount of global search near the edge point, ensures that the edge detection method cannot be trapped in the local edge point, and finds the most important image global edge characteristic.
(3) The invention applies the teaching and learning optimization algorithm to the image edge detection, expands the effectiveness and the universality of the group intelligent algorithm in the image analysis and processing problem, and has important significance to the field of image analysis and processing.
In alternative embodiments, the functions/acts noted in the block diagrams may occur out of the order noted in the operational illustrations. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality/acts involved. Furthermore, the embodiments presented and described in the flow charts of the present invention are provided by way of example in order to provide a more thorough understanding of the technology. The disclosed methods are not limited to the operations and logic flows presented herein. Alternative embodiments are contemplated in which the order of various operations is changed and in which sub-operations described as part of larger operations are performed independently.
Furthermore, although the present invention is described in the context of functional modules, it should be understood that, unless otherwise stated to the contrary, one or more of the described functions and/or features may be integrated in a single physical device and/or software module, or one or more functions and/or features may be implemented in a separate physical device or software module. It will also be appreciated that a detailed discussion of the actual implementation of each module is not necessary for an understanding of the present invention. Rather, the actual implementation of the various functional modules in the apparatus disclosed herein will be understood within the ordinary skill of an engineer, given the nature, function, and internal relationship of the modules. Accordingly, those skilled in the art can, using ordinary skill, practice the invention as set forth in the claims without undue experimentation. It is also to be understood that the specific concepts disclosed are merely illustrative of and not intended to limit the scope of the invention, which is defined by the appended claims and their full scope of equivalents.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The logic and/or steps represented in the flowcharts or otherwise described herein, e.g., an ordered listing of executable instructions that can be considered to implement logical functions, can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions. For the purposes of this description, a "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device.
More specific examples (a non-exhaustive list) of the computer-readable medium would include the following: an electrical connection (electronic device) having one or more wires, a portable computer diskette (magnetic device), a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium could even be paper or another suitable medium upon which the program is printed, as the program can be electronically captured, via for instance optical scanning of the paper or other medium, then compiled, interpreted or otherwise processed in a suitable manner if necessary, and then stored in a computer memory.
It should be understood that portions of the present invention may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, the various steps or methods may be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, any one or combination of the following techniques, which are known in the art, may be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application specific integrated circuit having an appropriate combinational logic gate circuit, a Programmable Gate Array (PGA), a Field Programmable Gate Array (FPGA), or the like.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
While embodiments of the invention have been shown and described, it will be understood by those of ordinary skill in the art that: various changes, modifications, substitutions and alterations can be made to the embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the claims and their equivalents.
While the preferred embodiments of the present invention have been illustrated and described, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.
Claims (8)
1. An image edge detection method, comprising:
converting an image to be detected into a gray image;
carrying out weighted average processing on the gray derivative of each candidate edge direction to determine the gray derivative of each pixel in the gray image in the candidate edge direction;
taking the maximum gray derivative of the candidate edge direction as the gray derivative of the target pixel, and establishing an edge point judgment matrix, an edge intensity matrix and an average edge intensity matrix according to a gray derivative threshold;
initializing population scale and problem dimension, and randomly generating a population sample;
constructing a fitness function according to the edge strength and the threshold value of the critical edge strength, and determining the cycle number;
determining boundary points by adopting a teacher student learning method according to the population samples, the fitness function and the cycle times;
randomly selecting a candidate sample from the neighborhood range of the boundary point to replace the boundary point, and outputting an edge detection result;
the step of taking the maximum gray derivative of the candidate edge direction as the gray derivative of the target pixel and establishing an edge point judgment matrix, an edge intensity matrix and an average edge intensity matrix according to a gray derivative threshold includes:
taking the maximum value in the corresponding gray derivative in different vertical directions as the gray derivative of each pixel;
selecting a gray derivative threshold value;
filtering non-edge noise pixel points in the gray level image according to the gray level derivative threshold value;
establishing an edge point judgment matrix;
according to the edge point judgment matrix, after the neighborhood width of a pixel point is selected, the sum of non-zero elements in the neighborhood width range around the elements is calculated, and an edge intensity matrix is determined;
and calculating an average edge intensity matrix according to the edge intensity matrix.
2. The image edge detection method according to claim 1, wherein the performing a weighted average process on the gray derivative of each candidate edge direction to determine the gray derivative of each pixel in the gray image in the candidate edge direction comprises:
defining eight candidate edge directions;
taking three pixels of any position in the gray-scale image along any candidate edge direction, and calculating gray-scale derivatives of the three pixels in four vertical directions;
and after sequencing the gray derivative, calculating corresponding weight and a weighted average value of the gray derivative.
3. The image edge detection method of claim 1, further comprising:
calculating a fitness value vector of a population matrix sample containing a plurality of elements according to the fitness function;
and taking the sample with the largest fitness value vector as a teacher, and calculating the average value vector and the average fitness value of the population.
4. The image edge detection method of claim 3, wherein determining the boundary points using a teacher student learning method based on the population samples, the fitness function, and the cycle number comprises:
in a stage of learning from a teacher, determining a new candidate sample according to any first sample in the population;
in a student mutual learning stage, randomly selecting a second sample different from a first sample in a population according to any first sample in the population, calculating a fitness value between the first sample and the second sample, and determining a new candidate sample according to the fitness value;
determining the boundary point from the new candidate sample.
5. The image edge detection method of claim 4, wherein determining the boundary points using a teacher student learning method based on the population samples, the fitness function, and the cycle number further comprises:
taking the sample with the largest fitness value as a new teacher, and calculating the average value vector and the average fitness value of the population according to the new teacher;
judging whether the edge intensity value of any sample in the population is greater than N times of the critical edge intensity, and if so, marking the pixel at the corresponding position of the current sample as a boundary point, wherein the average edge intensity is greater than an edge intensity threshold value;
and selecting a new candidate sample to replace the sample in the population corresponding to the boundary point.
6. An image edge detection apparatus, comprising:
the first module is used for converting an image to be detected into a gray image;
the second module is used for carrying out weighted average processing on the gray derivative of each candidate edge direction and determining the gray derivative of each pixel in the gray image in the candidate edge direction;
a third module, configured to use the maximum grayscale derivative of the candidate edge direction as a grayscale derivative of the target pixel, and establish an edge point determination matrix, an edge intensity matrix, and an average edge intensity matrix according to a grayscale derivative threshold;
the fourth module is used for initializing population scale and problem dimension and randomly generating population samples;
a fifth module, configured to construct a fitness function according to the edge strength and the threshold of the critical edge strength, and determine a cycle number;
a sixth module, configured to determine a boundary point by using a teacher-student learning method according to the population sample, the fitness function, and the cycle number;
a seventh module, configured to randomly select a candidate sample from a neighborhood range of the boundary point to replace the boundary point, and output an edge detection result;
wherein the third module is specifically configured to:
taking the maximum value in the corresponding gray derivative in different vertical directions as the gray derivative of each pixel;
selecting a gray derivative threshold value;
filtering non-edge noise pixel points in the gray level image according to the gray level derivative threshold value;
establishing an edge point judgment matrix;
according to the edge point judgment matrix, after the neighborhood width of a pixel point is selected, the sum of non-zero elements in the neighborhood width range around the elements is calculated, and an edge intensity matrix is determined;
and calculating an average edge intensity matrix according to the edge intensity matrix.
7. An electronic device comprising a processor and a memory;
the memory is used for storing programs;
the processor executing the program realizes the method of any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that the storage medium stores a program, which is executed by a processor to implement the method according to any one of claims 1 to 5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111457160.5A CN113870297B (en) | 2021-12-02 | 2021-12-02 | Image edge detection method and device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111457160.5A CN113870297B (en) | 2021-12-02 | 2021-12-02 | Image edge detection method and device and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113870297A CN113870297A (en) | 2021-12-31 |
CN113870297B true CN113870297B (en) | 2022-02-22 |
Family
ID=78985665
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111457160.5A Active CN113870297B (en) | 2021-12-02 | 2021-12-02 | Image edge detection method and device and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113870297B (en) |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2019041590A1 (en) * | 2017-08-31 | 2019-03-07 | 中国科学院微电子研究所 | Edge detection method using arbitrary angle |
Family Cites Families (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP5683888B2 (en) * | 2010-09-29 | 2015-03-11 | オリンパス株式会社 | Image processing apparatus, image processing method, and image processing program |
CN105139391B (en) * | 2015-08-17 | 2018-01-30 | 长安大学 | A kind of haze weather traffic image edge detection method |
CN108629786B (en) * | 2017-03-23 | 2020-07-21 | 展讯通信(上海)有限公司 | Image edge detection method and device |
CN110047088B (en) * | 2019-04-01 | 2022-08-26 | 南京邮电大学 | HT-29 image segmentation method based on improved teaching and learning optimization algorithm |
CN109961437B (en) * | 2019-04-04 | 2021-06-25 | 江南大学 | Method for detecting significant fabric defects based on machine teaching mode |
CN112435208B (en) * | 2019-08-07 | 2022-09-13 | 河海大学常州校区 | Insulator region detection method for significant edge guidance |
CN111415363B (en) * | 2020-04-20 | 2023-04-18 | 电子科技大学中山学院 | Image edge identification method |
-
2021
- 2021-12-02 CN CN202111457160.5A patent/CN113870297B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2019041590A1 (en) * | 2017-08-31 | 2019-03-07 | 中国科学院微电子研究所 | Edge detection method using arbitrary angle |
Non-Patent Citations (1)
Title |
---|
基于ACO的彩色图像边缘检测;郑晓霞等;《现代计算机(专业版)》;20161215(第35期);第58-61页 * |
Also Published As
Publication number | Publication date |
---|---|
CN113870297A (en) | 2021-12-31 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108460764B (en) | Ultrasonic image intelligent segmentation method based on automatic context and data enhancement | |
CN107506761B (en) | Brain image segmentation method and system based on significance learning convolutional neural network | |
CN116664559B (en) | Machine vision-based memory bank damage rapid detection method | |
CN111145209A (en) | Medical image segmentation method, device, equipment and storage medium | |
CN106709524B (en) | Element symbol detection and identification method in electrical engineering drawing | |
CN108009554A (en) | A kind of image processing method and device | |
CN104866868A (en) | Metal coin identification method based on deep neural network and apparatus thereof | |
CN109444169A (en) | A kind of bearing defect detection method and system | |
CN107784319A (en) | A kind of pathological image sorting technique based on enhancing convolutional neural networks | |
Raitoharju et al. | Benchmark database for fine-grained image classification of benthic macroinvertebrates | |
CN112330593A (en) | Building surface crack detection method based on deep learning network | |
TW202013311A (en) | Image processing method, electronic device, and storage medium | |
CN107122713B (en) | Analog property detection method based on deep learning | |
CN110517273B (en) | Cytology image segmentation method based on dynamic gradient threshold | |
CN111968081B (en) | Automatic fish shoal counting method and device, electronic equipment and storage medium | |
CN111145145B (en) | Image surface defect detection method based on MobileNet | |
Baker et al. | Deep Convolutional Networks do not Perceive Illusory Contours. | |
CN113362277A (en) | Workpiece surface defect detection and segmentation method based on deep learning | |
Leavline et al. | On teaching digital image processing with MATLAB | |
CN117094975A (en) | Method and device for detecting surface defects of steel and electronic equipment | |
CN113870297B (en) | Image edge detection method and device and storage medium | |
Aslam et al. | A modified adaptive thresholding method using cuckoo search algorithm for detecting surface defects | |
CN110349119B (en) | Pavement disease detection method and device based on edge detection neural network | |
Mayerich et al. | Fast cell detection in high-throughput imagery using GPU-accelerated machine learning | |
CN116542963A (en) | Float glass defect detection system and detection method based on machine learning |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |