A machine vision-based method and system for detecting internal defects of deer horn glue

CN122928852APending Publication Date: 2026-10-16HUNAN DONGJIAN PHARMA CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611308728.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-27
Publication Date
2026-10-16

AI Technical Summary

Technical Problem

这种传统的人工检测方法存在极其明显的缺点:首先,检测效率低下,完全无法满足现代中药企业大规模、流水线式的生产需求;其次,由于鹿角胶透光性较差,工人长时间在强光背景下注视暗色物体,极易产生视觉疲劳,导致漏检率和误检率居高不下;最后,人工评估缺乏统一的量化标准,质量等级的判定往往依赖于工人的主观经验,导致不同批次、不同检验员之间的评判结果存在显著的个体差异和不一致性

Benefits of technology

首先,在成像与预处理阶段,本发明并非单纯套用现有的图像直方图均衡或全局阈值算法,而是基于鹿角胶的材质属性进行了物理层面的创新。通过选用与胶体透过率相匹配的红光窄带光源进行透射照明,并严格依据胶块浇模成型特有的边缘厚、中部薄的物理分布规律,基于光学吸收定律构建了像素级的亮度补偿模型。这一改进从物理成像的根源上消除了厚度不均带来的边缘暗区假性缺陷干扰,为后续的深度学习网络提供了透光均匀、细节清晰的高质量图像基础。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122928852A_ABST
    Figure CN122928852A_ABST
Patent Text Reader

Abstract

The application discloses a kind of machine vision-based inner defect detection method and system of deer horn glue.The method adopts red light narrow band backlight transmission illumination to collect image, and carries out brightness compensation according to the thickness distribution law of glue block;Corrected image is sent into multi-scale layered cross-level fusion convolution network to extract fusion feature map;Subsequently, it is sent into bubble and impurity segmentation branch respectively, and the feature is enhanced using the same ring domain response contrast enhancement module and neighborhood mean deviation dark area strengthening module, and the different optical imaging forms of bubble and impurity are subjected to feature enhancement, and the defect segmentation graph is output;Finally, the quantitative description vector is constituted by counting the number of defects, equivalent diameter and density, and the quality grade score is output by combining deep features through full connection mapping.The application realizes accurate defect segmentation and objective and automatic scoring, and improves detection efficiency and quality control level.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the technical field of antler glue defect detection, and more particularly to a machine vision-based method and system for detecting internal defects in antler glue. Background Technology

[0002] Deer antler glue, a precious traditional Chinese medicine with a long history and high medicinal value, has wide applications in health maintenance and clinical treatment. In the modern production process of deer antler glue, the glue solution is boiled, filtered, poured into molds to cool and solidify, and finally cut into standard blocks. However, due to the complexity of the boiling process and the physical properties of the glue solution itself, tiny air bubbles, medium-sized impurity clumps, and large-scale defect aggregates are easily retained inside the glue during casting and cooling. These internal defects not only seriously affect the appearance quality of the deer antler glue but also directly reduce the purity and efficacy of the medicine. Therefore, rigorous testing for internal defects in deer antler glue and classifying its quality accordingly is a crucial step in ensuring the quality of traditional Chinese medicine products.

[0003] Traditionally, the detection of internal defects in deer antler glue has relied primarily on manual visual inspection. Quality inspectors typically need to pick up each dark brown block of glue one by one in front of a strong light box and examine it against the light to visually determine whether there are air bubbles or impurities inside. This traditional manual inspection method has extremely obvious drawbacks: First, the inspection efficiency is low and cannot meet the needs of large-scale, assembly-line production in modern Chinese medicine enterprises; second, because deer antler glue has poor light transmittance, workers are prone to visual fatigue when staring at dark objects against a strong light background for a long time, resulting in high rates of missed and false detections; finally, manual evaluation lacks unified quantitative standards, and the determination of quality grade often depends on the subjective experience of workers, leading to significant individual differences and inconsistencies in the evaluation results between different batches and different inspectors.

[0004] In recent years, with the development of industrial automation technology, machine vision-based non-destructive testing technology has begun to be introduced into the field of traditional Chinese medicine testing. However, for deer antler glue, a special testing object, existing machine vision testing methods have revealed many technical bottlenecks and shortcomings in practical applications.

[0005] Firstly, regarding optical imaging and illumination, antler glue is dark brown to blackish-brown in color, and its transmittance in conventional white light or short-wavelength visible light bands is extremely low. Existing conventional backlight transmission illumination schemes often cannot effectively penetrate glue blocks of a certain thickness, resulting in overall dark transmission images with extremely low contrast. Tiny internal defects are completely masked in the dark areas, making them difficult for subsequent algorithms to effectively extract.

[0006] Secondly, existing image processing methods have failed to effectively overcome the lighting interference caused by uneven thickness of the antler rubber blocks. Due to the physical law of condensation and shrinkage after molding, antler rubber blocks generally exhibit a thickness distribution characteristic of "thicker at the edges and thinner in the center." Under transmitted illumination, this thickness difference directly leads to high light transmittance in the central area of ​​the image and severe attenuation in the edge area. Traditional machine vision algorithms typically use global threshold segmentation or simple histogram equalization, which cannot distinguish between "dark areas at the edges caused by increased thickness" and "true internal impurity dark spots," easily generating a large number of false defect alarms at the edges of the rubber blocks, severely reducing the accuracy of detection.

[0007] Furthermore, in terms of defect feature extraction and segmentation, the bubbles and impurities inside the antler glue exhibit distinctly different and complex morphological characteristics under transmitted light. Due to light refraction, bubbles typically display a unique structure of "a bright spot in the center and a dark ring around the periphery"; while impurities appear as dark spots with low overall light transmittance and no bright center structure. Simultaneously, the size range of defects is extremely wide, ranging from barely perceptible microbubbles to large clumps of impurities. Existing general-purpose deep learning convolutional neural networks (CNNs) or conventional edge detection algorithms often lack targeted feature enhancement mechanisms when dealing with such complex targets of multiple scales and morphologies, easily losing edge details of microbubbles or confusing the dark rings of bubbles with dark spots of impurities, resulting in blurred segmentation boundaries and low classification accuracy.

