Machine Vision-Based Screening Method for Medicinal Material Raw Materials

Through the method of adaptively setting gamma values, the raw materials images of medicinal materials are processed in blocks and texture analysis, which solves the problems of low efficiency and poor accuracy of traditional medicinal materials screening, and achieves efficient and accurate raw materials screening of medicinal materials.

CN120235798BActive Publication Date: 2025-07-29SHAANXI EVERGREEN HERBAL BIOTECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510715908.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-30
Publication Date
2025-07-29
Estimated Expiration
2045-05-30

AI Technical Summary

Technical Problem

The screening of traditional medicinal materials depends on manual observation, which is low efficiency and strong subjectivity. The machine vision system is disturbed by uneven light and background noise, low image quality affects the screening accuracy, and the large dependence on gamma value setting leads to poor enhancement effect.

Method used

By adaptively setting the gamma value, the raw materials images of the medicinal material are blocked based on machine vision, the degree of stretching and the necessity of texture enhancement are calculated, and the gamma value is judged using texture distinction and highlighting to achieve adaptive enhancement of image blocks.

Benefits of technology

It improves image quality and screening accuracy, ensures the adaptability and efficiency of gamma value settings, and enhances the distinctive texture recognition ability of medicinal materials.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120235798B_ABST
    Figure CN120235798B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of image processing. More specifically, the present invention relates to a screening method for medicinal material raw materials based on machine vision. The method includes: performing block processing on the medicinal material raw material image to obtain a number of image blocks, obtaining the analysis segment of any pixel point in the image block on the gamma transformation baseline, calculating the stretching degree according to the value width of the input value and the value width of the output value within the analysis segment; calculating the necessity of texture enhancement for this pixel point, where the necessity of texture enhancement is equal to the ratio of texture distinctiveness to salience, taking the product of the stretching degree and the necessity of texture enhancement as the enhancement degree of this pixel point, and taking the sum of the enhancement degrees of all pixel points in the image block as the overall enhancement degree; taking the gamma value corresponding to the maximum overall enhancement degree as the target gamma value, and performing enhancement processing on the image block based on the target gamma value to achieve the screening of medicinal material raw materials. By adaptively setting the gamma value, the image enhancement effect is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing. More specifically, the present invention relates to a screening method for medicinal material raw materials based on machine vision. Background Art

[0002] The quality of medicinal material raw materials is directly related to the efficacy and safety of drugs. Therefore, in order to make the drugs achieve better effects, it is necessary to screen the medicinal material raw materials according to their quality.

[0003] Traditional screening of medicinal material raw materials mainly relies on manual operation, and the appearance characteristics of medicinal materials are distinguished by the experience of workers and naked-eye observation. However, there are many disadvantages in this manual screening method. For example, the screening efficiency is low and the subjectivity is strong. The machine vision system can quickly obtain the image information of medicinal material raw materials and evaluate the quality of medicinal materials through image processing and analysis algorithms. Compared with manual screening, machine vision technology has the advantages of high efficiency, objectivity, accuracy, etc. However, in practical applications, the images of medicinal material raw materials obtained by the machine vision system are often interfered by various factors, such as uneven illumination, background noise, complex surface texture of medicinal materials, etc., resulting in low image quality and unclear feature information, thus affecting the subsequent screening accuracy.

[0004] Image enhancement processing, as a key technology for improving image quality, plays a crucial role in the machine vision system. As a commonly used image enhancement algorithm, the gamma transformation algorithm has a good enhancement effect, but it is highly dependent on the gamma value. Setting the gamma value too large or too small will result in poor image enhancement effects. Traditionally, the appropriate gamma value is set according to experience or multiple attempts. This way of setting the gamma value not only has poor adaptability but also affects the image enhancement efficiency. Therefore, how to adaptively set the appropriate gamma value has become the research focus of the present invention. Summary of the Invention

[0005] To solve the problem of how to adaptively set the appropriate gamma value, the present invention proposes a screening method for medicinal material raw materials based on machine vision, which includes the following steps:

[0006] Obtain the image of the medicinal material raw material and the gamma transformation baseline for each gamma value;

[0007] The image of the medicinal material raw material is block-processed to obtain a number of image blocks. Obtain the analysis segment of any pixel point in the image block on the gamma transformation baseline, and calculate the stretching degree according to the value width of the input value and the value width of the output value within the analysis segment. The stretching degree is positively correlated with the value width of the output value and negatively correlated with the value width of the input value;

