A detection method for cashmere goat follicle density based on image recognition

CN122551032APending Publication Date: 2026-08-11INNER MONGOLIA AUTONOMOUS REGION ACAD OF AGRI & ANIMAL HUSBANDRY SCI
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-13
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

[0003]人工参与的毛囊检测容易受主观视觉判断影响,人为判定标准不统一,整体检测耗时较长

Benefits of technology

在待检测图像中标定参考标记并依托标记完成实际皮肤面积的换算,摒弃仅依靠图像像素比例估算皮肤面积的常规方式,以标定标记作为尺度参照,建立图像像素与实体皮肤尺寸之间的对应关联。该计量方式跳出纯像素维度的估算局限,适配体表检测区域的尺度计量需求,使毛囊数量统计与皮肤覆盖范围形成精准对应关系,弱化像素估算方式带来的尺度偏差,让毛囊密度核算所依托的面积参数具备统一计量标准,保障密度数值测算过程中基础参数的匹配一致性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122551032A_ABST
    Figure CN122551032A_ABST
Patent Text Reader

Abstract

This invention discloses a method for detecting the density of hair follicles in cashmere goats based on image recognition, belonging to the field of livestock detection technology. The method includes collecting images of the skin surface of a standard area on the side of a cashmere goat after skin preparation, using multispectral light source contact illumination to acquire high-resolution multispectral images. The images are preprocessed to obtain the image to be detected, and the actual skin area is calculated using reference markers in the image. The image is then input into an improved YOLOv8 algorithm, which distinguishes primary and secondary hair follicles based on the range of hair follicle opening diameters and the spatial distribution pattern of hair follicles. The number and location coordinates of hair follicles are output, and the density values ​​of the two types of hair follicles are calculated and output. Simultaneously, a hair follicle distribution heatmap is generated by overlaying the image. This method can accurately classify, count, and calculate the density of hair follicles, accurately reconstructing the spatial distribution of hair follicles.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of livestock testing technology, specifically a method for detecting the density of goat hair follicles based on image recognition. Background Technology

[0002] Currently, the detection of hair follicle density in goat hair generally relies on manual visual inspection to count the number of follicles. Some detection methods use ordinary visible light to capture skin images and combine them with basic image recognition algorithms to perform a rough detection of hair follicles. During image detection, the actual skin coverage area is generally estimated directly based on the image pixel ratio, and the classification of hair follicle types relies solely on a simple differentiation based on single grayscale texture features.

[0003] Manual hair follicle detection is susceptible to subjective visual judgment, with inconsistent human evaluation standards, resulting in lengthy detection times. Ordinary visible light imaging is easily affected by ambient lighting, and skin surface hair and pigment texture can interfere with imaging results. Furthermore, pixel ratio estimation methods deviate from the actual physical area of ​​the skin. Conventional image recognition algorithms have a single discrimination dimension, making it difficult to accurately distinguish between primary and secondary hair follicles in cashmere goats, and thus difficult to obtain accurate hair follicle quantity classification data.

[0004] A standardized method for converting skin area needs to be established, hair follicle type identification should be completed based on multi-dimensional features, intelligent detection algorithms should be used to locate and count hair follicles, objective calculation of hair follicle density parameters should be achieved, and intuitive presentation of hair follicle distribution status should be completed. Summary of the Invention

[0005] This invention aims to solve at least one of the technical problems existing in the prior art; Therefore, this invention proposes an image recognition-based method for detecting the density of goat hair follicles, comprising: Obtain the skin surface of the standard part of the body of the cashmere goat being tested after skin preparation; The skin surface is illuminated by a multispectral light source, and a high-resolution multispectral image of the skin surface is acquired. Preprocessing is performed on the multispectral high-definition image to generate a standardized image to be detected, and the actual skin area corresponding to the image to be detected is calculated based on the reference markers calibrated in the image to be detected. The image to be detected is input into the improved YOLOv8 algorithm for hair follicle target detection and classification. The improved YOLOv8 algorithm distinguishes primary hair follicles and secondary hair follicles based on the numerical range of hair follicle opening diameter and the spatial distribution pattern of hair follicles, and outputs the number of primary hair follicles, the number of secondary hair follicles detected, and the position coordinates of each hair follicle. The primary hair follicle density and secondary hair follicle density values ​​are calculated based on the number of primary hair follicles, the number of secondary hair follicles, and the actual skin area. The primary hair follicle density value and the secondary hair follicle density value are output, and a hair follicle distribution heatmap is generated by overlaying them onto the image to be detected.

[0006] Furthermore, the process of acquiring multispectral high-resolution images of the skin surface includes: The multispectral light source includes a polarized light source and a near-infrared light source; The polarized light source is used to generate linearly polarized light to irradiate the skin surface. The wavelength range of the near-infrared light source is from 700 nanometers to 1100 nanometers, which is used to penetrate the epidermal layer of the skin to enhance the visibility of the subcutaneous hair follicle structure. The polarized light source and the near-infrared light source are turned on in sequence, and grayscale images of the skin surface are acquired under each light source. The grayscale image acquired under the polarized light source and the grayscale image acquired under the near-infrared light source are fused at the pixel level to generate a multispectral high-definition image containing surface texture information and subcutaneous structure information. The multispectral high-definition image has an optical magnification of 50 to 150 times, an image resolution of no less than 1920 pixels multiplied by 1080 pixels, and an imaging frame rate of no less than 30 frames per second.

[0007] Further, preprocessing is performed on the multispectral high-resolution image to generate a standardized image to be detected, and the actual skin area corresponding to the image to be detected is calculated based on the reference markers calibrated in the image to be detected, including: The multispectral high-definition image is subjected to bilateral filtering denoising processing to maintain the sharpness of the hair follicle edges and generate a denoised image; Perform contrast-limited adaptive histogram equalization on the denoised image to enhance local contrast and generate an enhanced contrast image; Gaussian pyramid fusion processing is performed on the enhanced contrast image to reconstruct and fuse the image after multi-layer Gaussian pyramid decomposition, thereby improving the clarity of hair follicle edges and generating the image to be detected. Identify the boundary contour of a preset reference mark in the image to be detected, wherein the reference mark is a circular mark with a known actual diameter; The pixel coverage diameter of the reference mark in the image to be detected is calculated based on the boundary contour of the reference mark, and the conversion ratio between the pixel size and the actual physical size is calculated in combination with the actual diameter of the reference mark. The actual skin area corresponding to the image to be detected is obtained by multiplying the conversion ratio by the total pixel area of ​​the image to be detected.

[0008] Furthermore, the improved YOLOv8 algorithm includes an input terminal, a backbone network, a neck network, and a detection head; The input terminal is used to receive the image to be detected and scale the image to be detected to a preset input size; The backbone network uses a cross-stage local network structure to perform multi-level feature extraction on the scaled image, generating feature maps at multiple scales. The neck network employs a path aggregation network structure to perform bidirectional feature fusion of the feature maps at multiple scales from top to bottom and bottom to top, generating a fused feature pyramid; The detection head is used to predict the hair follicle category and regress the bounding box for each feature point in the fused feature pyramid, and outputs the category label and location coordinates of each hair follicle in the image to be detected. The category label includes primary hair follicle label and secondary hair follicle label.