[0008] Finally, in the final quality assessment stage, most existing automated inspection systems only output the location of defects or simply calculate the total area of ​​defects, lacking a comprehensive evaluation model that deeply integrates multi-dimensional quantitative indicators with deep semantic features of images. Relying solely on single indicators such as area or quantity cannot accurately reflect the distribution density of defects or the fatal impact of maximum size on overall quality, thus failing to achieve the precise and multi-level automated quality rating comparable to human expert inspection.

[0009] In summary, the industry urgently needs an automated internal defect detection method that can overcome the interference of the special optical properties and thickness distribution of antler glue, accurately enhance the complex defect morphology characteristics, and achieve scientific quantitative grading. Summary of the Invention

[0010] In view of this, the present invention provides a machine vision-based method for detecting internal defects in deer antler glue. The purpose is to achieve accurate segmentation and quantitative statistics of bubbles and impurities inside deer antler glue by using specific optical imaging design and image brightness compensation, combined with multi-scale feature fusion and feature enhancement network structure customized for different defect morphologies. This provides an objective and accurate automated quality grade score, thereby comprehensively improving the quality control level and detection efficiency of the deer antler glue production process.

[0011] To achieve the above objectives, the present invention provides a machine vision-based method for detecting internal defects in antler glue, comprising the following steps: S1: Place the antler glue between a surface light source and an industrial camera, use a red narrow-band light source to backlight the antler glue and collect the transmission image; based on the thickness distribution law that the edge thickness is greater than the middle thickness due to condensation shrinkage after the antler glue is molded, establish the correspondence between the local thickness of the glue block and the attenuation of the light transmission brightness, perform pixel-by-pixel brightness compensation on the transmission image, and obtain a corrected image with uniform light transmission. S2: The corrected image is fed into a multi-scale hierarchical cross-level fusion convolutional network. Through the convolutional operation of progressive downsampling, multi-level feature maps representing the edges of small bubbles, medium-sized impurity clumps and large-scale defect aggregation areas are extracted in sequence. The multi-level feature maps are fused across layers to obtain a fused feature map containing both detailed and overall information. S3: The fused feature maps are fed into the bubble segmentation branch and the impurity segmentation branch respectively. A concentric ring domain response contrast enhancement module is embedded in the bubble segmentation branch. This module calculates the mean response of the central region and the mean response of the ring neighborhood at each spatial location based on the imaging morphology of a bubble exhibiting a bright center and a dark ring around the periphery under transmitted light using a central circular mean convolution kernel and a concentric ring mean convolution kernel, respectively. The difference between the two is mapped as a bubble attention weight to enhance the bubble morphology features. A neighborhood mean deviation dark area enhancement module is embedded in the impurity segmentation branch. This module calculates the mean response of the neighborhood at each spatial location based on the imaging morphology of impurities exhibiting an overall low-transmittance dark spot without a ring bright center structure under transmitted light using a rectangular neighborhood mean convolution kernel. The difference between the mean response of the neighborhood and the response at the current location is mapped as an impurity attention weight to enhance the dark spot region features. The bubble segmentation branch and the impurity segmentation branch respectively restore the original image resolution through stepwise transposed convolution upsampling, outputting the bubble segmentation map and the impurity segmentation map. S4: Connected regions are extracted from the bubble segmentation map and the impurity segmentation map respectively. The number of defects of the two types, the equivalent diameter of each defect, and the distribution density of defects on the area of ​​the glue block are counted to form a defect quantification description vector. The defect quantification description vector and the deep channel features of the fusion feature map are sent to the defect feature fusion level mapping layer. The quality grade score of the antler glue is obtained by mapping through fully connected operation and output, thus completing the detection of internal defects in the antler glue.

[0012] As a further improvement of the present invention: Optionally, step S1 further includes: S101: Place the antler glue horizontally directly above a uniform surface light source, and use an industrial camera to acquire a transmitted image from directly above the glue block along the normal direction of the surface light source. The surface light source outputs red narrowband light with a wavelength range of 620 nm to 680 nm; the transmittance of antler glue in the red light band is significantly higher than its transmittance in the short wavelength visible light band, and the selection of the red narrowband light source is determined based on the optical absorption characteristics. S102: Based on the Lambert-Beer Law, establish the local thickness of the adhesive block. With pixel position The correspondence between the attenuation of transmitted brightness at a certain point, for the transmitted image Each pixel position Perform brightness compensation to obtain the corrected image. The brightness compensation formula is: ; in, To correct the pixel position of the image The brightness value at that location, For the transmission image at pixel position The original brightness value at that location, This represents the effective absorption coefficient of antler glue colloid in the red light band. pixel position The local thickness value of the adhesive block at a given location, exp represents the local thickness value of the adhesive block as expressed by the natural exponential function; Based on the thickness distribution pattern of the edge and middle of the antler glue formed by the casting process, the standard glue block sample was pre-calibrated and established after three-dimensional morphology measurement.

[0013] Optionally, step S2 further includes: S201: Correct the image The input is fed into the encoding stage of a multi-scale hierarchical cross-level fusion convolutional network, where it sequentially passes through the first, second, and third convolutional downsampling stages to extract the first-level feature maps representing the edges of the microbubbles. Second-level feature map characterizing medium-sized impurity agglomerates and the third-level feature map characterizing large-scale defect clusters. ; S202: For the first-level feature map Second-level feature map and third-level feature maps Each feature map is upsampled and aligned to the same spatial resolution using bilinear interpolation, then concatenated along the channel dimension and compressed through a convolutional layer to obtain the fused feature map. The fused feature map It also includes fine-grained edge detail information from the first level, medium-scale clumping information from the second level, and large-scale overall distribution information from the third level.

