A worm target recognition method based on boundary band and effective edge arc

CN123016482APending Publication Date: 2026-10-30AOTU TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611496195.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-24
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

但其存在明显缺陷:一是依赖大规模标注样本与模型训练,当检测对象、显微设备或成像条件变化时,需重新采集数据并训练模型,使用与维护成本高;二是对GPU等算力硬件要求较高,难以在嵌入式设备、工业控制设备及普通办公计算机上低成本部署

Benefits of technology

[0041]1.无需构建标注数据集与深度学习模型训练,当检测对象、成像设备或光源条件变更时,仅需调整颜色、几何阈值即可适配,大幅降低使用与维护成本。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123016482A_ABST
    Figure CN123016482A_ABST
Patent Text Reader

Abstract

The application discloses a worm body target recognition method based on a boundary band and an effective edge arc, relates to the technical field of worm body target recognition, and aims to solve the problems of high training and deployment costs of existing worm body detection which depends on deep learning models such as YOLO and low accuracy of traditional methods which depend on closed contours and broken boundaries. The method sequentially performs the steps of whole-image boundary band extraction, effective edge screening, effective edge arc worm body determination and target frame generation: the boundary band is extracted in combination with color difference and boundary width, the smooth effective edge arc is screened based on the included angle of the eight-neighbor direction vector after skeletonization, the worm body boundary is jointly determined through the arc length, the proportion of sharp inflection points and the maximum inflection point angle, and finally the target frame is generated and the labeled data is output. The application does not need deep learning model training and can be run by pure CPU, and is suitable for active sludge microscopic detection and other scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of insect target recognition technology, and in particular to an insect target recognition method based on boundary bands and effective edge arcs. Background Technology

[0002] In activated sludge processes for wastewater treatment, microscopic identification of microorganisms such as Vorticella, rotifers, and nematodes is a crucial method for assessing the operational status of the sludge. Currently, insect target detection primarily falls into two technical categories: the first is deep learning-based target detection methods, such as YOLO, Faster R-CNN, and SSD network models. These methods require collecting a large number of insect images and manually annotating the bounding boxes, constructing a dataset, training the model, and ultimately outputting the insect's location and category information. However, they have significant drawbacks: firstly, they rely on large-scale labeled samples and model training; when the target object, microscopic equipment, or imaging conditions change, data must be recollected and the model retrained, resulting in high usage and maintenance costs; secondly, they require high-performance computing hardware such as GPUs, making low-cost deployment on embedded devices, industrial control equipment, and ordinary office computers difficult.

[0003] The second category is traditional image processing methods, which extract target contours through threshold segmentation, edge detection, contour extraction, and morphological processing, and then complete the recognition based on overall morphological features such as area, perimeter, and roundness. The core drawback of this type of method is that it relies on complete closed contours. When the edges of the worm are obscured by sludge flocs or locally broken due to background interference, contour extraction is prone to failure. At the same time, it relies solely on overall morphological features for judgment and lacks an effective description of the continuous and smooth characteristics of the worm's edges, resulting in a high rate of false positives and false negatives against complex sludge backgrounds.

[0004] Therefore, how to reduce the hardware deployment threshold for insect detection without the need for deep learning model training and large-scale labeled samples, while solving the problem of low detection accuracy when traditional methods rely on closed contours and broken boundaries, is a technical challenge that urgently needs to be solved in this field. Summary of the Invention

[0005] In view of this, this application provides a method for insect target recognition based on boundary bands and effective edge arcs to address the shortcomings of existing technologies.

[0006] The first aspect of this application provides a method for insect target recognition based on boundary bands and effective edge arcs, including:

[0007] A color microscopic image to be detected is acquired. Candidate boundary regions are selected based on the color difference features between the insect body boundary and the background. Then, regions whose width does not meet the preset requirements are removed by filtering the boundary width. The whole image boundary band with the preset width is extracted.

[0008] The entire image boundary band is skeletonized to obtain a boundary skeleton with a single pixel width. During the path tracing process of the boundary skeleton, when encountering a skeleton intersection node, the boundary path with the smallest directional change is selected based on the angle between the eight neighboring direction vectors to obtain continuous effective edge arcs.

