A classification and retrieval method for ginseng images

By acquiring the epidermal color characterization value of the ginseng image and calculating the grayscale scaling coefficient of the gamma transformation algorithm, gamma transformation is enhanced on the ginseng image, solving the problem of low classification accuracy in the prior art, and achieving higher classification accuracy.

CN119693720BActive Publication Date: 2025-05-16JILIN AGRICULTURAL UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510193523.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-02-21
Publication Date
2025-05-16
Estimated Expiration
2045-02-21

AI Technical Summary

Technical Problem

The prior art is not very accurate when classifying ginseng images because there are only a small difference in color characteristics of ginseng images of different grades.

Method used

By obtaining the epidermal color representation value in the ginseng image, the grayscale scaling coefficient of the gamma transformation algorithm is calculated when the image is processed, and the image is enhanced, and then classified.

Benefits of technology

It improves the accuracy of ginseng image classification, increases the color difference between ginseng images of different grades, and makes it easier for the classification model to identify ginseng features of different grades.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119693720B_ABST
    Figure CN119693720B_ABST
Patent Text Reader

Abstract

The present application relates to the field of image processing technology, and specifically to a ginseng image classification and retrieval method, the method comprising: collecting ginseng images of multiple ginsengs of each grade respectively; obtaining epidermal pixels and non-epidermal pixels in each ginseng image; obtaining epidermal color representation values ​​of each ginseng image based on the grayscale values ​​of all epidermal pixels in each ginseng image; obtaining the grayscale scaling coefficient when the gamma transform algorithm processes each ginseng image; dividing each ginseng image into each superpixel block respectively, obtaining the influence weight of each superpixel block when stretched; obtaining the gamma control ratio of each superpixel block; obtaining the gamma factor when the gamma transform algorithm processes each superpixel block; using the gamma transform algorithm to enhance each ginseng image, and classifying the ginseng images to be classified based on the image-enhanced ginseng images. The present application aims to improve the accuracy of ginseng classification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of image processing, and in particular to a ginseng image classification and retrieval method. Background Art

[0002] As a precious Chinese herbal medicine, ginseng has the special effects of replenishing qi and strengthening body fluid, strengthening spleen and stomach, and strengthening the body. Ginseng can be divided into different grades according to its different growth years. Generally speaking, the longer the growth years, the higher the nutritional value and the more precious the ginseng, and the higher the grade of ginseng.

[0003] At present, ginseng is often classified into different grades by professionals, which is subjective to a certain extent. Different appraisers may have different appraisal grades for the same ginseng. With the development of machine learning technology, using machine learning methods to classify ginseng images of different grades has become a more efficient option. When classifying ginseng images, it is usually necessary to extract the distinctive features of ginseng of different grades. However, since ginseng images of different grades have only small differences in color features, the accuracy of existing algorithms in classifying ginseng is not high. Summary of the invention

[0004] In view of the above, it is necessary to provide a ginseng image classification and retrieval method, which improves the accuracy of ginseng classification compared with the traditional ginseng image classification and retrieval method.

[0005] A ginseng image classification retrieval method of the present application adopts the following technical solution:

[0006] An embodiment of the present application provides a ginseng image classification retrieval method, the method comprising the following steps:

[0007] Ginseng images are collected for multiple ginsengs at different levels;

[0008] Based on the distribution of the grayscale values ​​of the pixels in each ginseng image, the epidermal pixels and non-epidermal pixels in each ginseng image are obtained; based on the grayscale values ​​of all the epidermal pixels in each ginseng image, the epidermal color representation value of each ginseng image is obtained;

[0009] Based on the relative position of the epidermal color representation value in the epidermal color representation values ​​of all ginseng images, obtaining a grayscale scaling coefficient when a gamma transform algorithm is used to process each ginseng image;

[0010] Each ginseng image is divided into super-pixel blocks, and based on the distribution range of non-epidermal pixels in each super-pixel block and the gray value difference of non-epidermal pixels, the influence weight of each super-pixel block when stretched is obtained;

[0011] Based on the difference in the influence weights between each superpixel block and its multiple adjacent superpixel blocks, and the difference in the grayscale distribution of pixels between each superpixel block and its multiple adjacent superpixel blocks, a gamma control ratio of each superpixel block is obtained;

[0012] Based on the gamma control ratio, obtaining a gamma factor when a gamma transform algorithm processes each superpixel block;

[0013] Based on the grayscale scaling coefficient and the gamma factor, a gamma transform algorithm is used to perform image enhancement on each ginseng image, and based on the image-enhanced ginseng image, the ginseng images to be classified are classified.

[0014] In one embodiment, the process of acquiring the epidermal pixels and the non-epidermal pixels is as follows:

[0015] A threshold segmentation algorithm is used to obtain a segmentation threshold of the grayscale values ​​of all pixels in any ginseng image, and pixels in any ginseng image whose grayscale values ​​are less than the segmentation threshold are regarded as ginseng pixels;