[0014] Optionally, step S3 further includes: S301: Merge feature maps The samples are fed into the bubble separation branch and the impurity separation branch, respectively. S302: In the bubble segmentation branch, the concentric ring domain response contrast enhancement module is used to fuse feature maps. For input, Each channel is applied with a spatial position. Centered on, with radius After applying a circular mean convolution kernel, the mean value is taken along the channel dimension to obtain the mean response value of the central region. ; then Each channel is applied with a spatial position. Centered on, with an inner radius of Outer radius is After applying a circular mean convolution kernel, the mean value is taken along the channel dimension to obtain the mean response of the circular neighborhood. ,in Bubble attention weight matrix The calculation formula is: ; in, The attention weight matrix of the bubble is located in space. The weight value at that point, To fuse feature maps In spatial location The channel mean of the response in the circular region of each channel. To fuse feature maps In spatial location The channel mean of the ring neighborhood response of each channel. For learnable scaling factor, The bias coefficients are learnable, and the sigmoid function is the sigmoid activation function; With fusion feature map The bubble enhancement feature map is obtained by multiplying the spatial locations one by one. It is then upsampled through successive transpose convolutions to restore the original image resolution, and the bubble segmentation map is output. ; S303: In the impurity segmentation branch, the neighborhood mean deviation dark area enhancement module uses fused feature maps. For input, After applying a rectangular mean convolution kernel with side length l to each channel, the mean value is taken along the channel dimension to obtain each spatial location. Mean of rectangular neighborhood response at Impurity attention weight matrix The calculation formula is: ; in, The spatial location of the impurity attention weight matrix The weight value at that point, To fuse feature maps In spatial location Mean of the rectangular neighborhood response at that location. To fuse feature maps In spatial location The channel average of the response of each channel. For learnable scaling factor, These are learnable bias coefficients; With fusion feature map Multiplying by spatial location yields an impurity enhancement feature map, which is then upsampled through successive transpose convolutions to restore the original image resolution, outputting an impurity segmentation map. .

[0015] Optionally, step S4 further includes: S401: Bubble segmentation diagram Connected regions are marked, and components with an equivalent diameter smaller than a preset minimum effective diameter threshold are removed. Connected regions are used to eliminate noise interference, and the total number of bubble defects is counted for the retained effective connected regions. The equivalent diameter of each bubble's connected region , and bubble distribution density Impurity segmentation diagram Connected components are marked, and components with an equivalent diameter smaller than [a certain value] are also removed. For the connected regions, the total number of impurities and defects is counted for the retained valid connected regions. The equivalent diameter of each impurity connected region , and impurity distribution density The equivalent diameter is the diameter of a circle with the same area as the pixel area of ​​the connected region, and the distribution density is the ratio of the total area of ​​the effective connected region of this type of defect to the effective detection area of ​​the glue block. S402: with Mean equivalent diameter of bubbles With the maximum value , , Mean of equivalent diameter of impurities With the maximum value , The defect quantization description vector consists of eight dimensions. ; Quantize the defect description vector With fusion feature map Deep channel feature vectors extracted by global average pooling After splicing, the data is fed into the defect feature fusion level mapping layer. After fully connected operation, the probability distribution of each preset quality level is obtained through the Softmax function. The quality level with the highest probability is selected as the output quality level score of the deer antler glue.

[0016] This invention also discloses a machine vision-based system for detecting internal defects in antler glue, comprising: Image acquisition module: Acquires images through a specific light source and eliminates light interference caused by uneven thickness of the adhesive block to obtain a high-quality base image; Feature extraction and fusion module: Utilizes convolutional neural networks to extract features of defects of different sizes and effectively integrates multi-level information; Image segmentation module: It adopts a dual-branch structure for targeted feature enhancement and precise segmentation based on the different optical morphologies of bubbles and impurities; The comprehensive scoring module performs mathematical quantification on the segmentation results and combines them with deep image features to complete the final quality rating.

[0017] Compared with the prior art, the present invention has at least the following beneficial effects: First, in the imaging and preprocessing stages, this invention does not simply apply existing image histogram equalization or global thresholding algorithms, but rather innovates at the physical level based on the material properties of antler glue. By selecting a narrow-band red light source that matches the transmittance of the glue for transmission illumination, and strictly adhering to the unique physical distribution law of the glue block being thicker at the edges and thinner in the center during molding, a pixel-level brightness compensation model is constructed based on the optical absorption law. This improvement eliminates the false defect interference of edge dark areas caused by uneven thickness at the root of physical imaging, providing a high-quality image foundation with uniform light transmission and clear details for subsequent deep learning networks.

[0018] Secondly, in the defect feature extraction and segmentation network, this invention avoids the problem of insufficient feature extraction specificity caused by directly using general convolutional networks or conventional attention mechanisms. This invention not only constructs a multi-scale hierarchical cross-level fusion architecture to take into account the multi-scale features of microbubbles and large-scale impurities, but its more core improvement lies in the original design of a dual-branch feature enhancement mechanism targeting the specific visual manifestations of the two major types of defects inside antler glue under transmitted light. In the bubble segmentation branch, based on the unique central bright spot and peripheral dark ring morphology of bubbles, this invention specifically designs a concentric ring domain response contrast enhancement module, generating exclusive attention weights by calculating the response difference between the central region and the ring neighborhood. Simultaneously, in the impurity segmentation branch, based on the characteristic that impurities present as pure dark spots without a bright center structure, a neighborhood mean deviation dark area enhancement module is designed. This improvement directly transforms the prior knowledge of the physical and optical morphology of defects into the mathematical operation logic within the network, enabling the algorithm to adaptively enhance the features of specific morphologies of defects, completely solving the technical problem of easily confusing bubble dark rings with impurity dark spots, and greatly improving the segmentation accuracy of heterogeneous defects.