[0008] Calculate the texture enhancement necessity of the pixel. The texture enhancement necessity is equal to the ratio of texture distinctiveness to saliency, where the saliency reflects the difficulty of texture extraction; the texture distinctiveness reflects the difference between this texture and the corresponding textures of other medicinal material individuals.

[0009] Take the product of the stretching degree and the texture enhancement necessity as the enhancement degree of the pixel. Take the sum of the enhancement degrees of all pixels in the image block as the overall enhancement degree; take the gamma value corresponding to the maximum value of the overall enhancement degree as the target gamma value, and perform enhancement processing on the image block based on the target gamma value to achieve the screening of medicinal material individuals.

[0010] The present invention adaptively sets a suitable gamma value for each image block to achieve effective image enhancement, thereby improving the image quality; further, when adaptively setting a suitable gamma value, by analyzing the stretching of different gamma values for different pixel values, it can accurately judge whether the gamma value can effectively enhance the image to be enhanced, thereby providing a basis for accurately screening the gamma value; further, when adaptively setting a suitable gamma value, by introducing the enhancement necessity to judge the necessary situation of each pixel to be enhanced, thereby providing a basis for subsequent judgment of the enhancement situation of each gamma value; further, when analyzing the enhancement necessity, by introducing the saliency to reflect the texture saliency at the position of each pixel, thereby providing a basis for accurately determining the texture enhancement situation of each pixel; further, when analyzing the enhancement necessity, by introducing the texture distinctiveness to reflect the situation of the texture at the position of each pixel being a distinctive texture for medicinal material screening, thereby providing a basis for effectively enhancing the distinctive texture for medicinal material screening.

[0011] Preferably, the process of dividing the medicinal material image into blocks to obtain a plurality of image blocks includes:

[0012] Uniformly divide the medicinal material image into a plurality of image blocks with a preset size.

[0013] Preferably, the process of obtaining the analysis segment of any pixel in the image block on the gamma transformation baseline includes:

[0014] Obtain the neighboring pixels of the pixel, calculate the absolute value of the difference in gray values between the pixel and the neighboring pixels and record it as the contrast value between the pixel and the neighboring pixels. Divide the average value of the contrast values between the pixel and all neighboring pixels by 255 to obtain the analysis length of the pixel;

[0015] Intercept a curve segment with a horizontal axis length of the analysis length on the gamma transformation baseline with the normalized value of the gray value of the pixel as the center, and record it as the analysis segment of the pixel on the gamma transformation baseline.

[0016] The present invention analyzes the gamma transformation baseline stage according to the contrast values of local regions of each pixel, so that the information in the analysis stage can reflect the pixel value mapping stretching of the local regions of each pixel, thereby providing a basis for accurately analyzing the enhancement stretching of each pixel at different gamma values.

[0017] Preferably, calculating the stretching degree according to the value width of the input value and the value width of the output value in the analysis stage includes:

[0018] Obtaining the value width of the analysis stage on the horizontal axis and the value width on the vertical axis, and taking the ratio of the value width on the horizontal axis to the value width on the vertical axis as the stretching degree.

[0019] The present invention calculates the stretching degree by the ratio of the value widths, and this calculation method is relatively simple and has higher implementation efficiency.

[0020] Preferably, the saliency satisfies the relational expression:

[0021] ;

[0022] Among them, edge detection is performed on the medicinal material raw image based on different thresholds, and true edge pixel points are obtained in the edge images obtained under each threshold. Indicates the non-existence symbol. Indicates that the pixel point is a pixel point in the edge image obtained under i thresholds. Indicates the true edge pixel point. Indicates the existence symbol. Indicates the number of times the true edge pixel point appears in the edge images obtained under all thresholds for this pixel point. Indicates the average value of the number of times the true edge pixel point appears in the edge images obtained under all thresholds for all pixel points in the image block, and norm() represents the normalization function. Indicates the saliency of this pixel point.

[0023] The present invention accurately reflects the difficulty of extracting the texture at each pixel position by analyzing the proportion of the number of times the true edge pixel points at each pixel position are extracted under different thresholds, thereby more accurately quantifying the texture saliency of each pixel.

[0024] Preferably, the method for obtaining the true edge pixel points includes:

[0025] Obtain edge pixel points from the edge images obtained at each threshold. Take any edge pixel point as the center and obtain the edge pixel points existing in its neighborhood, which are recorded as the connected pixel points of this edge pixel point. Take any connected pixel point of this edge pixel point as the center and obtain the connected pixel points of this connected pixel point, and so on, until there are no connected pixel points in the neighborhood of the connected pixel points, then a connected chain of this edge pixel point is obtained. Obtain other connected chains according to other connected pixel points of this edge pixel point. Obtain the longest connected chain of this edge pixel point.