[0009] The directional change angle of the internal detection points on each effective edge arc segment, excluding the beginning and end endpoints, is calculated point by point. Based on the arc length of the effective edge arc, the proportion of sharp inflection points, and the maximum inflection point angle, a joint judgment is made to identify the effective edge arc belonging to the insect body boundary.

[0010] Based on the effective edge arcs of the identified insect body boundary, a target bounding rectangle corresponding to the insect body is generated, and an insect body target annotation file containing the coordinates of the target bounding rectangle is output.

[0011] In one possible implementation of the first aspect, a preprocessing operation is performed on the color micrograph before extracting the boundary band of the whole image:

[0012] The color microscopic image is converted to the HSV color space, and the converted image is denoised using a bilateral filtering algorithm.

[0013] In one possible implementation of the first aspect, the process of extracting the boundary band of the entire image specifically includes:

[0014] Based on the preset HSV color threshold range for the insect body boundary, the image in the HSV color space is segmented to generate candidate boundary masks.

[0015] The candidate boundary mask is processed using morphological erosion to remove candidate boundary regions whose width is less than a preset boundary width threshold.

[0016] Morphological dilation is used to process the eroded mask to restore the boundary width of the preserved area, resulting in the whole image boundary band after dual filtering by color and width.

[0017] In one possible implementation of the first aspect, the Zhang-Suen thinning algorithm is used to skeletonize the boundary band of the whole image to obtain a boundary skeleton with a single pixel width.

[0018] In one possible implementation of the first aspect, the effective edge arc is generated through skeleton path tracing, specifically as follows:

[0019] Traverse the boundary skeleton and select the skeleton endpoints as the starting points for tracing.

[0020] Path tracing is performed pixel by pixel along the extension direction of the boundary skeleton. When the skeleton intersection node is reached, the path with the smallest change in direction is selected based on the angle between the eight neighboring direction vectors and the path continues to extend.

[0021] The tracking continues until the skeleton endpoint or image boundary is reached, at which point the current tracking is terminated, resulting in a single continuous effective edge arc.

[0022] In one possible implementation of the first aspect, the process of filtering paths at the skeleton intersection nodes is specifically as follows:

[0023] Using the direction of the boundary path into the current skeleton intersection node as the entry direction vector, traverse all candidate continuation pixels belonging to the boundary skeleton within the eight neighborhoods of the current skeleton intersection node, and calculate the exit direction vector corresponding to each candidate continuation pixel.

[0024] Calculate the angle between each departure direction vector and the entry direction vector, and select the candidate continuation pixel with the smallest angle as the continuation path point of the effective edge arc.

[0025] In one possible implementation of the first aspect, the directional change angle of the internal detection point is calculated in the following way:

[0026] Along the extension path of the effective edge arc, take the previous and next adjacent pixels of the current internal detection point, and generate an entry direction vector pointing to the current detection point and a departure direction vector pointing away from the current detection point, respectively.

[0027] The angle between the entering direction vector and the leaving direction vector is calculated based on the vector dot product formula to obtain the directional change angle of the current detection point.

[0028] In one possible implementation of the first aspect, the specific process of joint determination is as follows:

[0029] Preset inflection point angle threshold, minimum arc length threshold, and inflection point ratio threshold; define internal detection points whose direction change angle is greater than the inflection point angle threshold as sharp inflection points;

[0030] The total number of sharp inflection points within a single effective edge arc segment is counted, and the ratio of the total number of sharp inflection points to the total number of detection points within that effective edge arc segment is calculated to obtain the percentage of sharp inflection points. The maximum value of the angle of change in all directions within that effective edge arc segment is extracted to obtain the maximum inflection point angle.

[0031] When the arc length of the effective edge arc is greater than or equal to the minimum arc length threshold, the proportion of sharp inflection points is less than the inflection point proportion threshold, and the maximum inflection point angle is less than the inflection point angle threshold, the effective edge arc segment is determined to be an effective edge arc of the insect body boundary.

[0032] In one possible implementation of the first aspect, the process of generating the target bounding rectangle for a single continuous effective edge arc of the insect body boundary is as follows:

[0033] Collect the coordinates of all skeleton points of the effective edge arc segment, and solve for the minimum horizontal bounding rectangle corresponding to all skeleton points;