[0019] Finally, the various improvements in this invention are not isolated but interdependent and synergistic. Front-end image correction based on physical laws eliminates interference from background lighting distribution for the customized feature enhancement in the mid-end; the dual-branch customized module incorporating morphological prior knowledge in the mid-end provides a high-precision segmentation base map for back-end quantitative statistics; ultimately, by jointly mapping the precisely extracted multi-dimensional quantitative indicators such as defect quantity, size, and density with the deep semantic features extracted by the network, a leap from pixel-level feature extraction to image-level quality scoring is achieved. The entire detection process, from physical imaging correction to morphological customized networks and then to multi-dimensional feature fusion evaluation, is interconnected, forming a comprehensive solution highly suited to the defect detection characteristics of antler glue, enabling objective, efficient, and accurate automated evaluation of antler glue quality levels. Attached Figure Description

[0020] Figure 1 This is a schematic flowchart of a machine vision-based method for detecting internal defects in antler glue according to an embodiment of the present invention. Figure 2 This is a schematic diagram of the transmission image acquisition and brightness compensation process based on thickness distribution. Figure 3 This is a schematic diagram of the multi-scale feature extraction and cross-layer fusion process; Figure 4 A schematic diagram of the customized enhancement and image segmentation process for dual-branch defect features; Figure 5 This is a schematic diagram of the process for quantifying defects and statistically analyzing quality levels. Detailed Implementation

[0021] The present invention will be further described below with reference to the accompanying drawings, but this is not intended to limit the present invention in any way. Any modifications or substitutions made based on the teachings of the present invention shall fall within the protection scope of the present invention.

[0022] Example 1: A machine vision-based method for detecting internal defects in antler glue, such as... Figure 1 As shown, it includes the following steps: S1: Place the antler glue between a surface light source and an industrial camera. Use a narrow-band red light source to backlight the antler glue and acquire transmitted images. Based on the thickness distribution pattern of the antler glue after molding, where the edge thickness is greater than the center thickness due to condensation shrinkage, establish the correspondence between the local thickness of the glue block and the attenuation of transmitted brightness. Perform pixel-by-pixel brightness compensation on the transmitted images to obtain a corrected image with uniform light transmission, such as... Figure 2 As shown, it includes: S101: Place the antler glue horizontally directly above a uniform surface light source, and use an industrial camera to acquire a transmitted image from directly above the glue block along the normal direction of the surface light source. The surface light source outputs a narrowband red light with a wavelength range of 620 nm to 680 nm. The transmittance of the antler colloid in the red light band is significantly higher than its transmittance in the short-wavelength visible light band. The selection of the narrowband red light source is based on the aforementioned optical absorption characteristics. In this embodiment, the effective emitting area of ​​the surface light source is set to 300 mm × 300 mm, and the output center wavelength is set to 650 nm. The image acquired by the industrial camera has an 8-bit grayscale image depth, with grayscale values ​​ranging from integers. ; S102: Based on the Lambert-Beer Law, establish the local thickness of the adhesive block. With pixel position The correspondence between the attenuation of transmitted brightness at a certain point, for the transmitted image Each pixel position Perform brightness compensation to obtain the corrected image. The brightness compensation formula is: ; in, To correct the pixel position of the image The brightness value at that location, For the transmission image at pixel position The original brightness value at that location, This represents the effective absorption coefficient of antler glue colloid in the red light band. pixel position The local thickness value of the adhesive block at a given location, exp represents the local thickness value of the adhesive block as expressed by the natural exponential function; Based on the thickness distribution pattern of the antler glue casting process, the thickness was pre-calibrated and established after three-dimensional morphological measurement of standard glue block samples; in this embodiment, the effective absorption coefficient... The thickness of the gelatin was determined by measuring the transmittance of 10 standard deer antler glue samples under red light illumination at a center wavelength of 650 nm. (Partial thickness diagram of the glue block) After measuring the 3D morphology of a standard adhesive block using a structured light 3D scanner, the point cloud data was mapped to the same pixel resolution as the transmission image using bicubic interpolation, and then pre-stored in a floating-point thickness map format; the image was then corrected. The brightness calculation results are truncated and limited to an integer range. Internal storage; In another embodiment, the effective absorption coefficient of different batches of deer antler glue is affected by the difference in raw material ratios. In cases of batch-to-batch variations, a batch-adaptive absorption coefficient calibration method is used to calibrate the absorbance coefficient before each batch is tested. Perform online updates: Extract three reference adhesive blocks of known thickness from the current testing batch, acquire transmission images of each block under the current imaging conditions, and update the thickness of the blocks according to the Lambert-Beer law. Reference block of glue, , Using the reference adhesive block serial number index, the measured effective absorption coefficient was calculated by reverse calculation. The arithmetic mean of the back-calculation results from the three reference rubber blocks is used to obtain the measured effective absorption coefficient of the current batch. ,by Alternative precalibration values Used for pixel-by-pixel brightness compensation calculations for all antler glue in the current batch.