[0026] Record the number of connected pixel points of each pixel on the longest connected chain of this edge pixel point as the connected head count of each pixel point. Take the normalized value of the ratio of the number of pixel points on the longest connected chain of this edge pixel point to the average value of the connected head counts of all pixel points on the longest connected chain as the authenticity degree of this edge pixel point.

[0027] Take the edge pixel points with authenticity degree greater than the preset degree threshold as real edge pixel points.

[0028] The present invention accurately reflects the situation of each edge pixel point being a real edge by introducing the authenticity degree, effectively eliminates false edge points, and obtains accurate edge pixel points.

[0029] Preferably, the method for obtaining the texture distinctiveness includes:

[0030] Segment a number of individual regions of the medicinal material raw material image.

[0031] In the edge images at all thresholds of the medicinal material raw material image, obtain the edge image with the most real edge pixel points and record it as the reference edge image. In the individual regions of the medicinal material raw material in the reference edge image, obtain each edge line and record it as the texture line of the individual region of the medicinal material raw material.

[0032] Calculate the similarity between each texture line of each individual region of the medicinal material raw material and the corresponding matching texture lines of other individual regions of the medicinal material raw material. Take the reciprocal of the average value of the similarities between each texture line of each individual region of the medicinal material raw material and the corresponding matching texture lines of all other individual regions of the medicinal material raw material as the texture distinctiveness of this texture line.

[0033] Take the texture distinctiveness of the texture line to which this pixel belongs as the texture distinctiveness of this pixel.

[0034] Preferably, the segmenting a number of individual regions of the medicinal material raw material image includes:

[0035] Use the Otsu threshold segmentation algorithm to perform segmentation processing on the medicinal material raw material image to obtain a number of connected domains. In the number of connected domains, obtain a preset number of connected domains with the smallest area and record them as alternative connected domains.

[0036] Denote the alternative connected region with an area at the median as the reference connected region;

[0037] Perform matching processing on the reference connected region and each other connected region, and divide each other connected region into several sub-connected regions based on the matching result;

[0038] Denote each sub-connected region as the individual area of the medicinal material raw material.

[0039] Preferably, after performing enhancement processing on the image block, it further includes:

[0040] Stitch all the enhanced image blocks together, and perform smoothing processing on the connection regions between the enhanced image blocks to obtain the enhanced medicinal material raw material image.

[0041] Preferably, the realization of the screening of the medicinal material raw material includes:

[0042] Input the enhanced medicinal material raw material image into the trained medicinal material raw material screening network to obtain the quality grades of each individual of the medicinal material raw material;

[0043] Screen out the individuals of the medicinal material raw material whose quality grades meet the grade requirements.

[0044] The present invention has the following beneficial effects:

[0045] The present invention realizes effective enhancement of the image by adaptively setting appropriate gamma values for each image block, thereby improving the image quality;

[0046] Furthermore, when adaptively setting appropriate gamma values, by analyzing the stretching situation of different gamma values for different pixel values, it can accurately judge whether the gamma value can effectively enhance the image to be enhanced, thereby providing a basis for accurately screening gamma values;

[0047] Furthermore, when adaptively setting appropriate gamma values, by introducing the necessity of enhancement to judge the necessary situation of each pixel to be enhanced, it provides a basis for subsequent judgment of the enhancement situation of each gamma value;

[0048] Furthermore, when analyzing the necessity of enhancement, by introducing the saliency to reflect the texture saliency situation at the position of each pixel, it provides a basis for accurately judging the situation where the texture of each pixel needs to be enhanced;

[0049] Furthermore, when analyzing the necessity of enhancement, by introducing the texture distinctiveness to reflect the situation where the texture at the position of each pixel is the distinctiveness texture for medicinal material screening, it provides a basis for effectively enhancing the distinctiveness texture for medicinal material screening. Description of the Drawings

[0050] Figure 1 It is the step flow chart of the method for screening medicinal material raw materials based on machine vision in the embodiment of the present invention. Detailed implementation manners

[0051] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts fall within the protection scope of the present invention.

[0052] The following will describe in detail the specific implementation manners of the present invention with reference to the accompanying drawings.

[0053] Please refer to Figure 1 , which shows a flowchart of the steps of a method for screening medicinal material raw materials based on machine vision provided by an embodiment of the present invention. The method includes the following steps:

[0054] S1: Obtain an image of the medicinal material raw material and the gamma transformation baseline for each gamma value.