[0016] Based on the difference between the grayscale values ​​of ginseng pixels in any ginseng image, all ginseng pixels in any ginseng image are classified, and the average grayscale values ​​of all pixels in each class are calculated respectively. The pixels in the class with the largest average value are taken as epidermal pixels, and the pixels in the class with the smallest average value are taken as non-epidermal pixels.

[0017] In one embodiment, the epidermal color representation value is the average of the grayscale values ​​of all epidermal pixels in each ginseng image.

[0018] In one embodiment, the grayscale scaling factor is expressed as:

[0019] ; In the formula, represents the grayscale scaling factor when the gamma transform algorithm processes the i-th ginseng image; is the preset initial value of the grayscale scaling factor; represents the epidermal color representation value of the i-th ginseng image; represents the average value of the epidermal color representation values ​​of all ginseng images; , They respectively represent the maximum and minimum values ​​of the epidermal color representation values ​​of all ginseng images.

[0020] In one embodiment, the process of obtaining the influence weight is as follows:

[0021] The density peak clustering algorithm is used to obtain the local density of each non-epidermal pixel in each ginseng image;

[0022] The average of the local densities of all non-epidermal pixels in each superpixel block is recorded as the density mean;

[0023] The influence weight is positively correlated with the number of non-epidermal pixels and the range of grayscale values ​​of non-epidermal pixels in each superpixel block; and negatively correlated with the density mean and the range of grayscale values ​​of all pixels in each superpixel block.

[0024] In one embodiment, the process of obtaining the influence weight is further as follows:

[0025] Based on the number of non-epidermal pixels in each superpixel block and the density mean, a first ratio is obtained, wherein the distribution range is reflected by the first ratio;

[0026] Obtaining a second ratio based on the range of the grayscale values ​​of the non-epidermal pixels in each superpixel block and the range of the grayscale values ​​of all pixels;

[0027] The influence weight is a fusion result of the first ratio and the second ratio.

[0028] In one embodiment, the process of obtaining the gamma control ratio is:

[0029] Calculate the difference between the influence weight of each superpixel block and the influence weight of each adjacent superpixel block;

[0030] Obtaining the grayscale histogram of each superpixel block, and calculating the similarity of the grayscale histograms between each superpixel block and its adjacent superpixel blocks;

[0031] The gamma regulation ratio is positively correlated with the difference and the similarity respectively.

[0032] In one embodiment, the expression of the gamma control ratio is: ; In the formula, represents the gamma control ratio of the jth superpixel block in the i-th ginseng image; M represents the number of adjacent superpixel blocks of the jth superpixel block in the i-th ginseng image; and They respectively represent the influence weights of the jth superpixel block and its pth adjacent superpixel block in the i-th ginseng image when they are stretched; and They represent the grayscale histograms of the j-th superpixel block and its p-th adjacent superpixel block in the i-th ginseng image respectively; BS( ) represents the similarity function; exp( ) represents the exponential function with a natural constant as the base.

[0033] In one embodiment, the gamma factor is a normalized value of the gamma control ratio of each super pixel block.

[0034] In one embodiment, the method of performing image enhancement on each ginseng image using a gamma transform algorithm based on the grayscale scaling coefficient and the gamma factor, and classifying the ginseng images to be classified based on the image-enhanced ginseng images includes:

[0035] The grayscale scaling factor when the gamma transform algorithm processes each superpixel block is the same as the grayscale scaling factor when the gamma transform algorithm processes the ginseng image to which each superpixel block belongs;

[0036] A neural network is trained based on the ginseng images after image enhancement, and the trained neural network is used to classify the ginseng images to be classified.

[0037] This application has at least the following beneficial effects:

[0038] The present application obtains epidermal color representation values ​​according to the grayscale characteristics of the pixel points in the ginseng epidermal area, characterizes the brightness and darkness of the ginseng epidermis in the ginseng image, and then obtains the grayscale scaling coefficient when the gamma transform algorithm processes each ginseng image by comparing the epidermal color representation values ​​of different ginseng images, so that the ginseng image with higher brightness becomes brighter, and the ginseng image with lower brightness becomes darker, thereby increasing the color difference between different ginseng images;

[0039] Furthermore, according to the characteristics of scars, pearl spots and shadow areas in the ginseng image, the gamma control ratio is obtained, and the value of the gamma factor is adjusted to adjust the stretching degree of non-epidermal pixels in each superpixel block, thereby reducing the local distortion in the ginseng image after the gamma transformation.

[0040] Furthermore, based on the grayscale scaling coefficient and the gamma factor, the ginseng image is enhanced, which is more conducive to the classification model to identify the characteristics of ginseng of different grades and improve the accuracy of ginseng classification; then based on the classified ginseng, the ginseng required by the seller can be quickly retrieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present application or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0042] Figure 1 A flowchart of the steps of a ginseng image classification and retrieval method provided in this application;