[0023] S2: The corrected image is fed into a multi-scale hierarchical cross-level fusion convolutional network. Through progressively downsampled convolutional operations, multi-level feature maps representing the edges of microbubbles, medium-sized impurity clumps, and large-scale defect clusters are extracted sequentially. These multi-level feature maps are then fused across layers to obtain a fused feature map containing both detailed and overall information. Figure 3 As shown, it includes: S201: Correct the image The input is fed into the encoding stage of a multi-scale hierarchical cross-level fusion convolutional network, where it sequentially passes through the first, second, and third convolutional downsampling stages to extract the first-level feature maps representing the edges of the microbubbles. Second-level feature map characterizing medium-sized impurity agglomerates and the third-level feature map characterizing large-scale defect clusters. In this embodiment, the first convolutional downsampling stage consists of two concatenated convolutional layers with a kernel size of 3×3 and an output channel number of 32. Each convolutional layer is followed by a batch normalization layer and a ReLU activation function, and then a max pooling layer with a stride of 2 is connected after the concatenation to correct the image. Downsampling was performed to obtain a first-level feature map with 32 channels. The second convolutional downsampling stage consists of two concatenated convolutional layers with a kernel size of 3×3 and 64 output channels. Each convolutional layer is followed by a batch normalization layer and a ReLU activation function, and then a max pooling layer with a stride of 2. Downsampling was performed to obtain a second-level feature map with 64 channels. The third convolutional downsampling stage consists of two concatenated convolutional layers with a kernel size of 3×3 and 128 output channels. Each convolutional layer is followed by a batch normalization layer and a ReLU activation function, and then a max pooling layer with a stride of 2. Downsampling was performed to obtain a third-level feature map with 128 channels. ; S202: For the first-level feature map Second-level feature map and third-level feature maps Each feature map is upsampled and aligned to the same spatial resolution using bilinear interpolation, then concatenated along the channel dimension and compressed through a convolutional layer to obtain the fused feature map. The fused feature map It simultaneously includes fine-grained edge detail information from the first level, medium-scale cluster information from the second level, and large-scale overall distribution information from the third level; in this embodiment, the first-level feature map No upsampling required, second-level feature map Upsampled by 2 times using bilinear interpolation, third-level feature map The samples were upsampled by a factor of 4 using bilinear interpolation. After concatenation of the three samples along the channel dimension, the total number of channels was 224. This was then compressed by a convolutional layer with a kernel size of 1×1 and an output channel count of 128, followed by a batch normalization layer and a ReLU activation function, resulting in the fused feature map. , The number of channels is 128; In another embodiment, to address the issue that extremely small air bubbles with an equivalent diameter of less than 3 pixels in the antler glue are difficult to effectively respond within the receptive field of the 3×3 convolution kernel in the first convolution downsampling stage, a shallow micro-detail enhancement convolutional layer with a 1×1 kernel size, 8 output channels, and a ReLU activation function is added before the input of the first convolution downsampling stage to improve the accuracy of the corrected image. Perform pixel-by-pixel channel expansion to obtain a micro-detail enhancement feature map with 8 channels. In the cross-layer fusion stage of step S202, After downsampling via bilinear interpolation, all channels are concatenated along the channel dimension, expanding the total number of channels to 232. The output channels of subsequent channel-compressing convolutional layers remain unchanged at 128 to facilitate feature map fusion. Expand the initial response basis for the edge details of extremely small bubbles while keeping the number of channels constant.

[0024] S3: The fused feature maps are fed into the bubble segmentation branch and the impurity segmentation branch respectively. A concentric ring domain response contrast enhancement module is embedded in the bubble segmentation branch. This module calculates the mean response of the central region and the mean response of the ring neighborhood at each spatial location based on the imaging morphology of a bubble exhibiting a bright center and a dark ring around the periphery under transmitted light using a central circular mean convolution kernel and a concentric ring mean convolution kernel, respectively. The difference between these two values ​​is mapped to the bubble attention weight to enhance the bubble morphology features. A neighborhood mean deviation dark area enhancement module is embedded in the impurity segmentation branch. This module calculates the mean response of the neighborhood at each spatial location based on the imaging morphology of impurities exhibiting an overall low-transmittance dark spot without a ring bright center structure under transmitted light using a rectangular neighborhood mean convolution kernel. The difference between the mean response of the neighborhood and the response at the current location is mapped to the impurity attention weight to enhance the dark spot region features. The bubble segmentation branch and the impurity segmentation branch respectively restore the original image resolution through stepwise transposed convolution upsampling, outputting the bubble segmentation map and the impurity segmentation map, as shown below. Figure 4 As shown, it includes: S301: Merge feature maps The samples are fed into the bubble separation branch and the impurity separation branch, respectively. S302: In the bubble segmentation branch, the concentric ring domain response contrast enhancement module is used to fuse feature maps. For input, Each channel is applied with a spatial position. Centered on, with radius After applying a circular mean convolution kernel, the mean value is taken along the channel dimension to obtain the mean response value of the central region. ; then Each channel is applied with a spatial position. Centered on, with an inner radius of Outer radius is After applying a circular mean convolution kernel, the mean value is taken along the channel dimension to obtain the mean response of the circular neighborhood. ,in Bubble attention weight matrix The calculation formula is: ; in, The attention weight matrix of the bubble is located in space. The weight value at that point, To fuse feature maps In spatial location The channel mean of the response in the circular region of each channel. To fuse feature maps In spatial location The channel mean of the ring neighborhood response of each channel. For learnable scaling factor, The bias coefficients are learnable, and the sigmoid function is the sigmoid activation function; With fusion feature map The bubble enhancement feature map is obtained by multiplying the spatial locations one by one. It is then upsampled through successive transpose convolutions to restore the original image resolution, and the bubble segmentation map is output. In this embodiment, the radius of the circular mean convolution kernel is... Set to 3 pixels, outer radius of the circular mean convolution kernel Set to 7 pixels; learnable scaling factor The initial value is set to 1.0, and the learnable bias is... The initial value is set to 0; the upsampling stage of the bubble segmentation branch is implemented by three transposed convolutional layers in series. The number of output channels of the three transposed convolutional layers are 64, 32, and 1 respectively. The size of the transposed convolutional kernel is 4×4 and the stride is 2. Finally, the bubble segmentation map is output after passing through the Sigmoid activation function. ; This is a single-channel probability map with the same resolution as the original image. Each pixel value represents the predicted probability that the location belongs to the bubble region, and the value range is... ; S303: In the impurity segmentation branch, the neighborhood mean deviation dark area enhancement module uses fused feature maps. For input, After applying a rectangular mean convolution kernel with side length l to each channel, the mean value is taken along the channel dimension to obtain each spatial location. Mean of rectangular neighborhood response at Impurity attention weight matrix The calculation formula is: ; in, The spatial location of the impurity attention weight matrix The weight value at that point, To fuse feature maps In spatial location Mean of the rectangular neighborhood response at that location. To fuse feature maps In spatial location The channel average of the response of each channel. For learnable scaling factor, These are learnable bias coefficients; With fusion feature map Multiplying by spatial location yields an impurity enhancement feature map, which is then upsampled through successive transpose convolutions to restore the original image resolution, outputting an impurity segmentation map. In this embodiment, the side length of the rectangular mean convolution kernel is set to 11 pixels; the learnable scaling factor... The initial value is set to 1.0, and the learnable bias is... The initial value is set to 0; the upsampling stage of the impurity segmentation branch and the bubble segmentation branch use the same three-stage transposed convolutional structure. The number of output channels of the transposed convolutional layers are 64, 32, and 1 respectively, the kernel size of the transposed convolution is 4×4, and the stride is 2. Finally, the impurity segmentation map is output after passing through the Sigmoid activation function. ; This is a single-channel probability map with the same resolution as the original image. Each pixel value represents the predicted probability that the location belongs to the impurity region, and the value range is... ; In this embodiment, all learnable parameters in the multi-scale hierarchical cross-level fusion convolutional network and the dual-channel defect segmentation network include the weights and biases of each encoding convolutional layer, the scaling parameters and offset parameters of the batch normalization layer, etc. , , , The weights and biases of each transposed convolutional layer were obtained through end-to-end supervised training. The training dataset consisted of 2000 pixel-level labeled images of antler glue with transmission correction, including 900 sample images with bubble defects, 700 sample images with impurity defects, and 400 defect-free sample images. The training and validation sets were randomly divided in an 8:2 ratio. The bubble segmentation branch independently calculated the binary cross-entropy loss using the bubble pixel-level labeled images as the supervised target. The impurity segmentation branch independently calculates the binary cross-entropy loss using the impurity pixel-level annotation map as the supervision target. Total training loss The weighted sum of the two-branch losses is calculated using the following formula: ; in, For total training losses, The weighting coefficients for the bubble segmentation branch loss are: The binary cross-entropy loss for bubble splitting branches, The weighting coefficients for the branching loss due to impurities. The binary cross-entropy loss is used to divide the impurity branches; in this embodiment, Set to 1.0. The initial learning rate was set to 1.2; training used the Adam optimizer, with the initial learning rate set to [value missing]. Every 20 training rounds, the learning rate is multiplied by a decay factor of 0.5, the batch size is set to 4, and the maximum number of training rounds is set to 100. In another embodiment, the large range of equivalent diameters of air bubbles in antler glue leads to a single circular mean convolution kernel radius... To address the challenge of simultaneously detecting both large and small-scale bubble bright center regions, the concentric ring domain response contrast enhancement module employs two sets of circular and annular mean convolution kernels with different radius parameters: the radius of the first set of circular mean convolution kernels is set to... The outer radius of the pixel and the circular mean convolution kernel are set to [value]. Pixels, specifically for enhancing the contrast between the bright center and dark ring of small-scale bubbles; the radius of the circular mean convolution kernel in the second parameter group is set to... The outer radius of the pixel and the circular mean convolution kernel are set to [value]. Pixels are specifically used for enhancing the contrast between the bright center and dark ring of large-scale bubbles; the attention weight matrix for small-scale bubbles is calculated using two sets of parameters. With large-scale bubble attention weight matrix ,Will and The element-wise maximum value at each spatial location is used as the final bubble attention weight matrix, which is then combined with the fused feature map. By multiplying spatially, adaptive feature enhancement coverage for bubbles of different sizes is achieved.