[0055] Specifically, after paving the medicinal material raw material, collect the image of the medicinal material raw material; and the gamma transformation baseline for each gamma value. Perform grayscale processing on the image of the medicinal material raw material to obtain a grayscale image of the medicinal material raw material. For the convenience of description, the grayscale image of the medicinal material raw material will still be referred to as the image of the medicinal material raw material hereinafter.

[0056] It should be noted that the gamma transformation baseline is an existing mathematical curve and will not be elaborated here.

[0057] S2: Divide the image of the medicinal material raw material into blocks to obtain a number of image blocks, obtain the analysis segment of any pixel point in the image block on the gamma transformation baseline, and calculate the stretching degree according to the value width of the input value and the value width of the output value in the analysis segment. The stretching degree is positively correlated with the value width of the output value and negatively correlated with the value width of the input value.

[0058] S20: Divide the image of the medicinal material raw material into blocks to obtain a number of image blocks.

[0059] It should be noted that there are differences in the illumination of each area in the image of the medicinal material raw material. If the entire image of the medicinal material raw material is enhanced using a consistent method, it is easy to have some areas being too bright and some areas being too dark. Therefore, in order to achieve a better enhancement effect, the image of the medicinal material raw material needs to be segmented into small blocks, and the corresponding gamma value is set according to the needs of each small block, so as to achieve a better enhancement effect.

[0060] Preferably, as an example, dividing the image of the medicinal material raw material into blocks to obtain a number of image blocks includes:

[0061] Uniformly divide the image of the medicinal material raw material into a number of image blocks with a preset size. In this embodiment, the preset size is taken For the sake of illustration, other embodiments may adopt other methods, and specific limitations are not imposed on this embodiment.

[0062] S21: Obtain the analysis segment of any pixel point in the image block on the gamma transformation baseline, and calculate the stretching degree according to the value width of the input value and the value width of the output value within the analysis segment.

[0063] It should be noted that the gamma transformation baseline compresses some data to a smaller value range and amplifies some data to a larger value range through a non-linear mapping transformation, so as to amplify the difference between the data and achieve image enhancement. In other words, if the gamma transformation with a certain gamma value can compress the smaller gray values in the texture area to be enhanced smaller and amplify the larger gray values in the texture area to be larger, the texture to be enhanced can achieve a better enhancement effect. Therefore, to set an appropriate gamma value, it is necessary to analyze the stretching situation of the gray value value width of each pixel in the texture area corresponding to the gamma transformation baseline of each gamma value.

[0064] S210: Obtain the analysis segment of any pixel point in the image block on the gamma transformation baseline.

[0065] It should be noted that since the texture area cannot be accurately extracted at present, the stretching situation of the gray value value width of the local area of each pixel is analyzed here. Since the gray value value diversity in the local area where each pixel is located is relatively large, in order to reduce the number of analyses, it is only necessary to analyze the stretching situation of the gray value value width that can represent most gray values in the local area where the pixel is located.

[0066] It should be further noted that the average contrast within the local area where each pixel is located can reflect the value width of the local area of the pixel. The value width of most gray values can be characterized by the average contrast. Therefore, the average contrast is used to obtain the corresponding transformation segment on the gamma transformation baseline to analyze the stretching situation of the gamma transformation on the gray value value width of the pixel.

[0067] Preferably, as an example, obtaining the analysis segment of any pixel point in the image block on the gamma transformation baseline includes:

[0068] Obtain the neighboring pixels of the pixel point, calculate the absolute value of the difference between the gray value of the pixel point and the neighboring pixels and record it as the contrast value between the pixel and the neighboring pixels, and divide the average value of the contrast values between the pixel and all neighboring pixels by 255 to obtain the analysis length of the pixel;

[0069] Intercept a curve segment with a horizontal axis length of the analysis length on the gamma transformation baseline with the normalized value of the gray value of the pixel as the center, and record it as the analysis segment of the pixel point on the gamma transformation baseline.

[0070] It should be noted that the analysis length is the normalized value of the value width of the local area of the pixel. The interval with the horizontal axis length equal to the analysis length centered on the normalized value of the pixel can reflect the value interval of the local area of the pixel. Therefore, the analysis segment intercepted in this way can reflect the change of the value before and after mapping in the local area of the pixel.

[0071] S211: Calculate the stretching degree according to the value width of the input value and the value width of the output value in the analysis segment.