[0043] Figure 2 A schematic diagram of the process of obtaining epidermal pixels and non-epidermal pixels;

[0044] Figure 3 Schematic diagram of the process of obtaining influence weights. DETAILED DESCRIPTION

[0045] In the description of the embodiments of the present application, words such as "exemplary", "or", "for example" and the like are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary", "or", "for example" and the like is intended to present related concepts in a concrete manner.

[0046] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art in the present application. The terms used in the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. It should be understood that, unless otherwise specified, " / " means or.

[0047] It should also be noted that the terms "first" and "second" in the present application are used to distinguish similar objects rather than to describe a specific order or sequence.

[0048] The specific scheme of the ginseng image classification and retrieval method provided by the present application is described in detail below with reference to the accompanying drawings.

[0049] An embodiment of the present application provides a ginseng image classification and retrieval method. Specifically, the following ginseng image classification and retrieval method is provided. Figure 1 , the method comprises the following steps:

[0050] Step 1: collect ginseng images of multiple ginsengs at different levels.

[0051] There are many types of ginseng, which can be divided into wild ginseng, garden ginseng, transplanted ginseng and forest ginseng according to their growing environment. Since the most common ginseng variety on the market is forest ginseng, which has a large market demand, this embodiment takes forest ginseng as an example to study the ginseng grade classification retrieval method.

[0052] Use a camera stand to fix a high-resolution camera at a preset height directly above the ginseng, maintain a uniform light source, and collect images of ginseng in any Chinese herbal medicine store. The background of the ginseng image is white. The rating standard refers to the "Authentic Medicinal Ginseng of Jilin Province", which divides ginseng into special grade, first grade, second grade and ordinary ginseng. A total of T ginseng images in RGB format were collected, among which the special grade forest ginseng Zhang, first-class forest ginseng Zhang, Secondary forest ginseng Common forest ginseng Zhang. All ginseng images were denoised using filtering algorithms.

[0053] In this embodiment, the values ​​of the preset height and T are 1m and 3000 respectively. The values ​​of the preset height and T are preset manually and can be set by the implementer. This application does not impose any special restrictions.

[0054] In this embodiment, a median filtering algorithm is used to denoise the ginseng image. The median filtering algorithm is a well-known technology and will not be described in detail in this application. As other implementation methods, on the basis of being able to denoise the ginseng image, the implementer may use other existing technologies to denoise the ginseng image, such as a mean filtering algorithm, a Gaussian filtering algorithm, etc., and this application does not impose any special restrictions.

[0055] Step 2, obtaining the epidermal color representation value of each ginseng image; based on the relative position of the epidermal color representation value in the epidermal color representation values ​​of all ginseng images, obtaining the grayscale scaling coefficient when the gamma transform algorithm processes each ginseng image.

[0056] Although there are differences in the colors of ginseng of different grades, the differences are small. The existing contrast enhancement algorithm mainly adjusts the contrast of a single image according to the color depth in a single image. If the ginseng images of different grades are enhanced with the same degree of enhancement, although all the ginseng images are enhanced, the color differences between the enhanced ginseng images of different grades are still not obvious. In order to make the enhanced ginseng images of different grades have obvious differences in color, it is necessary to perform different degrees of enhancement according to the color difference of each ginseng image relative to the other ginseng images.

[0057] When the gamma transform algorithm is used to adjust the brightness and contrast of the ginseng image, when the grayscale scaling factor is greater than 1, the greater the grayscale scaling factor, the greater the overall brightness and contrast of the image; when the grayscale scaling factor is greater than 0 and less than or equal to 1, the smaller the grayscale scaling factor, the smaller the overall brightness and contrast of the image. Since the skin color of ginseng in the special, first, second and ordinary ginseng images is dark brown, brown, yellow and light yellow respectively, and the color changes from dark to light, when the contrast of the ginseng image is enhanced, in order to make the ginseng images of different grades have obvious color differences, it is necessary to make the ginseng with darker skin color darker and make the ginseng with brighter skin color brighter.

[0058] Step 2.1, based on the distribution of grayscale values ​​of pixels in each ginseng image, obtain the epidermal pixels and non-epidermal pixels in each ginseng image; based on the grayscale values ​​of all epidermal pixels in each ginseng image, obtain the epidermal color representation value of each ginseng image.

[0059] In the ginseng image, since the pixels in the ginseng area are dark and the pixels in the background area are white, the grayscale value of the pixels in the ginseng area is significantly lower than that of the pixels in the background area. Based on the above analysis, the grayscale values ​​of all pixels in the i-th ginseng image are used as the input of the threshold segmentation algorithm to obtain the segmentation threshold, and the pixels in the i-th ginseng image that are less than the segmentation threshold are regarded as ginseng pixels.