[0009] Furthermore, the improved YOLOv8 algorithm distinguishes between primary and secondary hair follicles based on the numerical range of hair follicle opening diameter and the spatial distribution pattern of hair follicles, including the following specific processes: During the training phase, a skin sample image dataset containing multiple cashmere goat breeds, multiple age groups, and multiple cashmere growth stages is constructed. Each hair follicle in the skin sample image dataset is labeled, and the labeling content includes the hair follicle opening bounding box and the hair follicle type label. Based on the marked hair follicle opening boundary box, calculate the opening diameter value of each hair follicle. Hair follicles with an opening diameter value greater than 0.1 mm are marked as primary hair follicles, and hair follicles with an opening diameter value less than 0.05 mm are marked as secondary hair follicles. While annotating, the spatial distribution pattern of adjacent hair follicles around each hair follicle is recorded. For primary hair follicles that are surrounded by at least three secondary hair follicles and whose center point is less than the center point of the current hair follicle, a cluster structure label is added in the annotation. The dataset of skin sample images labeled with hair follicle type and cluster structure is input into the improved YOLOv8 algorithm for iterative training, so that the detection head of the improved YOLOv8 algorithm can predict hair follicle type based on the predicted value of hair follicle opening diameter and the cluster distribution density of secondary hair follicles around the hair follicle.

[0010] Furthermore, after outputting the number of primary hair follicles, the number of secondary hair follicles, and the location coordinates of each hair follicle, the system also includes a step of calculating the structural parameters of the hair follicle group. The steps for calculating the structural parameters of the hair follicle group include: Iterate through each hair follicle marked as a primary hair follicle and obtain the location coordinates of that primary hair follicle; Calculate the Euclidean distance between the location coordinates of the primary hair follicle and the location coordinates of all hair follicles marked as secondary hair follicles; Secondary hair follicles whose Euclidean distance is less than a preset group distance threshold are selected, and these selected secondary hair follicles are assigned to the same hair follicle group as the primary hair follicle. The number of secondary hair follicles in each hair follicle group is counted, and the arithmetic mean of the number of secondary hair follicles in all hair follicle groups is calculated to obtain the average number of secondary hair follicles around each primary hair follicle, which is then output as the structural parameter of the hair follicle group.

[0011] Furthermore, after outputting the number of primary hair follicles, the number of secondary hair follicles, and the location coordinates of each hair follicle, the output also includes a hair follicle distribution uniformity index calculation step. The steps for calculating the hair follicle distribution uniformity index include: Obtain the position coordinates of all hair follicles in the image to be detected, and construct a spatial point set of hair follicles; For each hair follicle in the hair follicle spatial point set, calculate the nearest neighbor distance between the hair follicle and its nearest neighbor hair follicle; The average nearest neighbor distance is obtained by arithmetically averaging the nearest neighbor distances of all hair follicles. The expected nearest neighbor distance under a theoretical random distribution is calculated based on the actual skin area and total number of hair follicles corresponding to the image to be detected. Divide the average nearest neighbor distance by the expected nearest neighbor distance to obtain the hair follicle distribution uniformity index.

[0012] Furthermore, after calculating the primary hair follicle density value and the secondary hair follicle density value based on the number of primary hair follicles, the number of secondary hair follicles, and the actual skin area, a density correction step is also included. The density correction step includes: Obtain a preset shrinkage correction coefficient, wherein the value range of the shrinkage correction coefficient is 0.75 to 0.85; Multiply the primary hair follicle density value by the shrinkage rate correction coefficient to generate the corrected primary hair follicle density value. Multiply the secondary hair follicle density value by the shrinkage rate correction coefficient to generate the corrected secondary hair follicle density value. The corrected primary hair follicle density value and the corrected secondary hair follicle density value are stored and output as converted density values ​​comparable to the traditional slicing method.

[0013] Further, the primary hair follicle density value and the secondary hair follicle density value are output, and a hair follicle distribution heatmap is generated by overlaying it onto the image to be detected, including: The image to be detected is used as the bottom layer; Create a transparent thermal overlay layer on the base layer; Using the location coordinates of each hair follicle as a heat source point, the heat contribution value of the pixels surrounding each heat source point is calculated using a preset Gaussian kernel function. The heat contribution value of each hair follicle is associated with the hair follicle type, wherein the heat contribution value corresponding to the primary hair follicle is higher than that corresponding to the secondary hair follicle. The total thermal value for each pixel is obtained by summing up all thermal contribution values ​​at each pixel location. According to the preset color level mapping table, the total heat value of each pixel position is mapped to the corresponding color value, and the heat overlay layer is filled to generate a hair follicle distribution heat map superimposed on the base layer. The primary hair follicle density values ​​and the secondary hair follicle density values ​​are labeled in text form at the edge of the hair follicle distribution heatmap to generate a detection result image.

[0014] Furthermore, the present invention also includes an image recognition-based goat hair follicle density detection system, wherein the goat hair follicle density detection system includes a processor and a memory, the memory being connected to the processor, the memory being used to store programs, instructions or code, and the processor being used to run the programs, instructions or code in the memory to implement the image recognition-based goat hair follicle density detection method described above.

[0015] Compared with the prior art, the beneficial effects of the present invention are: Reference markers are calibrated in the image to be detected, and the actual skin area is calculated based on these markers. This method abandons the conventional approach of estimating skin area solely based on image pixel ratios. Instead, the calibrated markers serve as a scale reference, establishing a correspondence between image pixels and actual skin dimensions. This measurement method transcends the limitations of pure pixel-level estimation, adapting to the scale measurement needs of the body surface detection area. It establishes a precise correspondence between hair follicle count and skin coverage, mitigating the scale bias introduced by pixel estimation methods. This ensures that the area parameters relied upon for hair follicle density calculation have a unified measurement standard, guaranteeing the consistency of basic parameters during density value calculation.

[0016] By incorporating the numerical range of hair follicle opening diameter and the spatial distribution pattern of hair follicles into the discrimination logic of the improved YOLOv8 algorithm, this approach overcomes the limitation of relying solely on single image texture features to classify hair follicle types. It performs hair follicle target detection and classification from two dimensions: diameter parameters and spatial arrangement. During the recognition process, the algorithm simultaneously records the positional coordinates of each hair follicle, completing the quantity statistics and category classification of primary and secondary hair follicles. Using the coordinate data, it performs layer overlay processing in the image to be detected, generating a hair follicle distribution heatmap. This multi-dimensional discrimination logic broadens the judgment dimensions for hair follicle classification, closely aligning with the inherent morphology and arrangement characteristics of hair follicles. The acquisition of coordinate information supports the visualization of hair follicle distribution, fully restoring the overall arrangement of hair follicles within the detection area. Attached Figure Description