[0072] It should be noted that the horizontal axis value of the gamma transformation baseline is the normalized value of the gray value before pixel mapping, and the vertical axis value of the analysis segment is the normalized value of the gray value after pixel mapping. Therefore, by calculating the difference between the value width of the horizontal axis and the value width of the vertical axis of the analysis segment, the stretching situation of the value in the local area of the texture of the local area of the pixel can be reflected.

[0073] Preferably, as an example, calculating the stretching degree according to the value width of the input value and the value width of the output value in the analysis segment includes:

[0074] Obtain the value width of the analysis segment on the horizontal axis and the value width on the vertical axis, and use the ratio of the value width of the horizontal axis to the value width of the vertical axis as the stretching degree.

[0075] It can be understood that the greater the stretching degree, the greater the magnification ratio of the value width of the local area of the pixel after enhancement. Therefore, the better the enhancement effect of the texture in the local area of the pixel.

[0076] S3: Calculate the necessity of texture enhancement for the pixel point. The necessity of texture enhancement is equal to the ratio of texture distinctiveness to saliency, where saliency reflects the difficulty of texture extraction; texture distinctiveness reflects the difference between this texture and the corresponding textures of other medicinal material raw material individuals.

[0077] It should be noted that to set an appropriate gamma value, it is also necessary to ensure that mapping under this gamma value can better enhance the pixels that need to be enhanced. Therefore, it is necessary to analyze the situation of each pixel that needs to be enhanced in the medicinal material raw material image.

[0078] For example, some weak textures. It is difficult to recognize their texture information without enhancement, which affects the screening accuracy of medicinal material raw materials. There are also some distinctiveness texture information used for medicinal material screening. If the saliency of these textures is poor, the texture information cannot be recognized during the screening of medicinal material raw materials, resulting in a reduction in the screening accuracy of medicinal material raw materials. Some areas need weaker enhancement, such as textureless areas or areas with relatively prominent textures. Therefore, it is necessary to analyze the enhancement necessity of each pixel point.

[0079] S30: Obtain the saliency.

[0080] It should be noted that some textures in the texture are more obvious and some are less obvious. Among them, the obvious textures can identify the texture information without enhancement, while the less obvious textures need to be enhanced to identify the texture information. The necessity of enhancing each texture can be reflected by the prominence of the texture.

[0081] It should be further noted that the textures extracted by the texture extraction algorithm under different parameters are different. Among them, the textures with higher prominence can be extracted under most parameters of the texture extraction algorithm, while the textures with lower prominence can only be identified under fewer parameters of the texture extraction algorithm. Therefore, the prominence can be analyzed according to the extraction situation of the texture under different parameters of the texture extraction algorithm.

[0082] Preferably, the method for obtaining the prominence includes:

[0083] Performing edge detection on the medicinal material raw image based on different thresholds, obtaining edge pixel points in the edge image obtained under each threshold, taking any edge pixel point as the center to obtain the edge pixel points existing in the neighborhood and recording them as the connected pixel points of the edge pixel point; taking any connected pixel point of the edge pixel point as the center to obtain the connected pixel points of the connected pixel point, and so on, until there are no connected pixel points in the neighborhood of the connected pixel point, obtaining a connected chain of the edge pixel point; obtaining other connected chains according to the other connected pixel points of the edge pixel point; obtaining the longest connected chain of the edge pixel point; recording the number of connected pixel points of each pixel on the longest connected chain of the edge pixel point as the connected head number of each pixel point, and taking the normalized value of the ratio of the number of pixel points on the longest connected chain of the edge pixel point to the average value of the connected head numbers of all pixel points on the longest connected chain as the authenticity degree of the edge pixel point; taking the edge pixel points with the authenticity degree greater than the preset degree threshold as the real edge pixel points.

[0084] It can be understood that when the threshold is set relatively low, some non-edge pixels are extracted. Generally, non-edge pixels exist concentratedly and do not have the characteristic of one-way extension. Therefore, the pseudo-edge pixels are excluded through this feature to obtain the real edge pixel points.

[0085] The relational expression satisfied by the prominence:

[0086] ;

[0087] Wherein, represents the non-existence symbol, represents the pixel point in the edge image obtained under the i-th threshold, represents the real edge pixel point, represents the existence symbol, Indicates the number of times the true edge pixel appears in the edge images obtained at all thresholds for this pixel point. Indicates the average number of times the true edge pixel appears in the edge images obtained at all thresholds for all pixel points in the image block. norm() represents the normalization function. Indicates the saliency of this pixel point.