[0025] S4: Connected regions are extracted from the bubble segmentation map and impurity segmentation map respectively. The number of defects of the two types, the equivalent diameter of each defect, and the distribution density of defects on the area of ​​the glue block are counted to construct a defect quantification description vector. The defect quantification description vector and the deep channel features of the fused feature map are fed into the defect feature fusion level mapping layer. After fully connected operation, the quality grade score of the antler glue is obtained and output, completing the detection of internal defects in the antler glue. Figure 5 As shown, it includes: S401: Bubble segmentation diagram Connected regions are marked, and components with an equivalent diameter smaller than a preset minimum effective diameter threshold are removed. Connected regions are used to eliminate noise interference, and the total number of bubble defects is counted for the retained effective connected regions. The equivalent diameter of each bubble's connected region , and bubble distribution density Impurity segmentation diagram Connected components are marked, and components with an equivalent diameter smaller than [a certain value] are also removed. For the connected regions, the total number of impurities and defects is counted for the retained valid connected regions. The equivalent diameter of each impurity connected region , and impurity distribution density The equivalent diameter is the diameter of a circle with the same area as the pixel area of ​​the connected region; the distribution density is the ratio of the total area of ​​the effective connected regions of this type of defect to the effective detection area of ​​the adhesive block; in this embodiment, the connected region marking is performed using the 8-connectivity criterion; in the probability map and Before performing connected component extraction, the probability map is first binarized using a fixed threshold, resulting in a bubble segmentation map. The binarization threshold is set to 0.5, and the impurity segmentation map is... The binarization threshold is set to 0.5, meaning pixels with a probability value greater than 0.5 are marked as defect foreground regions, and the remaining pixels are marked as background regions; a preset minimum effective diameter threshold is also used. Set to 3 pixels; the method for determining the effective detection area of ​​the adhesive block is: [referring to the calibration image]. After excluding the 10-pixel-wide borders on all four sides, the binarization threshold is automatically determined using Otsu's method and then applied. Binarization is performed, and the largest connected region in the binary image is taken as the outline of the glue block. The total number of pixels in the region inside the glue block outline is the effective detection area of ​​the glue block. S402: with Mean equivalent diameter of bubbles With the maximum value , , Mean of equivalent diameter of impurities With the maximum value , The defect quantization description vector consists of eight dimensions. ; Quantize the defect description vector With fusion feature map Deep channel feature vectors extracted by global average pooling After splicing, the data is fed into a defect feature fusion level mapping layer. After fully connected computation, the probability distribution of each preset quality level is obtained through a Softmax function. The quality level with the highest probability is selected as the output quality level score for the antler glue. In this embodiment, the deep channel feature vector... By analyzing the fused feature map Obtained by performing global average pooling along both the height and width dimensions. The dimension is 128; the defect quantization description vector The eight dimensions were normalized according to their respective maximum reference values ​​before being stitched together: Normalized to the maximum reference value of 50. and Normalized to the maximum reference value of 100 pixels. Normalized to the maximum reference value of 0.10, Normalized to the maximum reference value of 20. and Normalized to the maximum reference value of 200 pixels. Normalized to the maximum reference value of 0.05, the normalized values ​​of each dimension of Q are mapped to the interval [0, 1]. and After concatenating the feature dimensions, a 136-dimensional concatenated vector is formed and fed into the defect feature fusion level mapping layer. This layer consists of two fully connected layers connected in series. The first fully connected layer has an input dimension of 136 and an output dimension of 64, followed by a ReLU activation function. The second fully connected layer has an input dimension of 64 and an output dimension of 4, corresponding to four preset quality levels: superior, first-class, second-class, and unqualified. The output of the second fully connected layer is converted into a probability distribution of the four quality levels using a Softmax function, and the level with the highest probability value is selected as the final quality level score. The weights and biases of the fully connected layers in the defect feature fusion level mapping layer are obtained through supervised training. The training dataset consists of defect quantification features and corrected image fusion features corresponding to 1500 batches of deer antler glue samples that have completed quality level identification, including 300 batches of superior, 450 batches of first-class, 450 batches of second-class, and 300 batches of unqualified. Training uses the cross-entropy loss function, the optimizer is Adam, and the initial learning rate is set to [value missing]. The batch size is set to 16, and the maximum number of training rounds is set to 50. In another embodiment, a defect quantization description vector is used. The number of a certain type of defect is zero, that is or When a null value appears in the corresponding dimension, the following rule applies: hour, , , All three dimensions are assigned a value of 0; when hour, , , All three dimensions are assigned a value of 0; ensuring the defect quantification description vector is accurate. Under any detection result, a complete fixed eight-dimensional numerical vector is generated, ensuring that the input dimension of the defect feature fusion level mapping layer remains consistent in the absence of defects; at the same time, when outputting the quality level score, the maximum probability value in the Softmax probability distribution is used. and the second highest probability value difference As a confidence index of the test results, when Less than the preset confidence threshold When the current antler glue sample is marked as "requiring manual review" and output along with the scoring results; in this embodiment, the confidence threshold is... Set to 0.25.