[0034] Using the center of the horizontal minimum bounding rectangle as a reference, expand the rectangle symmetrically outward according to a preset expansion ratio so that the insect body is completely covered within the rectangle, thus obtaining the final bounding rectangle of the insect body target.

[0035] In one possible implementation of the first aspect, when there are multiple valid edge arcs of the insect body boundary, the arc segment same-body determination is performed first, and then the target bounding rectangle is generated.

[0036] The process for determining whether an arc segment is the same body is as follows:

[0037] Calculate the Euclidean distance between all pairs of endpoints of the two valid edge arcs to obtain the minimum endpoint distance;

[0038] When the minimum endpoint distance is less than a preset distance threshold, take the two endpoints that constitute the minimum endpoint distance, and calculate the angle between the extension direction vector of the two endpoints and the direction vector of the line connecting the two endpoints respectively; the extension direction vector of the endpoint is formed by the endpoint pointing to its adjacent skeleton pixel;

[0039] When both included angles are less than the preset direction consistency threshold, it is determined that the two valid edge arcs belong to the same insect body boundary. The two arcs are merged to generate the target bounding rectangle of the corresponding insect body.

[0040] Its beneficial effects are as follows:

[0041] 1. No need to build labeled datasets and train deep learning models. When the detected object, imaging device or light source conditions change, only the color and geometric thresholds need to be adjusted to adapt, which greatly reduces the cost of use and maintenance.

[0042] 2. The entire process is based on traditional image processing algorithms, which can run on CPU only and does not require GPU computing power. It can be directly deployed on ordinary office computers, embedded industrial equipment and low-cost microscopic inspection instruments.

[0043] 3. By adopting hierarchical feature descriptions of boundary bands and effective edge arcs to replace the traditional closed contour recognition logic, it can complete target recognition in scenarios where the insect body boundary is obscured by mud or partially missing, thus solving the problem that traditional methods fail when the contour is broken.

[0044] 4. The distinction between insect bodies and impurities is achieved based on the boundary geometric continuity characteristics. All judgment parameters have clear physical meanings and can be quantified and adjusted. The algorithm logic is highly interpretable and easy to debug in engineering and adapt to different scenarios. Attached Figure Description

[0045] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0046] Figure 1 This is a schematic diagram of a method for insect target recognition based on boundary bands and effective edge arcs provided in an embodiment of this application;

[0047] Figure 2 This is the original microscopic image of *Chilodonella* provided in the embodiments of this application;

[0048] Figure 3 This is a diagram showing the effect of extracting the boundary band from a microscopic image of *Chilodonella* provided in this application embodiment;

[0049] Figure 4 This is a traditional edge detection effect diagram of a microscopic image of *Chilodonella* provided in the embodiments of this application;

[0050] Figure 5 These are microscopic images of rotifers provided in the embodiments of this application;

[0051] Figure 6 These are microscopic images of Vorticella provided in the embodiments of this application;

[0052] Figure 7 This is a diagram showing the effect of bilateral filtering and noise reduction on the original microscopic image of *Chilodonella* provided in this application embodiment;

[0053] Figure 8 This is an example of the effect of skeletonizing the boundary band of the entire image, as provided in the embodiments of this application.

[0054] Figure 9 This is a schematic diagram of the intersection points after the boundary band of the whole image is skeletonized, as provided in the embodiments of this application;

[0055] Figure 10 This is a schematic diagram of the eight-neighbor direction filtering principle of the skeleton intersection provided in the embodiments of this application;

[0056] Figure 11 This is a schematic diagram of the effective edge-shaped arcus body determination results provided in the embodiments of this application;

[0057] Figure 12 This is a diagram showing the effect of generating and annotating the insect target bounding box according to an embodiment of this application. Detailed Implementation

[0058] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0059] In this application, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the element.

[0060] Example

[0061] This solution utilizes a pure OpenCV workflow—including whole-image boundary band extraction, effective skeleton edge filtering, effective edge arc worm body determination, and target box generation—to achieve automatic worm body recognition and annotation file output without requiring deep learning models such as YOLO. The overall technical workflow is as follows: Figure 1 As shown:

[0062] Step 1: Extract the boundary band of the entire image.

