Tea visual identification method, device and system
By performing regionalized cavities convolution and spectrum analysis on tea images, screening the areas to be enhanced and calculating the enhancement coefficients, the problem of difficult to capture the microscopic vein structure in traditional tea image enhancement algorithms is solved, and higher visual recognition accuracy is achieved.
Patent Information
- Application Number
- CN202510877850.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-27
- Publication Date
- 2025-07-29
- Estimated Expiration
- 2045-06-27
AI Technical Summary
Traditional tea image enhancement algorithms cannot effectively capture the microvein structure, resulting in a decrease in the accuracy of tea visual recognition, and hollow convolution may trigger the chessboard effect to destroy image features.
By dividing the tea image into several areas for hollow convolution operation, the areas to be enhanced with poor gain effect were selected, and the enhancement coefficient was calculated based on the differences in the airspace and frequency domains, and the areas to be enhanced are targeted.
It improves the recognizability of microveins in tea images, improves the accuracy of tea visual recognition, and avoids the problems of insufficient enhancement or destruction of features in traditional methods.
Smart Images

Figure CN120388362A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and particularly to a method, device and system for visual recognition of tea leaves. Background Art
[0002] With the development of artificial intelligence and image processing technologies, computer vision has been widely applied in the agricultural field, especially in the quality inspection and automatic grading of tea leaves. By analyzing the images of tea leaves, features such as the structure, veins, and color of the leaves can be extracted, providing technical support for the automatic recognition and classification of tea leaves. However, the tea leaf images actually collected are often affected by factors such as illumination changes, background interference, and shooting jitter, resulting in blurred representation of the microscopic vein structure in the leaves, seriously affecting the subsequent recognition accuracy.
[0003] Therefore, in order to better capture the microscopic vein structure in tea leaf images, it is necessary to enhance the tea leaf images. However, in the process of enhancing tea leaf images through the dilated convolution algorithm, the checkerboard effect may occur at the bifurcation of tea leaf veins due to the fixed interval sampling characteristics of dilated convolution, generating regular network artifacts, thereby destroying the microscopic veins in the tea leaf images, resulting in ineffective enhancement in some areas and thus affecting the accuracy of tea leaf visual recognition. Summary of the Invention
[0004] The present invention provides a method, device and system for visual recognition of tea leaves to solve the existing problem that the traditional algorithm for enhancing tea leaf images cannot effectively enhance tea leaf images.
[0005] The method, device and system for visual recognition of tea leaves of the present invention adopt the following technical solutions: An embodiment of the present invention provides a method for visual recognition of tea leaves, the method comprising the following steps: Obtain a tea leaf image; Divide the tea leaf image into several regions, and perform convolution operations on each region to obtain the convolution feature map of each region; obtain the gain degree of each region according to the gray values of the pixel points in each region and its convolution feature map; screen several gain deficit regions according to the gain degrees of each region; obtain the information complexity of the gain deficit regions according to the edge change trend in the gain deficit regions, and then screen out the regions to be enhanced from all the gain deficit regions; obtain the spatial domain difference of the regions to be enhanced according to the gray difference between the regions to be enhanced and their convolution feature maps at the pixel points. Obtain the spectrogram of the tea leaf image; perform clustering on the frequency units in the spectrogram of the tea leaf image to obtain the low-frequency frequency unit cluster; obtain the frequency domain difference of the regions to be enhanced according to the low-frequency frequency unit cluster and the regions to be enhanced. Obtain the enhancement coefficient of the area to be enhanced according to the spatial domain difference and frequency domain difference of the area to be enhanced; enhance the area to be enhanced according to the enhancement coefficient of the area to be enhanced.
[0006] Preferably, obtaining the gain degree of each area according to the gray values of the pixel points in each area and its convolution feature map; screening several gain deficit areas according to the gain degrees of each area, and the specific method included is: For any area, obtain the variance of the gray values of all pixel points in the area and the variance of the gray values of all pixel points in the convolution feature map of the area, and take the difference between the variance of the gray values of all pixel points in the convolution feature map of the area and the variance of the gray values of all pixel points in the area as the gain degree of the area; Taking the absolute value of the difference in the gain degrees between different areas as the metric distance, clustering all areas into two cluster classes, obtaining the mean of the gain degrees of all areas in any one cluster class as the average gain degree of this cluster class, recording the cluster class with the smallest average gain degree as the gain deficit cluster class, and recording the areas in the gain deficit cluster class as gain deficit areas.
[0007] Preferably, obtaining the information complexity of the gain deficit area according to the edge change trend in the gain deficit area, and the specific method included is: For any edge pixel point in any edge in any gain deficit area, obtain the slope of the edge pixel point in the edge according to the position coordinates of the edge pixel point in the edge and the position coordinates of the next edge pixel point of the edge pixel point; take the mean of the slopes of all edge pixel points in the edge as the slope of the edge; Take the product of the number of edges in the gain deficit area and the mean of the slopes of all edges in the gain deficit area as the information complexity of the gain deficit area.
[0008] Preferably, screening out the area to be enhanced from all gain deficit areas, and the specific method included is: Sort all gain deficit areas in ascending order according to the information complexity of all gain deficit areas to obtain a gain deficit area sequence; obtain the absolute value of the difference in information complexity between all adjacent gain deficit areas in the gain deficit area sequence, take the position corresponding to the largest absolute value of the difference as the demarcation point, and take all gain deficit areas before the demarcation point in the gain deficit area sequence as the area to be enhanced.
[0009] Preferably, obtaining the spatial domain difference of the area to be enhanced according to the gray difference of the pixel points between the area to be enhanced and its convolution feature map, and the specific method included is: Denote any pixel point in any region to be enhanced as the target pixel point, and denote the pixel point in the convolutional feature map of the region to be enhanced with the same position coordinates as the target pixel point as the corresponding pixel point of the target pixel point; obtain the absolute value of the difference in grayscale values between the target pixel point and its corresponding pixel point as the feature difference of the target pixel point, and take the mean value of the feature differences of all pixel points in the region to be enhanced as the spatial domain difference of the region to be enhanced.
[0010] Preferably, the method for clustering frequency units in the spectrogram of the tea leaf image to obtain the low-frequency frequency unit cluster class specifically includes: Taking the amplitude difference between different frequency units in the spectrogram of the tea leaf image as the metric distance, clustering all frequency units in the spectrogram of the tea leaf image to obtain several frequency unit cluster classes of the spectrogram of the tea leaf image, and denoting the mean value of the amplitudes of all frequency units in any one frequency unit cluster class as the high-frequency feature of this frequency unit cluster class, and taking the frequency unit cluster class with the smallest high-frequency feature as the low-frequency frequency unit cluster class.
[0011] Preferably, the method for obtaining the frequency domain difference of the region to be enhanced according to the low-frequency frequency unit cluster class and the region to be enhanced specifically includes: Perform inverse Fourier transform on the low-frequency frequency unit cluster class to obtain the corresponding partial original image region of the low-frequency frequency unit cluster class, denoted as the low-frequency region; For any region to be enhanced, take the absolute value of the difference between the variance of the grayscale values of all pixel points in the region to be enhanced and the variance of the grayscale values of all pixel points in the low-frequency region as the frequency domain difference of the region to be enhanced.
[0012] Preferably, the method for obtaining the enhancement coefficient of the region to be enhanced according to the spatial domain difference and the frequency domain difference of the region to be enhanced; and enhancing the region to be enhanced according to the enhancement coefficient of the region to be enhanced specifically includes: Take the square root sum of the spatial domain difference and the frequency domain difference of any region to be enhanced, and map the result to the range from -1 to 1 as the enhancement coefficient of the region to be enhanced; For any pixel point in the region to be enhanced, normalize the feature difference of the pixel point in the region to be enhanced to obtain the degree of feature difference of the pixel point in the region to be enhanced; take the product of the sum of the enhancement coefficient of the region to be enhanced and 1 and the degree of feature difference of the pixel point in the region to be enhanced as the grayscale enhancement coefficient of the pixel point in the region to be enhanced; adjust the grayscale value of the pixel point through the grayscale enhancement coefficient to obtain the enhanced grayscale value of the pixel point.
[0013] The present invention also provides a tea visual recognition system, which includes an image acquisition module, a spatial domain analysis module, a frequency domain analysis module, and an image enhancement module; The image acquisition module is used to obtain tea images; The spatial domain analysis module is used to divide the tea image into several regions, perform convolution operations on each region to obtain the convolution feature map of each region; obtain the gain degree of each region according to the gray values of the pixels in each region and its convolution feature map; screen several gain deficit regions according to the gain degrees of each region; obtain the information complexity of the gain deficit regions according to the edge change trend in the gain deficit regions, and further screen out the regions to be enhanced from all the gain deficit regions; obtain the spatial domain difference of the regions to be enhanced according to the gray difference between the regions to be enhanced and their convolution feature maps at the pixel points; The frequency domain analysis module is used to obtain the spectrogram of the tea image; cluster the frequency units in the spectrogram of the tea image to obtain the low-frequency frequency unit cluster classes; obtain the frequency domain difference of the regions to be enhanced according to the low-frequency frequency unit cluster classes and the regions to be enhanced; The image enhancement module is used to obtain the enhancement coefficient of the regions to be enhanced according to the spatial domain difference and the frequency domain difference of the regions to be enhanced; enhance the regions to be enhanced according to the enhancement coefficient of the regions to be enhanced.
[0014] The present invention also provides a tea visual recognition device, including a tea visual recognition device arranged, and the tea visual recognition device includes a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, the modules of the above system are implemented.
[0015] The beneficial effects of the technical solution of the present invention are as follows: The present invention divides the tea into several regions, performs dilated convolution operations on each region respectively, evaluates the beneficial effects of each region enhanced by the dilated convolution operation, and screens out some regions to be enhanced with poor gain effects from all regions. Further, through the gray difference between the regions to be enhanced and their convolution feature maps, the enhancement amplitude of the dilated convolution on the regions to be enhanced is quantified from the spatial domain perspective. The greater the enhancement amplitude of the dilated convolution on the regions to be enhanced, the more it indicates that there are deficiencies in the feature expression of the regions to be enhanced, and the convolution fails to fully extract or enhance their detailed features. Therefore, introducing the spatial domain difference as a reference index in the subsequent calculation of the enhancement coefficient can allocate more enhancement efforts to these regions with significant differences but not effectively enhanced, realizing more targeted image detail restoration and optimization, and further improving the discernibility of the micro veins in the tea image.
[0016] Further analyze the spectrogram of the tea leaf image. First, cluster the frequency units in the spectrogram of the tea leaf image, extract the cluster representing the low-frequency energy characteristics, and map it back to the original image to locate the low-frequency region. Then, taking the energy characteristics of the low-frequency region as a reference, comprehensively reflect the global characteristics of the energy distribution in the image. Finally, obtain the enhancement coefficient of the region to be enhanced according to the spatial domain difference and frequency domain difference of the region to be enhanced, and enhance the region to be enhanced, enhancing the regions in the tea leaf image that cannot be effectively enhanced by traditional methods, so as to better capture the microscopic vein characteristics in the tea leaves. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0018] Figure 1 is a flowchart of the steps of a tea leaf visual recognition method of the present invention; Figure 2 is an example diagram of a tea leaf image; Figure 3 is an example diagram of the enhanced tea leaf image. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0019] In order to further elaborate on the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following will, in conjunction with the accompanying drawings and preferred embodiments, describe in detail the specific embodiments, structures, features, and effects of a tea leaf visual recognition method, device, and system proposed according to the present invention. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. In addition, the specific features, structures, or characteristics in one or more embodiments can be combined in any suitable form.
[0020] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field to which the present invention belongs.
[0021] The following will specifically describe the specific solutions of a tea leaf visual recognition method, device, and system provided by the present invention with reference to the accompanying drawings.
[0022] Please refer to Figure 1 , which shows a flowchart of the steps of a tea leaf visual recognition method provided by an embodiment of the present invention. The method includes the following steps: Step S001: Obtain a tea leaf image.
[0023] It should be noted that with the development of the tea industry towards the direction of intelligence, visual recognition technology is increasingly widely used in tea quality detection and grading. Since tea images are often affected by factors such as illumination changes and background interference during the acquisition process, directly using the original images for recognition is likely to result in inaccurate feature extraction. Therefore, it is necessary to perform enhancement processing on the images to improve the image quality and the identifiability of key features, so as to better capture the microscopic vein features in tea leaves. Therefore, this embodiment proposes a tea visual recognition method, device, and system. Specifically, by enhancing the tea image, the tea can be better visually recognized. For this purpose, it is first necessary to collect pictures of tea leaves.
[0024] Specifically, a high-definition RGB image of a tea leaf is collected by an RGB high-definition camera, and the high-definition RGB image of the tea leaf is grayscale processed to obtain a tea image, as Figure 2 shown, the Figure 2 is an example diagram of a tea image.
[0025] Step S002: Divide the tea image into several regions, and perform convolution operations on each region to obtain the convolution feature map of each region; obtain the gain degree of each region according to the gray values of the pixel points in each region and its convolution feature map; screen several gain deficit regions according to the gain degrees of each region; obtain the information complexity of the gain deficit regions according to the edge change trend in the gain deficit regions, and then screen out the regions to be enhanced from all the gain deficit regions; obtain the spatial domain difference of the regions to be enhanced according to the gray difference between the regions to be enhanced and their convolution feature maps at the pixel points.
[0026] It should be noted that since the growth state of tea leaves is closely related to the vein morphology in the leaves, but during the process of collecting tea images, it will be affected by external factors such as illumination and vibration, resulting in the veins in the tea leaves not being well presented in the tea images. Therefore, it is necessary to perform image enhancement on the tea images to better capture the microscopic vein features in the tea images; while directly performing dilated convolution operations on the tea images in the traditional method may cause checkerboard effects and generate regular mesh artifacts at the tea vein bifurcation points (high-frequency mutation regions in the tea images) due to the fixed interval sampling characteristics of dilated convolution, thus destroying the microscopic veins in the tea images; therefore, this embodiment proposes a tea visual recognition method. Specifically, by dividing the tea into several regions and performing dilated convolution operations on each region separately, the beneficial effects of being enhanced by the dilated convolution operations on each region are evaluated, so as to screen out some regions with poor enhancement effects from all regions, which is beneficial to enhancing the regions with poor enhancement effects subsequently, thereby capturing the microscopic vein features in the tea images.
[0027] Specifically, the tea leaf image is segmented into several regions by using the superpixel segmentation algorithm. Since the superpixel segmentation is a well-known prior art, it will not be elaborated in this embodiment. Each region is subjected to a convolution operation by using the dilated convolution to obtain the dilated convolution operation result of each region, which is denoted as the convolution feature map of each region. Since the dilated convolution is a well-known prior art, it will not be elaborated in this embodiment.
[0028] Further, for any region, the variance of the gray values of all the pixel points in the region and the variance of the gray values of all the pixel points in the convolution feature map of the region are obtained, and the difference between the variance of the gray values of all the pixel points in the convolution feature map of the region and the variance of the gray values of all the pixel points in the region is used as the gain degree of the region. Taking the absolute value of the difference in the gain degrees between different regions as the metric distance, all the regions are clustered into two cluster classes by using the k-means clustering algorithm. The mean value of the gain degrees of all the regions in any one cluster class is obtained as the average gain degree of the cluster class. The cluster class with the minimum average gain degree and the cluster class with the maximum average gain degree are respectively denoted as the gain deficit cluster class and the gain cluster class, and the regions in the gain deficit cluster class and the gain cluster class are respectively denoted as the gain deficit regions and the gain regions.
[0029] It should be noted that the variance of the gray values of all the pixel points in the convolution feature map of the region and the region represents the significant degree of the detail change in the convolution feature map of the region and the region. Therefore, the larger the difference between the variance of the gray values of all the pixel points in the convolution feature map of the region and the variance of the gray values of all the pixel points in the region, the more it indicates that the dilated convolution enhances the image texture or details in this region and plays a role in improving the expression of microscopic features. On the contrary, if the difference is small, it indicates that the dilated convolution does not significantly change the image information. Therefore, based on this, the gain deficit regions are screened out from all the regions. The gain deficit regions are the regions where the dilated convolution does not significantly change, that is, the gain deficit regions include the regions with clear original images or the regions with unclear original images and ineffective enhancement by convolution.
[0030] Preferably, in a specific embodiment of the present invention, for any one gain deficit region, the canny edge detection algorithm is used to obtain several edges in the gain deficit region. Since the canny edge detection algorithm is a well-known prior art, it will not be elaborated in this embodiment. And the edges are traversed from left to right and from top to bottom to assign an order to the edge pixel points in the edges (preferably traversing from left to right).
[0031] Further, for any edge pixel point on any edge in any gain deficit region, according to the position coordinates of the edge pixel point in the edge and the position coordinates of the next edge pixel point of the edge pixel point, obtain the slope of the edge pixel point in the edge (if there is no next edge pixel point for the edge pixel point in the edge, then according to the position coordinates of the edge pixel point in the edge and the position coordinates of the previous edge pixel point of the edge pixel point, obtain the slope of the edge pixel point in the edge); take the average value of the slopes of all edge pixel points in the edge as the slope of the edge. Further, take the product of the number of edges in the gain deficit region and the average value of the slopes of all edges in the gain deficit region as the information complexity of the gain deficit region.
[0032] It should be noted that the information complexity of the gain deficit region comprehensively quantifies the richness of the texture structure within the gain deficit region through the number of edges and the degree of change in the edge direction in the gain deficit region; since the gain deficit region includes regions where the original image is already clear or regions where the original image is not clear and the convolution fails to effectively enhance the region, and since the richness of the texture structure in the region where the original image is already clear is high, while the richness of the region where the original image is not clear and the convolution fails to effectively enhance is low. Therefore, sort all gain deficit regions according to the information complexity, and extract the maximum value of the difference in information complexity between adjacent regions as the demarcation point, so as to obtain the region where the original image is not clear and the convolution fails to effectively enhance, and obtain the region to be enhanced.
[0033] Preferably, in a specific embodiment of the present invention, sort all gain deficit regions in ascending order according to the information complexity of all gain deficit regions to obtain a gain deficit region sequence; obtain the absolute value of the difference in information complexity between all adjacent gain deficit regions in the gain deficit region sequence, take the position corresponding to the largest absolute value of the difference as the demarcation point, and take all gain deficit regions in the gain deficit region sequence before the demarcation point as the region to be enhanced.
[0034] It should be noted that the region to be enhanced is the region in the tea leaf image that is not clear and the dilated convolution cannot effectively enhance it. Due to the characteristic of fixed interval sampling of the dilated convolution, when the micro veins in the region to be enhanced are more blurred, the dilated convolution may not be able to effectively activate or enhance the microstructures therein, resulting in an unclear enhancement effect. Therefore, other means are needed to enhance the region to be enhanced.
[0035] It should be further noted that although dilated convolution cannot effectively enhance the area to be enhanced, the enhancement amplitude of dilated convolution for the area to be enhanced can be quantified from the spatial domain perspective through the gray difference between the area to be enhanced and its convolution feature map. The greater the enhancement amplitude of dilated convolution for the area to be enhanced, the more deficiencies in feature expression exist in the area to be enhanced, indicating that the convolution fails to fully extract or enhance its detailed features. Therefore, introducing the spatial domain difference as a reference index in the subsequent calculation of the enhancement coefficient can allocate more enhancement efforts to these areas with significant differences but not effectively enhanced, realizing more targeted image detail restoration and optimization, and further improving the discernibility of micro veins in tea images.
[0036] Preferably, in a specific embodiment of the present invention, any pixel point in any area to be enhanced is denoted as the target pixel point, and the pixel point with the same position coordinates as the target pixel point in the convolution feature map of the area to be enhanced is denoted as the corresponding pixel point of the target pixel point; the absolute value of the difference in gray value between the target pixel point and its corresponding pixel point is obtained as the feature difference of the target pixel point, and the average value of the feature differences of all pixel points in the area to be enhanced is used as the spatial domain difference of the area to be enhanced.
[0037] Thus, the spatial domain differences of all areas to be enhanced are obtained.
[0038] Step S003: Obtain the frequency spectrum diagram of the tea image; cluster the frequency units in the frequency spectrum diagram of the tea image to obtain the low-frequency frequency unit cluster; and obtain the frequency domain difference of the area to be enhanced according to the low-frequency frequency unit cluster and the area to be enhanced.
[0039] It should be noted that the traditional enhancement of images by dilated convolution mainly analyzes and enhances the images from the spatial domain perspective, which often fails to comprehensively reflect the global characteristics of the energy distribution in the images. Especially for areas with weak texture detail distribution and blurred structures, the spatial domain enhancement effect is limited. Therefore, in this embodiment, by analyzing the frequency spectrum diagram of the tea image, the frequency units in the frequency spectrum diagram of the tea image are first clustered to extract the cluster representing the low-frequency energy characteristics and mapped back to the original image to locate the low-frequency area. Then, taking the energy characteristics of the low-frequency area as a reference, a comparison is made with the area to be enhanced obtained in step S002, and the frequency domain energy difference between the two is calculated to determine whether each area to be enhanced is not fully enhanced due to the weakening of the frequency domain characteristics, providing a basis for subsequent precise enhancement by combining frequency domain and spatial domain information to better enhance the area to be enhanced.
[0040] Preferably, in a specific embodiment of the present invention, the frequency spectrum diagram of the tea image is obtained by using the Fourier transform. Since the Fourier transform is a well-known existing technology, it will not be elaborated in this embodiment. Taking the amplitude difference between different frequency units in the spectrogram of the tea leaf image as the measurement distance, the elbow method is used to obtain the optimal number of cluster classes K for all frequency units in the spectrogram of the tea leaf image, and the number of cluster classes of the k-means clustering algorithm is set to K to cluster all frequency units in the spectrogram of the tea leaf image, obtaining several frequency unit clusters of the spectrogram of the tea leaf image, and taking the amplitude mean value of all frequency units in any one frequency unit cluster as the high-frequency feature of this frequency unit cluster, and taking the frequency unit cluster with the smallest high-frequency feature as the low-frequency frequency unit cluster.
[0041] Further, perform an inverse Fourier transform on the low-frequency frequency unit cluster to obtain the corresponding partial original image area of the low-frequency frequency unit cluster, denoted as the low-frequency area; For any one area to be enhanced, take the absolute value of the difference between the variance of the gray values of all pixel points in the area to be enhanced and the variance of the gray values of all pixel points in the low-frequency area as the frequency domain difference of the area to be enhanced.
[0042] It should be noted that the frequency domain difference of the area to be enhanced is the degree of difference in energy distribution between the area to be enhanced and the low-frequency area in the tea leaf image, indicating the degree of lack of microscopic vein characteristics in the area to be enhanced. If the frequency domain difference of the area to be enhanced is larger, then the energy feature difference between the area to be enhanced and the low-frequency area is large, indicating that the area to be enhanced contains more high-frequency information but is not fully enhanced. Subsequently, based on the frequency domain difference of the area to be enhanced, the enhancement coefficient of the area to be enhanced is obtained, thereby improving the enhancement effect of the area to be enhanced.
[0043] Step S004: Obtain the enhancement coefficient of the area to be enhanced according to the spatial domain difference and the frequency domain difference of the area to be enhanced; enhance the area to be enhanced according to the enhancement coefficient of the area to be enhanced.
[0044] It should be noted that after obtaining the spatial domain difference and the frequency domain difference of the area to be enhanced through step S002 and step S003 respectively, that is, obtaining the enhancement coefficient of the area to be enhanced according to the spatial domain difference and the frequency domain difference of the area to be enhanced, and enhancing the area to be enhanced through the enhancement coefficient of the area to be enhanced. Since dilated convolution can effectively enhance the gain area, the gain area is enhanced through dilated convolution. Also, since the microscopic vein characteristics in the remaining areas of the leaf image are clear, the areas other than the area to be enhanced and the gain area in the leaf image are not enhanced, so as to better capture the microscopic vein characteristics in the tea leaf.
[0045] Preferably, in a specific embodiment of the present invention, take the square root sum of the spatial domain difference and the frequency domain difference of any one area to be enhanced, and map the result to the range from -1 to 1 as the enhancement coefficient of the area to be enhanced.
[0046] As an example, the specific calculation formula for obtaining the enhancement coefficient of the area to be enhanced is as follows: ; In the formula, represents the enhancement coefficient of the area to be enhanced; represents the spatial domain difference of the area to be enhanced; represents the frequency domain difference of the area to be enhanced; represents the premnmx function, which is used to map the calculation result to the interval from -1 to 1 in this embodiment.
[0047] It should be noted that the larger the enhancement coefficient of the area to be enhanced, the more it should be enhanced; and the feature difference of the pixel points in the area to be enhanced represents the response degree of the pixel in the convolution enhancement process, that is, the pixel point has the microscopic vein feature, but the dilated convolution fails to capture the microscopic vein feature of the pixel point. Therefore, it is more necessary to enhance the pixel points with large feature differences in the area to be enhanced.
[0048] Preferably, in a specific embodiment of the present invention, for any pixel point in the area to be enhanced, the feature difference of the pixel point in the area to be enhanced is linearly normalized to obtain the feature difference degree of the pixel point in the area to be enhanced; the sum of adding 1 to the enhancement coefficient of the area to be enhanced, and the product of multiplying the sum by the feature difference degree of the pixel point in the area to be enhanced is used as the gray-scale enhancement coefficient of the pixel point in the area to be enhanced; the gray-scale value of the pixel point is adjusted through the gray-scale enhancement coefficient to obtain the enhanced gray-scale value of the pixel point.
[0049] As an example, the specific calculation formula for obtaining the enhanced gray-scale value of the pixel point in the area to be enhanced is as follows: ; In the formula, represents the enhanced gray-scale value of the pixel point in the area to be enhanced; represents the feature difference degree of the pixel point in the area to be enhanced; represents the enhancement coefficient of the area to be enhanced; represents the gray-scale value of the pixel point in the area to be enhanced; represents the ceiling function.
[0050] Similarly, enhance all regions to be enhanced. Since dilated convolution can enhance the gain regions in the tea leaf regions, the gain regions in the tea leaf image are enhanced through dilated convolution. Also, since the microscopic vein features of the regions other than the regions to be enhanced and the gain regions in the tea leaf image are clear, there is no need to enhance them. An enhanced tea leaf image is obtained, as Figure 3 shown, the Figure 3 is an example diagram of the enhanced tea leaf image. Finally, capture the microscopic vein detail features in the tea leaf image based on the enhanced tea leaf image, and analyze the variety, growth status, and disease conditions of the tea leaves according to the microscopic vein detail features in the tea leaf image to complete the visual recognition of the tea leaves.
[0051] Another embodiment of the present invention provides a tea leaf visual recognition system, which includes: an image acquisition module, a spatial domain analysis module, a frequency domain analysis module, and an image enhancement module; The image acquisition module is used to acquire a tea leaf image; The spatial domain analysis module is used to divide the tea leaf image into several regions, perform convolution operations on each region to obtain the convolution feature map of each region; obtain the gain degree of each region according to the gray values of the pixel points in each region and its convolution feature map; screen several gain deficit regions according to the gain degree of each region; obtain the information complexity of the gain deficit regions according to the edge change trend in the gain deficit regions, and then screen out the regions to be enhanced from all the gain deficit regions; obtain the spatial domain difference of the regions to be enhanced according to the gray difference of the regions to be enhanced and their convolution feature maps at the pixel points; The frequency domain analysis module is used to obtain the frequency spectrum diagram of the tea leaf image; cluster the frequency units in the frequency spectrum diagram of the tea leaf image to obtain the low-frequency frequency unit cluster classes; obtain the frequency domain difference of the regions to be enhanced according to the low-frequency frequency unit cluster classes and the regions to be enhanced; The image enhancement module is used to obtain the enhancement coefficient of the regions to be enhanced according to the spatial domain difference and the frequency domain difference of the regions to be enhanced; enhance the regions to be enhanced according to the enhancement coefficient of the regions to be enhanced.
[0052] Another embodiment of the present invention provides a tea leaf visual recognition device, including a tea leaf visual recognition device arranged. The tea leaf visual recognition device includes a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, the above modules are implemented.
[0053] 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 principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A visual recognition method for tea leaves, characterized in that, The method includes the following steps: Obtain a tea leaf image; Divide the tea leaf image into several regions, perform convolution operations on each region to obtain the convolution feature map of each region; obtain the gain degree of each region according to the gray values of the pixel points in each region and its convolution feature map; screen several gain deficit regions according to the gain degrees of each region; obtain the information complexity of the gain deficit regions according to the edge change trend in the gain deficit regions, and then screen out the regions to be enhanced from all the gain deficit regions; obtain the spatial domain difference of the regions to be enhanced according to the gray difference between the regions to be enhanced and their convolution feature maps at the pixel points. Obtain the spectrogram of the tea leaf image; cluster the frequency units in the spectrogram of the tea leaf image to obtain the low-frequency frequency unit cluster; obtain the frequency domain difference of the regions to be enhanced according to the low-frequency frequency unit cluster and the regions to be enhanced. Obtain the enhancement coefficient of the regions to be enhanced according to the spatial domain difference and the frequency domain difference of the regions to be enhanced; enhance the regions to be enhanced according to the enhancement coefficient of the regions to be enhanced.
2. The method for visual recognition of tea according to claim 1, wherein The specific method for obtaining the gain degree of each region according to the gray values of the pixel points in each region and its convolution feature map, and screening several gain deficit regions according to the gain degrees of each region includes: For any one region, obtain the variance of the gray values of all pixel points in the region and the variance of the gray values of all pixel points in the convolution feature map of the region, and take the difference between the variance of the gray values of all pixel points in the convolution feature map of the region and the variance of the gray values of all pixel points in the region as the gain degree of the region. Taking the absolute value of the difference in the gain degrees between different regions as the measurement distance, cluster all regions into two clusters, obtain the mean value of the gain degrees of all regions in any one cluster as the average gain degree of the cluster, record the cluster with the minimum average gain degree as the gain deficit cluster, and record the regions in the gain deficit cluster as the gain deficit regions.
3. The method for visual recognition of tea according to claim 1, wherein The specific method for obtaining the information complexity of the gain deficit regions according to the edge change trend in the gain deficit regions includes: For any one edge pixel point in any one edge in any one gain deficit region, obtain the slope of the edge pixel point in the edge according to the position coordinates of the edge pixel point in the edge and the position coordinates of the next edge pixel point of the edge pixel point; take the mean value of the slopes of all edge pixel points in the edge as the slope of the edge. Take the product of the number of edges in the gain deficit region and the mean value of the slopes of all edges in the gain deficit region as the information complexity of the gain deficit region.
4. The method for visual recognition of tea according to claim 1, characterized in that, The specific method for screening out the regions to be enhanced from all the gain deficit regions includes: Sort all the gain deficit regions in ascending order according to the information complexity of all the gain deficit regions to obtain the gain deficit region sequence; obtain the absolute value of the difference in the information complexity between all adjacent gain deficit regions in the gain deficit region sequence, take the position corresponding to the largest absolute value of the difference as the demarcation point, and take all the gain deficit regions in the gain deficit region sequence before the demarcation point as the regions to be enhanced.
5. The method for visual recognition of tea leaves according to claim 1, wherein The method for obtaining the spatial domain difference of the area to be enhanced according to the gray-scale difference between the area to be enhanced and its convolution feature map at pixel points includes the following specific steps: Denote any pixel point in any area to be enhanced as the target pixel point, and denote the pixel point with the same position coordinates as the target pixel point in the convolution feature map of the area to be enhanced as the corresponding pixel point of the target pixel point; obtain the absolute value of the difference in gray-scale value between the target pixel point and its corresponding pixel point as the feature difference of the target pixel point, and take the average value of the feature differences of all pixel points in the area to be enhanced as the spatial domain difference of the area to be enhanced.
6. The method for visual recognition of tea according to claim 1, characterized in that, The method for clustering frequency units in the spectrogram of the tea leaf image to obtain the low-frequency frequency unit cluster class includes the following specific steps: Using the amplitude difference between different frequency units in the spectrogram of the tea leaf image as the measurement distance, cluster all frequency units in the spectrogram of the tea leaf image to obtain several frequency unit cluster classes of the spectrogram of the tea leaf image, and denote the average value of the amplitudes of all frequency units in any frequency unit cluster class as the high-frequency feature of this frequency unit cluster class, and take the frequency unit cluster class with the smallest high-frequency feature as the low-frequency frequency unit cluster class.
7. The method for visual recognition of tea leaves according to claim 1, characterized in that, The method for obtaining the frequency domain difference of the area to be enhanced according to the low-frequency frequency unit cluster class and the area to be enhanced includes the following specific steps: Perform inverse Fourier transform on the low-frequency frequency unit cluster class to obtain the corresponding partial original image area of the low-frequency frequency unit cluster class, denoted as the low-frequency area; For any area to be enhanced, take the absolute value of the difference between the variance of the gray-scale values of all pixel points in the area to be enhanced and the variance of the gray-scale values of all pixel points in the low-frequency area as the frequency domain difference of the area to be enhanced.
8. The method for visual recognition of tea leaves according to claim 5, wherein, The method for obtaining the enhancement coefficient of the area to be enhanced according to the spatial domain difference and the frequency domain difference of the area to be enhanced, and enhancing the area to be enhanced according to the enhancement coefficient of the area to be enhanced includes the following specific steps: Take the square root sum of the spatial domain difference and the frequency domain difference of any area to be enhanced, and map the result to the range from -1 to 1 as the enhancement coefficient of the area to be enhanced; For any pixel point in the area to be enhanced, normalize the feature difference of the pixel point in the area to be enhanced to obtain the feature difference degree of the pixel point in the area to be enhanced; Take the product of the sum of the enhancement coefficient of the area to be enhanced and 1 and the feature difference degree of the pixel point in the area to be enhanced as the gray-scale enhancement coefficient of the pixel point in the area to be enhanced; adjust the gray-scale value of the pixel point through the gray-scale enhancement coefficient to obtain the enhanced gray-scale value of the pixel point.
9. A tea visual recognition system, characterized in that, The system includes: an image acquisition module, a spatial domain analysis module, a frequency domain analysis module, and an image enhancement module; The image acquisition module is used to acquire the tea leaf image; The airspace analysis module is used to divide the tea leaf image into several regions, perform convolution operations on each region to obtain the convolution feature map of each region; obtain the gain degree of each region according to the gray values of the pixels in each region and its convolution feature map; screen several gain deficit regions according to the gain degrees of each region; obtain the information complexity of the gain deficit regions according to the edge change trend in the gain deficit regions, and then screen out the regions to be enhanced from all the gain deficit regions; obtain the airspace difference of the regions to be enhanced according to the gray difference of the pixels between the regions to be enhanced and their convolution feature maps. The frequency domain analysis module is used to obtain the spectrogram of the tea leaf image; cluster the frequency units in the spectrogram of the tea leaf image to obtain the low-frequency frequency unit cluster; obtain the frequency domain difference of the regions to be enhanced according to the low-frequency frequency unit cluster and the regions to be enhanced. The image enhancement module is used to obtain the enhancement coefficient of the regions to be enhanced according to the airspace difference and the frequency domain difference of the regions to be enhanced; enhance the regions to be enhanced according to the enhancement coefficient of the regions to be enhanced.
10. A tea visual recognition device, including an arranged tea visual recognition device, characterized in that, The tea leaf visual recognition device includes a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, the steps of a tea leaf visual recognition method as described in any one of claims 1-8 are implemented.
Citation Information
Patent Citations
Kiwi fruit flower identification method based on spatial domain and frequency domain feature fusion
CN117876879A
Visual inspection method for quality of digital school uniform processing production line
CN118822994A
Image enhancement method and apparatus, and device and storage medium
WO2023123927A1
Cited By
Tea variety identification method and system based on machine vision
CN120635597A
Tea variety identification method and system based on machine vision
CN120635597B