[0060] In this embodiment, the Otsu threshold segmentation algorithm is used to obtain the segmentation threshold. The Otsu threshold segmentation algorithm is a well-known technology and will not be described in detail in this application. As other implementation methods, on the basis of being able to obtain the segmentation threshold, the implementer may adopt other existing technologies to obtain the segmentation threshold, such as global threshold segmentation, iterative threshold segmentation, etc., and this application does not make any special restrictions.

[0061] Whether it is high-grade ginseng or low-grade ginseng, there will be some dark scars on the reed head; there will be some shadow areas between adjacent ginseng roots due to the influence of light during shooting; in addition, since ginseng grows underground, the tiny roots will rot and fall off, and a dot-shaped scar will be produced at the place where it falls off. This dot-shaped scar is called a pearl point. There are some pearl points on the ginseng roots and ginseng body. The number and size of pearl points of different ginseng strains are different. Based on the above analysis, if the brightness of the ginseng epidermis color is directly determined by the average grayscale value of the ginseng pixel points in the ginseng image, there will be errors in the judgment result. Therefore, when measuring the brightness of the ginseng epidermis color, it is necessary to exclude the interference of the corresponding pixels of scars, pearl points and shadows from the ginseng pixel points.

[0062] Since the colors of scars, pearl spots and shadows are darker than the color of ginseng epidermis, all ginseng pixels in the i-th ginseng image are classified, and the average grayscale values ​​of all pixels in each class are calculated. The pixels in the class with the largest average value are taken as epidermal pixels, and the pixels in the class with the smallest average value are taken as non-epidermal pixels. Non-epidermal pixels are located in scars, pearl spots and shadow areas. The schematic diagram of the acquisition process of epidermal pixels and non-epidermal pixels is shown in the figure. Figure 2 shown.

[0063] In the present embodiment, the K-means clustering algorithm is used to classify all ginseng pixels in the i-th ginseng image. In the process of classifying the ginseng pixels, the distance between the ginseng pixels is the absolute value of the difference between the grayscale values ​​of the ginseng pixels. As other implementation methods, on the basis of being able to classify all ginseng pixels in the i-th ginseng image, the implementer may adopt other existing technologies, such as the Otsu threshold segmentation algorithm, etc., and this application does not impose any special restrictions.

[0064] Furthermore, the average grayscale value of all epidermal pixels in the i-th ginseng image is used as the epidermal color representation value of the i-th ginseng image. The larger the epidermal color representation value is, the brighter the epidermal color of the ginseng corresponding to the i-th ginseng image is.

[0065] The epidermis color representation values ​​of the remaining ginseng images are calculated using the same calculation method as the epidermis color representation value of the i-th ginseng image.

[0066] Step 2.2, based on the relative position of the epidermal color representation value in the epidermal color representation values ​​of all ginseng images, obtain the grayscale scaling coefficient when the gamma transform algorithm is used to process each ginseng image.

[0067] When the skin color representation value of the i-th ginseng image is greater than the mean of the skin color representation values ​​of all ginseng images, it means that the skin color of the ginseng corresponding to the i-th ginseng image is relatively bright. In this case, the larger the skin color representation value of the i-th ginseng image is, the larger the grayscale scaling coefficient should be when the gamma transform algorithm processes the i-th ginseng image, so as to make the i-th ginseng image brighter. On the contrary, when the skin color representation value of the i-th ginseng image is less than the mean of the skin color representation values ​​of all ginseng images, it means that the skin color of the ginseng corresponding to the i-th ginseng image is relatively dark. In this case, the smaller the skin color representation value of the i-th ginseng image is, the smaller the grayscale scaling coefficient should be when the gamma transform algorithm processes the i-th ginseng image, so as to make the i-th ginseng image darker.

[0068] Based on the above analysis, based on the relative position of the epidermal color representation value in the epidermal color representation values ​​of all ginseng images, the grayscale scaling coefficient when the gamma transform algorithm processes each ginseng image is obtained, and the expression is:

[0069] ; In the formula, represents the grayscale scaling factor when the gamma transform algorithm processes the i-th ginseng image; is the preset initial value of the grayscale scaling factor, which is 1; represents the epidermal color representation value of the i-th ginseng image; represents the average value of the epidermal color representation values ​​of all ginseng images; , They respectively represent the maximum and minimum values ​​of the epidermal color representation values ​​of all ginseng images.

[0070] The grayscale scaling coefficients of the remaining ginseng images processed by the gamma transform algorithm are calculated in the same way as the grayscale scaling coefficients of the i-th ginseng image processed by the gamma transform algorithm.

[0071] Step 3, divide each ginseng image into super-pixel blocks respectively, obtain the influence weight of each super-pixel block when stretched; obtain the gamma control ratio of each super-pixel block; based on the gamma control ratio, obtain the gamma factor when the gamma transform algorithm processes each super-pixel block.