[0063] This step uses boundary features as the entry point for insect identification. The core is to extract boundary bands with a certain width, which is different from the single-pixel edge lines output by traditional edge detection. Microscopic images of activated sludge contain multiple objects such as microorganisms, flocs, fibers, and impurities. If ordinary edge detection algorithms are used, the brightness changes of various particles will generate edge lines, resulting in a large number of dense and messy curves. The insect boundary is easily submerged in background interference and cannot be directly used for target identification.

[0064] Due to the combined effects of light transmission, refraction, scattering, phase difference, and imaging equipment performance during microscopic imaging, a transition region with a stable width forms near the edge of the microbial organism. For example, when observing from the outside of the organism inwards, a layered transition can be observed, consisting of a background, a dark purple area, and a bright yellow area. Alternatively, other stable changes in brightness, color, or contrast can be observed, ultimately resulting in a clearly discernible band-like structure at the edge of the organism.

[0065] Figure 2 This is the original micrograph of *Chilodonella*. Figure 3 This is the boundary zone extraction result of the present invention (it should be noted that subsequent steps are all based on the image of *Cyclophorus fasciatus*). Figure 4 The results are from traditional edge detection. As can be seen from the comparison, the boundary band extraction method of this invention can reliably detect the wide and thick edges of the insect body; while traditional edge detection outputs a large number of fragmented edge lines, with the insect target buried in background interference, resulting in a significantly inferior detection performance compared to this method.

[0066] Verification using numerous activated sludge microscopic image samples has shown that, under clear imaging conditions, the vast majority of rotifer bodies exhibit this banded boundary feature, providing a stable basis for the detection and analysis of activated sludge microbial populations. Rotifer body microscopic images can be found at [link to image]. Figure 5 Microscopic images of Vorticella bodies can be found in [reference needed]. Figure 6 .

[0067] The specific steps are as follows:

[0068] 1.1 Input color image preprocessing,

[0069] This embodiment uses color microscopic images as input, and can combine boundary width and boundary color features to achieve dual judgment, with better detection effect than grayscale images; grayscale images can also be used with this method, but the detection accuracy will be reduced accordingly.

[0070] Microscopic images contain numerous tiny particles and random bright spots. If boundary extraction is performed directly, these minute grayscale changes will generate a large number of fine edge lines, interfering with subsequent recognition. Therefore, image noise reduction processing is necessary first. Noise reduction can be achieved using various methods such as median filtering, Gaussian filtering, and bilateral filtering. This embodiment uses bilateral filtering, which can reduce image noise while better preserving edge information.

[0071] The specific processing flow is as follows: Read the color microscopic image and convert it to the HSV color space. Perform bilateral filtering on the HSV image. In this embodiment, the bilateral filtering parameters are set as follows: neighborhood diameter d=5, color space standard deviation sigma Color=30, and coordinate space standard deviation sigma Space=30. After the above preprocessing, the boundary features of the insect are less affected by the filtering, while the weak edges of objects such as fungal globules and fibers are further weakened. The noise reduction effect can be seen in [reference needed]. Figure 7 .

[0072] 1.2 Boundary band extraction,

[0073] This step is the core step that distinguishes this invention from traditional edge detection. Instead of directly extracting single-pixel edges using traditional edge detection algorithms, it determines a boundary band with a set width based on color differences and boundary width.

[0074] First, the color distribution range corresponding to the insect body boundary in the microscopic image is statistically analyzed. In this embodiment, the insect body boundary is represented by a purple area. It should be noted that the hue threshold in the HSV space has no absolutely fixed value, and it is strongly correlated with the imaging camera, light source conditions, white balance parameters, and exposure intensity. In the experimental scenario of this embodiment, the hue threshold range is set to Hue∈[130,145], and color segmentation is completed by combining saturation and brightness thresholds.

[0075] Since there may be color regions within the bacterial flocs that are close to the boundaries of the insect body, color screening alone cannot completely eliminate interference. Therefore, it is necessary to further screen the boundary width of each candidate region. This embodiment uses a combination of morphological erosion and dilation to achieve width screening: small, fragmented color regions with insufficient width will disappear directly after the erosion operation, while the insect body boundary, because it has a stable width, can be preserved. The boundary width of the preserved region can then be restored through a subsequent dilation operation.

