Stool sample microscopic image detection method and system based on morphological prior constraint
By employing morphological prior constraints, precise segmentation and feature extraction of fecal sample microscopic images were achieved, solving the problems of false detection and missed detection in complex backgrounds, improving detection accuracy and efficiency, and generating test reports that meet clinical requirements.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TECOM SCI CORP
- Filing Date
- 2026-03-23
- Publication Date
- 2026-05-29
AI Technical Summary
Existing automated fecal sample microscopic image detection technology is prone to false detection and false negative detection in complex backgrounds, which cannot meet the accuracy requirements of clinical testing, and requires manual verification, thus failing to leverage its high efficiency advantage.
A method based on morphological prior constraints is adopted. Through global background decoupling processing, multi-dimensional feature enhancement and a dual-branch instance segmentation network with category constraints, accurate semantic segmentation of foreground and background and instance boundary splitting of adhering targets are achieved. Combined with closed-loop verification and iterative optimization, a high-quality detection report is generated.
It significantly reduces the risk of false detection caused by background noise, solves the problem of missed detection caused by target adhesion, realizes accurate qualitative identification and quantitative counting of fecal formed elements, and improves the accuracy and stability of detection.
Smart Images

Figure CN121884016B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of sample detection technology, and in particular to a method and system for detecting fecal samples using microscopic images based on morphological prior constraints. Background Technology
[0002] The identification, classification, and counting of formed elements in feces are core non-invasive detection indicators for screening digestive system diseases, diagnosing intestinal pathogen infections, and providing early warning of digestive tract lesions. The accuracy of these detections directly determines the precision of clinical diagnosis. Traditional manual microscopic examination has inherent drawbacks such as low efficiency, high subjectivity, and difficulty in quality control, and cannot meet the needs of rapid detection of large batches of clinical samples. Automated detection technology based on microscopic image recognition has become the mainstream application solution in this field.
[0003] Currently, most mainstream automated detection solutions in this field adopt image recognition approaches based on traditional machine learning. Image segmentation of the target foreground and background is a crucial prerequisite for subsequent feature extraction and classification. Existing technologies generally employ segmentation methods that combine threshold segmentation, edge detection, and basic morphological processing, which are only suitable for simple and uniform image scenes. However, fecal samples have complex inherent matrices and cluttered backgrounds, and the formed elements to be detected are often in a low-contrast, adhered, and overlapping state. Existing segmentation methods cannot achieve accurate segmentation and are prone to serious undersegmentation and oversegmentation problems.
[0004] Furthermore, the aforementioned undersegmentation and oversegmentation issues directly lead to fundamental distortions in target feature extraction, resulting in large-scale false positives and false negatives in subsequent identification stages, and persistently high false positive and false negative rates. This deficiency makes it difficult for existing automated solutions to meet clinical compliance requirements, still requiring full manual review of results by professional laboratory personnel. This not only fails to leverage the core advantages of high throughput and high efficiency of automated solutions but also poses clinical risks of misdiagnosis and missed diagnosis. Currently, there is no mature technical solution in this field that effectively addresses the challenge of accurate segmentation in these complex scenarios. Summary of the Invention
[0005] Based on this, the purpose of the present invention is to provide a method and system for detecting fecal samples using microscopic images based on morphological prior constraints, in order to solve the problem that most existing technologies can only be adapted to simple image scenes, while fecal samples have complex inherent matrices and cluttered backgrounds, which easily leads to large-scale false detections and missed detections.
[0006] The first aspect of the present invention proposes:
[0007] A method for detecting fecal samples using microscopic images based on morphological prior constraints, wherein the method includes:
[0008] The collected fecal sample microscopic images are subjected to global background decoupling processing based on fecal matrix priors to separate the global background region and potential target candidate region. The potential target candidate region is subjected to multi-dimensional target perception enhancement processing to generate enhanced candidate region feature maps. Simultaneously, a prior knowledge base of fecal morphology is constructed to generate a standardized set of category morphological constraint parameters.
[0009] The enhanced candidate region feature map is input into a preset category-constrained dual-branch instance segmentation network. The category morphological constraint parameter set is used as the hard constraint condition for network inference. The accurate semantic segmentation of foreground and background and the instance boundary splitting of the adhered target are completed simultaneously to generate the initial instance mask set corresponding to each independent formed element.
[0010] The initial instance mask set is subjected to closed-loop verification of mask integrity and category consistency. The mask regions that fail the verification are iteratively optimized and corrected to generate an instance segmentation map. Simultaneously, each independent mask region in the instance segmentation map is spatially located and attribute-labeled.
[0011] Based on the attribute labeling results, multi-dimensional feature extraction and sub-category identification are performed on each independent mask region to complete the quantitative counting and qualitative analysis of the corresponding formed elements, and the corresponding fecal sample test report is generated simultaneously.
[0012] The beneficial effects of this invention are as follows: By using global background decoupling processing based on fecal matrix priors, complex background interference is removed from the source, and potential target areas are locked, significantly reducing the risk of false detection caused by background noise; by combining multi-dimensional feature enhancement of target perception with a prior knowledge base of fecal formed elements morphology, the target feature recognition is strengthened, providing standardized category morphological hard constraints for detection, thus making up for the shortcomings of existing technologies in adapting to complex sample scenarios; through a category-constrained dual-branch instance segmentation network, accurate semantic segmentation of foreground and background and instance boundary splitting of adhered targets are achieved simultaneously, solving the problem of missed detection caused by target adhesion and stacking; and further ensuring detection accuracy through closed-loop verification and iterative optimization, ultimately achieving accurate qualitative identification and quantitative counting of fecal formed elements.
[0013] Furthermore, the step of performing global background decoupling processing on the collected fecal sample microscopic images based on fecal matrix priors to separate the global background region and potential target candidate regions includes:
[0014] The fecal sample microscopic image was preprocessed with grayscale normalization and noise filtering, and the global texture entropy distribution and grayscale histogram distribution of the preprocessed image were calculated.
[0015] Based on the pre-calibrated gray-level prior range of fecal matrix and texture entropy threshold, regions with gray-level values falling within the matrix prior range and texture entropy values below the threshold are classified as global background regions, and the remaining regions are classified as initial candidate regions.
[0016] Morphological operations are performed on the initial candidate regions to remove isolated noise points, and a region growing algorithm is used to complete discontinuous regions to obtain the potential target candidate regions.
[0017] Furthermore, the category-constrained dual-branch instance segmentation network includes a shared encoding layer, a semantic segmentation branch, and an instance boundary regression branch;
[0018] The shared coding layer is used to perform multi-scale deep feature extraction on the input enhanced candidate region feature map to output a shared deep feature map, which is then input to the semantic segmentation branch and the instance boundary regression branch respectively.
[0019] The semantic segmentation branch is used to perform pixel-level classification on the shared deep feature map to distinguish between foreground formed pixels and background impurity pixels, and simultaneously outputs a foreground semantic segmentation mask.
[0020] The instance boundary regression branch is used to enhance the boundary features and predict the contours of the shared deep feature map in order to identify weak boundaries between adhered targets and simultaneously output instance boundary contour maps of each independent target.
[0021] In the process of network inference, the foreground semantic segmentation mask is used as a basis, and the instance boundary contour map is combined to complete the splitting of the sticky targets, so as to generate an initial instance mask set for each independent formed element.
[0022] Furthermore, during the training and inference process of the category-constrained dual-branch instance segmentation network, a multi-task weighted loss function is used for optimization. The multi-task weighted loss function includes the cross-entropy loss of the semantic segmentation branch, the Dice loss of the instance boundary regression branch, and the morphological constraint penalty loss.
[0023] The morphological constraint penalty loss is calculated based on the deviation between the morphological parameters corresponding to the initial instance mask set and the category morphological constraint parameter set. The morphological parameters include the area, roundness, aspect ratio, and contour smoothness of the region.
[0024] When the predicted morphological parameters exceed the constraint range of the corresponding category, the morphological constraint penalty loss increases linearly with the increase of the deviation value, thereby constraining the network output to a segmentation result that conforms to the morphological laws of fecal formed elements.
[0025] Furthermore, the step of performing closed-loop verification of mask integrity and category consistency on the initial instance mask set, and iteratively optimizing and correcting mask regions that fail the verification, includes:
[0026] For each single instance mask in the initial instance mask set, calculate its region connectivity, outline integrity and area ratio, and mark masks with outline breaks, region fragmentation, or areas exceeding the category constraint range as unqualified masks.
[0027] For a single instance mask that passes the integrity check, the shallow features of its corresponding image region are extracted and matched with the standard category features in the prior knowledge base of the morphology of the formed elements of feces. If the matching degree of the category with the highest matching degree is lower than the matching degree of the mask morphology parameters, it is marked as an unqualified mask.
[0028] For the image region corresponding to the unqualified mask, multi-dimensional enhancement and network inference are performed again, and the morphological constraint weights of the network inference are adjusted to complete the iterative optimization and correction of the mask until it passes the closed-loop verification.
[0029] Furthermore, the step of performing multi-dimensional feature extraction and subdivision category identification on each independent mask region based on the attribute labeling results includes:
[0030] Based on the spatial localization results of the attribute tags, the ROIs of each independent mask region in the instance segmentation map are cropped to obtain the local images of each individual target.
[0031] Multi-dimensional feature extraction is performed on each of the local images to obtain a comprehensive feature set including morphological features, texture features, grayscale features, and optical density features;
[0032] The comprehensive feature set is input into a pre-trained sub-category classifier, and matched and identified in combination with the standard category feature library in the prior knowledge base of fecal formed element morphology, so as to output the sub-category results corresponding to each target. The sub-category results include red blood cells, white blood cells, macrophages, parasite eggs, fungi, crystals, and food residues.
[0033] Furthermore, in the step of outputting the subcategories corresponding to each target, a category matching threshold is set. Targets whose highest matching degree between the comprehensive feature set and the standard category feature library is lower than the category matching threshold are marked as suspicious abnormal targets and specially marked in the fecal sample test report. The local image and feature parameters corresponding to the suspicious abnormal targets are output simultaneously to prompt the inspectors to conduct manual review.
[0034] The second aspect of the present invention proposes:
[0035] A fecal sample detection system based on morphological prior constraints, wherein the system comprises:
[0036] The decoupling module is used to perform global background decoupling processing on the collected fecal sample microscopic images based on fecal matrix priors, separating the global background region and potential target candidate regions. The potential target candidate regions are then subjected to multi-dimensional enhancement processing for target perception to generate enhanced candidate region feature maps. At the same time, a fecal morphological prior knowledge base is pre-constructed to generate a standardized set of category morphological constraint parameters.
[0037] The segmentation module is used to input the enhanced candidate region feature map into a preset category-constrained dual-branch instance segmentation network, using the category morphological constraint parameter set as the hard constraint condition for network inference, and simultaneously complete the accurate semantic segmentation of foreground and background and the instance boundary splitting of the adhered target, generating an initial instance mask set corresponding to each independent formed element.
[0038] The correction module is used to perform closed-loop verification of the mask integrity and category consistency of the initial instance mask set, iteratively optimize and correct mask regions that fail the verification, and generate an instance segmentation map; at the same time, it performs spatial positioning and attribute labeling on each independent mask region in the instance segmentation map.
[0039] The output module is used to perform multi-dimensional feature extraction and subdivision category identification on each independent mask region based on the attribute labeling results, complete the quantitative counting and qualitative analysis of the corresponding formed elements, and generate the corresponding fecal sample test report.
[0040] Furthermore, the decoupling module is specifically used for:
[0041] The fecal sample microscopic image was preprocessed with grayscale normalization and noise filtering, and the global texture entropy distribution and grayscale histogram distribution of the preprocessed image were calculated.
[0042] Based on the pre-calibrated gray-level prior range of fecal matrix and texture entropy threshold, regions with gray-level values falling within the matrix prior range and texture entropy values below the threshold are classified as global background regions, and the remaining regions are classified as initial candidate regions.
[0043] Morphological operations are performed on the initial candidate regions to remove isolated noise points, and a region growing algorithm is used to complete discontinuous regions to obtain the potential target candidate regions.
[0044] Furthermore, the category-constrained dual-branch instance segmentation network includes a shared encoding layer, a semantic segmentation branch, and an instance boundary regression branch;
[0045] The shared coding layer is used to perform multi-scale deep feature extraction on the input enhanced candidate region feature map to output a shared deep feature map, which is then input to the semantic segmentation branch and the instance boundary regression branch respectively.
[0046] The semantic segmentation branch is used to perform pixel-level classification on the shared deep feature map to distinguish between foreground formed pixels and background impurity pixels, and simultaneously outputs a foreground semantic segmentation mask.
[0047] The instance boundary regression branch is used to enhance the boundary features and predict the contours of the shared deep feature map in order to identify weak boundaries between adhered targets and simultaneously output instance boundary contour maps of each independent target.
[0048] In the process of network inference, the foreground semantic segmentation mask is used as a basis, and the instance boundary contour map is combined to complete the splitting of the sticky targets, so as to generate an initial instance mask set for each independent formed element.
[0049] Furthermore, during the training and inference process of the category-constrained dual-branch instance segmentation network, a multi-task weighted loss function is used for optimization. The multi-task weighted loss function includes the cross-entropy loss of the semantic segmentation branch, the Dice loss of the instance boundary regression branch, and the morphological constraint penalty loss.
[0050] The morphological constraint penalty loss is calculated based on the deviation between the morphological parameters corresponding to the initial instance mask set and the category morphological constraint parameter set. The morphological parameters include the area, roundness, aspect ratio, and contour smoothness of the region.
[0051] When the predicted morphological parameters exceed the constraint range of the corresponding category, the morphological constraint penalty loss increases linearly with the increase of the deviation value, thereby constraining the network output to a segmentation result that conforms to the morphological laws of fecal formed elements.
[0052] Furthermore, the correction module is specifically used for:
[0053] For each single instance mask in the initial instance mask set, calculate its region connectivity, outline integrity and area ratio, and mark masks with outline breaks, region fragmentation, or areas exceeding the category constraint range as unqualified masks.
[0054] For a single instance mask that passes the integrity check, the shallow features of its corresponding image region are extracted and matched with the standard category features in the prior knowledge base of the morphology of the formed elements of feces. If the matching degree of the category with the highest matching degree is lower than the matching degree of the mask morphology parameters, it is marked as an unqualified mask.
[0055] For the image region corresponding to the unqualified mask, multi-dimensional enhancement and network inference are performed again, and the morphological constraint weights of the network inference are adjusted to complete the iterative optimization and correction of the mask until it passes the closed-loop verification.
[0056] Furthermore, the output module is specifically used for:
[0057] Based on the spatial localization results of the attribute tags, the ROIs of each independent mask region in the instance segmentation map are cropped to obtain the local images of each individual target.
[0058] Multi-dimensional feature extraction is performed on each of the local images to obtain a comprehensive feature set including morphological features, texture features, grayscale features, and optical density features;
[0059] The comprehensive feature set is input into a pre-trained sub-category classifier, and matched and identified in combination with the standard category feature library in the prior knowledge base of fecal formed element morphology, so as to output the sub-category results corresponding to each target. The sub-category results include red blood cells, white blood cells, macrophages, parasite eggs, fungi, crystals, and food residues.
[0060] Furthermore, in the step of outputting the subcategories corresponding to each target, a category matching threshold is set. Targets whose highest matching degree between the comprehensive feature set and the standard category feature library is lower than the category matching threshold are marked as suspicious abnormal targets and specially marked in the fecal sample test report. The local image and feature parameters corresponding to the suspicious abnormal targets are output simultaneously to prompt the inspectors to conduct manual review.
[0061] The third aspect of the present invention proposes:
[0062] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the fecal sample microscopic image detection method based on morphological prior constraints as described above.
[0063] The fourth aspect of the present invention proposes:
[0064] A computer-readable storage medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the above-described method for detecting fecal samples using microscopic images based on morphological prior constraints.
[0065] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0066] Figure 1 A flowchart of a fecal sample microscopic image detection method based on morphological prior constraints provided in the first embodiment of the present invention;
[0067] Figure 2 This is a structural block diagram of a fecal sample microscopic image detection system based on morphological prior constraints provided in the third embodiment of the present invention.
[0068] The following detailed description, in conjunction with the accompanying drawings, will further illustrate the present invention. Detailed Implementation
[0069] To facilitate understanding of the present invention, a more complete description will be given below with reference to the accompanying drawings. Several embodiments of the invention are illustrated in the drawings. However, the invention can be implemented in many different forms and is not limited to the embodiments described herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete.
[0070] It should be noted that when a component is said to be "fixed to" another component, it can be directly on the other component or there may be an intervening component. When a component is said to be "connected to" another component, it can be directly connected to the other component or there may be an intervening component. The terms "vertical," "horizontal," "left," "right," and similar expressions used in this document are for illustrative purposes only.
[0071] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.
[0072] Please see Figure 1 The image shows a fecal sample microscopic image detection method based on morphological prior constraints provided in the first embodiment of the present invention. The fecal sample microscopic image detection method based on morphological prior constraints provided in this embodiment can ultimately achieve accurate qualitative identification and quantitative counting of formed elements in feces, and can simultaneously generate standardized detection reports. The entire process greatly improves the accuracy, stability and adaptability of fecal microscopic detection, and provides reliable technical support for the intelligent and standardized detection of fecal samples.
[0073] Specifically, this embodiment provides:
[0074] A method for detecting fecal samples using microscopic images based on morphological prior constraints, wherein the method includes:
[0075] Step S10: Perform global background decoupling processing based on fecal matrix prior on the collected fecal sample microscopic image to separate the global background region and potential target candidate region. Perform multi-dimensional enhancement processing of target perception on the potential target candidate region to generate enhanced candidate region feature map. Simultaneously construct a prior knowledge base of fecal morphology to generate a standardized set of category morphological constraint parameters.
[0076] It is important to note that the core source of interference in fecal microscopic images is the fecal matrix background, which accounts for over 90%. The grayscale and texture characteristics of this matrix have clear clinical prior rules and are fundamentally different from the formed elements to be detected, such as red blood cells, white blood cells, and parasite eggs. Traditional detection methods directly process the entire image, which is not only computationally inefficient but also easily interfered with by matrix impurities, leading to a large number of false positives. At the same time, the formed elements of feces all follow clear morphological rules in clinical laboratory science. Different categories of targets have fixed and reasonable ranges in dimensions such as area, roundness, aspect ratio, and contour features. This is the core basis for distinguishing targets from impurities and determining the category of targets. This step first decouples and separates most of the meaningless matrix background from the potential target area based on the prior characteristics of the fecal matrix, significantly reducing the scope of subsequent processing. At the same time, it enhances the target perception of potential target areas in multiple dimensions, highlighting the characteristics of weak contrast targets and targets with blurred edges, and avoiding the missed detection of low-contrast formed elements. Simultaneously, based on industry standards for clinical fecal examination and a large amount of labeled data, it constructs a morphological prior knowledge base for fecal formed elements, generating a standardized set of category morphological constraint parameters. This provides hard constraints and judgment benchmarks throughout the entire process for subsequent network inference, result verification, and category recognition, integrating clinical prior knowledge into the entire testing process from the source.
[0077] Step S20: Input the enhanced candidate region feature map into a preset category-constrained dual-branch instance segmentation network, and use the category morphological constraint parameter set as the hard constraint condition for network inference to simultaneously complete the accurate semantic segmentation of foreground-background and the instance boundary splitting of the adhered target, so as to generate an initial instance mask set corresponding to each independent formed element.
[0078] It should be noted that there are two major technical challenges in the detection of formed elements in feces: first, it is difficult to distinguish the foreground from the background of weak contrast targets and matrix-encapsulated targets; second, it is difficult to separate instances of clustered red blood cells, white blood cells, crystals and other adherent targets. Traditional single-branch instance segmentation networks cannot simultaneously meet these two requirements, and are prone to problems such as missed foreground detection and inability to separate adherent targets. This step employs a dual-branch network structure, using the category morphological constraint parameter set from the prior knowledge base as a hard constraint for network inference. One branch is dedicated to pixel-level foreground-background semantic segmentation, accurately distinguishing formed element pixels from background impurity pixels to address the "whether there is a target" problem. The other branch is dedicated to enhancing the boundary features of adhered targets and predicting instance contours, identifying weak boundaries between adhered targets to address the "how many targets are there, and where are the boundaries of each target" problem. Simultaneously, the morphological constraint parameter set serves as a hard constraint, ensuring that the segmentation results output by the network must conform to the morphological rules of the corresponding category of formed elements, avoiding erroneous results that are morphologically strange or inconsistent with clinical understanding. Ultimately, it generates an initial instance mask set corresponding to each independent formed element, providing a foundation for subsequent result verification and category recognition.
[0079] Step S30: Perform closed-loop verification of mask integrity and category consistency on the initial instance mask set, iteratively optimize and correct mask regions that fail the verification, so as to generate an instance segmentation map, and simultaneously perform spatial positioning and attribute labeling on each independent mask region in the instance segmentation map.
[0080] It should be noted that even with morphologically constrained network inference, substandard segmentation results may still occur due to issues such as target overlap, blurred edges, and matrix encapsulation. These substandard masks may result in broken mask contours, fragmented regions, or mismatches between morphological parameters and category features. Such substandard masks will directly lead to subsequent category recognition errors and counting biases. This step performs a dual closed-loop verification on the initial instance mask set. The first layer is mask integrity verification, which determines whether the connectivity, contour integrity, and morphological parameters of each single instance mask conform to the prior constraints. The second layer is category consistency verification, which determines whether the mask features match the standard features of the corresponding category in the prior knowledge base. The mask regions that fail the dual verification are iteratively optimized by adjusting the morphological constraint weights and reinforcing the inference, correcting segmentation errors, and finally generating a high-quality instance segmentation map. At the same time, each independent mask region in the map is spatially located and its attributes are labeled to clarify the position, contour, and basic morphological parameters of each target in the original image, providing accurate localization basis for subsequent single-target feature extraction and category recognition.
[0081] Step S40: Based on the attribute labeling results, perform multi-dimensional feature extraction and subdivision category identification on each independent mask region to complete the quantitative counting and qualitative analysis of the corresponding formed elements, and simultaneously generate the corresponding fecal sample test report.
[0082] It is important to note that the ultimate goal of routine clinical stool examination is to achieve qualitative identification (determining the composition) and quantitative counting (counting the quantity of each category) of formed elements, providing a basis for the diagnosis of digestive tract diseases. This step, based on the previously completed spatial localization and attribute labeling, performs multi-dimensional feature extraction on a single target within each independent masked region, comprehensively capturing the core distinguishing features of different categories of formed elements. This is then combined with standard category features from a prior knowledge base to complete sub-category identification, accurately distinguishing core clinical indicators such as red blood cells, white blood cells, parasite eggs, and crystals. Based on the identification results, quantitative counting of each category of formed elements is performed, and qualitative analysis is completed in accordance with clinical testing standards. Finally, a stool sample test report that meets clinical requirements is generated, completing the automated closed-loop detection of the entire stool microscopic image.
[0083] Second Embodiment
[0084] Furthermore, the step of performing global background decoupling processing on the collected fecal sample microscopic images based on fecal matrix priors to separate the global background region and potential target candidate regions includes:
[0085] The fecal sample microscopic image was preprocessed with grayscale normalization and noise filtering, and the global texture entropy distribution and grayscale histogram distribution of the preprocessed image were calculated.
[0086] Based on the pre-calibrated gray-level prior range of fecal matrix and texture entropy threshold, regions with gray-level values falling within the matrix prior range and texture entropy values below the threshold are classified as global background regions, and the remaining regions are classified as initial candidate regions.
[0087] Morphological operations are performed on the initial candidate regions to remove isolated noise points, and a region growing algorithm is used to complete discontinuous regions to obtain the potential target candidate regions.
[0088] It should be noted that clinically acquired fecal microscopic images can vary in brightness and contrast due to differences in microscope type, light source brightness, acquisition focal length, and fecal sample concentration. Additionally, lens dust, salt-and-pepper noise generated during acquisition, and Gaussian noise can all contribute to interference, directly affecting the accuracy of subsequent background-target differentiation. This step first uses grayscale normalization to map the grayscale values of images acquired under different conditions to a uniform 0-255 range, eliminating interference from brightness differences. Then, median filtering and Gaussian filtering are used to filter out image noise while preserving the edge features of the target. Subsequently, the global texture entropy distribution and grayscale histogram distribution of the preprocessed image are calculated. The texture entropy value reflects the textural complexity of the image region; the fecal matrix region has a uniform texture and extremely low entropy value, while the formed element region has a clear structural texture and higher entropy value. The grayscale histogram reflects the pixel distribution of different grayscale values in the image, providing a quantitative basis for subsequent matrix-based region segmentation.
[0089] After extensive pre-calibration of clinical samples, the grayscale and texture entropy values of fecal matrix exhibit fixed and reproducible prior ranges. This is the core basis for distinguishing matrix background from formed elements. Traditional global threshold segmentation methods divide background and foreground solely based on a single grayscale value, easily misclassifying weak-contrast formed elements with grayscale values close to the matrix as background, or misclassifying complex matrix impurities as foreground. This step employs dual prior constraints of grayscale and texture entropy values. Only regions that simultaneously meet the conditions of "grayscale value falling within the matrix prior range" and "texture entropy value below the threshold" are classified as global background regions. The remaining regions are classified as initial candidate regions. This avoids missing weak-contrast formed elements and eliminates uniform matrix background to the greatest extent possible, compressing the area to be processed to less than 10% of the original image, significantly improving the efficiency and accuracy of subsequent processing.
[0090] In the initial candidate region, there will still be some isolated, tiny noise points and matrix debris. Meanwhile, some formed elements with uneven internal gray levels (such as white blood cells containing particles or parasite eggs containing contents) will be missegmented into multiple discontinuous small regions, affecting subsequent target recognition. This step first uses morphological operations such as opening and closing operations to remove isolated tiny noise points in the initial candidate region, smoothing the target's edge contours while preserving the overall shape of the target. Then, a region growing algorithm is used, with the core pixels in the initial candidate region as seed points, and based on growth criteria of gray-level similarity and texture similarity, to complete discontinuous regions within the same target, merging scattered regions originally belonging to the same formed element into complete connected regions. Finally, a potential target candidate region with complete contours and no redundant noise is obtained, providing high-quality input for subsequent feature enhancement and network inference.
[0091] Furthermore, the category-constrained dual-branch instance segmentation network includes a shared encoding layer, a semantic segmentation branch, and an instance boundary regression branch;
[0092] The shared coding layer is used to perform multi-scale deep feature extraction on the input enhanced candidate region feature map to output a shared deep feature map, which is then input to the semantic segmentation branch and the instance boundary regression branch respectively.
[0093] The semantic segmentation branch is used to perform pixel-level classification on the shared deep feature map to distinguish between foreground formed pixels and background impurity pixels, and simultaneously outputs a foreground semantic segmentation mask.
[0094] The instance boundary regression branch is used to enhance the boundary features and predict the contours of the shared deep feature map in order to identify weak boundaries between adhered targets and simultaneously output instance boundary contour maps of each independent target.
[0095] In the process of network inference, the foreground semantic segmentation mask is used as a basis, and the instance boundary contour map is combined to complete the splitting of the sticky targets, so as to generate an initial instance mask set for each independent formed element.
[0096] It should be noted that the formed elements in fecal microscopic images vary greatly in size. Large targets, such as parasite eggs, can reach hundreds of micrometers in diameter, while small targets, such as bacteria and microcrystals, are only a few micrometers in diameter. Single-scale feature extraction cannot simultaneously capture the overall features of large targets and the detailed features of small targets. The shared coding layer adopts a multi-scale convolutional structure and residual connection design. Through downsampling and feature fusion, it extracts multi-scale deep features from the input feature map, capturing both the global contour features of large targets and preserving the detailed texture features of small targets. The output shared deep feature map has both multi-scale characteristics and strong semantic expressive power, providing a unified and high-quality feature input for both branches, avoiding the computational redundancy and feature inconsistency problems caused by separate feature extraction by the two branches.
[0097] The core objective of the semantic segmentation branch is to solve the binary classification problem of "which pixels belong to formed elements". This branch uses an upsampling structure and skip connections to restore the shared deep feature map to the same resolution as the input image. It performs foreground-background binary classification on each pixel, accurately distinguishing foreground pixels of formed elements from the remaining background noise pixels. Finally, it outputs a foreground semantic segmentation mask, which clarifies the pixel range of all potential formed elements and completely removes the remaining background noise interference, providing a pixel-level foundation for subsequent instance splitting.
[0098] To address the common problem of target adhesion in fecal microscopy images, traditional instance segmentation methods easily misidentify multiple adhered targets as a single entity, leading to counting errors and classification bias. The core objective of the instance boundary regression branch is to solve the problem of separating the boundaries of adhered targets. This branch specifically uses reinforcement learning to target edge features, amplifying the weak boundary features between adhered targets through a boundary attention mechanism. It accurately predicts the complete contour of each independent target, identifies the segmentation boundaries between different targets, and finally outputs instance boundary contour maps of each independent target, providing clear boundary criteria for separating adhered targets.
[0099] During the inference process, the overall pixel range of all formed elements is first determined by the foreground semantic segmentation mask. Then, based on the independent target boundaries in the instance boundary contour map, the adhered foreground regions are split, and the overall foreground mask is divided into single instance masks corresponding to each independent formed element. At the same time, the above-mentioned category morphological constraint parameter set is used as a hard constraint to ensure that each single instance mask after splitting conforms to the morphological rules of the corresponding category of formed elements. Finally, a complete initial instance mask set is generated, realizing the simultaneous completion of foreground and background differentiation and adhered target splitting, which is perfectly adapted to the complex scene of fecal microscopic images.
[0100] Furthermore, during the training and inference process of the category-constrained dual-branch instance segmentation network, a multi-task weighted loss function is used for optimization. The multi-task weighted loss function includes the cross-entropy loss of the semantic segmentation branch, the Dice loss of the instance boundary regression branch, and the morphological constraint penalty loss.
[0101] The morphological constraint penalty loss is calculated based on the deviation between the morphological parameters corresponding to the initial instance mask set and the category morphological constraint parameter set. The morphological parameters include the area, roundness, aspect ratio, and contour smoothness of the region.
[0102] When the predicted morphological parameters exceed the constraint range of the corresponding category, the morphological constraint penalty loss increases linearly with the increase of the deviation value, thereby constraining the network output to a segmentation result that conforms to the morphological laws of fecal formed elements.
[0103] It should be noted that, firstly, the cross-entropy loss of the semantic segmentation branch is optimized for the pixel-level binary classification task of the semantic segmentation branch. The cross-entropy loss can accurately measure the difference between the pixel classification result predicted by the network and the actual annotation result. By minimizing the cross-entropy loss, the classification accuracy of the semantic segmentation branch for foreground formed pixels and background impurity pixels is improved, avoiding missed detection of foreground pixels and misjudgment of background pixels, and ensuring the accuracy of the foreground semantic segmentation mask.
[0104] The Dice loss of the instance boundary regression branch is optimized for the task of predicting the contour of instance boundaries. In fecal microscopic images, the proportion of foreground pixels of formed elements is much lower than that of background pixels, resulting in a serious foreground-background pixel imbalance problem. Traditional cross-entropy loss is prone to optimization bias in this scenario. However, the Dice loss is calculated based on the intersection-union ratio of the predicted region and the ground truth labeled region. It is not sensitive to the pixel imbalance problem and can effectively focus on the contour prediction accuracy of the foreground target. By minimizing the Dice loss, the prediction accuracy of the instance boundary regression branch for the target contour, especially the weak boundary between adhered targets, is improved, ensuring the accuracy of the instance boundary contour map.
[0105] Traditional instance segmentation loss functions focus only on pixel-level segmentation accuracy, neglecting whether the segmented targets conform to clinical morphological patterns. This easily leads to problems such as segmenting multiple adhered red blood cells into a single elongated abnormal target, or segmenting fragmented crystals with broken outlines into multiple fragmented targets. Even if such segmentation results are accurate at the pixel level, they do not conform to clinical understanding and directly cause subsequent classification and counting errors. This morphological constraint penalty loss uses the category morphological constraint parameter set in the prior knowledge base as a benchmark. It calculates the deviation between the morphological parameters of the initial instance mask predicted by the network and the corresponding category standard parameters. When the predicted morphological parameters exceed the constraint range of the corresponding category, the morphological constraint penalty loss increases linearly with the increase of the deviation value. This penalizes segmentation results that do not conform to morphological patterns, forcing the network to adjust the segmentation boundary, correcting the segmentation errors of adhered targets and outline prediction errors, and outputting segmentation results that conform to the morphological patterns of formed elements in feces. During network training, through the collaborative optimization of multi-task weighted loss functions, the pixel classification accuracy, boundary prediction accuracy, and morphological rationality of the network are simultaneously improved, allowing the network to not only "segment accurately" but also "segment correctly," fully meeting the morphological requirements of clinical testing.
[0106] Furthermore, the step of performing closed-loop verification of mask integrity and category consistency on the initial instance mask set, and iteratively optimizing and correcting mask regions that fail the verification, includes:
[0107] For each single instance mask in the initial instance mask set, calculate its region connectivity, outline integrity and area ratio, and mark masks with outline breaks, region fragmentation, or areas exceeding the category constraint range as unqualified masks.
[0108] For a single instance mask that passes the integrity check, the shallow features of its corresponding image region are extracted and matched with the standard category features in the prior knowledge base of the morphology of the formed elements of feces. If the matching degree of the category with the highest matching degree is lower than the matching degree of the mask morphology parameters, it is marked as an unqualified mask.
[0109] For the image region corresponding to the unqualified mask, multi-dimensional enhancement and network inference are performed again, and the morphological constraint weights of the network inference are adjusted to complete the iterative optimization and correction of the mask until it passes the closed-loop verification.
[0110] It's important to note that this step verifies the integrity of the mask, serving as the first quality checkpoint for the segmentation results. Formed components in clinical fecal samples are all complete connected domains. If the segmented mask exhibits contour breaks or regional fragmentation, it indicates incorrect edge segmentation of the target. If the area exceeds the prior constraints of the corresponding category, it suggests multiple adhered targets were not separated, or background impurities were mistakenly segmented as targets. This step determines whether the mask is a single, complete connected domain by calculating the regional connectivity of each individual instance mask; it determines whether the contour is broken by calculating the contour closure and smoothness; and it determines whether the area complies with the area range in the category morphological constraint parameter set. Masks exhibiting any of the above problems are marked as unqualified masks, accurately locating the erroneously segmented regions.
[0111] While some masks may be morphologically complete and have compliant areas, their features may not match the categories corresponding to their morphological parameters. For example, a mask might meet the roundness and area requirements of red blood cells, but its texture features might have a very low match with the standard features of red blood cells in the prior knowledge base, instead resembling crystallization features. Such masks can lead to subsequent category recognition errors. This step extracts shallow features such as grayscale, texture, and edges of the corresponding image regions from masks that pass the integrity check. These features are then matched with the standard category features in the prior knowledge base. If the category with the highest matching degree has a matching degree lower than a preset threshold with the standard category corresponding to the mask's morphological parameters, it indicates a mismatch between the mask's morphological and semantic features, resulting in an error in the segmentation. This mask is then marked as an unqualified mask, and regions with hidden segmentation errors are further filtered out.
[0112] For the identified unqualified masks, this step does not directly discard or forcibly correct them. Instead, it returns to the corresponding original image region and performs targeted multi-dimensional feature enhancement to highlight the edge and texture features of the region. The resulting image is then input into the dual-branch instance segmentation network for re-inference. Simultaneously, based on the reason for the unqualification, the morphological constraint weights of the network inference are dynamically adjusted. For example, for masks with broken contours, the constraint weights of contour smoothness are increased; for masks with stuck and unseparated contours, the constraint weights of area and roundness are increased; and for masks with mismatched categories, the constraint weights of category feature matching are increased. Through multiple rounds of iterative optimization, segmentation errors are corrected until the masks pass the dual closed-loop verification of integrity and category consistency. Finally, a high-quality instance segmentation map with all masks compliant is generated, providing an absolutely reliable foundation for subsequent category recognition and counting.
[0113] Furthermore, the step of performing multi-dimensional feature extraction and subdivision category identification on each independent mask region based on the attribute labeling results includes:
[0114] Based on the spatial localization results of the attribute tags, the ROIs of each independent mask region in the instance segmentation map are cropped to obtain the local images of each individual target.
[0115] Multi-dimensional feature extraction is performed on each of the local images to obtain a comprehensive feature set including morphological features, texture features, grayscale features, and optical density features;
[0116] The comprehensive feature set is input into a pre-trained sub-category classifier, and matched and identified in combination with the standard category feature library in the prior knowledge base of fecal formed element morphology, so as to output the sub-category results corresponding to each target. The sub-category results include red blood cells, white blood cells, macrophages, parasite eggs, fungi, crystals, and food residues.
[0117] It should be noted that, after the previous closed-loop verification, each independent mask region in the instance segmentation map corresponds to a complete formed element, and has already completed accurate spatial localization and attribute labeling. Based on the spatial localization results, this step performs region of interest (ROI) cropping on each independent mask region, accurately extracting a local image containing only a single target, completely eliminating interference from the background and other targets, so that subsequent feature extraction focuses only on the target to be identified, avoiding interference from irrelevant regions, and ensuring the purity and accuracy of the feature data.
[0118] Identifying the types of formed elements in feces requires a multi-dimensional assessment based on characteristics. Relying on a single characteristic can easily lead to misjudgment. For example, red blood cells and fungal spores are similar in shape and size and cannot be distinguished by morphological characteristics alone, but their internal texture and refractive properties are fundamentally different. Macrophages and large white blood cells are similar in size, but their internal granular texture and nuclear type are completely different. This step extracts features from the local image of each single target in four core dimensions: First, morphological features, including parameters such as the target's area, perimeter, roundness, aspect ratio, contour smoothness, and solidity, corresponding to the category morphological constraint parameters in the prior knowledge base, which are the basic features for distinguishing different categories of targets; second, texture features, including parameters such as gray-level co-occurrence matrix, entropy value, contrast, and correlation, capturing the differences in the internal texture structure of the target, which are the core features for distinguishing cells, crystals, and parasite eggs; third, gray-level features, including parameters such as average gray level, gray-level variance, maximum gray level, and minimum gray level, reflecting the overall brightness and gray-level distribution differences of the target; and fourth, optical density features, including parameters such as integral optical density and average optical density, reflecting the refractive index and internal material density differences of the target, which are the key features for distinguishing highly refractive crystals and fungi from weakly refractive cells. These four dimensions of features together constitute a comprehensive feature set, fully covering the core identification points of different categories of formed elements, providing sufficient feature basis for subsequent accurate classification.
[0119] The pre-trained sub-classifier is trained on a large number of clinically labeled formed fecal samples. It can accurately classify targets based on the comprehensive feature set of the input. At the same time, it combines the standard category feature library in the prior knowledge base for secondary matching and verification to further improve the accuracy of classification. The final output sub-classification results cover all the core detection indicators in routine clinical fecal examination. Among them, red blood cells are the core diagnostic indicator of gastrointestinal bleeding, white blood cells and macrophages are the core indicators of gastrointestinal inflammation and infection, parasite eggs are the basis for confirming parasitic infection, and fungi, crystals, and food residues can provide diagnostic references for intestinal flora imbalance, indigestion, and crystal-related diseases. The accurate sub-classification identification results provide the core basis for subsequent quantitative counting and clinical diagnosis.
[0120] Furthermore, in the step of outputting the subcategories corresponding to each target, a category matching threshold is set. Targets whose highest matching degree between the comprehensive feature set and the standard category feature library is lower than the category matching threshold are marked as suspicious abnormal targets and specially marked in the fecal sample test report. The local image and feature parameters corresponding to the suspicious abnormal targets are output simultaneously to prompt the inspectors to conduct manual review.
[0121] It is important to note that clinical stool samples are extremely complex in composition. Besides the seven common formed elements, they may also contain rare parasite eggs, abnormal cells, atypical pathological components, and atypical targets with characteristics significantly different from the standard categories. The overall feature set of these targets has a very low match with the standard category feature library. If the classifier forcibly classifies them, serious misclassifications may occur, even missing crucial pathological abnormalities, posing a significant risk to clinical diagnosis. This step pre-sets a category matching threshold that conforms to clinical testing standards. Only when the highest match between the overall feature set and the standard category feature library exceeds the threshold is the corresponding sub-category result output. For targets with a highest match below the threshold, they are not forcibly classified but are marked as suspicious abnormalities. This mechanism avoids misclassification of unfamiliar abnormalities and eliminates false negative and false positive results.
[0122] For marked suspicious abnormal targets, this step prominently marks them in the final fecal sample test report. Simultaneously, it outputs the corresponding local microscopic image, multi-dimensional feature parameters, the three candidate categories with the highest matching degree, and their corresponding matching scores, providing comprehensive reference information for manual review by laboratory personnel. Based on the report's prompts, personnel can directly perform manual microscopic examination of suspicious abnormal targets to confirm their true category and determine whether they are rare pathological components. This design perfectly adapts to the actual workflow of clinical testing. It achieves rapid identification and counting of over 99% of routine targets through automated detection, significantly improving testing efficiency. Furthermore, the manual review prompts for suspicious targets safeguard the quality baseline of clinical testing, preventing the missed detection of rare and abnormal pathological targets. This allows the entire method to be truly implemented in clinical testing scenarios, meeting the safety and accuracy requirements of clinical diagnosis.
[0123] Please see Figure 2 The third embodiment of the present invention provides:
[0124] A fecal sample detection system based on morphological prior constraints, wherein the system comprises:
[0125] The decoupling module is used to perform global background decoupling processing on the collected fecal sample microscopic images based on fecal matrix priors, separating the global background region and potential target candidate regions. The potential target candidate regions are then subjected to multi-dimensional enhancement processing for target perception to generate enhanced candidate region feature maps. At the same time, a fecal morphological prior knowledge base is pre-constructed to generate a standardized set of category morphological constraint parameters.
[0126] The segmentation module is used to input the enhanced candidate region feature map into a preset category-constrained dual-branch instance segmentation network, using the category morphological constraint parameter set as the hard constraint condition for network inference, and simultaneously complete the accurate semantic segmentation of foreground and background and the instance boundary splitting of the adhered target, generating an initial instance mask set corresponding to each independent formed element.
[0127] The correction module is used to perform closed-loop verification of the mask integrity and category consistency of the initial instance mask set, iteratively optimize and correct mask regions that fail the verification, and generate an instance segmentation map; at the same time, it performs spatial positioning and attribute labeling on each independent mask region in the instance segmentation map.
[0128] The output module is used to perform multi-dimensional feature extraction and subdivision category identification on each independent mask region based on the attribute labeling results, complete the quantitative counting and qualitative analysis of the corresponding formed elements, and generate the corresponding fecal sample test report.
[0129] Furthermore, the decoupling module is specifically used for:
[0130] The fecal sample microscopic image was preprocessed with grayscale normalization and noise filtering, and the global texture entropy distribution and grayscale histogram distribution of the preprocessed image were calculated.
[0131] Based on the pre-calibrated gray-level prior range of fecal matrix and texture entropy threshold, regions with gray-level values falling within the matrix prior range and texture entropy values below the threshold are classified as global background regions, and the remaining regions are classified as initial candidate regions.
[0132] Morphological operations are performed on the initial candidate regions to remove isolated noise points, and a region growing algorithm is used to complete discontinuous regions to obtain the potential target candidate regions.
[0133] Furthermore, the category-constrained dual-branch instance segmentation network includes a shared encoding layer, a semantic segmentation branch, and an instance boundary regression branch;
[0134] The shared coding layer is used to perform multi-scale deep feature extraction on the input enhanced candidate region feature map to output a shared deep feature map, which is then input to the semantic segmentation branch and the instance boundary regression branch respectively.
[0135] The semantic segmentation branch is used to perform pixel-level classification on the shared deep feature map to distinguish between foreground formed pixels and background impurity pixels, and simultaneously outputs a foreground semantic segmentation mask.
[0136] The instance boundary regression branch is used to enhance the boundary features and predict the contours of the shared deep feature map in order to identify weak boundaries between adhered targets and simultaneously output instance boundary contour maps of each independent target.
[0137] In the process of network inference, the foreground semantic segmentation mask is used as a basis, and the instance boundary contour map is combined to complete the splitting of the sticky targets, so as to generate an initial instance mask set for each independent formed element.
[0138] Furthermore, during the training and inference process of the category-constrained dual-branch instance segmentation network, a multi-task weighted loss function is used for optimization. The multi-task weighted loss function includes the cross-entropy loss of the semantic segmentation branch, the Dice loss of the instance boundary regression branch, and the morphological constraint penalty loss.
[0139] The morphological constraint penalty loss is calculated based on the deviation between the morphological parameters corresponding to the initial instance mask set and the category morphological constraint parameter set. The morphological parameters include the area, roundness, aspect ratio, and contour smoothness of the region.
[0140] When the predicted morphological parameters exceed the constraint range of the corresponding category, the morphological constraint penalty loss increases linearly with the increase of the deviation value, thereby constraining the network output to a segmentation result that conforms to the morphological laws of fecal formed elements.
[0141] Furthermore, the correction module is specifically used for:
[0142] For each single instance mask in the initial instance mask set, calculate its region connectivity, outline integrity and area ratio, and mark masks with outline breaks, region fragmentation, or areas exceeding the category constraint range as unqualified masks.
[0143] For a single instance mask that passes the integrity check, the shallow features of its corresponding image region are extracted and matched with the standard category features in the prior knowledge base of the morphology of the formed elements of feces. If the matching degree of the category with the highest matching degree is lower than the matching degree of the mask morphology parameters, it is marked as an unqualified mask.
[0144] For the image region corresponding to the unqualified mask, multi-dimensional enhancement and network inference are performed again, and the morphological constraint weights of the network inference are adjusted to complete the iterative optimization and correction of the mask until it passes the closed-loop verification.
[0145] Furthermore, the output module is specifically used for:
[0146] Based on the spatial localization results of the attribute tags, the ROIs of each independent mask region in the instance segmentation map are cropped to obtain the local images of each individual target.
[0147] Multi-dimensional feature extraction is performed on each of the local images to obtain a comprehensive feature set including morphological features, texture features, grayscale features, and optical density features;
[0148] The comprehensive feature set is input into a pre-trained sub-category classifier, and matched and identified in combination with the standard category feature library in the prior knowledge base of fecal formed element morphology, so as to output the sub-category results corresponding to each target. The sub-category results include red blood cells, white blood cells, macrophages, parasite eggs, fungi, crystals, and food residues.
[0149] Furthermore, in the step of outputting the subcategories corresponding to each target, a category matching threshold is set. Targets whose highest matching degree between the comprehensive feature set and the standard category feature library is lower than the category matching threshold are marked as suspicious abnormal targets and specially marked in the fecal sample test report. The local image and feature parameters corresponding to the suspicious abnormal targets are output simultaneously to prompt the inspectors to conduct manual review.
[0150] The fourth embodiment of the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the fecal sample microscopic image detection method based on morphological prior constraints as described above.
[0151] The fifth embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein when the program is executed by a processor, it implements the fecal sample microscopic image detection method based on morphological prior constraints as described above.
[0152] In summary, the fecal sample microscopic image detection method and system based on morphological prior constraints provided by the above embodiments of the present invention can ultimately achieve accurate qualitative identification and quantitative counting of formed elements in feces, and can simultaneously generate standardized detection reports. The entire process significantly improves the accuracy, stability and adaptability to complex scenarios of fecal microscopic detection, and provides reliable technical support for the intelligent and standardized detection of fecal samples.
[0153] It should be noted that the above modules can be functional modules or program modules, and can be implemented through software or hardware. For modules implemented through hardware, the above modules can reside in the same processor; or the above modules can be located in different processors in any combination.
[0154] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-including system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device.
[0155] More specific examples of computer-readable media (a non-exhaustive list) include: electrical connections (electronic devices) having one or more wires, portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.
[0156] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can 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, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0157] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0158] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the appended claims.
Claims
1. A method for detecting fecal samples using microscopic images based on morphological prior constraints, characterized in that, The method includes: The collected fecal sample microscopic images are subjected to global background decoupling processing based on fecal matrix priors to separate the global background region and potential target candidate region. The potential target candidate region is subjected to multi-dimensional target perception enhancement processing to generate enhanced candidate region feature maps. Simultaneously, a prior knowledge base of fecal morphology is constructed to generate a standardized set of category morphological constraint parameters. The enhanced candidate region feature map is input into a preset category-constrained dual-branch instance segmentation network. The category morphological constraint parameter set is used as the hard constraint condition for network inference. The accurate semantic segmentation of foreground and background and the instance boundary splitting of the adhered target are completed simultaneously to generate the initial instance mask set corresponding to each independent formed element. The initial instance mask set is subjected to closed-loop verification of mask integrity and category consistency. The mask regions that fail the verification are iteratively optimized and corrected to generate an instance segmentation map. Simultaneously, each independent mask region in the instance segmentation map is spatially located and attribute-labeled. Based on the attribute labeling results, multi-dimensional feature extraction and subdivision category identification are performed on each independent mask region to complete the quantitative counting and qualitative analysis of the corresponding formed elements, and the corresponding fecal sample test report is generated simultaneously. The category-constrained dual-branch instance segmentation network includes a shared encoding layer, a semantic segmentation branch, and an instance boundary regression branch; The shared coding layer is used to perform multi-scale deep feature extraction on the input enhanced candidate region feature map to output a shared deep feature map, which is then input to the semantic segmentation branch and the instance boundary regression branch respectively. The semantic segmentation branch is used to perform pixel-level classification on the shared deep feature map to distinguish between foreground formed pixels and background impurity pixels, and simultaneously outputs a foreground semantic segmentation mask. The instance boundary regression branch is used to enhance the boundary features and predict the contours of the shared deep feature map in order to identify weak boundaries between adhered targets and simultaneously output instance boundary contour maps of each independent target. In the process of network inference, the foreground semantic segmentation mask is used as a basis, and the instance boundary contour map is combined to complete the splitting of the sticky targets, so as to generate an initial instance mask set for each independent formed element.
2. The method for detecting fecal samples using microscopic images based on morphological prior constraints according to claim 1, characterized in that, The step of performing global background decoupling processing on the collected fecal sample microscopic images based on fecal matrix priors to separate the global background region and potential target candidate regions includes: The fecal sample microscopic image was preprocessed with grayscale normalization and noise filtering, and the global texture entropy distribution and grayscale histogram distribution of the preprocessed image were calculated. Based on the pre-calibrated gray-level prior range of fecal matrix and texture entropy threshold, regions with gray-level values falling within the matrix prior range and texture entropy values below the threshold are classified as global background regions, and the remaining regions are classified as initial candidate regions. Morphological operations are performed on the initial candidate regions to remove isolated noise points, and a region growing algorithm is used to complete discontinuous regions to obtain the potential target candidate regions.
3. The method for detecting fecal samples using microscopic images based on morphological prior constraints according to claim 1, characterized in that, During the training and inference process of the category-constrained dual-branch instance segmentation network, a multi-task weighted loss function is used for optimization. The multi-task weighted loss function includes the cross-entropy loss of the semantic segmentation branch, the Dice loss of the instance boundary regression branch, and the morphological constraint penalty loss. The morphological constraint penalty loss is calculated based on the deviation between the morphological parameters corresponding to the initial instance mask set and the category morphological constraint parameter set. The morphological parameters include the area, roundness, aspect ratio, and contour smoothness of the region. When the predicted morphological parameters exceed the constraint range of the corresponding category, the morphological constraint penalty loss increases linearly with the increase of the deviation value, thereby constraining the network output to a segmentation result that conforms to the morphological laws of fecal formed elements.
4. The method for detecting fecal samples using microscopic images based on morphological prior constraints according to claim 1, characterized in that, The steps of performing closed-loop verification of the initial instance mask set for mask integrity and category consistency, and iteratively optimizing and correcting mask regions that fail the verification, include: For each single instance mask in the initial instance mask set, calculate its region connectivity, outline integrity and area ratio, and mark masks with outline breaks, region fragmentation, or areas exceeding the category constraint range as unqualified masks. For a single instance mask that passes the integrity check, the shallow features of its corresponding image region are extracted and matched with the standard category features in the prior knowledge base of the morphology of the formed elements of feces. If the matching degree of the category with the highest matching degree is lower than the matching degree of the mask morphology parameters, it is marked as an unqualified mask. For the image region corresponding to the unqualified mask, multi-dimensional enhancement and network inference are performed again, and the morphological constraint weights of the network inference are adjusted to complete the iterative optimization and correction of the mask until it passes the closed-loop verification.
5. The method for detecting fecal samples using microscopic images based on morphological prior constraints according to claim 1, characterized in that, The steps for multi-dimensional feature extraction and subdivision category identification of each independent mask region based on the attribute labeling results include: Based on the spatial localization results of the attribute tags, the ROIs of each independent mask region in the instance segmentation map are cropped to obtain the local images of each individual target. Multi-dimensional feature extraction is performed on each of the local images to obtain a comprehensive feature set including morphological features, texture features, grayscale features, and optical density features; The comprehensive feature set is input into a pre-trained sub-category classifier, and matched and identified in combination with the standard category feature library in the prior knowledge base of fecal formed element morphology, so as to output the sub-category results corresponding to each target. The sub-category results include red blood cells, white blood cells, macrophages, parasite eggs, fungi, crystals, and food residues.
6. The method for detecting fecal samples using microscopic images based on morphological prior constraints according to claim 5, characterized in that, In the step of outputting the subcategories corresponding to each target, a category matching threshold is set. Targets whose highest matching degree between the comprehensive feature set and the standard category feature library is lower than the category matching threshold are marked as suspicious abnormal targets and annotated in the fecal sample test report. The local image and feature parameters corresponding to the suspicious abnormal targets are output simultaneously to prompt the inspectors to conduct manual review.
7. A fecal sample detection system based on morphological prior constraints, characterized in that, The system is used to perform the fecal sample detection method based on morphological prior constraints as described in any one of claims 1 to 6, the system comprising: The decoupling module is used to perform global background decoupling processing on the collected fecal sample microscopic images based on fecal matrix priors, separating the global background region and potential target candidate regions. The potential target candidate regions are then subjected to multi-dimensional enhancement processing for target perception to generate enhanced candidate region feature maps. At the same time, a fecal morphological prior knowledge base is pre-constructed to generate a standardized set of category morphological constraint parameters. The segmentation module is used to input the enhanced candidate region feature map into a preset category-constrained dual-branch instance segmentation network, using the category morphological constraint parameter set as the hard constraint condition for network inference, and simultaneously complete the accurate semantic segmentation of foreground and background and the instance boundary splitting of the adhered target, generating an initial instance mask set corresponding to each independent formed element. The correction module is used to perform closed-loop verification of the mask integrity and category consistency of the initial instance mask set, iteratively optimize and correct mask regions that fail the verification, and generate an instance segmentation map; at the same time, it performs spatial positioning and attribute labeling on each independent mask region in the instance segmentation map. The output module is used to perform multi-dimensional feature extraction and subdivision category identification on each independent mask region based on the attribute labeling results, complete the quantitative counting and qualitative analysis of the corresponding formed elements, and generate the corresponding fecal sample test report.
8. A computer device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the fecal sample microscopic image detection method based on morphological prior constraints as described in any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by the processor, the program implements the fecal sample microscopic image detection method based on morphological prior constraints as described in any one of claims 1 to 6.