[0017] Figure 1 This is a flowchart of a method for detecting the density of goat hair follicles based on image recognition, as described in this invention. Figure 2 A flowchart for multispectral high-definition image processing and skin area calculation methods; Figure 3 This is a flowchart of a hair follicle annotation and training method based on the improved YOLOv8 algorithm. Detailed Implementation

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

[0019] See Figure 1 This invention provides a method for detecting hair follicle density in cashmere goats based on image recognition. The method includes: acquiring the skin surface of a standard part of the side of a cashmere goat after skin preparation; illuminating the skin surface with a multispectral light source using contact illumination and acquiring a multispectral high-resolution image of the skin surface; performing preprocessing on the multispectral high-resolution image to generate a standardized image to be detected, and calculating the actual skin area corresponding to the image to be detected based on reference markers calibrated in the image to be detected; inputting the image to be detected into an improved YOLOv8 algorithm for hair follicle target detection and classification, wherein the improved YOLOv8 algorithm distinguishes between primary and secondary hair follicles based on the range of hair follicle opening diameter and the spatial distribution pattern of hair follicles, and outputs the number of detected primary hair follicles, the number of secondary hair follicles, and the position coordinates of each hair follicle; calculating the primary hair follicle density value and the secondary hair follicle density value based on the number of primary hair follicles, the number of secondary hair follicles, and the actual skin area; outputting the primary hair follicle density value and the secondary hair follicle density value, and superimposing a hair follicle distribution heatmap on the image to be detected.

[0020] In one embodiment of the present invention, during the acquisition of a multispectral high-definition image of the skin surface, the multispectral light source includes a polarized light source and a near-infrared light source. The polarized light source is used to generate linearly polarized light to irradiate the skin surface, and the near-infrared light source has a wavelength range of 700 nanometers to 1100 nanometers, used to penetrate the epidermal layer of the skin to enhance the visibility of the subcutaneous hair follicle structure. The polarized light source and the near-infrared light source are turned on sequentially, and grayscale images of the skin surface are acquired under each light source. The grayscale images acquired under the polarized light source and the grayscale images acquired under the near-infrared light source are then fused at the pixel level to generate a multispectral high-definition image containing surface texture information and subcutaneous structure information. The optical magnification of the multispectral high-definition image is 50x to 150x, the image resolution is not less than 1920 pixels multiplied by 1080 pixels, and the imaging frame rate is not less than 30 frames per second.

[0021] In a specific implementation, the process of using a multispectral light source to provide contact illumination to the skin surface of a standard area on the side of a cashmere goat after skin preparation and acquiring a multispectral high-definition image is described in a specific example scenario as follows: The multispectral light source includes a polarized light source and a near-infrared light source. The polarized light source is used to generate linearly polarized light to illuminate the skin surface, and the near-infrared light source has a wavelength range of 700 nanometers to 1100 nanometers to penetrate the epidermal layer of the skin to enhance the visibility of the subcutaneous hair follicle structure. In a specific implementation, the polarized light source and the near-infrared light source are turned on sequentially, and grayscale images of the skin surface are acquired under each light source. That is, the polarized light source is turned on first and a polarized light grayscale image of the skin surface is acquired, then the polarized light source is turned off and the near-infrared light source is turned on to acquire a near-infrared grayscale image of the skin surface. In a specific implementation, the grayscale image acquired under the polarized light source and the grayscale image acquired under the near-infrared light source are fused at the pixel level to generate a multispectral high-definition image containing surface texture information and subcutaneous structure information. The fusion process is represented as follows: in: Indicates pixel coordinates The pixel grayscale values ​​of the fused multispectral high-resolution image. This indicates that the grayscale image acquired under the polarized light source is located at pixel coordinates. The pixel grayscale value at that location, This indicates that the grayscale image acquired under the near-infrared light source is located at pixel coordinates. The pixel grayscale value at that location, and These are the weighting coefficients of the grayscale image acquired under the polarized light source and the weighting coefficients of the grayscale image acquired under the near-infrared light source, respectively. In specific implementation, the optical magnification of the multispectral high-definition image is 50 to 150 times, the image resolution is not less than 1920 pixels multiplied by 1080 pixels, and the imaging frame rate is not less than 30 frames per second.

[0022] In some embodiments, the polarized light source is a combination of a linear polarizer and a light-emitting diode (LED). The linear polarizer is placed in front of the LED to generate linearly polarized light that irradiates the skin surface. The near-infrared light source is an array of LEDs with a center wavelength of 850 nanometers or 940 nanometers.

[0023] In some embodiments, during the pixel-level weighted fusion process, the weighting coefficients are dynamically adjusted based on the richness of the skin surface texture. and the weighting coefficients The weighting coefficient is increased when there are more residual hairs on the skin surface. To enhance surface texture information, the weighting coefficient is increased when the epidermal layer of the skin surface is thicker. To enhance the visibility of subcutaneous hair follicle structures.

[0024] Optionally, before performing pixel-level weighted fusion of the grayscale image acquired under the polarized light source and the grayscale image acquired under the near-infrared light source, a pixel position alignment operation is performed on the two grayscale images to ensure that each pixel in the grayscale image acquired under the polarized light source precisely overlaps with the pixel at the same physical location in the grayscale image acquired under the near-infrared light source. Optionally, the imaging frame rate of the multispectral high-definition image is not less than thirty frames per second. When continuously acquiring multiple frames of multispectral high-definition images, the consecutive frames are subjected to temporal averaging to reduce random noise.

[0025] It is understood that when the linearly polarized light generated by the polarized light source illuminates the skin surface, it can reduce the interference of specular reflection light from the skin surface, enhance the contrast of the hair follicle opening edge, and make the hair follicle opening boundary clearer in the grayscale image acquired under the polarized light source. It is also understood that the wavelength range of the near-infrared light source is 700 nanometers to 1100 nanometers. Light in this band has a low scattering coefficient in biological tissues and can penetrate the epidermis to reach the dermis, causing the subcutaneous hair follicle structure to appear as a localized grayscale abnormality area in the grayscale image acquired under the near-infrared light source.

[0026] In one embodiment of the present invention, the process of performing preprocessing operations on the multispectral high-resolution image to generate a standardized image to be detected, and calculating the actual skin area corresponding to the image to be detected based on the reference markers calibrated in the image to be detected, is as follows. (See also...) Figure 2The multispectral high-definition image is subjected to bilateral filtering denoising to maintain the sharpness of hair follicle edges, generating a denoised image. The denoised image is then subjected to contrast-limited adaptive histogram equalization to enhance local contrast, generating an enhanced contrast image. Gaussian pyramid fusion is performed on the enhanced contrast image, reconstructing and fusing the images decomposed by multiple Gaussian pyramids to improve the clarity of hair follicle edges, generating the image to be detected. The boundary contour of a preset reference marker in the image to be detected is identified; the reference marker is a circular marker with a known actual diameter. The pixel coverage diameter of the reference marker in the image to be detected is calculated based on the boundary contour of the reference marker, and the conversion ratio between the pixel size and the actual physical size is calculated based on the actual diameter of the reference marker. This conversion ratio is multiplied by the total pixel area of ​​the image to be detected to obtain the actual skin area corresponding to the image to be detected.