[0076] After two steps of color and width filtering, the boundary band of the entire image with double constraints is obtained. (See reference for extraction results.) Figure 3 .

[0077] 2. Effective edge arc extraction,

[0078] The boundary band extraction results show that the boundary features of the insect target differ significantly in morphology from background objects such as bacterial flocs, fibers, and impurities: the insect boundary is generally smooth, with continuous curvature changes and no obvious sharp corners; while the boundaries of background objects such as bacterial flocs, fibers, and impurities are composed of numerous short broken lines, with many sharp turns and drastic curvature changes, even exhibiting a serrated honeycomb structure when continuous. Based on this difference, this step filters out effective arc segments with continuous curvature changes from the boundary band as the basis for subsequent insect identification.

[0079] 2.1 Boundary band skeletonization,

[0080] Since the boundary band has a certain width, it is inconvenient to directly perform curvature calculation and path tracing. Therefore, the boundary band is first skeletonized, and the boundary region with width is refined into a center line with a single pixel width. While preserving the boundary topology, this facilitates subsequent geometric feature calculation and continuous path extraction.

[0081] This embodiment uses the Zhang-Suen thinning algorithm to achieve boundary band skeletonization, which can be directly implemented using OpenCV. The skeletonization effect can be seen in [reference needed]. Figure 8 After processing, the honeycomb-like irregular structure of the background impurities is clearer, and the continuous smooth boundary features corresponding to the insect body are more prominent, making the morphological differences between the two directly distinguishable.

[0082] 2.2 Effective edge arc extraction,

[0083] The skeletonized boundary network contains a large number of intersection and bifurcation points (see reference). Figure 9 If every branch path is calculated and analyzed individually, it will result in a large amount of computation, fragmented paths, and low recognition efficiency. Based on the inherent characteristic of the smooth and continuous boundary of the insect body, this embodiment selects only the smooth and continuous path with the least directional change at the bifurcation position to extract the effective edge, which can significantly filter out the irregular bifurcation interference of background impurities.

[0084] Effective edges are extracted dynamically through skeleton path tracing. When tracing to a skeleton intersection node, the continuation direction is selected based on the angle between the eight neighboring direction vectors. The selection principle can be found in [link to relevant documentation]. Figure 10 The specific calculation rules are as follows:

[0085] Let the preceding pixel of the path tracing leading to the current intersection node be . The current cross node is All candidate continuation pixels belonging to the boundary skeleton within the eight neighborhoods of the intersection node are ;

[0086] Calculate the entry direction vector and the exit direction vector corresponding to each candidate point respectively:

[0087] Calculate the angle between each departure direction vector and the entry direction vector, and select the candidate pixel with the smallest angle as the continuation path point of the effective edge. That is, always select the path with the gentlest change in direction as the effective edge.

[0088] Example: Given that the skeleton path has been traced to intersection node B, with corresponding coordinates of... , , , ; where the entry direction vector Candidate directions Candidate directions The angle between direction 1 and the entering direction is smaller, so point C is selected as the continuation path point.

[0089] Starting from the skeleton endpoints, the tracking proceeds pixel-by-pixel according to the aforementioned rules. At intersections, the direction of extension is chosen based on the principle of minimum angle, continuing until another skeleton endpoint or image boundary is reached, thus obtaining a single continuous effective edge arc. This process is repeated for all unvisited skeleton endpoints to extract all effective edge arcs.

[0090] 3. Valid determination of marginal arcuate bodies.

[0091] After extracting multiple effective edge arcs through the aforementioned steps, this step distinguishes the insect body from background impurities by quantifying the smoothness of the boundaries. While the boundaries of the insect body exhibit various forms such as arcs and straight lines, the overall directional change is continuous and gradual; whereas the boundaries of background objects such as bacterial flocs, fibers, and impurities are prone to abrupt directional changes over short distances, exhibiting numerous sharp inflection points. This step calculates the directional change angle at each point and combines it with statistical parameters to complete the joint judgment.

[0092] 3.1 Quantitative calculation of smoothness,