[0088] It can be understood that if edge pixels cannot be recognized at different thresholds, it means that this pixel itself is not a texture pixel. Therefore, the non-texture information feature of this pixel has been clearly highlighted, and thus the saliency of this pixel is set to 1. If edge pixels can only be recognized at a few thresholds, it means that the texture recognition of this pixel is more difficult, so the ability of this pixel to highlight texture information is weak, and the necessity of enhancing this pixel is greater.

[0089] S31: Obtain texture distinctiveness.

[0090] It should be noted that there are differences between the textures of poor-quality and good-quality medicinal material raw materials. Therefore, some distinctive textures are beneficial for screening medicinal material raw materials, and thus the necessity of enhancing those distinctive textures is greater.

[0091] Preferably, as an example, the method for obtaining texture distinctiveness includes:

[0092] Use the Otsu threshold segmentation algorithm to segment the medicinal material raw material image to obtain several connected regions, and obtain a preset number of connected regions with the smallest area in the several connected regions and record them as alternative connected regions.

[0093] Record the alternative connected region with the median area as the reference connected region.

[0094] Perform matching processing on the reference connected region and each other connected region, obtain several matching regions of the reference connected region in other connected regions, separate the several matching regions in each other connected region, and record the separated sub-regions as the individual regions of the medicinal material raw material.

[0095] Obtain the edge image with the most true edge pixel points in the edge images at all thresholds of the medicinal material raw material image and record it as the reference edge image; obtain each edge line in the individual region of the medicinal material raw material in the reference edge image and record it as the texture line of the individual region of the medicinal material raw material.

[0096] Calculate the similarity between each texture line in each individual region of the medicinal material raw material and the corresponding matching texture line in other individual regions of the medicinal material raw material, and use the reciprocal of the average similarity of each texture line in each individual region of the medicinal material raw material and the corresponding matching texture lines in all other individual regions of the medicinal material raw material as the texture distinctiveness of this texture line.

[0097] Use the texture distinctiveness of the texture line to which the pixel belongs as the texture distinctiveness of the pixel.

[0098] The method for calculating the similarity between each texture line of each individual area of the medicinal material raw material and the corresponding matching texture lines of all other individual areas of the medicinal material raw material can be:

[0099] Count the curvature of each texture line to obtain a curvature histogram, and use the cosine similarity between the curvature histograms of each texture line of each individual area of the medicinal material raw material and the corresponding matching texture lines of all other individual areas of the medicinal material raw material as the similarity between each texture line of each individual area of the medicinal material raw material and the corresponding matching texture lines of all other individual areas of the medicinal material raw material.

[0100] Here, only an example of calculating the similarity between each texture line of each individual area of the medicinal material raw material and the corresponding matching texture lines of all other individual areas of the medicinal material raw material is given. Other existing methods can also be used for calculation, and the specific calculation method is not limited.

[0101] It should be added that the method for obtaining several matching areas of the reference connected component in other connected components includes:

[0102] Obtain the corresponding area of the reference connected component in the medicinal material raw material image and record it as the reference area, and obtain the corresponding areas of other connected components in the medicinal material raw material image and record them as the areas to be segmented;

[0103] Rotate the reference area according to a preset angle, and obtain several rotated reference areas for several preset angles;

[0104] Starting from one side edge of the area to be segmented, slide the reference area on the area to be segmented. After each slide, perform a matching process on the rotated reference area and its corresponding area in the area to be segmented, and calculate the matching value. Select the maximum matching value among all the matching values of the rotated reference areas and their corresponding areas in the area to be segmented and record it as the comprehensive matching value. Use the corresponding area with the comprehensive matching value greater than the preset matching threshold as the matching area of the reference connected component in other connected components.

[0105] It should be further added that the method for obtaining the corresponding matching texture lines of each texture line of each individual area of the medicinal material raw material and other individual areas of the medicinal material raw material includes:

[0106] Perform a matching process on each individual area of the medicinal material raw material and other individual areas of the medicinal material raw material, obtain the matching areas of each texture line of each individual area of the medicinal material raw material in other individual areas of the medicinal material raw material, and use the texture lines existing in the matching areas as the matching texture lines of each texture line of each individual area of the medicinal material raw material in other individual areas of the medicinal material raw material.

[0107] Specifically, if there is no texture line in the matching region, the similarity between each texture line of the individual region of the medicinal material and the corresponding matching texture lines of other individual regions of the medicinal material is set to 0.

[0108] S4: The product of the stretching degree and the necessity of texture enhancement is used as the enhancement degree of the pixel point, and the cumulative sum of the enhancement degrees of all pixels in the image block is used as the overall enhancement degree; the gamma value corresponding to the maximum value of the overall enhancement degree is used as the target gamma value, and the image block is enhanced based on the target gamma value to achieve the screening of medicinal raw materials.

