Method, device and computer equipment for counting milk somatic cells
By using a watershed algorithm in cow's somatic cell count combined with image grayscale remapping technology, the problem of less missed detection in cow's somatic cell count is solved, achieving higher counting accuracy and efficiency.
Patent Information
- Application Number
- CN202411556166.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2044-11-04
AI Technical Summary
The prior art has the problem of less detection and missed detection in the segmentation and counting scenarios of cow milk somatic cells, which affects the accuracy of counting. Especially in the case of mastitis and other diseases, when cell adhesions are severe, the watershed algorithm is difficult to effectively separate, resulting in misidentification and Missed inspection.
The watershed algorithm based on the original fluorescence image and segmentation assisted image is used for initial cell segmentation. If there are adhesion cell clusters, the model image is obtained and image grayscale remapping is performed. After determining the number of somatic cells, the adhesion cell segmentation is performed to increase the count accuracy.
It effectively solves the problem of less missed detection and improves the accuracy and efficiency of somatic cell counting of cow milk, especially in the case of severe cell adhesions, somatic cells can be segmented and counted more accurately.
Smart Images

Figure CN119048521B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of dairy product quality control technology, and in particular to a method, apparatus and computer equipment for counting bovine milk somatic cells. Background Technology
[0002] Somatic cell count (SCC) is an important indicator for evaluating the health status of dairy cows and the quality of milk products. Somatic cells are mainly composed of leukocytes (macrophages, lymphocytes, polymorphonuclear neutrophils) and a small number of mammary gland epithelial cells, with approximately 93% to 99% of the cells being leukocytes. Therefore, high somatic cell counts are often associated with mammary gland infections such as mastitis, which not only affect the health of dairy cows but also reduce milk yield and quality. Therefore, regular monitoring and control of somatic cell counts in dairy cows is crucial for maintaining herd health and improving milk yield and quality. Thus, a method for accurately counting somatic cells in dairy cows is needed. Summary of the Invention
[0003] This application provides a method, apparatus, and computer device for counting bovine milk somatic cells, which solves the problem of under-detection and missed detection in the scenario of segmented counting of bovine milk somatic cells, and achieves the technical effect of improving the accuracy of counting.
[0004] To achieve the above objectives, the main technical solutions adopted in this application include:
[0005] This application provides a method for counting bovine milk somatic cells, the method comprising:
[0006] Initial cell segmentation is performed based on the original fluorescence image of bovine milk somatic cells and the first segmentation auxiliary image to obtain a list of bovine milk somatic cell outlines; wherein, the first segmentation auxiliary image is generated by marking the background region and the foreground region in the original fluorescence image; the pixel position between two adjacent pixels of each somatic cell outline in the outline list does not exceed a preset pixel threshold, and each somatic cell outline in the outline list has the same level and is independent of each other.
[0007] If there are suspicious cell outlines of adherent cell clusters in the outline list, the image of the adherent cell cluster is obtained from the original fluorescence image based on the mask data corresponding to the suspicious cell outline; and the image grayscale remapping is performed on the image of the image to obtain the grayscale remapping result of the adherent cell cluster.
[0008] The number of somatic cells in the image is determined based on the grayscale remapping result, and the image is segmented into adhesion cells based on the number of somatic cells to obtain the adhesion cell segmentation result.
[0009] Somatic cell counting was performed based on the segmentation results of the adhesion cells to obtain the somatic cell count results.
[0010] This application also provides a bovine milk somatic cell counting device, the device comprising:
[0011] An initial cell segmentation module is used to perform initial cell segmentation based on the original fluorescence image of bovine milk somatic cells and a first segmentation auxiliary image to obtain a list of contours of the bovine milk somatic cells; wherein, the first segmentation auxiliary image is generated by marking the background region and the foreground region in the original fluorescence image; the pixel position between two adjacent pixels of each somatic cell contour in the contour list does not exceed a preset pixel threshold, and each somatic cell contour in the contour list has the same level and is independent of each other.
[0012] The grayscale remapping module is used to obtain a model image of the adherent cell cluster from the original fluorescence image based on the mask data corresponding to the suspected cell cluster if there is a suspicious cell contour of the adherent cell cluster in the contour list; and to perform image grayscale remapping on the model image to obtain the grayscale remapping result of the adherent cell cluster.
[0013] The adhesion cell segmentation module is used to determine the number of somatic cells in the modeling image based on the grayscale remapping result, and to perform adhesion cell segmentation on the modeling image based on the number of somatic cells to obtain the adhesion cell segmentation result.
[0014] The somatic cell counting module is used to perform somatic cell counting based on the results of the adhesion cell segmentation to obtain somatic cell counting results.
[0015] This application also provides a computer device, including: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the computer instructions to perform the method described in any of the above-mentioned embodiments.
[0016] This application also provides a computer-readable storage medium storing computer instructions that cause a computer to perform any of the methods described above.
[0017] This application also provides a computer program product, including computer instructions for causing a computer to perform any of the methods described above.
[0018] In this application, a first watershed segmentation is performed based on the original fluorescence image of bovine somatic cells and a first segmentation auxiliary image to obtain a list of bovine somatic cell outlines. If there are suspicious cell outlines of adherent cell clusters in the outline list, a mock-up image of the adherent cell clusters is obtained from the original fluorescence image based on the mask data corresponding to the suspicious cell outlines. The mock-up image is then subjected to image grayscale remapping to obtain the grayscale remapping result of the adherent cell clusters. The number of somatic cells in the mock-up image is determined based on the grayscale remapping result, and a second watershed segmentation is performed on the mock-up image based on the number of somatic cells to obtain the adherent cell segmentation result. This effectively segments the adherent cells. Finally, somatic cell counting is performed based on the adherent cell segmentation result obtained from the second watershed segmentation to obtain the somatic cell counting result, thus improving the accuracy of cell identification and cell counting. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the specific embodiments of this application or the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0020] Figure 1a A schematic diagram of the original fluorescence image provided in the embodiments of this specification;
[0021] Figure 1b A schematic diagram of the original fluorescence image after suppressing stray light, provided in the embodiments of this specification;
[0022] Figure 1c A flowchart of the bovine milk somatic cell counting method provided in the embodiments of this specification;
[0023] Figure 1d A schematic diagram of the binary image corresponding to the original fluorescence image provided in the embodiments of this specification;
[0024] Figure 1e A schematic diagram of the distance transformation image corresponding to the original fluorescence image provided in the embodiments of this specification;
[0025] Figure 1f A schematic diagram of the first segmentation auxiliary image provided for an embodiment of this specification;
[0026] Figure 2 A flowchart of the bovine milk somatic cell counting method provided in the embodiments of this specification;
[0027] Figure 3 A flowchart of the bovine milk somatic cell counting method provided in the embodiments of this specification;
[0028] Figure 4 A flowchart of the bovine milk somatic cell counting method provided in the embodiments of this specification;
[0029] Figure 5a A flowchart of the bovine milk somatic cell counting method provided in the embodiments of this specification;
[0030] Figure 5b A schematic diagram of the mold-taking image provided in the embodiments of this specification;
[0031] Figure 5c A schematic diagram of the cell segmentation results after the second watershed provided in the embodiments of this specification;
[0032] Figure 5d A schematic diagram of bovine milk somatic cell counting results provided in the embodiments of this specification;
[0033] Figure 6 A flowchart of the bovine milk somatic cell counting method provided in the embodiments of this specification;
[0034] Figure 7 A schematic diagram of the bovine milk somatic cell counting device provided in the embodiments of this specification;
[0035] Figure 8 This is a schematic diagram of the structure of a computer device corresponding to the present invention. Detailed Implementation
[0036] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, 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, 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.
[0037] The International Organization for Standardization (ISO) and the International Dairy Federation (IDF) have specified standard methods for somatic cell counts in cow's milk. According to these standards, somatic cell counts in cow's milk are typically expressed as the number of somatic cells per milliliter of milk (cells / mL). In healthy dairy cows, the somatic cell count is generally below 200,000 cells / mL; a value exceeding this may indicate mastitis or other health problems.
[0038] Bovine milk somatic cell counting requires high accuracy. To obtain more representative counting results with fewer images, microscopes need to use lower magnification to achieve a larger field of view. This results in a large number of small somatic cells that need to be counted at a time, with more clustered cells. Furthermore, if the cow being tested has inflammation, somatic cell adhesion will increase significantly, further challenging the accuracy of the count.
[0039] In related technologies, the watershed algorithm is used to segment cells with large image sizes and has good counting results. However, when dealing with the segmentation and counting of bovine somatic cells, there is a problem of under-detection and missed detection, which affects the technical effect on determining whether the cow has inflammation. Analysis shows that the reason for under-detection and missed detection is that the watershed algorithm relies on the extraction of "seed points" for segmentation and counting. "Seed points" are generally extracted using distance transform methods. However, when the cells are too adhered, this method cannot effectively separate them, causing adhered cell clusters to be misidentified as single cells, affecting the accuracy of counting.
[0040] Therefore, to address the issue of under-detection and under-detection problems in watershed algorithms in related technologies, this specification provides a method for counting bovine somatic cells. First, an original fluorescence image of bovine somatic cells is acquired, and a first conventional image processing method is used to mark the background and foreground regions in the original fluorescence image, obtaining a first segmentation auxiliary image. The original fluorescence image and the first segmentation auxiliary image are used as input to the watershed algorithm for initial cell segmentation, resulting in a list of bovine somatic cell contours. Second, since adherent cell clusters exist in the initial cell segmentation, the contour list is traversed. If a suspicious cell contour of an adherent cell cluster is detected in the contour list, mask data is generated based on this suspicious cell contour, and a model image of the adherent cell cluster is obtained from the original fluorescence image based on the mask data. Next, a second conventional image processing method is used to mark the background and foreground regions in the model image, obtaining a second segmentation auxiliary image. The model image and the second segmentation auxiliary image are used as input to the watershed algorithm for adherent cell segmentation, obtaining the adherent cell segmentation result. Finally, somatic cell counting is performed based on the contour list and the adherent cell segmentation result, obtaining the somatic cell count result.
[0041] In the embodiments of this specification, the first conventional image processing method includes: applying distance transform and threshold segmentation to the binary image corresponding to the original fluorescence image to obtain the foreground region of the original fluorescence image; performing opening and morphological dilation operations on the binary image corresponding to the original fluorescence image to determine the background region of the original fluorescence image, so as to mark the background region and the foreground region in the original fluorescence image, and obtain a first segmentation auxiliary image. Specifically, the binary image corresponding to the original fluorescence image is determined; wherein, the pixels corresponding to the somatic cell region in the binary image are recorded as foreground pixels; the pixel values of the foreground pixels are replaced with the distance from the foreground pixel to the nearest background pixel to obtain a distance transform image, and threshold segmentation is performed based on the distance transform image to determine the foreground region of the original fluorescence image; morphological opening and morphological dilation operations are applied to the binary image to determine the background region of the original fluorescence image; the region located between the foreground region and the background region is determined as an unknown region, and the first segmentation auxiliary image is obtained.
[0042] In the embodiments of this specification, the second conventional image processing method includes: marking the region in the sampled image other than the clusters of adherent cells as the background region; performing image grayscale remapping on the sampled image to obtain the grayscale remapping result of the clusters of adherent cells; determining the number of somatic cells in the sampled image based on the grayscale remapping result; and marking the foreground region in the sampled image based on the number of somatic cells to obtain the second segmentation auxiliary image. Specifically, the pixels corresponding to the clusters of adherent cells in the sampled image are clustered according to the number of somatic cells, and the foreground region is marked in the sampled image based on the clustering result to obtain the second segmentation auxiliary image.
[0043] In the above embodiments, considering the small area of adherent cell clusters, a higher precision segmentation method is required to accurately determine the boundaries of individual cells within the clusters. Therefore, the labeled image input to the second watershed algorithm is generated by image grayscale remapping and determining the number of somatic cells in the model image to identify the foreground region. Furthermore, considering the differences between the object using the watershed algorithm for the first and second applications, the first and second traditional image processing methods differ; that is, different traditional image processing methods are used before each application of the watershed algorithm to determine the labeled images for the watershed algorithm (the first segmentation auxiliary image and the second segmentation auxiliary image).
[0044] Furthermore, compared to gradient images using edge detection with the watershed algorithm in related technologies, the first traditional image processing method employs two different processing branches on the binary image corresponding to the original fluorescence image (one branch applies distance transformation and threshold segmentation, and the other branch applies morphological opening and morphological dilation operations) to determine the foreground and background regions of the original fluorescence image respectively. The second traditional image processing method first generates a model image of the adherent cell clusters. Then, it employs two different processing branches on the model image (one branch directly marks the regions other than the adherent cell clusters in the model image as background regions, and the other branch performs image grayscale remapping and determines the number of somatic cells based on the model image to mark the foreground region in the model image), thereby determining the foreground and background regions of the model image respectively. It is evident that generating accurate labeled images through the above traditional image processing methods provides more precise guidance or assistance to the watershed algorithm, enabling accurate determination of somatic cell boundaries. It is understandable that compared to deep learning algorithms, traditional image processing methods can generate labeled images with less computation and faster processing speed.
[0045] It can be understood that the first or second segmentation auxiliary image can be considered as the guide image or marker image for the watershed algorithm. Taking the first segmentation auxiliary image as an example, the contour in the first segmentation auxiliary image is used as a seed (also called a water-filling point). Other pixels in the original fluorescence image are judged according to the watershed algorithm rules, and the region of each pixel is defined, until all pixels in the original fluorescence image have been processed. The value at the boundary between regions is set to "-1" for distinction. Similarly, taking the second segmentation auxiliary image as an example, the contour in the second segmentation auxiliary image is used as a seed (also called a water-filling point). Other pixels in the modulus image are judged according to the watershed algorithm rules, and the region of each pixel is defined, until all pixels in the modulus image have been processed. The value at the boundary between regions is set to "-1" for distinction.
[0046] This specification also provides a scenario example of a bovine milk somatic cell counting method, which includes: fluorescence image acquisition, image stray light suppression (image preprocessing), initial segmentation using the watershed algorithm, screening of adherent cells and secondary segmentation using the watershed algorithm, abnormal cell removal and automatic counting.
[0047] The process of acquiring fluorescence images is illustrated by way of example. Milk sampled from the automated pipeline is thoroughly stained with fluorescent dye and then transported to the observation area of a microfluidic chip. It is then irradiated with excitation light of a specific wavelength. The appropriate object distance is adjusted to ensure clear focus of the sample under the microscope. When the milk is in a low-flow-rate state that does not create shadows or is completely still, dotted fluorescence from somatic cells can be seen in the field of view. This fluorescence has a significant contrast with the dark background. Fluorescence images are acquired using a digital camera and recorded as the raw fluorescence images of the milk somatic cells. These images are numbered and saved to a designated folder for subsequent image processing.
[0048] The process of image stray light suppression is illustrated by example. Irregular reflection and scattering of excitation light within the optical system cause inhomogeneity in the imaging background, reducing image quality and contrast, and affecting subsequent image processing and analysis. To suppress and eliminate this phenomenon and improve the contrast between somatic cell fluorescence and the background, various image processing techniques and methods can be employed. These methods include, but are not limited to, HSV color separation, RGB color channel separation, dark field correction, and adaptive filtering. The comparison results of fluorescence images before and after using the aforementioned image processing methods are shown below. Figure 1a and Figure 1b As shown.
[0049] In this example, the procedure for suppressing and eliminating stray light in an image by combining RGB color channel separation and HSV color separation is as follows:
[0050] 1) Remove irrelevant colors: Read the acquired image as a BGR three-channel image, set the values of the B and R channels to zero, retain the G channel and multiply its value by n to enhance the brightness of the fluorescent cells.
[0051] 2) Convert color space: Use cv2.cvtcolor(img, cv2.COLOE_BGR2HSV) to convert the img image from BGR space to HSV space.
[0052] 3) Setting Thresholds: The HSV color space uses H (hue), S (saturation), and V (hue) to describe color. Define the HSV threshold range for green fluorescent cells: H value between 40-80, S value between 43-255, and V value between 170-255.
[0053] 4) Create a mask: Use the threshold above to generate a binary mask image for extracting fluorescent cell regions.
[0054] 5) Applying a mask: Applying a mask to the original image eliminates the uneven blue background caused by the excitation light, retaining only the green fluorescent cells and enhancing the image contrast.
[0055] This example illustrates the use of the watershed algorithm for initial segmentation, primarily including image preprocessing, image binarization, generating labeled images, and applying the watershed segmentation algorithm. Image preprocessing may include grayscale conversion and smoothing filtering to obtain a preprocessed image. Based on the preprocessed image, image binarization is performed to obtain a binary image corresponding to the original fluorescence image. Based on the binary image corresponding to the original fluorescence image, the foreground, background, and unknown regions of the original fluorescence image are determined, resulting in the corresponding labeled image (i.e., the first segmentation auxiliary image). Guided by the labeled image, the watershed segmentation algorithm is applied to the original fluorescence image to obtain a list of milk somatic cell outlines. It should be noted that the watershed algorithm is a mathematical morphology segmentation method based on topological theory. Its principle is to treat the image as a topological surface, where pixel values correspond to terrain height. The watershed algorithm first identifies local minima in the image and uses these points as initial seeds. Then, the watershed algorithm simulates water filling from these seed points, gradually submerging higher regions. When water meets at different seed points, segmentation boundaries are formed, dividing the image into different regions. This method allows fluorescent somatic cells with clearly defined boundaries to be separated from the dark field background.
[0056] The image preprocessing process is illustrated below. Image preprocessing includes grayscale conversion and smoothing filtering. The acquired fluorescent somatic cell image is a three-channel RGB image. Subsequent processing operations are performed based on a single-channel grayscale image, so the RGB image needs to be converted to grayscale first. The grayscale value represents the brightness of that pixel. The grayscale conversion method used is the weighted average method, and its standard formula is:
[0057]
[0058] Smoothing filtering uses bilateral filtering for noise reduction, removing noise and artifacts from the image while preserving boundary contour details. This filtering algorithm combines two Gaussian functions: one in the spatial domain and the other in the pixel value domain. The specific steps are as follows:
[0059] 1) Spatial Domain Filtering: This part is similar to Gaussian filtering, using a distance-based Gaussian function to weight pixels within the neighborhood. The weights decrease as the distance between pixels increases. This ensures that neighboring pixels have a greater influence on the central pixel, while distant pixels have a smaller influence. Gaussian Spatial Weights The calculation formula is:
[0060]
[0061] in, and It is a pixel and coordinates It is a parameter that controls the range of influence of the spatial domain.
[0062] 2) Pixel Value Range Filtering: This part considers the differences in pixel values and uses a Gaussian function based on these differences for weighting. Pixels with similar values are more affected, while those with large differences are less affected. Gaussian Value Range Weighting The calculation formula is:
[0063]
[0064] in, and It is a pixel and The intensity value, It is a parameter that controls the range of influence of pixel value range.
[0065] 3) The final weight is the product of two Gaussian weights: one for the spatial domain and one for the pixel value domain.
[0066]
[0067] Using these weights, a weighted average of the pixel values within the neighborhood is performed to obtain the filtered pixel values:
[0068]
[0069] in, Represents pixels The neighborhood, These are the filtered pixel values.
[0070] The image binarization process is illustrated exemplarily. A thresholding algorithm is used to set a grayscale threshold, roughly converting the aforementioned grayscale image into a binary image with a white foreground and a black background (where the white foreground is not an exact somatic cell range, but only represents an approximate range). The basic principle of the thresholding algorithm is to set a global threshold and compare the grayscale values of all pixels in the image with this threshold to determine whether each pixel belongs to the foreground or background. The comparison result can be calculated using the following formula:
[0071]
[0072] in, The maximum pixel value. The set threshold; These are the pixel values of the original image. These are the pixel values after threshold comparison.
[0073] Global thresholding algorithms allow users to manually set or automatically calculate the optimal threshold, depending on the specific needs. Representative methods include the fixed threshold method and Otsu's method. The fixed threshold method is the simplest global thresholding algorithm. It involves manually setting an appropriate threshold, processing the data in real-time, and displaying the binarization effect, allowing for a direct assessment of the threshold based on the binarization result. Otsu's method, on the other hand, determines the optimal threshold by maximizing the inter-class variance between the foreground and background. Its basic principle is as follows:
[0074] 1) Normalized histogram
[0075] Assuming the grayscale range of the acquired somatic cell images is: Where L is the number of gray levels (usually 256). First, calculate the histogram of the image, then normalize it so that the sum of the probabilities of all gray levels is 1:
[0076]
[0077] in, It is grayscale. The number of pixels, It is the total number of pixels in the image. It is grayscale. The normalized probability.
[0078] 2) Calculate the within-class variance and between-class variance.
[0079] The image is divided into foreground (class 0) and background (class 1). The grayscale range is defined by a threshold of t. As background, If the background is the foreground, then the probabilities of the background and the foreground are respectively:
[0080]
[0081]
[0082] The mean values of the background and foreground are as follows:
[0083]
[0084]
[0085] The overall mean of the image is:
[0086]
[0087] 3) Maximize inter-class variance
[0088] The core idea of the Otsu method is to choose a threshold t that maximizes the inter-class variance. The formula for inter-class variance is:
[0089]
[0090] By maximizing the between-class variance, the optimal threshold t can be found. The formula for between-class variance can be further integrated into the following equation:
[0091]
[0092] Then, we only need to iterate through all the thresholds t within the grayscale range, calculate the inter-class variance, and find the threshold that maximizes it, which is the optimal threshold.
[0093] This section exemplifies the secondary segmentation process using the watershed algorithm. Due to differences in the area of individual somatic cells and cell clusters, the shape of individual somatic cells differs from that of cell clusters, and the roundness of individual somatic cells differs from that of cell clusters, suspicious cell contours of adherent cell clusters can be detected from the contour list. Based on these suspicious cell contours and the original fluorescence image, a mock-up image of the adherent cell clusters is generated, and the regions in the mock-up image other than the adherent cell clusters are marked as background regions. Image grayscale remapping is performed on the mock-up image to obtain the grayscale remapping result of the adherent cell clusters. A local peak detection algorithm is applied to the grayscale remapping result to locate the center point of each somatic cell in the adherent cell cluster. Furthermore, based on the center points of each somatic cell, the foreground region is determined in the mock-up image, resulting in a second segmentation auxiliary image. Guided by the second segmentation auxiliary image, the watershed algorithm is applied to the mock-up image to segment the adherent cell clusters, obtaining the segmentation result of the adherent cells corresponding to the adherent cell clusters.
[0094] This document exemplifies the process of abnormal cell screening and automatic counting. The somatic cell contour information obtained from the first and second applications of the watershed algorithm is stored in a data structure, and parameters such as area, shape features, and geometric properties are calculated. Based on preset screening criteria, somatic cell contours that meet the conditions are selected. These qualified contours are then drawn, numbered, and automatically counted. Finally, the maximum output number represents the total somatic cell count.
[0095] In the above scenario example, firstly, by employing automated fluorescence image acquisition and processing technology, the tediousness and time-consuming nature of manual operations are reduced, improving the detection speed and efficiency of large numbers of milk samples. Secondly, by using fluorescence staining and image processing techniques to suppress background stray light and optimize the segmentation algorithm, the stability and accuracy of the counting results are ensured, unaffected by other components in the milk. Next, compared to deep learning counting methods, this scenario example relies on traditional image processing and segmentation techniques, reducing the need for large datasets and high computing resources, enabling it to operate effectively in environments with limited computing resources, such as embedded systems. Furthermore, by using the watershed algorithm twice, and generating labeled images in different ways each time, adherent cells can be effectively segmented, improving the accuracy and efficiency of cell identification and counting. Finally, in the process of abnormal cell screening and automatic counting, this scenario example utilizes multiple parameters such as area, shape features, and geometric properties for screening, ensuring the accuracy and reliability of the counting results.
[0096] According to an embodiment of this application, an embodiment of a breast cell counting method is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0097] Figure 1c This is a flowchart of a bovine milk somatic cell counting method according to an embodiment of this application, such as... Figure 1c As shown, the process includes the following steps:
[0098] S110. Initial cell segmentation is performed based on the original fluorescence image of bovine milk somatic cells and the first segmentation auxiliary image to obtain a list of bovine milk somatic cell outlines.
[0099] The first segmentation auxiliary image is generated by marking the background and foreground regions in the original fluorescence image. In the contour list, the pixel positions between any two adjacent pixels of each somatic cell contour do not exceed a preset pixel threshold, and the somatic cell contours in the contour list have the same level and are independent of each other.
[0100] Specifically, the raw fluorescence image of bovine somatic cells is acquired, and the background and foreground regions are marked in the raw fluorescence image to obtain a first segmentation auxiliary image. The first segmentation auxiliary image can be understood as a labeled image. Guided by the first segmentation auxiliary image, the raw fluorescence image and the first segmentation auxiliary image are input into the watershed algorithm for initial cell segmentation, resulting in a list of bovine somatic cell outlines. For example, the watershed algorithm can be applied using image processing libraries, specifically the `cv2.watershed()` function from the OpenCV computer vision library. Two important parameters are passed in: first, the acquired multi-channel color raw fluorescence image is used as the input image; second, the first segmentation auxiliary image is passed as an auxiliary parameter. This function returns a labeled result image, where the outline boundaries of each somatic cell can be labeled with a value of -1, while the background and connected regions of different cells can be labeled with different integer values.
[0101] It is important to emphasize that the watershed algorithm's performance in segmenting adherent cell clusters needs improvement, especially in cases where the cow has inflammation, which significantly increases somatic cell adhesion and can lead to under-detection and missed detections. Therefore, to improve counting accuracy, this implementation applies the watershed algorithm a second time to adherent cell clusters after the initial cell segmentation. Furthermore, before the second application of the watershed algorithm, it is necessary to accurately extract the region image corresponding to the adherent cell clusters from the original fluorescence image. Extracting this region image relies on precise boundary contours. Therefore, in this implementation, the pixel positions between adjacent pixels of the stored somatic cell contours do not exceed a preset pixel threshold, and the somatic cell contours in the contour list have the same level and are mutually independent, thus improving the accuracy of the somatic cell contours.
[0102] S120. If there are suspicious cell outlines of adherent cell clusters in the outline list, obtain the model image of the adherent cell clusters from the original fluorescence image based on the mask data corresponding to the suspicious cell outlines; and perform image grayscale remapping on the model image to obtain the grayscale remapping result of the adherent cell clusters.
[0103] Specifically, the contour list obtained from the first application of the watershed algorithm includes the contours of individual somatic cells and the contours of clustered cell groups. The region image corresponding to the contour of the clustered cell group is the object for which the watershed algorithm needs to be applied a second time. The contours of somatic cells in the contour list are traversed. If a suspicious cell contour of a clustered cell group is detected in the contour list, mask data is generated based on the suspicious cell contour. The image of the clustered cell group is then extracted from the original fluorescence image based on the mask data.
[0104] In some cases, the watershed algorithm's segmentation performance heavily relies on the initial markers used to determine the seed points. If the initial markers do not accurately represent the center of each cell, then when processing clusters of adhered cells, they will be treated as a single entity. In related technologies, the watershed algorithm requires a distance transform algorithm to extract the central region of somatic cells as seed points. However, the distance transform algorithm has two main failure scenarios. First, when cell adhesion is severe, a large segmentation threshold is needed for effective separation. However, a large threshold can also affect other cells, especially smaller cells, which are easily misjudged as noise and discarded, resulting in missed detections. Second, when cell adhesion is very severe, no matter how large the segmentation threshold, it is impossible to separate the central regions of two somatic cells. Therefore, to overcome the limitations of the distance transform algorithm, this implementation uses a new method to process the model image to obtain the labeled image.
[0105] To enhance the brightness difference between the cell center and the cell junction, the image grayscale is remapped to obtain the grayscale remapped result of the adherent cell cluster, thereby increasing the value of the bright part and decreasing the value of the dark part.
[0106] For example, remapping can be performed using the Sigmoid function, whose expression is:
[0107]
[0108] For example, since most pixels in the grayscale histogram of the adherent cells are concentrated in the high-brightness range, histogram equalization can also be used to remap the brightness distribution of all pixels.
[0109] S130. Determine the number of somatic cells in the model image based on the grayscale remapping result, and perform adhesion cell segmentation on the model image based on the number of somatic cells to obtain the adhesion cell segmentation result.
[0110] Specifically, since the brightness difference between the cell center and the cell connection region has been increased, the number of somatic cells in the modeled image can be determined based on the grayscale remapping result. For example, a local peak-finding method can be used on the grayscale remapping result to obtain the centers of somatic cells in the modeled image; the number of somatic cell centers represents the number of somatic cells. Furthermore, to improve the accuracy of the somatic cell count, different local peak detection methods can be used. These methods can employ detection functions or sliding window approaches.
[0111] After determining the number of somatic cells, the foreground can be identified in the model image to obtain a labeled image for a second application of the watershed algorithm. Thus, a method different from the distance transform algorithm in related techniques is used to obtain the labels and graphics. Finally, guided by this labeled image, the model image is segmented into adhesion cells to obtain the adhesion cell segmentation results.
[0112] S140. Perform somatic cell counting based on the results of adhering cell segmentation to obtain somatic cell count results.
[0113] In this process, since the adherent cell clusters have already undergone secondary segmentation, resulting in adherent cell segmentation results, which include individual somatic cells within the adherent cell clusters, a more accurate somatic cell count can be obtained based on these segmentation results. Specifically, a contour list is obtained during the first segmentation. This list is then traversed and counted to determine the number of individual somatic cells. If an adherent cell cluster is encountered, it is segmented again to obtain the adherent cell segmentation results. The individual somatic cells within these clusters are then counted to obtain the final somatic cell count.
[0114] In some implementations, the contour list is updated based on the segmentation results of adherent cells, resulting in an updated contour list. Abnormal cell contours are then removed from the updated contour list, resulting in a deleted contour list. Somatic cell counting is performed based on the deleted contour list to obtain the somatic cell count results.
[0115] In the above implementation, a first watershed segmentation is performed based on the original fluorescence image of bovine somatic cells and a first segmentation auxiliary image to obtain a list of bovine somatic cell outlines. If there are suspicious cell outlines of adherent cell clusters in the outline list, a mock-up image of the adherent cell clusters is obtained from the original fluorescence image based on the mask data corresponding to the suspicious cell outlines. The mock-up image is then subjected to image grayscale remapping to obtain the grayscale remapping result of the adherent cell clusters. The number of somatic cells in the mock-up image is determined based on the grayscale remapping result, and a second watershed segmentation is performed on the mock-up image based on the number of somatic cells to obtain the adherent cell segmentation result. This effectively segments adherent cells. Finally, somatic cell counting is performed based on the adherent cell segmentation result obtained from the second watershed segmentation to obtain the somatic cell counting result, improving the accuracy of cell identification and cell counting. Furthermore, compared with deep learning counting methods, this method relies on traditional image processing and segmentation techniques, reducing the need for large datasets and high computing resources, enabling it to operate effectively in environments with limited computing resources.
[0116] In some implementations, the first segmentation auxiliary image is obtained by: determining a binary image corresponding to the original fluorescence image; wherein the pixels corresponding to the somatic cell region in the binary image are denoted as foreground pixels; replacing the pixel values of the foreground pixels with the distance from the foreground pixel to the nearest background pixel to obtain a distance-transformed image, and performing threshold segmentation based on the distance-transformed image to determine the foreground region of the original fluorescence image; applying morphological opening and morphological dilation operations to the binary image to determine the background region of the original fluorescence image; and determining the region located between the foreground region and the background region as an unknown region to obtain the first segmentation auxiliary image.
[0117] The original fluorescence image is binarized to obtain a corresponding binary image. The binary image includes somatic cell regions and background regions; pixels corresponding to the somatic cell regions in the binary image are designated as foreground pixels. To provide a base labeled image for the watershed algorithm, the binary image is processed through two branches (one including distance transformation, and the other including morphological operations) to generate a first segmentation auxiliary image. Specifically, as follows... Figure 1d and Figure 1e , Figure 1d The image shown is a binary image. Figure 1e The image shown is a distance-transformed image. On one hand, the pixel values of foreground pixels in the binary image are replaced with the distance from the foreground pixel to the nearest background pixel, resulting in a distance-transformed image. The pixel values in the distance-transformed image represent the Euclidean distance (i.e., the straight-line distance between two pixels) between the foreground pixel and the nearest background pixel. The closer to the center, the larger the distance value. The distance-transformed image is normalized to the range (0, 255), and then a suitable threshold is selected for threshold segmentation. This segmentation can divide the cell into multiple independent single somatic cells. These segmented somatic cell pixels are labeled as "determined foreground," obtaining the foreground region of the original fluorescence image. On the other hand, morphological opening operations are applied to the binary image, i.e., erosion followed by dilation. This eliminates small noise and tiny foreground regions in the binary image's foreground, ensuring a more connected and defined background region. Next, a morphological dilation operation is performed to enlarge the foreground region. The remaining regions, excluding the foreground region, are labeled as "determined background," determining the background region of the original fluorescence image. The region between the foreground and background regions is determined as an unknown region, resulting in the first segmentation auxiliary image. For an example, please refer to [link to example image]. Figure 1f , Figure 1f The black area 102 in the middle is the defined background area. Figure 1f The white area 104 is the defined foreground area. Figure 1f Gray area 106 represents a defined unknown area.
[0118] In the above implementation, compared with the gradient image obtained by edge detection using the watershed algorithm in related technologies, two different processing branches are used on the binary image corresponding to the original fluorescence image (one branch applies distance transformation and threshold segmentation, and the other branch applies morphology to perform opening operation and morphological dilation operation) to determine the foreground and background regions of the original fluorescence image respectively. It can be seen that generating accurate labeled images through the above-mentioned traditional image processing method can more accurately guide or assist the watershed algorithm, and subsequently accurately determine the somatic cell boundaries. It is understood that compared with deep learning algorithms, traditional image processing methods can generate labeled images with less computation and faster processing speed.
[0119] In some implementations, initial cell segmentation is performed based on the original fluorescence image of bovine somatic cells and a first segmentation auxiliary image to obtain a list of bovine somatic cell contours. This includes: performing cell segmentation based on the original fluorescence image and the first segmentation auxiliary image to obtain a first contour-marked image of bovine somatic cells; and performing contour recognition on the first contour-marked image according to the principle of contour level equality and independence to obtain a contour list. The principle of contour level equality and independence describes the relationship that the identified somatic cell contours belong to the same level and are independent of each other.
[0120] Specifically, using the first segmentation auxiliary image as the labeled image, the watershed algorithm is applied to the original fluorescence image for the first time to obtain the first contour labeled image of bovine somatic cells. Since each individual somatic cell is equal and independent, contour recognition is performed on the first contour labeled image according to the principle of equal and independent contour levels, resulting in a contour list. For example, contour recognition identifies the contours of each cell's connected components in the first contour labeled image, facilitating subsequent processing of specific cells. The `cv2.findContours()` function is used to find the contours of each connected component. The basic input parameters of `cv2.findContours()` are the first contour labeled image, the contour level establishment method, and the contour data storage format. The final output is a contour list containing information for each contour data point. The `cv2.RETR_LIST` parameter is set to detect all contours, and no hierarchical relationship is established between contours; they are mutually independent. It is necessary to accurately extract the region image corresponding to the adherent cell clusters from the original fluorescence image. Extracting the region image corresponding to the adherent cell clusters depends on the precise boundary contour. Therefore, setting the cv2.CHAIN_APPROX_NONE parameter will save every pixel of each contour, and the pixel position difference between two adjacent points will not exceed 1.
[0121] In some implementations, please refer to Figure 2 The number of somatic cells in the modeled image is determined based on the grayscale remapping results, including:
[0122] S210. Input the grayscale remapping results into the adhesion level classification model to obtain the adhesion level of the adhered cell clusters.
[0123] S220. Based on the adhesion level, search in the level quantity mapping relationship to obtain the number of individual somatic cells included in the adhered cell cluster, which is taken as the somatic cell count.
[0124] The hierarchical quantity mapping relationship describes the correspondence between the adhesion grade of an adherent cell cluster and the number of individual somatic cells within the cluster. The adhesion grade characterizes the number of individual somatic cells included in an adherent cell cluster. The adhesion grade classification model can be a classification model used to determine the adhesion grade of an adherent cell cluster.
[0125] In some cases, the somatic cell regions determined by the distance transformation algorithm have certain limitations. Therefore, this embodiment pre-trains an adhesion level classification model. The grayscale remapping result of the adherent cell clusters is input into the adhesion level classification model for adhesion level classification to obtain the adhesion level of the adherent cell clusters. Since a level-quantity mapping relationship between the adhesion level and the number of individual somatic cells in the adherent cell clusters has been established in advance, the adhesion level of the adherent cell clusters is used to search in the level-quantity mapping relationship to obtain the number of individual somatic cells included in the adherent cell clusters, which is the somatic cell count.
[0126] It should be noted that a training dataset can be pre-constructed. The data samples in the training dataset are grayscale remapping results of multiple adherent cell clusters, and the labels used for the data samples are the number of individual somatic cells in each adherent cell cluster. The initial classification model is trained using the training dataset until the model stops training, resulting in an adhesion level classification model. It is understandable that, compared to deep learning-based somatic cell counting models in related technologies, the adhesion level classification model requires less data and computational resources.
[0127] In some implementations, please refer to Figure 3 The number of somatic cells in the modeled image is determined based on the grayscale remapping results, including:
[0128] S310. Based on the grayscale remapping results, perform local peak detection to obtain the coordinates of the local peaks.
[0129] S320. Determine the number of somatic cells based on the coordinates of the local peak.
[0130] In some cases, the brightness distribution of fluorescent somatic cells gradually decreases from the center outwards, even when two cells are severely adhered together. Each somatic cell will still have a brightness peak at its center. Therefore, the coordinates of the center of a single somatic cell can be obtained by finding these local brightness peaks; the number of somatic cell centers represents the total number of somatic cells. Specifically, local peak detection is performed on the grayscale remapping results of adherent cell clusters to obtain the coordinates of these local peaks, which are the coordinates of the somatic cell centers. The number of somatic cells in the image is then determined based on these coordinates.
[0131] For example, peak detection functions can be used to locate somatic cell centers. For instance, using the `scipy.signal.find_peaks()` peak detection function, first calculate the maximum value of each column of the image to construct a one-dimensional signal array in the x-direction. Inputting this one-dimensional array into the peak detection function will yield the x-coordinates corresponding to local peaks. Similarly, construct a one-dimensional array in the y-direction row by row to calculate the y-coordinates corresponding to local peaks. Combine these x and y coordinates, and after eliminating unreasonable coordinate combinations based on grayscale values, the remaining combination is the actual somatic cell center.
[0132] For example, a sliding window can be used to find local peaks in an image. First, select a window of, say, 5x5 size. Then, slide the window horizontally or vertically across the image. Each slide checks if a point within the window is larger than its surrounding points. If so, mark it as a local peak. Record the peaks found in each window and their locations. Finally, process the results from all windows, merge and filter duplicate or adjacent peaks, and output the coordinates of all local peaks in the image. These coordinates represent the somatic cell centers.
[0133] For example, on the one hand, a peak detection function can be used to perform local peak detection on the grayscale remapping result to obtain the first coordinate of the local peak; on the other hand, a sliding window can be used to perform local peak detection on the grayscale remapping result to obtain the second coordinate of the local peak. The intersection or union between the first coordinate and the second coordinate of the local peak is used as the coordinate of the local peak, which is the coordinate of the somatic cell center.
[0134] In the above embodiments, the center point of somatic cells is located by using the local peak finding method, which provides an accurate data basis for secondary segmentation of adherent cells, thereby overcoming the limitations of distance transformation algorithms in related technologies.
[0135] In some implementations, please refer to Figure 4 Based on the grayscale remapping results, local peak detection is performed to obtain the coordinates of the local peaks, including:
[0136] S410. Input the grayscale remapping result into the adhesion degree classification model to obtain the adhesion degree of the adhered cell clusters.
[0137] S420. Call the local peak detection method corresponding to the degree of adhesion to perform local peak detection on the grayscale remapping result and obtain the coordinates of the local peak.
[0138] The degree of adhesion can be measured by the overlap between individual cells within the adherent cell cluster. Different overlap patterns can be addressed using different local peak detection methods. For example, if the overlap area between individual cells in the adherent cell cluster exceeds a preset area threshold, a peak detection function can be used; if the overlap area does not exceed the preset area threshold, a sliding window or peak detection function can be used.
[0139] Specifically, the grayscale remapping results of the adherent cell clusters are input into the adhesion degree classification model for adhesion degree classification to obtain the adhesion degree of the adherent cell clusters. Since a mapping relationship between adhesion degree and local peak detection method has been established in advance, the local peak detection method corresponding to the adhesion degree is determined, and the local peak detection method corresponding to the adhesion degree is called to perform local peak detection on the grayscale remapping results to obtain the coordinates of the local peak.
[0140] It should be noted that a training dataset can be pre-constructed. The data samples in the training dataset are grayscale remapping results of multiple adherent cell clusters, and the labels used for the data samples are numerical values representing the degree of adhesion of individual somatic cells within each adherent cell cluster, such as 1 or 2. Here, 1 represents that the overlap area between somatic cells in the adherent cell cluster does not exceed a preset area threshold, and 2 represents that the overlap area between somatic cells in the adherent cell cluster exceeds the preset area threshold. The initial classification model is trained using the training dataset until the model stops training, resulting in an adhesion degree classification model. It is understandable that, compared to deep learning-based somatic cell counting models in related technologies, the adhesion degree classification model is a simpler classification model, requiring less data and computational resources.
[0141] In some implementations, please refer to Figure 5a Adhesive cell segmentation is performed on the image based on the number of somatic cells to obtain the adhesion cell segmentation results, including:
[0142] S510. Mark the region in the sampled image other than the clustered cells as the background region. Perform clustering processing on the pixels corresponding to the clustered cells in the sampled image according to the number of somatic cells. Mark the foreground region in the sampled image according to the clustering processing results to obtain the second segmentation auxiliary image.
[0143] S520. Based on the second segmentation auxiliary image and the model image, the adhesion cells are segmented to obtain the second contour marker image corresponding to the adhesion cell cluster.
[0144] S530. Perform contour recognition based on the second contour marker image to obtain the segmentation result of the adhesion cells.
[0145] Specifically, please refer to Figure 5b After generating a model image based on the original fluorescence image and the outlines of suspicious cells, the regions in the model image other than the clusters of adherent cells are marked as background regions. It is necessary to determine the foreground and unknown regions within the regions corresponding to the clusters of adherent cells. Since the number of somatic cells has been determined, the pixels corresponding to the clusters of adherent cells in the model image are clustered using the number of somatic cells as the cluster number, yielding the clustering results. Based on the clustering results, the foreground regions are marked in the model image, thus completing the determination of the background and foreground regions in the model image, resulting in the second segmentation auxiliary image. (See also...) Figure 5c Guided by the second segmentation auxiliary image, the second segmentation auxiliary image and the model image are used as inputs to the second watershed algorithm to segment the adhesiocellular clusters in the model image, thereby obtaining the second contour label image corresponding to the adhesiocellular clusters. Contour recognition is then performed based on the second contour label image to obtain the adhesiocellular cluster segmentation result.
[0146] Understandably, the first time the watershed algorithm is used, a model image is generated based on the original fluorescence image and the outline of suspicious cells, such as... Figure 5b As shown, after the first watershed, somatic cells 502 and clusters of adherent cells 504 are obtained. The outline of somatic cell 502 is marked as 1, and the outline of clusters of adherent cells 504 is marked as 2. Clearly, after the first watershed, clusters of adherent cells 504 are identified as a single somatic cell. Further analysis shows that outline 2 of somatic cell 504 is a suspicious cell outline, requiring a second watershed algorithm for secondary segmentation. After the second watershed, the two somatic cells within clusters of adherent cells 504 are segmented, as shown... Figure 5c As shown, somatic cells 502, 506, and 508 are obtained (i.e., somatic cells 506 and 508 adhere to each other to form an adhered cell cluster 504). The outline of somatic cell 502 is marked as 1, the outline of somatic cell 506 is marked as 2, and the outline of somatic cell 508 is marked as 3. It can be seen that by using the watershed algorithm twice, the somatic cells with adhesion can be accurately identified.
[0147] It should be noted that if there are multiple suspicious cell contours in the contour list, each suspicious cell contour can be processed in the same way. The number of somatic cells included in a suspicious cell contour can be greater than or equal to 2.
[0148] In the above implementation, compared with the gradient image obtained by edge detection using the watershed algorithm in related technologies, a model image of the adherent cell clusters is first generated. Then, two different processing branches are used for the model image (one branch directly marks the area in the model image other than the adherent cell clusters as the background area, and the other branch performs image grayscale remapping based on the model image and determines the number of somatic cells to mark the foreground area in the model image), thereby determining the foreground and background areas of the model image respectively. It can be seen that generating an accurate labeled image through the above traditional image processing method can more accurately guide or assist the watershed algorithm, and subsequently, the boundaries of somatic cells can be accurately determined. Furthermore, considering the differences between the object using the watershed algorithm for the first time and the object using it for the second time, the generation method of the second segmentation auxiliary image differs from the generation method of the first segmentation auxiliary image.
[0149] In some embodiments, before obtaining the molded image of the adherent cell clusters from the original fluorescence image based on the mask data corresponding to the suspicious cell contours, the method further includes: generating a black image of the same size as the original fluorescence image; wherein the pixel values of the black image are equal to 0; updating the pixel values of the suspicious cell contours in the black image to 255 to obtain the mask data corresponding to the suspicious cell contours. Accordingly, obtaining the molded image of the adherent cell clusters from the original fluorescence image based on the mask data corresponding to the suspicious cell contours includes: performing a matting operation on the original fluorescence image and the mask data to obtain the molded image.
[0150] Specifically, the outline list is traversed, and suspicious cell outlines of adherent cell clusters are identified by the area and shape of the somatic cell outlines. If an outline is found to be too large or abnormally shaped, mask data is generated, and the adherent cell cluster is then used for image extraction. The mask data is generated by: generating a black image of the same size as the original fluorescence image; wherein the pixel values of the black image are equal to 0; updating the pixel values of the suspicious cell outlines in the black image to 255, and setting the values of areas outside the outlines to 0, thus obtaining the mask data corresponding to the suspicious cell outlines. The image extraction is generated by performing a bitwise AND operation between the original fluorescence image and the mask data to obtain the image extraction image.
[0151] In some embodiments, before performing somatic cell counting based on the adhesion cell segmentation results to obtain the somatic cell count results, the method may further include: traversing the somatic cell contours in the contour list; if a somatic cell contour corresponds to a single cell, drawing the somatic cell contour of the single cell in the original fluorescence image and outputting the single cell number; correspondingly, performing somatic cell counting based on the adhesion cell segmentation results to obtain the somatic cell count results includes: drawing the contours of the single cells in the adhesion cell segmentation results in the original fluorescence image and numbering the single cells in the adhesion cell segmentation results to obtain the somatic cell count results.
[0152] Specifically, the contour list includes parameters such as contour area and contour shape features. The somatic cell contours in the contour list are traversed based on these parameters. If any somatic cell contour corresponds to a single cell based on its contour area and shape features, the contour of that somatic cell is drawn in the original fluorescence image, and the single cell's number is output. If any somatic cell contour corresponds to an adhesion cell cluster based on its contour area and shape features, the corresponding image for the adhesion cell cluster is determined. The image grayscale remapping of the image is performed to obtain the grayscale remapping result of the adhesion cell cluster. A marker image is generated based on the grayscale remapping result. Using the marker image as a guide, adhesion cell segmentation is performed on the image for adhesion cell segmentation, resulting in adhesion cell segmentation results. The adhesion cell segmentation results include the contours of single cells. The contours of the single cells in the adhesion cell segmentation results are drawn in the original fluorescence image (e.g., ...). Figure 5d As shown in the figure, the individual cells in the segmentation results of the adhesion cells are numbered to obtain the somatic cell count results.
[0153] In some implementations, please refer to Figure 6 The method may also include:
[0154] S610. Calculate the centroid coordinates of each somatic cell contour according to the order of the contour list.
[0155] S620. Sort the somatic cell contours in the contour list according to the centroid coordinates to obtain a set of somatic cell contours arranged in a preset format.
[0156] S630. Traverse the set of somatic cell outlines and determine whether any somatic cell outline needs to be deleted based on its area and shape parameters.
[0157] Specifically, the centroid coordinates of each somatic cell contour are calculated according to the order of the contour list. The contours in the list are then sorted based on their centroid coordinates, arranging them from top to bottom and left to right, resulting in a set of somatic cell contours arranged according to a preset format. This set is then iterated through, looping through the contours in the list. Parameters such as the area and shape of the somatic cells are calculated based on these contours. If any somatic cell contour does not meet the criteria, it is removed from the list.
[0158] In some implementations, suspicious cell outlines of adherent cell clusters are determined by traversing a list of outlines and searching for suspicious cell outlines that meet preset screening criteria based on the area and shape parameters of any somatic cell outline.
[0159] The preset screening criteria include an area parameter exceeding a cell area threshold or a shape parameter exceeding a preset roundness threshold. Specifically, the contour list can include the area and shape parameters of somatic cell contours. The contour list is traversed to determine whether the area and shape parameters of the somatic cell contours meet the preset screening criteria, thus obtaining suspicious cell contours. The cell area threshold can be determined based on the area of a single somatic cell, and the preset roundness threshold can be determined based on the roundness of a single somatic cell.
[0160] In the above embodiments, during the process of determining the outline of suspicious cells, any one of multiple parameters is used to determine the outline of suspicious cells in the outline list, thereby enabling a more comprehensive determination of the outline of suspicious cells and improving the accuracy and reliability of the counting results.
[0161] This specification also provides a bovine milk somatic cell counting device 700; please refer to [link to documentation]. Figure 7 The bovine milk somatic cell counting device 700 includes:
[0162] The initial cell segmentation module 710 is used to perform initial cell segmentation based on the original fluorescence image of bovine somatic cells and the first segmentation auxiliary image to obtain a list of bovine somatic cell contours; wherein, the first segmentation auxiliary image is generated by marking the background region and the foreground region in the original fluorescence image; the pixel position between two adjacent pixels of each somatic cell contour in the contour list does not exceed a preset pixel threshold, and each somatic cell contour in the contour list has the same level and is independent of each other.
[0163] The grayscale remapping module 720 is used to obtain a model image of the adherent cell cluster from the original fluorescence image based on the mask data corresponding to the suspected cell cluster if there are suspicious cell contours of adherent cell clusters in the contour list; and to perform image grayscale remapping on the model image to obtain the grayscale remapping result of the adherent cell cluster.
[0164] The adhesion cell segmentation module 730 is used to determine the number of somatic cells in the model image based on the grayscale remapping result, and to perform adhesion cell segmentation on the model image based on the number of somatic cells to obtain the adhesion cell segmentation result.
[0165] The somatic cell counting module 740 is used to perform somatic cell counting based on the results of adhering cell segmentation to obtain somatic cell counting results.
[0166] In some embodiments, the initial cell segmentation module 710 is further configured to perform cell segmentation based on the original fluorescence image and the first segmentation auxiliary image to obtain a first contour marker image of bovine milk somatic cells; and to perform contour recognition on the first contour marker image according to the principle of equal and independent contour levels to obtain a contour list; wherein, the principle of equal and independent contour levels is used to describe the relationship that the identified somatic cell contours belong to the same level and are independent of each other.
[0167] In some embodiments, the adhesion cell segmentation module 730 is further configured to input the grayscale remapping result into the adhesion level classification model to obtain the adhesion level of the adhesion cell cluster; and to search in the level quantity mapping relationship according to the adhesion level to obtain the number of individual somatic cells included in the adhesion cell cluster as the number of somatic cells; wherein, the level quantity mapping relationship is used to describe the correspondence between the adhesion level of the adhesion cell cluster and the number of individual somatic cells in the adhesion cell cluster.
[0168] In some implementations, the adhesion cell segmentation module 730 is also used to perform local peak detection based on the grayscale remapping results to obtain the coordinates of the local peaks; and to determine the number of somatic cells based on the coordinates of the local peaks.
[0169] In some implementations, the adhesion cell segmentation module 730 is also used to input the grayscale remapping result into the adhesion degree classification model to obtain the adhesion degree of the adhesion cell cluster; and to call the local peak detection method corresponding to the adhesion degree to perform local peak detection on the grayscale remapping result to obtain the coordinates of the local peak.
[0170] In some embodiments, the adhesion cell segmentation module 730 is used to mark the area other than the adhesion cell clusters in the molded image as the background area, cluster the pixels corresponding to the adhesion cell clusters in the molded image according to the number of somatic cells, and mark the foreground area in the molded image according to the clustering result to obtain a second segmentation auxiliary image; perform adhesion cell segmentation based on the second segmentation auxiliary image and the molded image to obtain a second contour labeling image corresponding to the adhesion cell clusters; and perform contour recognition based on the second contour labeling image to obtain the adhesion cell segmentation result.
[0171] In some embodiments, the milk somatic cell counting device 700 further includes a somatic cell contour traversal module, which is used to traverse the somatic cell contours in the contour list. If the somatic cell contour corresponds to a single cell, the somatic cell contour of the single cell is drawn in the original fluorescence image, and the single cell number is output.
[0172] The somatic cell counting module 740 is also used to plot the outline of a single cell in the adhesion cell segmentation result on the original fluorescence image and to number the single cells in the adhesion cell segmentation result to obtain the somatic cell counting result.
[0173] In some embodiments, the milk somatic cell counting device 700 further includes a somatic cell contour filtering module, which is used to calculate the centroid coordinate position of each somatic cell contour according to the order of the contour list; sort the somatic cell contours in the contour list according to the centroid coordinate position to obtain a set of somatic cell contours arranged in a preset format; traverse the set of somatic cell contours and determine whether any somatic cell contour needs to be deleted according to the area parameter and shape parameter of any somatic cell contour.
[0174] In some embodiments, the bovine somatic cell counting device 700 further includes a labeled image generation module for determining a binary image corresponding to the original fluorescence image; wherein, the pixels corresponding to the somatic cell region in the binary image are denoted as foreground pixels; the pixel values of the foreground pixels are replaced with the distance from the foreground pixel to the nearest background pixel to obtain a distance-transformed image, and threshold segmentation is performed based on the distance-transformed image to determine the foreground region of the original fluorescence image; morphological opening and morphological dilation operations are applied to the binary image to determine the background region of the original fluorescence image; the region located between the foreground region and the background region is determined as an unknown region to obtain a first segmentation auxiliary image.
[0175] Further functional descriptions of the above modules are the same as those in the corresponding embodiments described above, and will not be repeated here.
[0176] The bovine milk somatic cell counting device in this embodiment is presented in the form of a functional unit. Here, a unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.
[0177] Please see Figure 8 , Figure 8 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application, such as... Figure 8 As shown, the computer device includes one or more processors 10, memory 20, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components communicate with each other via different buses and can be mounted on a common motherboard or otherwise installed as needed. The processors can process instructions executed within the computer device, including instructions stored in or on memory to display graphical information of a GUI on external input / output devices (such as display devices coupled to the interfaces). In some alternative implementations, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple computer devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 8 Take a processor 10 as an example.
[0178] Processor 10 may be a central processing unit, a network processor, or a combination thereof. Processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GDA), or any combination thereof.
[0179] The memory 20 stores instructions executable by at least one processor 10 to cause the at least one processor 10 to perform the method shown in the above embodiments.
[0180] The memory 20 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the computer device. Furthermore, the memory 20 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, the memory 20 may optionally include memory remotely located relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0181] The memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk or solid-state drive; the memory 20 may also include a combination of the above types of memory.
[0182] The computer device also includes a communication interface 30 for communicating with other devices or communication networks.
[0183] This application also provides a computer-readable storage medium. The methods described in this application can be implemented in hardware or firmware, or implemented as recordable on a storage medium, or implemented as computer code downloaded over a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and subsequently stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code. When the software or computer code is accessed and executed by the computer, processor, or hardware, the methods shown in the above embodiments are implemented.
[0184] This application provides a computer program product including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the method of any embodiment of this application.
[0185] Although embodiments of this application have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of this application, and all such modifications and variations fall within the scope defined by the appended claims.
[0186] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.
[0187] For ease of description, the above devices are described separately by function as various units. Of course, in implementing this application, the functions of each unit can be implemented in one or more software and / or hardware.
[0188] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0189] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in one or more blocks of the flowchart illustrations and / or one or more blocks of the block diagrams.
[0190] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means that implement the functions specified in one or more flowcharts and / or one or more block diagrams.
[0191] These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process, such that the instructions, which execute on the computer or other programmable apparatus, provide steps for implementing the functions specified in one or more flowcharts and / or one or more block diagrams.
[0192] It should also be noted that 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 said element.
[0193] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0194] The foregoing is merely an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.
[0195] Although embodiments of this application have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of this application, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. A method for counting bovine milk somatic cells, characterized in that: The method comprises: Performing initial cell segmentation based on the original fluorescent image of bovine milk somatic cells and the first segmentation auxiliary image to obtain a contour list of the bovine milk somatic cells; wherein the first segmentation auxiliary image is generated by marking the background area and the foreground area in the original fluorescent image; the pixel position between two adjacent pixel points of each somatic cell contour in the contour list does not exceed a preset pixel threshold, and the somatic cell contours in the contour list have the same level and are independent of each other; If there is a suspicious cell contour of the adherent cell cluster in the contour list, acquiring a model image of the adherent cell cluster from the original fluorescent image based on mask data corresponding to the suspicious cell contour; and performing image grayscale remapping on the model image to obtain a grayscale remapping result of the adherent cell cluster; Determine the number of somatic cells in the modeling image according to the grayscale remapping result, and perform adhesion cell segmentation on the modeling image according to the number of somatic cells to obtain an adhesion cell segmentation result; Somatic cell counting is performed based on the adhesion cell segmentation result to obtain a somatic cell counting result.
2. The method according to claim 1, characterized in that: The initial cell segmentation is performed based on the original fluorescent image of the bovine milk somatic cells and the first segmentation auxiliary image to obtain the outline list of the bovine milk somatic cells, including: Perform cell segmentation based on the original fluorescent image and the first segmentation auxiliary image to obtain a first contour marking image of the bovine milk somatic cell; The first contour-marked image is subjected to contour recognition according to the contour level equality and independence principle to obtain the contour list; wherein the contour level equality and independence principle is used to describe the relationship that the recognized somatic cell contours belong to the same level and are independent of each other.
3. The method according to claim 1, characterized in that The determining the number of somatic cells in the modulus image according to the grayscale remapping result includes: Performing local peak detection based on the grayscale remapping result to obtain the coordinates of the local peak; The somatic cell number is determined based on the coordinates of the local peak.
4. The method according to claim 3, characterized in that The performing local peak detection based on the grayscale remapping result to obtain the coordinates of the local peak includes: Inputting the grayscale remapping result into an adhesion degree classification model to obtain the adhesion degree of the adhesion cell cluster; The local peak detection method corresponding to the adhesion degree is called to perform local peak detection on the grayscale remapping result to obtain the coordinates of the local peak.
5. The method according to claim 1, characterized in that The step of performing adhesion cell segmentation on the modeling image according to the number of somatic cells to obtain an adhesion cell segmentation result includes: Marking the area other than the adhesion cell cluster in the modulus image as a background area, clustering the pixels corresponding to the adhesion cell cluster in the modulus image according to the number of somatic cells, and marking the foreground area in the modulus image according to the clustering result to obtain a second segmentation auxiliary image; Perform adhesion cell segmentation based on the second segmentation auxiliary image and the modeling image to obtain a second contour marking image corresponding to the adhesion cell cluster; Contour recognition is performed according to the second contour-marked image to obtain the adhesion cell segmentation result.
6. The method according to claim 1, characterized in that Before performing somatic cell counting based on the adhesion cell segmentation result to obtain a somatic cell counting result, the method further includes: Traversing the somatic cell contours in the contour list, if the somatic cell contour corresponds to a single cell, drawing the somatic cell contour of the single cell in the original fluorescent image, and outputting the number of the single cell; The step of performing somatic cell counting based on the adhesion cell segmentation result to obtain a somatic cell counting result comprises: The outline of the single cell in the adhesion cell segmentation result is drawn in the original fluorescent image, and the single cell in the adhesion cell segmentation result is numbered to obtain the somatic cell counting result.
7. The method according to claim 1, characterized in that The method further comprises: Calculating the centroid coordinate position of each somatic cell contour in the order of the contour list; Sorting the somatic cell contours in the contour list according to the centroid coordinate positions to obtain a somatic cell contour set arranged in a preset format; The somatic cell contour set is traversed, and it is determined whether any somatic cell contour needs to be deleted according to the area parameter and shape parameter of any somatic cell contour.
8. The method according to claim 1, characterized in that The first segmentation auxiliary image is obtained by: Determine a binary image corresponding to the original fluorescent image; wherein pixels corresponding to the somatic cell region in the binary image are recorded as foreground pixels; Replacing the pixel value of the foreground pixel with the distance from the foreground pixel to the nearest background pixel to obtain a distance transformation image, and performing threshold segmentation based on the distance transformation image to determine the foreground area of the original fluorescent image; Applying morphology to perform an opening operation and a morphological dilation operation on the binary image to determine a background area of the original fluorescent image; An area between the foreground area and the background area is determined as an unknown area to obtain the first segmentation auxiliary image.
9. A milk somatic cell counting device, characterized in that: The device comprises: An initial cell segmentation module is used to perform initial cell segmentation based on an original fluorescent image of bovine milk somatic cells and a first segmentation auxiliary image to obtain a contour list of the bovine milk somatic cells; wherein the first segmentation auxiliary image is generated by marking a background area and a foreground area in the original fluorescent image; the pixel position between two adjacent pixel points of each somatic cell contour in the contour list does not exceed a preset pixel threshold, and each somatic cell contour in the contour list has the same level and is independent of each other; A grayscale remapping module is used for obtaining a modeling image of the adhesion cell cluster from the original fluorescent image based on mask data corresponding to the suspicious cell contour if there is a suspicious cell contour of the adhesion cell cluster in the contour list; and performing image grayscale remapping on the modeling image to obtain a grayscale remapping result of the adhesion cell cluster; an adhesion cell segmentation module, used for determining the number of somatic cells in the modeling image according to the grayscale remapping result, and performing adhesion cell segmentation on the modeling image according to the number of somatic cells to obtain an adhesion cell segmentation result; The somatic cell counting module is used to count somatic cells based on the adhesion cell segmentation result to obtain a somatic cell counting result.
10. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method according to any one of claims 1 to 8 by executing the computer instructions.
Citation Information
Patent Citations
Image processing-based erythrocyte and leukocyte classification counting method, system and device
CN110110709A
Fluorescence image cell rapid segmentation method and system
CN116645390A