[0093] For each valid edge arc, the angle of change in boundary direction is calculated point-by-point to quantify the local smoothness. The calculation is performed based on adjacent points of a single-pixel skeleton, as follows:

[0094] Along the extension path of the effective edge arc, take the previous adjacent pixel of the current detection point. Current pixel and the next adjacent pixel Construct the entry direction vector and the exit direction vector respectively:

[0095] Calculate the angle between two direction vectors using the dot product formula. This angle represents the angle of change of direction at the current point. The smaller the angle value, the smoother the boundary at that point.

[0096] It should be noted that the first and last endpoints of the effective edge arc only have adjacent pixels on one side, and it is impossible to construct a bidirectional vector, so they are not included in the detection point statistics.

[0097] Examples of typical directional changes in angle are shown below:

[0098] Straight-through scenario: , The dot product is 100, and the product of the vector magnitudes is 100. The angle changes in the corresponding direction ;

[0099] Smoothly curved scenes: , The angle of change of direction was calculated. ;

[0100] Sharp inflection point scenario: , The angle of change of direction was calculated. .

[0101] 3.2 Feature parameter statistics,

[0102] Based on the directional change angle at each point, three criteria for determining the effective edge arc of a single segment are calculated:

[0103] 1. Number of sharp inflection points: Preset inflection point angle threshold The angle of change of direction is greater than The detection point is defined as a sharp inflection point. The total number of sharp inflection points within a single arc segment is counted and denoted as . .

[0104] 2. Sharp Inflection Point Ratio: Calculate the ratio of the number of sharp inflection points to the total number of detection points, denoted as . The calculation formula is:

[0105] in This represents the total number of detection points for the effective edge arc segment, which is the total number of pixels after removing the first and last endpoints. The lower the value, the smoother the overall boundary, and the more it conforms to the characteristics of the insect body boundary; the higher the value, the closer it is to the boundary characteristics of fungal flocs, fibers, and impurities.

[0106] 3. Maximum Inflection Point Angle: Extract the maximum value of the angle change in all directions within a single effective edge arc segment, denoted as... This is used to characterize the degree of the largest directional abrupt change that has occurred at the boundary of this segment:

[0107] 3.3 Joint determination of insect body boundaries

[0108] Combined with the length of the effective edge arc (in this embodiment, the arc length of the effective edge arc is the number of pixels contained in the arc segment) The three parameters—characteristics, percentage of sharp inflection points, and maximum inflection point angle—are used to jointly determine whether an arc segment belongs to the boundary of the insect body. In this embodiment, the determination thresholds are set as follows: minimum arc length threshold 20 pixels, sharp inflection point percentage threshold 0.2, and maximum inflection point angle threshold 30°. The determination rules are as follows:

[0109] Judgment conditions: ,and ,and Result: Smooth insect body edge.

[0110] Judgment conditions: ,or ,or Result: Not the edge of the insect body.

[0111] After joint evaluation, valid edge arcs that conform to the characteristics of the insect body boundary are retained, while other arc segments determined to be fungal clumps, fibers, or impurities are discarded. The evaluation results of this embodiment can be found in [reference needed]. Figure 11 The red-marked arcs represent the identified insect boundaries.

[0112] 4. Generation and annotation output of insect target bounding boxes.

[0113] After determining the worm's boundary, a bounding rectangle of the corresponding target is generated based on the preserved effective edge arcs of the worm. An annotation file containing the target bounding box coordinates is output, and the output format is compatible with the annotation format of deep learning object detection models, directly replacing the detection output of models such as YOLO. This step handles two scenarios separately: continuous single-segment worm edges and multi-segment discontinuous worm edges.

[0114] 4.1 Generation of target bounding boxes for continuous insect body edges.

[0115] For a single continuous effective edge arc of the worm body, the coordinates of all skeleton points of the arc segment are collected, and the minimum horizontal bounding rectangle corresponding to all skeleton points is calculated. Since the skeletonization yields the boundary centerline, the rectangle generated solely based on the skeleton cannot completely encompass the worm body; therefore, the bounding rectangle needs to be expanded. In this embodiment, the width and height of the rectangle are each increased by 10%, that is, symmetrically expanded by 5% on both sides along the center of the rectangle to ensure that the entire worm body is completely included within the target bounding box.