[0109] It should be noted that if the gamma transform baseline at a certain gamma value can significantly expand the value width of a local area of a pixel where texture enhancement is particularly necessary, the texture in that local area of the pixel can be better enhanced. Consequently, image enhancement at this gamma value has a better effect. Therefore, this gamma value should be selected as the target gamma value for image enhancement processing.

[0110] S40: taking the product of the stretching degree and the necessity of texture enhancement as the enhancement degree of the pixel point, and taking the cumulative sum of the enhancement degrees of all pixels in the image block as the overall enhancement degree.

[0111] S41: taking the gamma value corresponding to the maximum value of the overall enhancement degree as the target gamma value, and performing enhancement processing on the image block based on the target gamma value.

[0112] Preferably, as an example, taking the gamma value corresponding to the maximum value of the overall enhancement degree as the target gamma value, and performing enhancement processing on the image block based on the target gamma value includes:

[0113] The gamma value corresponding to the maximum value of the overall enhancement degree is used as the target gamma value, the target gamma value is set as the gamma value of the gamma transform algorithm, and the image block is enhanced using the gamma transform algorithm.

[0114] It should be added that all enhanced image blocks are spliced together, and the connected pixels between two enhanced image blocks are smoothed using a Gaussian filter to obtain an enhanced medicinal material raw material image.

[0115] S42: To achieve the screening of medicinal raw materials.

[0116] Preferably, as an example, to implement the screening of medicinal materials, the method includes:

[0117] A medicinal raw material screening network is constructed, and the medicinal raw material screening network is trained using the medicinal raw material image dataset. The enhanced medicinal raw material images are input into the trained medicinal raw material screening network to obtain abnormal medicinal raw material areas.

[0118] Screen out the corresponding medicinal material raw materials in the abnormal medicinal material raw material area.

[0119] In this embodiment, the YoloV10 network is used as the medicinal material raw material screening network. Other embodiments can adopt other recognition networks, and this embodiment does not make specific limitations. The medicinal material raw material image dataset contains several labeled medicinal material raw material images, where the label of the abnormal medicinal material raw material area in the medicinal material raw material image is 1; the label of the non-abnormal medicinal material raw material area in the medicinal material raw material image is set to 0.

[0120] So far, this embodiment is completed.

[0121] The above are only the preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the principles of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for screening medicinal material raw materials based on machine vision, characterized in that, Including: Obtaining an image of the medicinal material raw material and the gamma transformation baseline for each gamma value; Performing a block processing on the medicinal material raw material image to obtain a number of image blocks, obtaining an analysis segment of any pixel point in the image block on the gamma transformation baseline, and calculating a stretching degree according to the value width of the input value and the value width of the output value within the analysis segment, where the stretching degree is positively correlated with the value width of the output value and negatively correlated with the value width of the input value; Calculating the necessity of texture enhancement for this pixel point, where the necessity of texture enhancement is equal to the ratio of texture distinctiveness to prominence, and the prominence reflects the difficulty of extracting the texture; the texture distinctiveness reflects the difference between this texture and the corresponding textures of other individual medicinal material raw materials; Taking the product of the stretching degree and the necessity of texture enhancement as the enhancement degree of this pixel point, and taking the sum of the enhancement degrees of all pixel points in the image block as the overall enhancement degree; Taking the gamma value corresponding to the maximum value of the overall enhancement degree as the target gamma value, and performing an enhancement process on the image block based on the target gamma value to achieve the screening of the medicinal material raw materials; The prominence satisfies the relational expression: ; Among them, edge detection is performed on the medicinal material raw material image based on different thresholds, and true edge pixel points are obtained from the edge images obtained under each threshold. Indicates the absence of a symbol. Indicates that the pixel point is a pixel point in the edge image obtained under i thresholds. Indicates a true edge pixel point. Indicates the presence of a symbol. Indicates the number of times that the true edge pixel point appears in the edge images obtained under all thresholds for this pixel point. Indicates the average value of the number of times that the true edge pixel point appears in the edge images obtained under all thresholds for all pixel points in the image block. norm() represents the normalization function. Indicates the saliency of this pixel point.

2. The method for screening medicinal material raw materials based on machine vision according to claim 1, wherein The performing a block processing on the medicinal material raw material image to obtain a number of image blocks includes: Uniformly dividing the medicinal material raw material image into a number of preset-size image blocks.