[0027] In a specific implementation, a method for detecting the density of hair follicles in goat hair based on image recognition performs preprocessing operations on the multispectral high-definition image to generate a standardized image to be detected, and calculates the actual skin area corresponding to the image to be detected based on the reference markers calibrated in the image to be detected. A specific example scenario is described as follows: Bilateral filtering denoising is performed on the multispectral high-definition image to maintain the sharpness of the hair follicle edges, generating a denoised image. The bilateral filtering denoising process considers both the spatial distance between pixels and the similarity of pixel value domains. For each pixel in the multispectral high-definition image, the density of the hair follicle is determined by the reference markers calibrated in the image to be detected. A neighborhood window of a preset size is selected at the center. The spatial domain weight and pixel value domain weight of each neighboring pixel within the window are calculated. These two weights are multiplied to obtain the bilateral filtering weight. The grayscale values ​​of all pixels within the neighborhood window are then weighted and averaged using the bilateral filtering weight. The weighted average result is used as the grayscale value of the corresponding pixel in the denoised image. In a specific implementation, contrast-limited adaptive histogram equalization is performed on the denoised image to enhance local contrast and generate an enhanced contrast image. The contrast-limited adaptive histogram equalization divides the denoised image into multiple non-overlapping rectangular sub-blocks. For each... A grayscale histogram is calculated for each rectangular sub-block. A preset contrast limit threshold is set. The portion of the grayscale histogram of each rectangular sub-block exceeding the contrast limit threshold is cropped and evenly redistributed across the various gray levels of the grayscale histogram. A grayscale mapping function is calculated for each rectangular sub-block based on the redistributed grayscale histogram. The corresponding grayscale mapping function is applied to the pixels within each rectangular sub-block for grayscale transformation. The boundary regions between the rectangular sub-blocks are smoothly transitioned using bilinear interpolation to generate the enhanced contrast image. In a specific implementation, Gaussian gold is applied to the enhanced contrast image. The pyramid fusion process reconstructs and fuses images decomposed from multiple Gaussian pyramids to improve the clarity of hair follicle edges and generate the image to be detected. The Gaussian pyramid fusion process first constructs a Gaussian pyramid on the image with enhanced contrast. Each layer of the Gaussian pyramid is obtained by downsampling the image of the previous layer after Gaussian smoothing. Then, each layer of the Gaussian pyramid is decomposed into a Laplacian pyramid. The images corresponding to the Laplacian pyramids at different scales are pixel-weighted and superimposed according to a preset fusion rule. Finally, the superimposed Laplacian pyramid is reconstructed to obtain the image to be detected.

[0028] In some embodiments, the spatial domain distance in the bilateral filtering denoising process is calculated using Euclidean distance, the pixel value domain similarity is calculated using the absolute value of the pixel grayscale difference, and both the spatial domain weights and the pixel value domain weights are mapped using a Gaussian function. The standard deviation of the spatial domain Gaussian function ranges from 1.0 to 3.0, and the standard deviation of the pixel value domain Gaussian function ranges from 20 to 50.

[0029] In some embodiments, the size of the rectangular sub-block in the limited contrast adaptive histogram equalization process is from 8 pixels by 8 pixels to 64 pixels by 64 pixels, and the value range of the contrast limitation threshold is from 2 to 10. The contrast limitation threshold represents the ratio of the maximum number of pixels allowed for each gray level in the grayscale histogram to the average number of pixels.

[0030] In a specific implementation, the boundary contour of a preset reference marker in the image to be detected is identified. The reference marker is a circular marker with a known actual diameter. The boundary contour identification process of the reference marker is as follows: The image to be detected is binarized and segmented to extract connected regions with gray values ​​different from the skin background. The circularity of each connected region is calculated. The circularity is obtained by multiplying 4π by the ratio between the area of ​​the connected region and the square of the perimeter of the connected region. Connected regions with a circularity greater than a preset circularity threshold are selected as candidate regions of the reference marker. The Hough circle transform algorithm is used to detect the center coordinates and radius of the candidate regions to obtain the boundary contour of the reference marker. In a specific implementation, the pixel coverage diameter of the reference marker in the image to be detected is calculated based on the boundary contour of the reference marker. The conversion ratio between the pixel size and the actual physical size is calculated by combining the actual diameter of the reference marker. The conversion ratio is calculated by dividing the actual diameter of the reference marker by the pixel coverage diameter to obtain the actual physical length represented by each pixel. In a specific implementation, the conversion ratio is multiplied by the total pixel area of ​​the image to be detected to obtain the actual skin area corresponding to the image to be detected. The calculation process is expressed as follows: in: This represents the actual skin area corresponding to the image to be detected. This represents the total number of pixels in the image to be detected. The conversion ratio is indicated, which corresponds to the actual physical length of a single pixel's side length.

[0031] Optionally, the reference marker is made of biocompatible medical-grade silicone material, and its actual diameter is one of 2 mm, 5 mm, or 10 mm. The reference marker is attached and fixed to the skin surface of the cashmere goat at a standard location on its side after skin preparation. Optionally, the total pixel area of ​​the image to be tested is obtained by multiplying the image width in pixels by the image height in pixels. The image width in pixels and the image height in pixels are obtained by reading the metadata of the image to be tested.

[0032] It is understood that the bilateral filtering denoising process removes random noise from the multispectral high-definition image while preserving the original gradient value of gray-level abrupt changes at the hair follicle edge, ensuring that the hair follicle opening boundary is not smoothed or blurred in the denoised image. It is also understood that the Gaussian pyramid fusion process reconstructs and fuses images obtained from decomposition at different scales, enhancing the gray-level transition region near the hair follicle edge, and presenting the circular boundary of the hair follicle opening as a high-contrast closed curve in the image to be detected.

[0033] In one embodiment of the present invention, the improved YOLOv8 algorithm includes an input terminal, a backbone network, a neck network, and a detection head. The input terminal receives the image to be detected and scales it to a preset input size. The backbone network employs a cross-stage local network structure to extract multi-level features from the scaled image, generating feature maps at multiple scales. The neck network uses a path aggregation network structure to perform bidirectional feature fusion of the feature maps at multiple scales, from top to bottom and from bottom to top, generating a fused feature pyramid. The detection head performs hair follicle category prediction and bounding box regression on each feature point in the fused feature pyramid, outputting the category label and location coordinates of each hair follicle in the image to be detected. The category label includes a primary hair follicle label and a secondary hair follicle label.