[0116] The coordinates of the top left corner of the target box were calculated. and the coordinates of the bottom right corner Then, the coordinates are converted to a normalized format and output as a txt file that is consistent with the YOLO annotation format.

[0117] The values ​​are, in order: target category number, normalized center x-coordinate, normalized center y-coordinate, normalized width, and normalized height. The target bounding box annotation on the original image can be found in [reference needed]. Figure 12 This method is based entirely on traditional image processing algorithms and can replace deep learning target detection models to complete insect localization and labeling output.

[0118] 4.2 Determination and merging of discontinuous arc segments as a single entity

[0119] When the boundary of the worm is obscured by sludge flocs or there is local breakage due to background interference, multiple valid edge arcs belonging to the same worm will be generated. In this case, it is necessary to first perform arc segment co-occurrence determination to confirm whether multiple arc segments belong to the same worm before merging them to generate the target bounding box.

[0120] Let the two valid edge arcs to be determined be respectively and Each arc segment contains two endpoints, and the determination process is as follows:

[0121] 1. Initial screening of endpoint distances: Calculate the Euclidean distances between all pairs of endpoints of the two arc segments, obtain four sets of distance values, and take the minimum value; set a distance threshold. For each pixel, if the distance between the smallest endpoints is less than the threshold, it proceeds to the subsequent directional consistency check.

[0122] 2. Endpoint Direction Consistency Verification: Based on the aforementioned eight-neighborhood direction vector calculation method, the edge extension directions at both endpoints are obtained, and two conditions must be met simultaneously: the end extension direction of the first arc roughly points to the corresponding endpoint of the second arc; the starting extension direction of the second arc is roughly consistent with the direction of the line connecting the two endpoints. That is, both included angles are less than the preset direction consistency threshold, which is preset to 30° in this embodiment, and can be adjusted according to the detection scenario.

[0123] If both the distance threshold requirement and the direction consistency requirement are met, then the two valid edge arcs are determined to belong to the same insect body boundary. After merging all the skeleton points of the two arcs, the bounding rectangle of the corresponding insect body is calculated according to the above method for generating the target box of continuous arcs.

[0124] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computing software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0125] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the invention.

[0126] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.

Claims

1. A method for insect target recognition based on boundary bands and effective edge arcs, characterized in that, include: A color microscopic image to be detected is acquired. Candidate boundary regions are selected based on the color difference features between the insect body boundary and the background. Then, regions whose width does not meet the preset requirements are removed by filtering the boundary width. The whole image boundary band with the preset width is extracted. The entire image boundary band is skeletonized to obtain a boundary skeleton with a single pixel width. During the path tracing process of the boundary skeleton, when encountering a skeleton intersection node, the boundary path with the smallest directional change is selected based on the angle between the eight neighboring direction vectors to obtain continuous effective edge arcs. The directional change angle of the internal detection points on each effective edge arc segment, excluding the beginning and end endpoints, is calculated point by point. Based on the arc length of the effective edge arc, the proportion of sharp inflection points, and the maximum inflection point angle, a joint judgment is made to identify the effective edge arc belonging to the insect body boundary. Based on the effective edge arcs of the identified insect body boundary, a target bounding rectangle corresponding to the insect body is generated, and an insect body target annotation file containing the coordinates of the target bounding rectangle is output.

2. The insect target recognition method based on boundary bands and effective edge arcs according to claim 1, characterized in that, Preprocessing operations are performed on the color micrograph before extracting the boundary band of the whole image: The color microscopic image is converted to the HSV color space, and the converted image is denoised using a bilateral filtering algorithm.

3. The insect target recognition method based on boundary bands and effective edge arcs according to claim 2, characterized in that, The process of extracting the boundary band of the entire image specifically includes: Based on the preset HSV color threshold range for the insect body boundary, the image in the HSV color space is segmented to generate candidate boundary masks. The candidate boundary mask is processed using morphological erosion to remove candidate boundary regions whose width is less than a preset boundary width threshold. Morphological dilation is used to process the eroded mask to restore the boundary width of the preserved area, resulting in the whole image boundary band after dual filtering by color and width.