[0026] Example 2: This invention also discloses a machine vision-based internal defect detection system for antler glue, comprising the following modules: Image acquisition module: Acquires images through a specific light source and eliminates light interference caused by uneven thickness of the adhesive block to obtain a high-quality base image; Feature extraction and fusion module: Utilizes convolutional neural networks to extract features of defects of different sizes and effectively integrates multi-level information; Image segmentation module: It adopts a dual-branch structure for targeted feature enhancement and precise segmentation based on the different optical morphologies of bubbles and impurities; The comprehensive scoring module performs mathematical quantification on the segmentation results and combines them with deep image features to complete the final quality rating.

[0027] It should be noted that the sequence numbers of the above embodiments of the present invention are merely for descriptive purposes and do not represent the superiority or inferiority of the embodiments. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, apparatus, article, or method. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, apparatus, article, or method that includes that element.

[0028] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0029] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.

Claims

1. A machine vision-based method for detecting internal defects in antler glue, characterized in that, Includes the following steps: S1: Place the antler glue between a surface light source and an industrial camera, use a red narrow-band light source to backlight the antler glue and collect the transmission image; based on the thickness distribution law that the edge thickness is greater than the middle thickness due to condensation shrinkage after the antler glue is molded, establish the correspondence between the local thickness of the glue block and the attenuation of the light transmission brightness, perform pixel-by-pixel brightness compensation on the transmission image, and obtain a corrected image with uniform light transmission. S2: The corrected image is fed into a multi-scale hierarchical cross-level fusion convolutional network. Through the convolutional operation of progressive downsampling, multi-level feature maps representing the edges of small bubbles, medium-sized impurity clumps and large-scale defect aggregation areas are extracted in sequence. The multi-level feature maps are fused across layers to obtain a fused feature map containing both detailed and overall information. S3: The fused feature maps are fed into the bubble segmentation branch and the impurity segmentation branch respectively. A concentric ring domain response contrast enhancement module is embedded in the bubble segmentation branch. This module calculates the mean response of the central region and the mean response of the ring neighborhood at each spatial location based on the imaging morphology of a bubble exhibiting a bright center and a dark ring around the periphery under transmitted light using a central circular mean convolution kernel and a concentric ring mean convolution kernel, respectively. The difference between the two is mapped as a bubble attention weight to enhance the bubble morphology features. A neighborhood mean deviation dark area enhancement module is embedded in the impurity segmentation branch. This module calculates the mean response of the neighborhood at each spatial location based on the imaging morphology of impurities exhibiting an overall low-transmittance dark spot without a ring bright center structure under transmitted light using a rectangular neighborhood mean convolution kernel. The difference between the mean response of the neighborhood and the response at the current location is mapped as an impurity attention weight to enhance the dark spot region features. The bubble segmentation branch and the impurity segmentation branch respectively restore the original image resolution through stepwise transposed convolution upsampling, outputting the bubble segmentation map and the impurity segmentation map. S4: Connected regions are extracted from the bubble segmentation map and the impurity segmentation map respectively. The number of defects of the two types, the equivalent diameter of each defect, and the distribution density of defects on the area of ​​the glue block are counted to form a defect quantification description vector. The defect quantification description vector and the deep channel features of the fusion feature map are sent to the defect feature fusion level mapping layer. The quality grade score of the antler glue is obtained by mapping through fully connected operation and output, thus completing the detection of internal defects in the antler glue.