[0072] In addition, there is a gamma factor in the gamma transform algorithm. When the gamma factor is less than 1, the gamma transform algorithm will stretch the areas with lower gray levels in the image and compress the areas with higher gray levels, making the dark parts of the image brighter and the bright parts darker; when the gamma factor is greater than 1, the gamma transform algorithm will stretch the areas with higher gray levels in the image and compress the areas with lower gray levels, making the dark parts of the image darker and the bright parts brighter.

[0073] For forest ginseng of the same level, due to different growth environments and other factors, the size and number of surface features such as scars and pearls on the surface of forest ginseng are different, and different forest ginsengs form different shadows during the shooting process. Therefore, even for forest ginseng of the same level, the grayscale value distribution of scars, pearls and shadow areas in the ginseng image is different. These areas cannot be used to distinguish different levels of forest ginseng, and will only affect the final classification results. Therefore, the pixels in these areas should be suppressed, that is, the pixels in these areas should be stretched to make the pixels from dark to bright. However, since the size of scars, pearls and shadow areas on the surface of ginseng is not fixed, if the grayscale value of a single pixel is stretched excessively, it will cause local distortion of the ginseng image. It is also necessary to consider the local density and coverage of the pixels in the scars, pearls and shadow areas, so that the stretched ginseng image is locally smooth.

[0074] Based on the above analysis, the non-epidermal pixels in the i-th ginseng image are used as the input of the Density Peak Clustering Algorithm (DPC) to obtain the local density of each non-epidermal pixel in the i-th ginseng image. The method for obtaining the cutoff distance in the density peak clustering algorithm is: calculate the Euclidean distance between all any two non-epidermal pixels in the i-th ginseng image, and arrange the Euclidean distances in ascending order, and use the Euclidean distances at the top 2% positions as the cutoff distance. It should be noted that 2% is only an embodiment of the present application, and the implementer can select the Euclidean distance at other positions as the cutoff distance, and the present application does not impose any special restrictions on this. The specific process of the density peak clustering algorithm is a well-known technology and will not be repeated in this application.

[0075] Furthermore, each ginseng image is segmented into superpixels to obtain superpixel blocks of each ginseng image.

[0076] In this embodiment, the SLIC (Simple Linear Iterative Clustering) superpixel segmentation algorithm is used to perform superpixel segmentation on each ginseng image, wherein the ginseng image is pre-divided into 80 superpixel blocks. As other implementation methods, on the basis of being able to perform superpixel segmentation on each ginseng image, the implementer may use other existing technologies to perform superpixel segmentation on each ginseng image, such as the subclass createSuperpixelSEEDS under the ximgproc class in opencv, the subclass createSuperpixelLSC under the ximgproc class in opencv, etc., and this application does not impose any special restrictions.

[0077] The proportion of non-epidermal pixels in each superpixel block is calculated. If the proportion of non-epidermal pixels in any superpixel block is higher, the grayscale change in any superpixel block before and after the gamma transform is greater, and it is easier to cause distortion between adjacent superpixel blocks.

[0078] Step 3.1, based on the distribution range of non-epidermal pixels in each superpixel block and the gray value difference of non-epidermal pixels, obtain the influence weight of each superpixel block when stretched.

[0079] Based on the above analysis, based on the number and local density of non-epidermal pixels in each superpixel block, and the range of the grayscale values ​​of non-epidermal pixels relative to the range of the grayscale values ​​of all pixels, the influence weight of each superpixel block when stretched is obtained. The specific process is:

[0080] Calculate the mean of the local density of all non-epidermal pixels in each superpixel block, recorded as the density mean; obtain a first ratio based on the number of non-epidermal pixels in each superpixel block and the density mean; obtain a second ratio based on the range of the grayscale values ​​of the non-epidermal pixels in each superpixel block and the range of the grayscale values ​​of all pixels;

[0081] A fusion result of the first ratio and the second ratio is used as an influence weight of each super pixel block when it is stretched.

[0082] It should be understood that fusion refers to combining multiple independent variables in a way that enhances the overall effect, such as additive relationship, multiplicative relationship, etc., and implementers can limit it according to actual conditions.

[0083] In this embodiment, the sum of the first ratio and the second ratio is used as the influence weight of each super pixel block when it is stretched, and the expression is:

[0084] ; In the formula, represents the influence weight of the jth superpixel block in the i-th ginseng image when it is stretched; represents the number of non-epidermal pixels in the jth superpixel block in the i-th ginseng image; represents the mean of the local density of all non-epidermal pixels in the jth superpixel block in the i-th ginseng image; represents the extreme difference of the gray value of the non-epidermal pixel in the jth superpixel block in the i-th ginseng image; represents the extreme difference of the grayscale values ​​of all pixels in the jth superpixel block in the i-th ginseng image; ω and τ are both positive numbers less than or equal to 0.1, used to prevent the denominator from being 0. The values ​​of ω and τ can be set by the implementer. In this embodiment, the values ​​of ω and τ are both 0.001. is the first ratio, is the second ratio.