4. The insect target recognition method based on boundary bands and effective edge arcs according to claim 1, characterized in that, The Zhang-Suen thinning algorithm is used to skeletonize the boundary band of the whole image to obtain a boundary skeleton with a width of one pixel.

5. The insect target recognition method based on boundary bands and effective edge arcs according to claim 1, characterized in that, Effective edge arcs are generated through skeleton path tracing, the specific process of which is as follows: Traverse the boundary skeleton and select the skeleton endpoints as the starting points for tracing. Path tracing is performed pixel by pixel along the extension direction of the boundary skeleton. When the skeleton intersection node is reached, the path with the smallest change in direction is selected based on the angle between the eight neighboring direction vectors and the path continues to extend. The tracking continues until the skeleton endpoint or image boundary is reached, at which point the current tracking is terminated, resulting in a single continuous effective edge arc.

6. The insect target recognition method based on boundary bands and effective edge arcs according to claim 5, characterized in that, The process of filtering paths at skeleton intersection nodes is as follows: Using the direction of the boundary path into the current skeleton intersection node as the entry direction vector, traverse all candidate continuation pixels belonging to the boundary skeleton within the eight neighborhoods of the current skeleton intersection node, and calculate the exit direction vector corresponding to each candidate continuation pixel. Calculate the angle between each departure direction vector and the entry direction vector, and select the candidate continuation pixel with the smallest angle as the continuation path point of the effective edge arc.

7. The insect target recognition method based on boundary bands and effective edge arcs according to claim 1, characterized in that, The directional change angle of the internal detection points is calculated in the following way: Along the extension path of the effective edge arc, take the previous and next adjacent pixels of the current internal detection point, and generate an entry direction vector pointing to the current detection point and a departure direction vector pointing away from the current detection point, respectively. The angle between the entering direction vector and the leaving direction vector is calculated based on the vector dot product formula to obtain the directional change angle of the current detection point.

8. The insect target recognition method based on boundary bands and effective edge arcs according to claim 7, characterized in that, The specific process of joint determination is as follows: Preset inflection point angle threshold, minimum arc length threshold, and inflection point ratio threshold; define internal detection points whose direction change angle is greater than the inflection point angle threshold as sharp inflection points; The total number of sharp inflection points within a single effective edge arc segment is counted, and the ratio of the total number of sharp inflection points to the total number of detection points within that effective edge arc segment is calculated to obtain the percentage of sharp inflection points. The maximum value of the angle of change in all directions within that effective edge arc segment is extracted to obtain the maximum inflection point angle. When the arc length of the effective edge arc is greater than or equal to the minimum arc length threshold, the proportion of sharp inflection points is less than the inflection point proportion threshold, and the maximum inflection point angle is less than the inflection point angle threshold, the effective edge arc segment is determined to be an effective edge arc of the insect body boundary.

9. The insect target recognition method based on boundary bands and effective edge arcs according to claim 1, characterized in that, For a single continuous effective edge arc of the insect body boundary, the process of generating the target bounding rectangle is as follows: Collect the coordinates of all skeleton points of the effective edge arc segment, and solve for the minimum horizontal bounding rectangle corresponding to all skeleton points; Using the center of the horizontal minimum bounding rectangle as a reference, expand the rectangle symmetrically outward according to a preset expansion ratio so that the insect body is completely covered within the rectangle, thus obtaining the final bounding rectangle of the insect body target.

10. The insect target recognition method based on boundary bands and effective edge arcs according to claim 1, characterized in that, When there are multiple valid edge arcs of the insect body boundary, first perform arc segment same-body determination, and then generate the target bounding rectangle; The process for determining whether an arc segment is the same body is as follows: Calculate the Euclidean distance between all pairs of endpoints of the two valid edge arcs to obtain the minimum endpoint distance; When the minimum endpoint distance is less than a preset distance threshold, take the two endpoints that constitute the minimum endpoint distance, and calculate the angle between the extension direction vector of the two endpoints and the direction vector of the line connecting the two endpoints respectively; the extension direction vector of the endpoint is formed by the endpoint pointing to its adjacent skeleton pixel; When both included angles are less than the preset direction consistency threshold, it is determined that the two valid edge arcs belong to the same insect body boundary. The two arcs are merged to generate the target bounding rectangle of the corresponding insect body.