2. The machine vision-based method for detecting internal defects in antler glue according to claim 1, characterized in that, Step S1 includes: S101: Place the antler glue horizontally directly above a uniform surface light source, and use an industrial camera to acquire a transmitted image from directly above the glue block along the normal direction of the surface light source. The surface light source outputs red narrowband light with a wavelength range of 620 nm to 680 nm; the transmittance of antler glue in the red light band is significantly higher than its transmittance in the short wavelength visible light band, and the selection of the red narrowband light source is determined based on the optical absorption characteristics. S102: Based on the Lambert-Beer Law, establish the local thickness of the adhesive block. With pixel position The correspondence between the attenuation of transmitted brightness at a certain point, for the transmitted image Each pixel position Perform brightness compensation to obtain the corrected image. The brightness compensation formula is: ; in, To correct the pixel position of the image The brightness value at that location, For the transmission image at pixel position The original brightness value at that location, This represents the effective absorption coefficient of antler glue colloid in the red light band. pixel position The local thickness value of the adhesive block at a given location, exp represents the local thickness value of the adhesive block as expressed by the natural exponential function; Based on the thickness distribution pattern of the edge and middle of the antler glue formed by the casting process, the standard glue block sample was pre-calibrated and established after three-dimensional morphology measurement.

3. The machine vision-based method for detecting internal defects in antler glue according to claim 1, characterized in that, In step S2, the process of extracting multi-level feature maps includes: S201: Correct the image The input is fed into the encoding stage of a multi-scale hierarchical cross-level fusion convolutional network, where it sequentially passes through the first, second, and third convolutional downsampling stages to extract the first-level feature maps representing the edges of the microbubbles. Second-level feature map characterizing medium-sized impurity agglomerates and the third-level feature map characterizing large-scale defect clusters. .

4. The machine vision-based method for detecting internal defects in antler glue according to claim 3, characterized in that, In step S2, the process of obtaining the fused feature map includes: S202: For the first-level feature map Second-level feature map and third-level feature maps Each feature map is upsampled and aligned to the same spatial resolution using bilinear interpolation, then concatenated along the channel dimension and compressed through a convolutional layer to obtain the fused feature map. The fused feature map It also includes fine-grained edge detail information from the first level, medium-scale clumping information from the second level, and large-scale overall distribution information from the third level.

5. The machine vision-based method for detecting internal defects in antler glue according to claim 1, characterized in that, In step S3, the process of processing bubble segmentation branches includes: S301: Merge feature maps The samples are fed into the bubble separation branch and the impurity separation branch, respectively. S302: In the bubble segmentation branch, the concentric ring domain response contrast enhancement module is used to fuse feature maps. For input, Each channel is applied with a spatial position. Centered on, with radius After applying a circular mean convolution kernel, the mean value is taken along the channel dimension to obtain the mean response value of the central region. ; then Each channel is applied with a spatial position. Centered on, with an inner radius of Outer radius is After applying a circular mean convolution kernel, the mean value is taken along the channel dimension to obtain the mean response of the circular neighborhood. ,in Bubble attention weight matrix The calculation formula is: ; in, The attention weight matrix of the bubble is located in space. The weight value at that location, To fuse feature maps In spatial location The channel mean of the response in the circular region of each channel. To fuse feature maps In spatial location The channel mean of the ring neighborhood response of each channel. For learnable scaling factor, The bias coefficients are learnable, and the sigmoid function is the sigmoid activation function; With fusion feature map The bubble enhancement feature map is obtained by multiplying the spatial locations one by one. It is then upsampled through successive transpose convolutions to restore the original image resolution, and the bubble segmentation map is output. .

6. The machine vision-based method for detecting internal defects in antler glue according to claim 5, characterized in that, In step S3, the impurity splitting branch processing includes: S303: In the impurity segmentation branch, the neighborhood mean deviation dark area enhancement module uses fused feature maps. For input, After applying a rectangular mean convolution kernel with side length l to each channel, the mean value is taken along the channel dimension to obtain each spatial location. Mean of rectangular neighborhood response at Impurity attention weight matrix The calculation formula is: ; in, The spatial location of the impurity attention weight matrix The weight value at that location, To fuse feature maps In spatial location Mean of the rectangular neighborhood response at that location. To fuse feature maps In spatial location The channel average of the response of each channel. For learnable scaling factor, These are learnable bias coefficients; With fusion feature map Multiplying by spatial location yields an impurity enhancement feature map, which is then upsampled through successive transpose convolutions to restore the original image resolution, outputting an impurity segmentation map. .

7. The machine vision-based method for detecting internal defects in antler glue according to claim 5, characterized in that, Step S4 includes: S401: Bubble segmentation diagram Connected regions are marked, and components with an equivalent diameter smaller than a preset minimum effective diameter threshold are removed. Connected regions are used to eliminate noise interference, and the total number of bubble defects is counted for the retained effective connected regions. The equivalent diameter of each bubble's connected region , and bubble distribution density Impurity segmentation diagram Connected components are marked, and components with an equivalent diameter smaller than [a certain value] are also removed. For the connected regions, the total number of impurities and defects is counted for the retained valid connected regions. The equivalent diameter of each impurity connected region , and impurity distribution density The equivalent diameter is the diameter of a circle with the same area as the pixel area of ​​the connected region, and the distribution density is the ratio of the total area of ​​the effective connected region of this type of defect to the effective detection area of ​​the glue block. S402: with Mean equivalent diameter of bubbles With the maximum value , , Mean of equivalent diameter of impurities With the maximum value , The defect quantization description vector consists of eight dimensions. ; Quantize the defect description vector With fusion feature map Deep channel feature vectors extracted by global average pooling After splicing, the data is fed into the defect feature fusion level mapping layer. After fully connected operation, the probability distribution of each preset quality level is obtained through the Softmax function. The quality level with the highest probability is selected as the output quality level score of the deer antler glue.

8. A machine vision-based system for detecting internal defects in antler glue, characterized in that, include: Image acquisition module: Acquires images through a specific light source and eliminates light interference caused by uneven thickness of the adhesive block to obtain a high-quality base image; Feature extraction and fusion module: Utilizes convolutional neural networks to extract features of defects of different sizes and effectively integrates multi-level information; Image segmentation module: It adopts a dual-branch structure for targeted feature enhancement and precise segmentation based on the different optical morphologies of bubbles and impurities; Comprehensive scoring module: performs mathematical quantification on the segmentation results and combines them with deep image features to complete the final quality rating; To achieve the detection of internal defects in antler glue based on machine vision as described in any one of claims 1-7.