[0034] The improved YOLOv8 algorithm distinguishes between primary and secondary hair follicles based on the numerical range of hair follicle opening diameter and the spatial distribution pattern of hair follicles, as follows. (See reference...) Figure 3 During the training phase, a skin sample image dataset containing multiple cashmere goat breeds, age groups, and hair growth stages is constructed. Each hair follicle in this dataset is labeled, including a follicle opening bounding box and a follicle type label. Based on the labeled follicle opening bounding boxes, the opening diameter of each follicle is calculated. Follicles with an opening diameter greater than 0.1 mm are labeled as primary follicles, and those with an opening diameter less than 0.05 mm are labeled as secondary follicles. Simultaneously with labeling, the spatial distribution pattern of adjacent follicles around each follicle is recorded. For primary follicles surrounded by at least three secondary follicles, and where the distance between the center point of each of the at least three secondary follicles and the center point of the current follicle is less than a preset cluster distance threshold, a cluster structure label is added to the label. The dataset of skin sample images labeled with hair follicle type and cluster structure is input into the improved YOLOv8 algorithm for iterative training, so that the detection head of the improved YOLOv8 algorithm can predict hair follicle type based on the predicted value of hair follicle opening diameter and the cluster distribution density of secondary hair follicles around the hair follicle.

[0035] In a specific implementation, a method for detecting the density of goat hair follicles based on image recognition, employing an improved YOLOv8 algorithm for hair follicle target detection and classification, is described in a specific example scenario as follows: The improved YOLOv8 algorithm includes an input terminal, a backbone network, a neck network, and a detection head. The input terminal receives the image to be detected and scales it to a preset input size of 640 pixels by 640 pixels. In a specific implementation, the backbone network uses a cross-stage local network structure to perform multi-level feature extraction on the scaled image, generating feature maps at multiple scales. The cross-stage local network structure divides the input feature map into two branches. One branch undergoes stacking processing through several convolutional layers and bottleneck layers, while the other branch directly connects to the processed feature map via a shortcut. Feature maps are stitched together to preserve gradient information while reducing computational load. In specific implementation, the neck network uses a path aggregation network structure to perform bidirectional feature fusion of the feature maps at multiple scales from top to bottom and bottom to top, generating a fused feature pyramid. The top-down fusion process upsamples the deep semantic feature map and superimposes it with the shallow detail feature map, while the bottom-up fusion process downsamples the shallow feature map and superimposes it with the deep feature map. In specific implementation, the detection head performs hair follicle category prediction and bounding box regression for each feature point in the fused feature pyramid, outputting the category label and location coordinates of each hair follicle in the image to be detected. The category label includes primary hair follicle labels and secondary hair follicle labels, and the location coordinates are represented by the center point coordinates of the bounding box and the width and height of the bounding box.

[0036] In specific implementation, the improved YOLOv8 algorithm distinguishes primary and secondary hair follicles based on the numerical range of hair follicle opening diameter and the spatial distribution pattern of hair follicles, as described in an example scenario as follows: During the training phase, a skin sample image dataset containing multiple cashmere goat breeds, multiple age groups, and multiple hair growth stages is constructed. Each hair follicle in the skin sample image dataset is labeled, including the hair follicle opening bounding box and the hair follicle type label. In specific implementation, the opening diameter value of each hair follicle is calculated based on the labeled hair follicle opening bounding box. Hair follicles with an opening diameter value greater than 0.1 mm are labeled as primary hair follicles, and hair follicles with an opening diameter value less than 0.05 mm are labeled as secondary hair follicles. Secondary hair follicles; in specific implementations, the spatial distribution pattern of adjacent hair follicles around each hair follicle is recorded during annotation. For primary hair follicles surrounded by at least three secondary hair follicles, and where the distance between the center point of each of the at least three secondary hair follicles and the center point of the current hair follicle is less than a preset cluster distance threshold, a cluster structure label is added to the annotation. The preset cluster distance threshold is 0.3 mm. In specific implementations, the skin sample image dataset with hair follicle type labels and cluster structure labels is input into the improved YOLOv8 algorithm for iterative training. This allows the detection head of the improved YOLOv8 algorithm to predict hair follicle type based on both the predicted value of the hair follicle opening diameter and the cluster distribution density of the secondary hair follicles surrounding the hair follicle. The annotation parameters used in the training phase of the skin sample image dataset are shown in Table 1.

[0037] Table 1: Annotation Parameters for Skin Sample Image Dataset In some embodiments, the cross-stage local network structure in the backbone network comprises four stages, each outputting feature maps at different scales. The sizes of the four feature maps are 1 / 4, 1 / 8, 1 / 16, and 1 / 32 of the input image size, respectively. In some embodiments, the path aggregation network structure in the neck network adopts a bidirectional fusion architecture of feature pyramid network and pixel aggregation network, performing three-level feature fusion on the four scale feature maps output by the backbone network to generate three-scale fused feature pyramids, corresponding to 1 / 8, 1 / 16, and 1 / 32 of the input image size, respectively.

[0038] In practical implementation, when predicting hair follicle type, the detection head simultaneously considers the predicted value of the hair follicle opening diameter and the clustering distribution density of secondary hair follicles surrounding the hair follicle. Its joint loss function is expressed as: in: This represents the value of the joint loss function. The bounding box regression loss is calculated using the perfect intersection-over-union (MIU) loss function. The classification loss for hair follicle categories is represented by the binary cross-entropy loss function, which is used for calculation. This represents the cluster structure consistency loss, used to penalize situations where the predicted hair follicle type is inconsistent with the distribution pattern of surrounding secondary hair follicle clusters. The weighting coefficient represents the loss of consistency in the clustered structure.

[0039] Optionally, the preset cluster distance threshold is set differently according to the cashmere goat breed. For the Liaoning cashmere goat breed, the preset cluster distance threshold is set to 0.35 mm, and for the Inner Mongolia cashmere goat breed, the preset cluster distance threshold is set to 0.28 mm. Optionally, the number of samples in the skin sample image dataset is no less than fifty for each cashmere goat breed, no less than thirty for each age group, and no less than forty for each cashmere growth stage. The cashmere growth stage includes the early, middle, and late stages of cashmere growth.

[0040] It is understood that the clustered structure label is used to indicate that a primary hair follicle is located at the center of a clustered distribution surrounded by multiple secondary hair follicles. During training, the improved YOLOv8 algorithm learns the correlation features between hair follicle type and the spatial distribution pattern of surrounding hair follicles through the clustered structure consistency loss. It is also understood that after completing the training of the improved YOLOv8 algorithm, for each input image to be detected, the detection head simultaneously outputs bounding box regression results and hair follicle category prediction results, wherein the hair follicle category prediction results are inferred based on the optimal balanced weights of each loss term in the joint loss function.

[0041] In one embodiment of the present invention, after outputting the detected number of primary hair follicles, the number of secondary hair follicles, and the position coordinates of each hair follicle, a hair follicle group structure parameter calculation step is performed. Each hair follicle marked as a primary hair follicle is traversed, and the position coordinates of that primary hair follicle are obtained. The Euclidean distance between the position coordinates of the primary hair follicle and the position coordinates of all hair follicles marked as secondary hair follicles is calculated. Secondary hair follicles whose Euclidean distance is less than a preset group distance threshold are selected, and these selected secondary hair follicles are grouped with the primary hair follicles into the same hair follicle group. The number of secondary hair follicles within each hair follicle group is counted, and the arithmetic mean of the number of secondary hair follicles in all hair follicle groups is calculated to obtain the average number of secondary hair follicles around each primary hair follicle, which is output as the hair follicle group structure parameter.

