Non-invasive dairy cow mastitis detection device
By using infrared thermal imaging technology and image processing technology in the detection of cow mastitis, non-invasive cow mastitis detection devices are designed, and the problems of low detection efficiency and poor accuracy in the existing technology are solved, and rapid and accurate detection of cow mastitis is achieved, and the cost is reduced.
Patent Information
- Application Number
- CN202510108875.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-23
- Publication Date
- 2025-05-13
AI Technical Summary
In the prior art, the detection of dairy cow mastitis has problems with low image quality, difficulty in precise positioning of key parts, and difficulty in building multi-factor fusion grading models, resulting in low detection efficiency and poor accuracy.
An infrared thermal imaging technology combined with image processing technology is used to design a non-invasive cow mastitis detection device. The device includes an image acquisition module, an image enhancement module, an image feature extraction module, an image segmentation module, a coordinate marking module and a detection module. Through wavelet transformation, region suggestion network, deep learning semantic segmentation algorithm and mastitis grading model, rapid and accurate detection of mastitis in dairy cows is achieved.
This device can achieve rapid and accurate detection of mastitis in cows, avoid interference and harm from traditional detection methods on cows, improve detection efficiency and accuracy, and significantly reduce costs.
Smart Images

Figure CN119992598A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of deep learning and artificial intelligence, and in particular relates to a non-invasive cow mastitis detection device. Background Art
[0002] Cow mastitis is one of the common diseases in dairy farming. Traditional mastitis detection and grading methods require manual collection of milk samples for testing and analysis, which has problems such as low detection efficiency and poor real-time performance. Infrared thermal imaging technology can quickly obtain the temperature distribution information of the cow's body surface, providing a new idea for mastitis detection and grading. However, infrared thermal imaging data is easily interfered by environmental factors, the imaging quality is not high, and the reliability of direct application in mastitis detection is insufficient. In addition, the precise positioning of key parts such as eyes and udders in infrared images of cows is also a major difficulty, which is crucial for subsequent temperature information extraction and analysis. Mastitis detection also needs to consider the influence of factors such as cow breed, parity, and lactation stage. It is difficult to achieve comprehensive and accurate mastitis grading with only a single temperature indicator. In summary, non-invasive cow mastitis detection faces three major technical challenges: image quality enhancement, precise positioning of key parts, and construction of a mastitis grading model integrating multiple factors. Summary of the invention
[0003] In order to solve the problems existing in the prior art, the present invention provides a non-invasive cow mastitis detection device, which adopts infrared thermal imaging technology and can perform detection without contacting the cow, thus avoiding the interference and harm to the cow caused by traditional detection methods.
[0004] To achieve the above object, the present invention provides the following solutions:
[0005] A non-invasive cow mastitis detection device comprises: an image acquisition module, an image enhancement module, an image feature extraction module, an image segmentation module, a coordinate marking module and a detection module;
[0006] An image acquisition module is used to acquire RGB images and original infrared thermal imaging images of dairy cows based on an infrared thermal imager;
[0007] The image enhancement module is used to perform denoising on the RGB image using an image enhancement algorithm based on wavelet transform to obtain an enhanced first image;
[0008] The image feature extraction module is used to extract image features from the first image through a pre-built feature extraction model, generate candidate regions using a region proposal network, and obtain a second image containing key parts;
[0009] The image segmentation module is used to extract semantic information and perform ROI region segmentation on the second image using a semantic segmentation algorithm based on deep learning to obtain segmentation coordinates; wherein the ROI region includes a bull's eye region and a breast region;
[0010] The coordinate marking module is used to mark the segmentation coordinates into the acquired original infrared thermal imaging image, and extract the temperature feature vectors of the cow's eye area and the breast area in the original infrared thermal imaging image based on the segmentation coordinates;
[0011] The detection module is used to perform mastitis grading detection based on the temperature feature vectors of the cow's eye area and the udder area through a mastitis grading model to obtain a mastitis grading result.
[0012] Preferably, the image enhancement module includes:
[0013] A denoising unit, used for decomposing the RGB image of the cow into a low-frequency component and a high-frequency component by performing wavelet decomposition on the RGB image of the cow, and filtering and denoising the noise information in the high-frequency component;
[0014] The enhancement unit is used to fuse the denoised high-frequency component and the low-frequency component using a wavelet reconstruction algorithm to obtain an enhanced first image.
[0015] Preferably, the feature extraction module includes:
[0016] An image feature data acquisition unit, configured to acquire a multi-dimensional feature vector representation of the first image according to the feature extraction model to obtain image feature data; the multi-dimensional feature vector representation includes color, texture and shape;
[0017] A sliding window unit is used to determine whether each window area contains key parts by sliding on the image in a sliding window manner according to the image feature data and using a region proposal network algorithm; wherein the key parts include cow eyes and cow udders;
[0018] A candidate coordinate acquisition unit, used to determine the current area as a candidate area if the current window area contains the key part, and obtain the coordinate data of the candidate area;
[0019] A candidate image acquisition unit, configured to extract corresponding candidate region image data from the first image according to the candidate region coordinate data, to obtain a plurality of candidate region images;
[0020] A candidate region feature acquisition unit, configured to extract features from each candidate region image using the feature extraction model to obtain candidate region feature data;
[0021] A clustering unit, used to perform cluster analysis on the candidate region feature data, determine the similarity of each candidate region, and obtain candidate region category information based on the similarity;
[0022] The image stitching unit is used to extract the candidate area image containing the key part from the first image according to the candidate area category information and stitch it into a second image to obtain the second image containing the target key part.
[0023] Preferably, the structure of the feature extraction model includes: two input layers, two encoders with the same structure and a predictor; wherein the encoder includes a convolutional layer, a pooling layer, a residual block, a channel attention mechanism module and a global average pooling layer; the predictor includes two fully connected layers.
[0024] Preferably, the image segmentation module comprises:
[0025] A preliminary segmentation unit, used to perform semantic segmentation on the second image according to a pre-established deep learning semantic segmentation model, identify and segment the cow's eye area and the breast area in the second image, and obtain a preliminary segmentation result;
[0026] An optimization unit, used for post-processing the preliminary segmentation result through morphological operations to optimize the segmentation boundary;
[0027] A ROI region acquisition unit, used to obtain the contour of the ROI region according to the optimized segmentation result; wherein the ROI region includes the bull's eye region and the breast region;
[0028] The segmentation coordinate acquisition unit is used to extract the pixel coordinates of the cow eye area and the breast area, and use the pixel coordinates as the segmentation coordinates.
[0029] Preferably, the structure of the deep learning semantic segmentation model includes: a ResNet50 backbone network, an attention refinement module, a feature pyramid module, and a spatial attention feature fusion module.
[0030] Preferably, the process of obtaining the preliminary segmentation result includes:
[0031] Perform multi-scale feature extraction on the second image based on the ResNet50 backbone network to obtain multi-scale features;
[0032] Performing key feature enhancement on the multi-scale features based on the attention refinement module to obtain a key feature map;
[0033] Based on the feature pyramid module, multi-scale context information and local detail information of the key feature graph are obtained to obtain high-level semantic features;
[0034] Based on the spatial attention feature fusion module, the multi-scale features are fused to obtain low-level semantic features, and the low-level semantic features are fused with the high-level semantic features to obtain the preliminary segmentation result; wherein each pixel in the preliminary segmentation result is assigned a category label; the category labels include bull's eye area, breast area and background area.
[0035] Preferably, the coordinate marking module includes:
[0036] A temperature distribution matrix acquisition unit is used to extract the temperature distribution information of the cow's eye area and the breast area in the original infrared thermal imaging image based on the segmentation coordinates, and use a Gaussian filter algorithm to smooth the temperature distribution information to obtain a temperature distribution matrix;
[0037] The temperature characteristic vector acquisition unit is used to calculate the average temperature, temperature standard deviation and temperature gradient of the cow eye area and the udder area according to the temperature distribution matrix to obtain the temperature characteristic vector.
[0038] Preferably, the detection module comprises:
[0039] A feature coding unit, used for taking the breed, parity and lactation stage of the dairy cow as non-temperature features, and converting the non-temperature features into numerical feature vectors by using a feature coding method;
[0040] A feature fusion unit, used for fusing the temperature feature vector with the non-temperature feature vector to obtain a fused feature vector;
[0041] The detection unit is used to input the fused feature vector into a mastitis grading model constructed based on a random forest algorithm to obtain the mastitis grading result.
[0042] Compared with the prior art, the present invention has the following beneficial effects:
[0043] Non-invasive: The device uses infrared thermal imaging technology and can perform detection without touching the cows, avoiding the interference and harm to cows caused by traditional detection methods.
[0044] Strong real-time performance: The infrared images collected in the prior art occupy memory and have a slow processing speed. Therefore, the present invention collects RGB and IFR images of dairy cows at the same time, uses the RGB images for ROI segmentation, and marks the segmentation coordinates in the IFR image, thereby improving the data processing speed of the device.
[0045] Fast and accurate: Through advanced image processing technology and mastitis grading model, the device can achieve fast and accurate detection of cow mastitis, greatly improving detection efficiency and accuracy.
[0046] Reduce costs: The use of this device can significantly reduce the manpower, material and time costs required for traditional detection methods, providing strong support for the healthy development of the dairy farming industry.
[0047] In summary, the non-invasive bovine mastitis detection device constructed by the present invention has significant technical advantages and practical application value, and is an indispensable and important tool in the dairy cattle breeding industry. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solution of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0049] Figure 1 The figure is a schematic diagram of the structure of a non-invasive bovine mastitis detection device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0050] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0051] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0052] Embodiment 1
[0053] like Figure 1 As shown, a non-invasive cow mastitis detection device includes: an image acquisition module, an image enhancement module, an image feature extraction module, an image segmentation module, a coordinate marking module and a detection module;
[0054] An image acquisition module is used to acquire RGB images and original infrared thermal imaging images of dairy cows based on an infrared thermal imager;
[0055] The image enhancement module is used to perform denoising on the RGB image using an image enhancement algorithm based on wavelet transform to obtain an enhanced first image; a further implementation method is that the image enhancement module includes:
[0056] The denoising unit is used to decompose the RGB image of the cow into low-frequency components and high-frequency components by performing wavelet decomposition on the RGB image of the cow, and filter and denoise the noise information in the high-frequency component; specifically, the low-frequency component usually reflects the main content and structure of the image, while the high-frequency component contains more details and edge information, and may also contain noise. In this embodiment, adaptive filtering is used to identify and effectively remove noise information. This step is intended to retain useful details in the image while removing unnecessary noise.
[0057] The enhancement unit is used to fuse the denoised high-frequency components and low-frequency components using a wavelet reconstruction algorithm to obtain an enhanced first image. Specifically, based on the component fusion, the enhancement unit uses a wavelet reconstruction algorithm to generate a new image. This image removes noise while retaining the main content of the original image, and enhances the clarity and contrast of the image.
[0058] An image feature extraction module is used to extract image features from the first image through a pre-built feature extraction model, generate candidate regions using a region proposal network, and obtain a second image containing key parts; a further implementation method is that the feature extraction module includes:
[0059] The image feature data acquisition unit is used to acquire a multi-dimensional feature vector representation of the first image according to a feature extraction model to obtain image feature data; the multi-dimensional feature vector representation includes color, texture and shape.
[0060] The sliding window unit is used to use the region proposal network (RPN) algorithm for image feature data, slide on the image by sliding the window, and determine whether each window area contains key parts; wherein the key parts include cow eyes and cow udders; specifically, RPN is a fully convolutional network that can slide small windows (also called anchors) on the feature map and generate a series of candidate regions (region proposals) for each window. These candidate regions have different sizes and aspect ratios, and are designed to cover objects of various shapes and sizes that may appear in the image. RPN moves on the feature map by sliding the window, and calculates the category score of the candidate region (i.e., the probability of whether the region contains key parts) and the bounding box regression offset for each window. These scores and offsets are calculated by the convolutional layer and fully connected layer inside the RPN.
[0061] The candidate coordinate acquisition unit is used to determine the current area as a candidate area if the current window area contains the key part, and obtain the coordinate data of the candidate area; specifically, according to the category score output by the RPN, a threshold is set to determine whether each candidate area contains the key part (such as a cow's eye or a cow's udder).
[0062] The candidate image acquisition unit is used to extract the corresponding candidate area image data from the first image according to the candidate area coordinate data to obtain a plurality of candidate area images; specifically, if a candidate area with coordinates (100, 200) and a size of 150x150 is detected, the image data of the area can be extracted from the original image to form a new sub-image.
[0063] The candidate region feature acquisition unit is used to extract features from each candidate region image using a feature extraction model to obtain candidate region feature data.
[0064] The clustering unit is used to perform cluster analysis on the feature data of the candidate regions to determine the similarity of each candidate region and obtain the category information of the candidate regions based on the similarity.
[0065] The image stitching unit is used to extract the candidate area image containing the key part from the first image according to the candidate area category information, and stitch it into a second image to obtain the second image containing the target key part.
[0066] A further implementation method is that the structure of the feature extraction model includes: two input layers, two encoders with the same structure and a predictor; wherein the encoder includes a convolutional layer, a pooling layer, a residual block, a channel attention mechanism module and a global average pooling layer; the predictor includes two fully connected layers.
[0067] The specific structure includes: a 7x7 convolutional layer with a stride of 2 and a padding of 3, which is used to extract preliminary features of the image. This is followed by a batch normalization layer and a ReLU activation function layer. After the convolutional layer, a 3x3 max pooling layer with a stride of 2 is set to further reduce the size of the feature map. Then there are four stages of residual blocks, each of which contains multiple residual blocks, and as the stage goes deeper, the number of convolutional layers and channels in the residual block will gradually increase. The residual block implements residual learning by introducing skip connections, so that the network can maintain good performance while deepening. There are two types of residual blocks: basic residual blocks (for shallower network layers) and bottleneck residual blocks (for deeper network layers). The bottleneck residual block consists of three convolutional layers: the first 1x1 convolutional layer is used to reduce the number of channels; the second 3x3 convolutional layer is used to extract features; and the last 1x1 convolutional layer is used to restore the number of channels. The skip connection directly connects the input and output to achieve residual learning.
[0068] In this embodiment, a channel attention mechanism module is introduced after the residual block. Specifically, the output feature map of the residual block is first subjected to global average pooling (Global Average Pooling) to compress the feature map of each channel into a scalar value. This step aims to obtain the global receptive field information of each channel. Next, a fully connected layer (or two fully connected layers with a ReLU activation function in between) is used to transform the compressed features to predict the importance weight of each channel. Finally, the Sigmoid activation function is used to map the output of the excitation operation to between 0 and 1 to obtain the weight of each channel. These weights are then multiplied channel by channel with the original feature map to achieve recalibration of the feature map.
[0069] A global average pooling layer is used before the last layer of the network to reduce the spatial dimension and convert it into a one-dimensional vector.
[0070] The predictor is used to map the feature map generated by any one of the encoders, and then calculate the similarity between the feature map produced by the other encoder and the mapping map. The result of the similarity calculation reflects the degree of semantic or content proximity between the two feature maps. When the similarity meets the preset similarity threshold, the candidate region feature data is output.
[0071] An image segmentation module is used to extract semantic information and segment the ROI region of the second image using a semantic segmentation algorithm based on deep learning to obtain segmentation coordinates; wherein the ROI region includes a bull's eye region and a breast region; a further implementation method is that the image segmentation module includes:
[0072] The preliminary segmentation unit performs semantic segmentation on the second image according to a pre-established deep learning semantic segmentation model, identifies and segments the cow's eye area and the breast area in the second image, and obtains a preliminary segmentation result.
[0073] The optimization unit post-processes the preliminary segmentation results through morphological operations to optimize the segmentation boundaries.
[0074] The ROI region acquisition unit is used to obtain the contour of the ROI region according to the optimized segmentation result; wherein the ROI region includes the cow eye region and the breast region; in this embodiment, the segmentation map is post-processed to obtain a more accurate RO1 segmentation result. The post-processing steps include morphological operations and contour detection. Through these operations, the noise in the segmentation map can be eliminated, holes can be filled, and boundaries can be smoothed to obtain a more accurate ROI region. Specifically, an image data set containing the target ROI is collected and annotated. The data set contains a large number of positive samples (images containing ROI) and negative samples (images that do not contain ROI), and the ROI is annotated at the pixel level. The semantic segmentation model is trained using the annotated data set. During the training process, the model will learn how to classify each pixel in the image as ROI or background.
[0075] The segmentation coordinate acquisition unit is used to extract the pixel coordinates of the cow eye area and the breast area, and use the pixel coordinates as the segmentation coordinates.
[0076] A further implementation method is that the structure of the deep learning semantic segmentation model includes: a ResNet50 backbone network, an attention refinement module, a feature pyramid module, and a spatial attention feature fusion module.
[0077] A further implementation method is that the process of obtaining the preliminary segmentation result includes:
[0078] Perform multi-scale feature extraction on the second image based on the ResNet50 backbone network to obtain multi-scale features;
[0079] Based on the attention refinement module, the key features of the multi-scale features are enhanced to obtain the key feature map; in this embodiment, the attention refinement module (SARM) includes global maximum pooling GMP, global average pooling GAP and stripe pooling SP at the same time. GMP is translation invariant, and can retain more local details while capturing global information, and gather more detailed channel information. GAP can retain the integrity and more background information of the feature map data. SP uses a long strip-shaped pooling kernel to perform pooling operations along the horizontal or vertical spatial dimension, and pays more attention to the long-distance spatial dependencies of isolated areas. SARM redistributes feature weights in a targeted manner to enhance the perception of small target information.
[0080] Based on the feature pyramid module, multi-scale context information and local detail information of the key feature graph are obtained to obtain high-level semantic features; in this embodiment, the feature pyramid module adopts a parallel pyramid module, which is composed of a 1×1 convolution, a 3×3 dilated convolution with dilated rates of 6, 12, and 18, and a hybrid stripe pooling module. The feature pyramid module removes the original global average pooling GAP of the feature pyramid module. After adding the IMSPM module, the feature pyramid module can integrate multi-scale context information while paying attention to local detail information, and enhance the spatial correlation and the perception of context information in other dimensions. At the same time, the feature pyramid module and the SARM module jointly construct an efficient encoder, which improves the model's ability to extract features. Among them, the hybrid stripe pooling module includes stripe pooling SP, which is used to encode the input feature map in horizontal and vertical dimensions through two branches.
[0081] Based on the spatial attention feature fusion module, multi-scale features are fused to obtain low-level semantic features, and low-level semantic features are fused with high-level semantic features to obtain preliminary segmentation results. Each pixel in the preliminary segmentation result is assigned a category label; the category labels include the cow's eye area, breast area, and background area.
[0082] In this embodiment, the spatial attention feature fusion module specifically includes:
[0083] Spatial attention mechanism subunit: By spatially weighting the feature map, the importance of each position is learned. Specifically, the spatial attention mechanism generates an attention map by calculating the similarity or correlation of each position in the feature map, and then weights the feature map according to the attention map.
[0084] Feature fusion subunit: After obtaining the weighted feature maps, SAFFM will fuse them. Fusion methods include but are not limited to addition, concatenation, or more complex operations (such as weighted summation). The fused feature map contains both the spatial details of low-level features and the semantic information of high-level features, which helps to improve the accuracy of segmentation.
[0085] The coordinate marking module is used to mark the segmentation coordinates into the acquired original infrared thermal imaging image, and extract the temperature feature vectors of the cow's eye area and the breast area in the original infrared thermal imaging image based on the segmentation coordinates.
[0086] The coordinate marking module includes:
[0087] The temperature distribution matrix acquisition unit is used to extract the temperature distribution information of the cow's eye area and the breast area in the original infrared thermal imaging image based on the segmentation coordinates, and use the Gaussian filter algorithm to smooth the temperature distribution information to obtain the temperature distribution matrix; specifically, the images of the cow's eye area and the breast area are grayed, and the color image is converted into a gray image for subsequent temperature analysis. The Gaussian filter algorithm is used to smooth the gray image to eliminate noise and reduce local outliers in the temperature distribution. The image is calibrated so that the gray value directly corresponds to the temperature value. The temperature value of each pixel is extracted according to the smoothed gray image, and the temperature distribution matrix of the cow's eye area and the breast area is constructed.
[0088] The temperature feature vector acquisition unit is used to calculate the average temperature, temperature standard deviation and temperature gradient of the breast area according to the temperature distribution matrix to obtain the temperature feature vector; specifically, the average temperature of the cow's eye area and the breast area is calculated by averaging all the temperature values in the matrix. The temperature standard deviation is calculated to measure the degree of discreteness of the temperature distribution in the cow's eye area and the breast area. The larger the standard deviation, the more uneven the temperature distribution. The temperature gradient is calculated to reflect the speed of temperature change in the cow's eye area and the breast area. The temperature gradient is obtained by differentially calculating the temperature values of adjacent pixels. The average temperature, temperature standard deviation and temperature gradient are combined into a temperature feature vector.
[0089] The detection module is used to perform mastitis grading detection based on the temperature feature vectors of the cow's eye area and the udder area through a mastitis grading model to obtain a mastitis grading result. A further embodiment is that the detection module includes:
[0090] The feature coding unit is used to take the breed, parity and lactation stage of dairy cows as non-temperature features, and convert the non-temperature features into numerical feature vectors by using the feature coding method; specifically, the non-temperature feature information such as the breed, parity and lactation stage of dairy cows is collected. This information usually exists in the form of text or categorical variables. Specifically, taking the breed as an example, it may include Holstein, Jersey, Simmental, etc. Parity refers to the number of calving times of dairy cows, usually ranging from 1 to 7. The lactation stage can be divided into early, middle and late stages. These data may be missing or abnormal, such as the parity record is 0 or the lactation stage is incorrectly marked, which needs to be cleaned and corrected. Feature coding is a key technology for converting unstructured data into numerical features that can be processed by machine learning algorithms. For discrete features such as dairy cow breeds, this embodiment uses unique hot encoding. For example, Holstein is encoded as [1, 0, 0], Jersey is [0, 1, 0], and Simmental is [0, 0, 1]. Parity is an ordered categorical feature, using sequence encoding, such as encoding 1-7 parities as integer values 1-7. Lactation stage is a continuous feature, normalized according to the number of days, such as converting a 300-day lactation period to a range of 0-1. Feature selection and dimensionality reduction help improve model efficiency and generalization ability.
[0091] The feature fusion unit is used to fuse the temperature feature vector with the non-temperature feature vector to obtain a fused feature vector; feature fusion is the process of combining temperature features and non-temperature features. Assuming that the temperature feature includes the average body temperature and the surface temperature distribution, and the non-temperature feature includes the breed, parity, and lactation stage, the fused feature vector is in the form of [37.5, 0.8, 1, 0, 0, 3, 0.4], where the first two values represent the temperature features and the last five values represent the encoded non-temperature features.
[0092] The detection unit is used to input the fused feature vector into the mastitis grading model built based on the random forest algorithm to obtain the mastitis grading result. The performance of the mastitis grading model is evaluated, including the calculation of indicators such as accuracy, recall rate, and F1 score to ensure the reliability of the model. According to the preset grading threshold, the mastitis grading results include mild, moderate, and severe.
[0093] The detection device of the present invention also includes a visualization module for visualizing the collected cow images and the image data analysis process.
[0094] The embodiments described above are only descriptions of the preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Without departing from the design spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary technicians in this field should all fall within the protection scope determined by the claims of the present invention.
Claims
1. A non-invasive bovine mastitis detection device, characterized in that: include: Image acquisition module, image enhancement module, image feature extraction module, image segmentation module, coordinate marking module and detection module; An image acquisition module is used to acquire RGB images and original infrared thermal imaging images of dairy cows based on an infrared thermal imager; The image enhancement module is used to perform denoising on the RGB image using an image enhancement algorithm based on wavelet transform to obtain an enhanced first image; The image feature extraction module is used to extract image features from the first image through a pre-built feature extraction model, generate candidate regions using a region proposal network, and obtain a second image containing key parts; The image segmentation module is used to extract semantic information and perform ROI region segmentation on the second image using a semantic segmentation algorithm based on deep learning to obtain segmentation coordinates; wherein the ROI region includes a bull's eye region and a breast region; The coordinate marking module is used to mark the segmentation coordinates into the acquired original infrared thermal imaging image, and extract the temperature feature vectors of the cow's eye area and the breast area in the original infrared thermal imaging image based on the segmentation coordinates; The detection module is used to perform mastitis grading detection based on the temperature feature vectors of the cow's eye area and the udder area through a mastitis grading model to obtain a mastitis grading result.
2. The device according to claim 1, characterized in that The image enhancement module comprises: A denoising unit, used for decomposing the RGB image of the cow into a low-frequency component and a high-frequency component by performing wavelet decomposition on the RGB image of the cow, and filtering and denoising the noise information in the high-frequency component; The enhancement unit is used to fuse the denoised high-frequency component and the low-frequency component using a wavelet reconstruction algorithm to obtain an enhanced first image.
3. The device according to claim 1, characterized in that The feature extraction module comprises: An image feature data acquisition unit, configured to acquire a multi-dimensional feature vector representation of the first image according to the feature extraction model to obtain image feature data; the multi-dimensional feature vector representation includes color, texture and shape; A sliding window unit is used to determine whether each window area contains key parts by sliding on the image in a sliding window manner according to the image feature data and using a region proposal network algorithm; wherein the key parts include cow eyes and cow udders; A candidate coordinate acquisition unit, used to determine the current area as a candidate area if the current window area contains the key part, and obtain the coordinate data of the candidate area; A candidate image acquisition unit, configured to extract corresponding candidate region image data from the first image according to the candidate region coordinate data, to obtain a plurality of candidate region images; A candidate region feature acquisition unit, configured to extract features from each candidate region image using the feature extraction model to obtain candidate region feature data; A clustering unit, used to perform cluster analysis on the candidate region feature data to determine the similarity of each candidate region, and obtain candidate region category information based on the similarity; The image stitching unit is used to extract the candidate area image containing the key part from the first image according to the candidate area category information and stitch it into a second image to obtain the second image containing the target key part.
4. The device according to claim 1, characterized in that The structure of the feature extraction model includes: two input layers, two encoders with the same structure and a predictor; wherein the encoder includes a convolutional layer, a pooling layer, a residual block, a channel attention mechanism module and a global average pooling layer; the predictor includes two fully connected layers.
5. The device according to claim 1, characterized in that The image segmentation module comprises: A preliminary segmentation unit, used to perform semantic segmentation on the second image according to a pre-established deep learning semantic segmentation model, identify and segment the cow's eye area and the breast area in the second image, and obtain a preliminary segmentation result; An optimization unit, used for post-processing the preliminary segmentation result through morphological operations to optimize the segmentation boundary; A ROI region acquisition unit, used to obtain the contour of the ROI region according to the optimized segmentation result; wherein the ROI region includes the bull's eye region and the breast region; The segmentation coordinate acquisition unit is used to extract the pixel coordinates of the cow eye area and the breast area, and use the pixel coordinates as the segmentation coordinates.
6. The device according to claim 5, characterized in that The structure of the deep learning semantic segmentation model includes: ResNet50 backbone network, attention refinement module, feature pyramid module, and spatial attention feature fusion module.
7. The device according to claim 6, characterized in that The process of obtaining preliminary segmentation results includes: Perform multi-scale feature extraction on the second image based on the ResNet50 backbone network to obtain multi-scale features; Performing key feature enhancement on the multi-scale features based on the attention refinement module to obtain a key feature map; Based on the feature pyramid module, multi-scale context information and local detail information of the key feature graph are obtained to obtain high-level semantic features; Based on the spatial attention feature fusion module, the multi-scale features are fused to obtain low-level semantic features, and the low-level semantic features are fused with the high-level semantic features to obtain the preliminary segmentation result; wherein each pixel in the preliminary segmentation result is assigned a category label; the category labels include bull's eye area, breast area and background area.
8. The device according to claim 6, characterized in that The coordinate marking module comprises: A temperature distribution matrix acquisition unit is used to extract the temperature distribution information of the cow's eye area and the breast area in the original infrared thermal imaging image based on the segmentation coordinates, and use a Gaussian filter algorithm to smooth the temperature distribution information to obtain a temperature distribution matrix; The temperature characteristic vector acquisition unit is used to calculate the average temperature, temperature standard deviation and temperature gradient of the cow eye area and the udder area according to the temperature distribution matrix to obtain the temperature characteristic vector.
9. The device according to claim 8, characterized in that The detection module comprises: A feature coding unit, used for taking the breed, parity and lactation stage of the dairy cow as non-temperature features, and converting the non-temperature features into numerical feature vectors by using a feature coding method; A feature fusion unit, used for fusing the temperature feature vector with the non-temperature feature vector to obtain a fused feature vector; The detection unit is used to input the fused feature vector into a mastitis grading model constructed based on a random forest algorithm to obtain the mastitis grading result.