[0085] In another embodiment, the product of the first ratio and the second ratio is used as the influence weight of each super pixel block when stretched, and the expression is:

[0086] ; In the formula, represents the influence weight of the jth superpixel block in the i-th ginseng image when it is stretched; represents the number of non-epidermal pixels in the jth superpixel block in the i-th ginseng image; represents the mean of the local density of all non-epidermal pixels in the jth superpixel block in the i-th ginseng image; represents the extreme difference of the gray value of the non-epidermal pixel in the jth superpixel block in the i-th ginseng image; represents the extreme difference of the grayscale values ​​of all pixels in the jth superpixel block in the i-th ginseng image; ω and τ are both positive numbers less than or equal to 0.1, used to prevent the denominator from being 0. The values ​​of ω and τ can be set by the implementer. In this embodiment, the values ​​of ω and τ are both 0.001. is the first ratio, is the second ratio.

[0087] It should be noted that: Used to characterize the impact of stretching non-epidermal pixels on the jth superpixel block; The larger the value of is, the larger the distribution range of non-epidermal pixels in the jth superpixel block is, and the greater the impact on the jth superpixel block during stretching; The larger the value of , the greater the grayscale value difference of the non-epidermal pixels in the jth superpixel block, and the more likely the non-epidermal pixels are distorted when stretched. The flow chart of the influence weight acquisition is as follows: Figure 3 shown.

[0088] Step 3.2, based on the difference in influence weights between each superpixel block and its multiple adjacent superpixel blocks, and the difference in grayscale distribution of pixels between each superpixel block and its multiple adjacent superpixel blocks, obtain the gamma control ratio of each superpixel block.

[0089] Further, based on the difference in the influence weights between each superpixel block and its multiple adjacent superpixel blocks, and the difference in the grayscale distribution of pixels between each superpixel block and its multiple adjacent superpixel blocks, the gamma control ratio of each superpixel block is obtained, which is used to adjust the value of the gamma factor when the non-epidermal pixels in the superpixel block are stretched. The expression is:

[0090] ; In the formula, represents the gamma control ratio of the jth superpixel block in the i-th ginseng image; M represents the number of adjacent superpixel blocks of the jth superpixel block in the i-th ginseng image; and They respectively represent the influence weights of the jth superpixel block and its pth adjacent superpixel block in the i-th ginseng image when they are stretched; and They respectively represent the grayscale histograms of the jth superpixel block and its pth adjacent superpixel block in the i-th ginseng image; BS( ) represents the similarity function; exp( ) represents an exponential function with a natural constant as the base. The acquisition of the grayscale histogram is a well-known technology and will not be described in detail in this application.

[0091] In this embodiment, the similarity function is the Bhattacharyya distance. As other implementation methods, on the basis of being able to measure the similarity between grayscale histograms, the implementer may use other existing technologies to measure the similarity between grayscale histograms, such as chi-square calculation, etc. This application does not impose any special restrictions.

[0092] It should be noted that: The larger the value of , the more susceptible the j-th superpixel block is to stretching than its adjacent superpixel blocks, and the smaller the stretching should be for the non-epidermal pixels in the j-th superpixel block; the larger the value of BS( ), the greater the grayscale difference between the j-th superpixel block and its adjacent superpixel blocks, and the smaller the stretching should be for the non-epidermal pixels in the j-th superpixel block to reduce the local distortion after the gamma transform. The larger the value of , the less the non-epidermal pixels in the j-th superpixel block should be stretched.

[0093] Since it is necessary to make the pixels of scars, pearl spots and shadow areas in the ginseng image change from dark to bright, the value range of the gamma factor when the gamma transform algorithm processes each superpixel block is (0,1).

[0094] Step 3.3, based on the gamma control ratio, obtain the gamma factor when the gamma transform algorithm processes each super pixel block.

[0095] Further, based on the gamma control ratio, the gamma factor when the gamma transform algorithm processes each super pixel block is obtained, and the expression is:

[0096] ; In the formula, represents the gamma factor when the gamma transform algorithm processes the jth superpixel block in the i-th ginseng image; norm() represents the normalization function; Represents the gamma control ratio of the jth superpixel block in the i-th ginseng image.

[0097] In this embodiment, the Min-Max normalization method is used to normalize the gamma control ratio. As other implementation methods, on the basis of being able to realize the normalization of the gamma control ratio, the implementer may use other existing technologies to normalize the gamma control ratio, such as decimal calibration normalization method, Sigmoid function, etc., and this application does not make any special restrictions.

[0098] According to The same calculation method is used to calculate the gamma factor of each superpixel block in each ginseng image when the gamma transform algorithm is used to process the superpixel block.

[0099] Step 4: Based on the grayscale scaling coefficient and the gamma factor, each ginseng image is enhanced by using a gamma transform algorithm, and the ginseng images to be classified are classified based on the image-enhanced ginseng images.