[0042] After outputting the detected number of primary hair follicles, the number of secondary hair follicles, and the location coordinates of each hair follicle, a hair follicle distribution uniformity index calculation step is performed. The location coordinates of all hair follicles in the image to be detected are obtained to construct a hair follicle spatial point set. For each hair follicle in the hair follicle spatial point set, the nearest neighbor distance between that hair follicle and its nearest neighbor is calculated. The arithmetic mean of the nearest neighbor distances of all hair follicles is obtained to obtain the average nearest neighbor distance. Based on the actual skin area and the total number of hair follicles corresponding to the image to be detected, the expected nearest neighbor distance under a theoretical random distribution is calculated. The average nearest neighbor distance is divided by the expected nearest neighbor distance to obtain the hair follicle distribution uniformity index.

[0043] In specific implementation, after outputting the detected number of primary hair follicles, the number of secondary hair follicles, and the position coordinates of each hair follicle, the specific process of performing the hair follicle group structure parameter calculation step is described in an example scenario as follows: traverse each hair follicle marked as a primary hair follicle and obtain the position coordinates of the primary hair follicle; calculate the Euclidean distance between the position coordinates of the primary hair follicle and the position coordinates of all hair follicles marked as secondary hair follicles; filter out secondary hair follicles whose Euclidean distance is less than a preset group distance threshold, and classify the filtered secondary hair follicles and the primary hair follicles into the same hair follicle group; count the number of secondary hair follicles in each hair follicle group, and take the arithmetic mean of the number of secondary hair follicles in all hair follicle groups to obtain the average number of secondary hair follicles around each primary hair follicle, which is used as the hair follicle group structure parameter output.

[0044] In specific implementation, after outputting the number of detected primary hair follicles, the number of secondary hair follicles, and the position coordinates of each hair follicle, the specific process of calculating the hair follicle distribution uniformity index is described in an example scenario as follows: Obtain the position coordinates of all hair follicles in the image to be detected, and construct a hair follicle spatial point set; for each hair follicle in the hair follicle spatial point set, calculate the nearest neighbor distance between the hair follicle and its nearest neighbor hair follicle; arithmetically average the nearest neighbor distances of all hair follicles to obtain the average nearest neighbor distance; calculate the expected nearest neighbor distance under a theoretical random distribution based on the actual skin area and the total number of hair follicles corresponding to the image to be detected; divide the average nearest neighbor distance by the expected nearest neighbor distance to obtain the hair follicle distribution uniformity index. The parameter definitions involved in the calculation of the hair follicle distribution uniformity index are shown in Table 2.

[0045] Table 2: Definition of Parameters for Calculating Hair Follicle Distribution Uniformity Index In practical implementation, the formula for calculating the expected nearest neighbor distance under the theoretical random distribution is expressed as follows: in: This represents the hair follicle distribution uniformity index. This represents the average nearest neighbor distance. This represents the expected nearest neighbor distance under the theoretical random distribution. This indicates the total number of hair follicles in the image to be detected. Indicates the first The nearest neighbor distance between a hair follicle and its nearest neighbor hair follicle This represents the actual skin area corresponding to the image to be detected.

[0046] In some embodiments, the preset group distance threshold is set to 2.5 to 3.5 times the average opening diameter of hair follicles marked as primary follicles. The average opening diameter is calculated by the average width and height of the bounding boxes of all hair follicles marked as primary follicles output by the improved YOLOv8 algorithm during detection. In some embodiments, the hair follicle distribution uniformity index... A value of 1 indicates that the hair follicle spatial point set exhibits a completely random distribution pattern, and the hair follicle distribution uniformity index... A value greater than 1 indicates that the hair follicle spatial point set exhibits a uniform distribution pattern, and the hair follicle distribution uniformity index... When the value is less than 1, it indicates that the spatial point set of hair follicles exhibits an aggregated distribution pattern.

[0047] Optionally, in the hair follicle cluster structure parameter calculation step, the average number of secondary hair follicles around each primary hair follicle is retained to two decimal places, and the average number of secondary hair follicles is associated with and stored with the opening diameter of the primary hair follicle to form a record of hair follicle cluster development status. Optionally, in the hair follicle distribution uniformity index calculation step, the expected nearest neighbor distance under theoretical random distribution is calculated based on the null hypothesis of completely spatial random distribution, which assumes that the positions of all hair follicles on the skin surface are independent of each other and follow a uniform distribution.

[0048] It is understood that the hair follicle spatial point set is composed of the position coordinates of each hair follicle output by the improved YOLOv8 algorithm, and the position coordinates of each hair follicle are represented by the center point coordinates of the hair follicle opening bounding box. It is also understood that the hair follicle group structure parameters reflect the number of secondary hair follicles accompanying a single primary hair follicle, and the hair follicle distribution uniformity index reflects the spatial arrangement pattern of all hair follicles on the skin surface; both together describe the spatial organizational structure characteristics of the hair follicle group.

[0049] In one embodiment of the present invention, after calculating the primary hair follicle density and secondary hair follicle density values ​​based on the number of primary hair follicles, the number of secondary hair follicles, and the actual skin area, a density correction step is performed. A preset shrinkage rate correction coefficient is obtained, the value of which ranges from 0.75 to 0.85. The primary hair follicle density value is multiplied by the shrinkage rate correction coefficient to generate a corrected primary hair follicle density value. The secondary hair follicle density value is multiplied by the shrinkage rate correction coefficient to generate a corrected secondary hair follicle density value. The corrected primary hair follicle density value and the corrected secondary hair follicle density value are stored and output as converted density values ​​comparable to the traditional slicing method.

[0050] The specific process of outputting the primary and secondary hair follicle density values ​​and overlaying them onto the image to be detected to generate a hair follicle distribution heatmap is as follows: The image to be detected is used as the base layer. A transparent heatmap overlay layer is created on the base layer. Using the location coordinates of each hair follicle as a heat source point, the heat contribution value of the pixels surrounding each heat source point is calculated using a preset Gaussian kernel function. The heat contribution value of each hair follicle is associated with the hair follicle type, where the heat contribution value corresponding to primary hair follicles is higher than that corresponding to secondary hair follicles. All heat contribution values ​​at each pixel location are accumulated to obtain the total heat value for each pixel location. The total heat value at each pixel location is mapped to the corresponding color value according to a preset color mapping table, filling the heatmap overlay layer to generate a hair follicle distribution heatmap overlaid on the base layer. The primary and secondary hair follicle density values ​​are labeled in text form on the edge area of ​​the hair follicle distribution heatmap to generate a detection result image.