3. The method for screening medicinal material raw materials based on machine vision according to claim 1, wherein The obtaining an analysis segment of any pixel point in the image block on the gamma transformation baseline includes: Obtaining the neighborhood pixels of this pixel point, calculating the absolute value of the difference in gray values between this pixel point and the neighborhood pixels as the contrast value between this pixel and the neighborhood pixels, and dividing the average value of the contrast values between this pixel and all neighborhood pixels by 255 to obtain the analysis length of this pixel; Taking the normalized value of the gray value of this pixel as the center and intercepting a curve segment with a horizontal axis length of the analysis length on the gamma transformation baseline as the analysis segment of this pixel point on the gamma transformation baseline.

4. The method for screening medicinal material raw materials based on machine vision according to claim 1, wherein The calculating a stretching degree according to the value width of the input value and the value width of the output value within the analysis segment includes: Obtaining the value width on the horizontal axis and the value width on the vertical axis of the analysis segment, and taking the ratio of the value width on the horizontal axis to the value width on the vertical axis as the stretching degree.

5. The method for screening medicinal material raw materials based on machine vision according to claim 1, characterized in that, The method for obtaining the true edge pixel points includes: Obtaining edge pixel points in the edge image obtained under each threshold, taking any edge pixel point as the center and obtaining the edge pixel points existing in the neighborhood as the connected pixel points of this edge pixel point; taking any connected pixel point of this edge pixel point as the center and obtaining the connected pixel points of this connected pixel point, and so on, until there are no connected pixel points in the neighborhood of the connected pixel points, obtaining a connected chain of this edge pixel point; obtaining other connected chains according to the other connected pixel points of this edge pixel point; obtaining the longest connected chain of this edge pixel point; Taking the number of connected pixel points of each pixel on the longest connected chain of this edge pixel point as the connected head number of each pixel point, and taking the normalized value of the ratio of the number of pixel points on the longest connected chain of this edge pixel point to the average value of the connected head numbers of all pixel points on the longest connected chain as the true degree of this edge pixel point; Taking the edge pixel points with a true degree greater than the preset degree threshold as the true edge pixel points.

6. The method for screening medicinal material raw materials based on machine vision according to claim 1, wherein The method for obtaining the texture distinctiveness includes: Segment a number of individual regions of medicinal material raw materials in the image of the medicinal material raw materials; Obtain the edge image with the largest number of real edge pixels among the edge images at all thresholds of the medicinal material raw material image, and record it as the reference edge image; obtain each edge line in the individual region of the medicinal material raw material in the reference edge image, and record it as the texture line of the individual region of the medicinal material raw material; Calculate the similarity between each texture line of each individual region of the medicinal material raw material and the corresponding matching texture line of other individual regions of the medicinal material raw material, and take the reciprocal of the average similarity of each texture line of each individual region of the medicinal material raw material and the corresponding matching texture line of all other individual regions of the medicinal material raw material as the texture distinctiveness of this texture line; Take the texture distinctiveness of the texture line to which the pixel belongs as the texture distinctiveness of this pixel.

7. The method for screening medicinal material raw materials based on machine vision according to claim 6, wherein The segmenting a number of individual regions of medicinal material raw materials in the image of the medicinal material raw materials includes: Use the Otsu threshold segmentation algorithm to segment the image of the medicinal material raw materials to obtain a number of connected regions, and obtain a preset number of connected regions with the smallest area among the number of connected regions, and record them as alternative connected regions; Record the alternative connected region with the median area as the reference connected region; Perform matching processing on the reference connected region and each other connected region, and segment each other connected region into a number of sub-connected regions based on the matching result; Record each sub-connected region as an individual region of the medicinal material raw material.

8. The method for screening medicinal material raw materials based on machine vision according to claim 1, wherein After enhancing the image block, it further includes: Stitch all the enhanced image blocks together, and perform smoothing processing on the connection regions between the enhanced image blocks to obtain the enhanced image of the medicinal material raw materials.

9. The method for screening medicinal material raw materials based on machine vision according to claim 8, wherein, The realizing the screening of the medicinal material raw materials includes: Input the enhanced image of the medicinal material raw materials into the trained medicinal material raw material screening network to obtain the quality grades of each individual of the medicinal material raw materials; Screen out the individuals of the medicinal material raw materials whose quality grades meet the grade requirements.

Citation Information

Patent Citations

  • Fast image enhancement method based on gamma transformation

    CN107527333A

  • Global self-adaptive grayscale image enhancement method based on double gamma correction

    CN110084760A