[0100] The grayscale scaling coefficient when the gamma transform algorithm processes each superpixel block is the same as the grayscale scaling coefficient when the gamma transform algorithm processes the ginseng image to which each superpixel block belongs. Each superpixel block and the grayscale scaling coefficient and the gamma factor corresponding to each superpixel block are used as inputs of the gamma transform algorithm to enhance the brightness and contrast of each superpixel block in each ginseng image. The gamma transform algorithm is a well-known technology and is not specifically limited in this application.

[0101] All ginseng images after image enhancement are divided into training set and test set according to a preset ratio, and the training set is used as the input of the VGG-16 neural network model, and the cross entropy loss function is used as the classification loss function. Adam is used as the optimizer of the model to train the VGG-16 neural network to obtain the ginseng grade classification model. The training of the neural network is a well-known technology and will not be described in detail in this application. The implementer can choose other existing feasible neural networks at his own discretion, and this application does not limit this.

[0102] In this embodiment, the value of the preset ratio is 7:3. On the basis that the value of the preset ratio is within the range of [6:4, 8:2], the implementer can set the value of the preset ratio by himself, and this application does not impose any special restrictions.

[0103] In this embodiment, during the training of the VGG-16 neural network, the learning rate is 0.001, the batch size is 64, and the number of iterations is 300. The values ​​of the learning rate, batch size, and number of iterations are preset manually, and this application does not impose any special restrictions.

[0104] Further, firstly, step 1 is used to collect ginseng images of all ginsengs to be classified in any Chinese herbal medicine store, then steps 2 and 3 are used to enhance the ginseng images to be classified, and finally the ginseng grade classification model is used to classify the ginseng images to obtain the grade of each ginseng image to be classified. Specific labels are respectively assigned to all ginsengs in any Chinese herbal medicine store, and the labels provide basic information of ginseng, such as grade, origin, variety, etc.

[0105] Furthermore, when a buyer needs to purchase ginseng of a specific grade and a specific appearance, the buyer can quickly retrieve ginseng of a specific appearance from ginseng of a corresponding grade through the ginseng label.

[0106] In summary, the present application obtains the epidermal color representation value according to the grayscale characteristics of the pixel points in the ginseng epidermal area, characterizes the brightness and darkness of the ginseng epidermis in the ginseng image, and then obtains the grayscale scaling coefficient when the gamma transform algorithm processes each ginseng image by comparing the epidermal color representation values ​​of different ginseng images, which can make the ginseng image with higher brightness brighter and the ginseng image with lower brightness darker, thereby increasing the color difference between different ginseng images;

[0107] Furthermore, according to the characteristics of scars, pearl spots and shadow areas in the ginseng image, the gamma control ratio is obtained, and the value of the gamma factor is adjusted to adjust the stretching degree of non-epidermal pixels in each superpixel block, thereby reducing the local distortion in the ginseng image after the gamma transformation.

[0108] Furthermore, based on the grayscale scaling coefficient and the gamma factor, the ginseng image is enhanced, which is more conducive to the classification model to identify the characteristics of ginseng of different grades and improve the accuracy of ginseng classification; then based on the classified ginseng, the ginseng required by the seller can be quickly retrieved.

[0109] The flowchart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to the embodiment of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. In some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. In the description corresponding to the flowchart and the block diagram in the accompanying drawings, the operations or steps corresponding to different boxes can also occur in a different order from the order disclosed in the description, and sometimes there is no specific order between different operations or steps. For example, two consecutive operations or steps can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. Each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented by a dedicated hardware-based system that performs the specified functions or actions, or may be implemented by a combination of dedicated hardware and computer instructions.

[0110] It is obvious to those skilled in the art that the present application is not limited to the details of the above exemplary embodiments, and that the present application can be implemented in other specific forms without departing from the basic features of the present application. Therefore, no matter from which point of view, the above embodiments of the present application should be regarded as exemplary and non-restrictive.

Claims

1. A ginseng image classification retrieval method, characterized in that: The method comprises the following steps: Collecting ginseng images of multiple ginsengs at different levels respectively; Based on the distribution of the grayscale values ​​of the pixels in each ginseng image, the epidermal pixels and non-epidermal pixels in each ginseng image are obtained; based on the grayscale values ​​of all the epidermal pixels in each ginseng image, the epidermal color representation value of each ginseng image is obtained; Based on the relative position of the epidermal color representation value in the epidermal color representation values ​​of all ginseng images, obtaining a grayscale scaling coefficient when a gamma transform algorithm is used to process each ginseng image; Each ginseng image is divided into super-pixel blocks, and based on the distribution range of non-epidermal pixels in each super-pixel block and the gray value difference of non-epidermal pixels, the influence weight of each super-pixel block when stretched is obtained; Based on the difference in the influence weights between each superpixel block and its multiple adjacent superpixel blocks, and the difference in the grayscale distribution of pixels between each superpixel block and its multiple adjacent superpixel blocks, a gamma control ratio of each superpixel block is obtained; Based on the gamma control ratio, obtaining a gamma factor when a gamma transform algorithm processes each superpixel block; Based on the grayscale scaling coefficient and the gamma factor, a gamma transform algorithm is used to perform image enhancement on each ginseng image, and based on the image-enhanced ginseng image, the ginseng images to be classified are classified.