[0051] In specific implementation, after calculating the primary and secondary hair follicle density values ​​based on the number of primary hair follicles, the number of secondary hair follicles, and the actual skin area, the specific process of performing the density correction step is described in an example scenario as follows: A preset shrinkage rate correction coefficient is obtained, the value of which ranges from 0.75 to 0.85; the primary hair follicle density value is multiplied by the shrinkage rate correction coefficient to generate a corrected primary hair follicle density value; the secondary hair follicle density value is multiplied by the shrinkage rate correction coefficient to generate a corrected secondary hair follicle density value; the corrected primary and secondary hair follicle density values ​​are stored and output as converted density values ​​comparable to the traditional slicing method.

[0052] In a specific implementation, the process of outputting the primary hair follicle density value and the secondary hair follicle density value, and overlaying them onto the image to be detected to generate a hair follicle distribution heatmap, is described in an example scenario as follows: The image to be detected is used as the base layer; a transparent heatmap overlay layer is created on the base layer; the position coordinates of each hair follicle are used as heat source points, and the heat contribution value of the pixels surrounding each heat source point is calculated using a preset Gaussian kernel function. The heat contribution value of each hair follicle is associated with the hair follicle type, where the heat contribution value corresponding to the primary hair follicle is higher than that corresponding to the secondary hair follicle; all heat contribution values ​​at each pixel location are accumulated to obtain the total heat value at each pixel location; the total heat value at each pixel location is mapped to the corresponding color value according to a preset color mapping table, and the heatmap overlay layer is filled to generate a hair follicle distribution heatmap overlaid on the base layer; the primary hair follicle density value and the secondary hair follicle density value are labeled in text form on the edge area of ​​the hair follicle distribution heatmap to generate a detection result image.

[0053] In practical implementation, the location coordinates of each hair follicle are used as heat source points. The process of calculating the thermal contribution value of the pixels surrounding each heat source point using a preset Gaussian kernel function is expressed as follows: in: Represents pixel coordinates Total heat value at location, This represents the total number of hair follicles detected in the image to be detected. Indicates the first The thermal contribution weighting coefficient of each hair follicle, the thermal contribution weighting coefficient being related to the first... The hair follicle type is associated with the number of hair follicles, when the number of hair follicles is When the first hair follicle is a primary hair follicle, the thermal contribution weighting coefficient is 2.0. When each hair follicle is a secondary hair follicle, the thermal contribution weighting coefficient is set to 1.0. Indicates the first The location coordinates of each hair follicle The standard deviation parameter of the preset Gaussian kernel function is represented.

[0054] In some embodiments, the shrinkage correction coefficient is set differently according to the age group of the cashmere goat. For cashmere goats under one year old, the shrinkage correction coefficient is 0.85; for cashmere goats between one and three years old, the shrinkage correction coefficient is 0.80; and for cashmere goats over three years old, the shrinkage correction coefficient is 0.75. In some embodiments, the standard deviation parameter of the preset Gaussian kernel function... The value range is from 5 pixels to 15 pixels. The preset color level mapping table adopts a color level that is gradually changed from blue to red. The area with the lowest total heat value corresponds to blue, the area with the middle total heat value corresponds to yellow, and the area with the highest total heat value corresponds to red.

[0055] Optionally, the transparent thermal overlay layer uses an alpha channel for transparency control, with the alpha channel transparency value set to 40% to 60%, ensuring that the hair follicle edge contour of the base layer remains visible beneath the thermal overlay layer. Optionally, when annotating the primary and secondary hair follicle density values ​​in text form on the edge area of ​​the hair follicle distribution heatmap, the corrected primary and secondary hair follicle density values ​​are simultaneously annotated, and the specific value of the shrinkage rate correction coefficient is noted in the annotation content.

[0056] It is understood that the shrinkage correction coefficient is used to compensate for the area measurement deviation caused by tissue elastic recoil during skin preparation and image acquisition, so that the corrected primary hair follicle density value and the corrected secondary hair follicle density value are on the same comparable dimension as the hair follicle density value measured on the fixed skin sample using the traditional tissue sectioning method. It is also understood that the total heat value of each pixel in the hair follicle distribution heatmap reflects the degree of hair follicle aggregation and the comprehensive weight of hair follicle type within the pixel's neighborhood, with the heat value contributed by primary hair follicles being higher than that contributed by secondary hair follicles, causing the central area of ​​the hair follicle cluster to appear as a bright color area in the hair follicle distribution heatmap.

[0057] The above embodiments are only used to illustrate the technical methods of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical methods of the present invention without departing from the spirit and scope of the technical methods of the present invention.

Claims

1. A method for detecting the density of goat hair follicles based on image recognition, characterized in that, The method includes: Obtain the skin surface of the standard part of the body of the cashmere goat being tested after skin preparation; The skin surface is illuminated by a multispectral light source, and a high-resolution multispectral image of the skin surface is acquired. Preprocessing is performed on the multispectral high-definition image to generate a standardized image to be detected, and the actual skin area corresponding to the image to be detected is calculated based on the reference markers calibrated in the image to be detected. The image to be detected is input into the improved YOLOv8 algorithm for hair follicle target detection and classification. The improved YOLOv8 algorithm distinguishes primary hair follicles and secondary hair follicles based on the numerical range of hair follicle opening diameter and the spatial distribution pattern of hair follicles, and outputs the number of primary hair follicles, the number of secondary hair follicles detected, and the position coordinates of each hair follicle. The primary hair follicle density and secondary hair follicle density values ​​are calculated based on the number of primary hair follicles, the number of secondary hair follicles, and the actual skin area. The primary hair follicle density value and the secondary hair follicle density value are output, and a hair follicle distribution heatmap is generated by overlaying them onto the image to be detected.

2. The method for detecting goat hair follicle density based on image recognition according to claim 1, characterized in that, The process of acquiring multispectral high-resolution images of the skin surface includes: The multispectral light source includes a polarized light source and a near-infrared light source; The polarized light source is used to generate linearly polarized light to irradiate the skin surface. The wavelength range of the near-infrared light source is from 700 nanometers to 1100 nanometers, which is used to penetrate the epidermal layer of the skin to enhance the visibility of the subcutaneous hair follicle structure. The polarized light source and the near-infrared light source are turned on in sequence, and grayscale images of the skin surface are acquired under each light source. The grayscale image acquired under the polarized light source and the grayscale image acquired under the near-infrared light source are fused at the pixel level to generate a multispectral high-definition image containing surface texture information and subcutaneous structure information. The multispectral high-definition image has an optical magnification of 50 to 150 times, an image resolution of no less than 1920 pixels multiplied by 1080 pixels, and an imaging frame rate of no less than 30 frames per second.