2. A ginseng image classification retrieval method as claimed in claim 1, characterized in that: The process of acquiring the epidermal pixels and non-epidermal pixels is as follows: A threshold segmentation algorithm is used to obtain a segmentation threshold of the grayscale values ​​of all pixels in any ginseng image, and pixels in any ginseng image whose grayscale values ​​are less than the segmentation threshold are regarded as ginseng pixels; Based on the difference between the grayscale values ​​of ginseng pixels in any ginseng image, all ginseng pixels in any ginseng image are classified, and the average grayscale values ​​of all pixels in each class are calculated respectively. The pixels in the class with the largest average value are taken as epidermal pixels, and the pixels in the class with the smallest average value are taken as non-epidermal pixels.

3. A ginseng image classification retrieval method as claimed in claim 1, characterized in that: The epidermis color characterization value is the average of the grayscale values ​​of all epidermis pixels in each ginseng image.

4. The ginseng image classification retrieval method according to claim 1, characterized in that: The expression of the grayscale scaling factor is: ; In the formula, represents the grayscale scaling factor when the gamma transform algorithm processes the i-th ginseng image; is the preset initial value of the grayscale scaling factor; represents the epidermal color representation value of the i-th ginseng image; represents the average value of the epidermal color representation values ​​of all ginseng images; , They respectively represent the maximum and minimum values ​​of the epidermal color representation values ​​of all ginseng images.

5. The ginseng image classification retrieval method according to claim 1, characterized in that: The process of obtaining the influence weight is as follows: The density peak clustering algorithm is used to obtain the local density of each non-epidermal pixel in each ginseng image; The average of the local densities of all non-epidermal pixels in each superpixel block is recorded as the density mean; The influence weight is positively correlated with the number of non-epidermal pixels and the range of grayscale values ​​of non-epidermal pixels in each superpixel block; and negatively correlated with the density mean and the range of grayscale values ​​of all pixels in each superpixel block.

6. A ginseng image classification retrieval method as claimed in claim 5, characterized in that: The process of obtaining the influence weight is further as follows: Based on the number of non-epidermal pixels in each superpixel block and the density mean, a first ratio is obtained, wherein the distribution range is reflected by the first ratio; Obtaining a second ratio based on the range of the grayscale values ​​of the non-epidermal pixels in each superpixel block and the range of the grayscale values ​​of all pixels; The influence weight is a fusion result of the first ratio and the second ratio.

7. The ginseng image classification retrieval method according to claim 1, characterized in that: The process of obtaining the gamma regulation ratio is as follows: Calculate the difference between the influence weight of each superpixel block and the influence weight of each adjacent superpixel block; Obtaining the grayscale histogram of each superpixel block, and calculating the similarity of the grayscale histograms between each superpixel block and its adjacent superpixel blocks; The gamma regulation ratio is positively correlated with the difference and the similarity respectively.

8. The ginseng image classification retrieval method according to claim 7, characterized in that: The expression of the gamma control ratio is: ; In the formula, represents the gamma control ratio of the jth superpixel block in the i-th ginseng image; M represents the number of adjacent superpixel blocks of the jth superpixel block in the i-th ginseng image; and They respectively represent the influence weights of the jth superpixel block and its pth adjacent superpixel block in the i-th ginseng image when they are stretched; and They represent the grayscale histograms of the j-th superpixel block and its p-th adjacent superpixel block in the i-th ginseng image respectively; BS( ) represents the similarity function; exp( ) represents the exponential function with a natural constant as the base.

9. The ginseng image classification retrieval method according to claim 1, characterized in that: The gamma factor is a normalized value of the gamma control ratio of each superpixel block.

10. The ginseng image classification retrieval method according to claim 1, characterized in that: The method of performing image enhancement on each ginseng image by using a gamma transform algorithm based on the grayscale scaling coefficient and the gamma factor, and classifying the ginseng images to be classified based on the image-enhanced ginseng images, comprises: The grayscale scaling factor when the gamma transform algorithm processes each superpixel block is the same as the grayscale scaling factor when the gamma transform algorithm processes the ginseng image to which each superpixel block belongs; A neural network is trained based on the ginseng images after image enhancement, and the trained neural network is used to classify the ginseng images to be classified.

Citation Information

Patent Citations

  • Visual inspection method for water-soluble fertilizer packaging

    CN116704516A

  • Garden pest control method based on infrared image

    CN119228806A