3. The method for detecting goat hair follicle density based on image recognition according to claim 2, characterized in that, Preprocessing is performed on the multispectral high-resolution image to generate a standardized image to be detected, and the actual skin area corresponding to the image to be detected is calculated based on the reference markers calibrated in the image to be detected, including: The multispectral high-definition image is subjected to bilateral filtering denoising processing to maintain the sharpness of the hair follicle edges and generate a denoised image; Perform contrast-limited adaptive histogram equalization on the denoised image to enhance local contrast and generate an enhanced contrast image; Gaussian pyramid fusion processing is performed on the enhanced contrast image to reconstruct and fuse the image after multi-layer Gaussian pyramid decomposition, thereby improving the clarity of hair follicle edges and generating the image to be detected. Identify the boundary contour of a preset reference mark in the image to be detected, wherein the reference mark is a circular mark with a known actual diameter; The pixel coverage diameter of the reference mark in the image to be detected is calculated based on the boundary contour of the reference mark, and the conversion ratio between the pixel size and the actual physical size is calculated in combination with the actual diameter of the reference mark. The actual skin area corresponding to the image to be detected is obtained by multiplying the conversion ratio by the total pixel area of ​​the image to be detected.

4. The method for detecting goat hair follicle density based on image recognition according to claim 1, characterized in that, The improved YOLOv8 algorithm includes an input terminal, a backbone network, a neck network, and a detection head; The input terminal is used to receive the image to be detected and scale the image to be detected to a preset input size; The backbone network uses a cross-stage local network structure to perform multi-level feature extraction on the scaled image, generating feature maps at multiple scales. The neck network employs a path aggregation network structure to perform bidirectional feature fusion of the feature maps at multiple scales from top to bottom and bottom to top, generating a fused feature pyramid; The detection head is used to predict the hair follicle category and regress the bounding box for each feature point in the fused feature pyramid, and outputs the category label and location coordinates of each hair follicle in the image to be detected. The category label includes primary hair follicle label and secondary hair follicle label.

5. The method for detecting goat hair follicle density based on image recognition according to claim 4, characterized in that, The improved YOLOv8 algorithm distinguishes between primary and secondary hair follicles based on the numerical range of hair follicle opening diameter and the spatial distribution pattern of hair follicles. The specific process includes: During the training phase, a skin sample image dataset containing multiple cashmere goat breeds, multiple age groups, and multiple cashmere growth stages is constructed. Each hair follicle in the skin sample image dataset is labeled, and the labeling content includes the hair follicle opening bounding box and the hair follicle type label. Based on the marked hair follicle opening boundary box, calculate the opening diameter value of each hair follicle. Hair follicles with an opening diameter value greater than 0.1 mm are marked as primary hair follicles, and hair follicles with an opening diameter value less than 0.05 mm are marked as secondary hair follicles. While annotating, the spatial distribution pattern of adjacent hair follicles around each hair follicle is recorded. For primary hair follicles that are surrounded by at least three secondary hair follicles and whose center point is less than the center point of the current hair follicle, a cluster structure label is added in the annotation. The dataset of skin sample images labeled with hair follicle type and cluster structure is input into the improved YOLOv8 algorithm for iterative training, so that the detection head of the improved YOLOv8 algorithm can predict hair follicle type based on the predicted value of hair follicle opening diameter and the cluster distribution density of secondary hair follicles around the hair follicle.

6. The method for detecting goat hair follicle density based on image recognition according to claim 5, characterized in that, After outputting the number of primary hair follicles, the number of secondary hair follicles, and the location coordinates of each hair follicle, the system also includes a step of calculating the structural parameters of the hair follicle group. The steps for calculating the structural parameters of the hair follicle group include: Iterate through each hair follicle marked as a primary hair follicle and obtain the location coordinates of that primary hair follicle; Calculate the Euclidean distance between the location coordinates of the primary hair follicle and the location coordinates of all hair follicles marked as secondary hair follicles; Secondary hair follicles whose Euclidean distance is less than a preset group distance threshold are selected, and these selected secondary hair follicles are assigned to the same hair follicle group as the primary hair follicle. The number of secondary hair follicles in each hair follicle group is counted, and the arithmetic mean of the number of secondary hair follicles in all hair follicle groups is calculated to obtain the average number of secondary hair follicles around each primary hair follicle, which is then output as the structural parameter of the hair follicle group.

7. The method for detecting goat hair follicle density based on image recognition according to claim 6, characterized in that, After outputting the number of primary hair follicles, the number of secondary hair follicles, and the location coordinates of each hair follicle, the system also includes a step of calculating the hair follicle distribution uniformity index. The steps for calculating the hair follicle distribution uniformity index include: Obtain the position coordinates of all hair follicles in the image to be detected, and construct a spatial point set of hair follicles; For each hair follicle in the hair follicle spatial point set, calculate the nearest neighbor distance between the hair follicle and its nearest neighbor hair follicle; The average nearest neighbor distance is obtained by arithmetically averaging the nearest neighbor distances of all hair follicles. The expected nearest neighbor distance under a theoretical random distribution is calculated based on the actual skin area and total number of hair follicles corresponding to the image to be detected. Divide the average nearest neighbor distance by the expected nearest neighbor distance to obtain the hair follicle distribution uniformity index.

8. The method for detecting goat hair follicle density based on image recognition according to claim 1, characterized in that, After calculating the primary hair follicle density value and the secondary hair follicle density value based on the number of primary hair follicles, the number of secondary hair follicles, and the actual skin area, a density correction step is also included. The density correction step includes: Obtain a preset shrinkage correction coefficient, wherein the value range of the shrinkage correction coefficient is 0.75 to 0.85; Multiply the primary hair follicle density value by the shrinkage rate correction coefficient to generate the corrected primary hair follicle density value. Multiply the secondary hair follicle density value by the shrinkage rate correction coefficient to generate the corrected secondary hair follicle density value. The corrected primary hair follicle density value and the corrected secondary hair follicle density value are stored and output as converted density values ​​comparable to the traditional slicing method.

9. The method for detecting goat hair follicle density based on image recognition according to claim 1, characterized in that, Output the primary hair follicle density value and the secondary hair follicle density value, and overlay them onto the image to be detected to generate a hair follicle distribution heatmap, including: The image to be detected is used as the bottom layer; Create a transparent thermal overlay layer on the base layer; Using the location coordinates of each hair follicle as a heat source point, the heat contribution value of the pixels surrounding each heat source point is calculated using a preset Gaussian kernel function. The heat contribution value of each hair follicle is associated with the hair follicle type, wherein the heat contribution value corresponding to the primary hair follicle is higher than that corresponding to the secondary hair follicle. The total thermal value for each pixel is obtained by summing up all thermal contribution values ​​at each pixel location. According to the preset color level mapping table, the total heat value of each pixel position is mapped to the corresponding color value, and the heat overlay layer is filled to generate a hair follicle distribution heat map superimposed on the base layer. The primary hair follicle density values ​​and the secondary hair follicle density values ​​are labeled in text form at the edge of the hair follicle distribution heatmap to generate a detection result image.

10. A method for detecting the density of goat hair follicles based on image recognition, characterized in that, The cashmere goat skin hair follicle density detection system includes a processor and a memory. The memory is connected to the processor and is used to store programs, instructions, or code. The processor is used to run the programs, instructions, or code in the memory to implement the cashmere goat hair follicle density detection method based on image recognition as described in any one of claims 1 to 9.