Coffee bean color comparison method and device, computer equipment and storage medium
By processing the image of coffee beans and colorimetric cards, converting the color space and comparing the tone value, the problem of naked-eye observation dependence is solved, and the accuracy of coffee bean maturity evaluation and recognition efficiency are improved.
Patent Information
- Application Number
- CN202411054975.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-02
- Publication Date
- 2024-11-08
AI Technical Summary
In the prior art, the judgment of coffee bean maturity depends on naked eye observation and personal experience, is inefficient and difficult to ensure accuracy and repeatability, and is difficult to accurately identify the color changes of coffee beans during growth.
By obtaining the sampled images of coffee beans and colorimetric cards, segmenting the images into the coffee bean area and colorimetric card area, converting the RGB field color value to the HSV field, extracting the tone value comparison, and determining the color of the coffee beans by using edge detection , deep learning segmentation algorithms and clustering processing technologies to ensure the accuracy and efficiency of color recognition.
The accuracy and repetition of the evaluation of coffee bean ripening is achieved, the efficiency of coffee bean fruit color recognition is improved, and an efficient and accurate monitoring method is provided.
Smart Images

Figure CN118918345A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image recognition technology, and in particular to a method, device, computer equipment and storage medium for comparing the colors of coffee beans. Background Art
[0002] The color change of coffee beans during the growth process is one of the key factors in determining their maturity. Currently, most coffee growers rely on visual observation and personal experience to judge the maturity of coffee beans. This method is not only inefficient, but also highly subjective and difficult to ensure the accuracy and repeatability of the assessment. In addition, the current color comparison recognition method is difficult to accurately identify the color of coffee beans during the growth process. Summary of the invention
[0003] The embodiments of the present application provide a coffee bean color comparison method, device, computer equipment and storage medium, which can solve the technical problems that there is currently a lack of color comparison and identification methods for coffee bean fruits during the growth process, and that the maturity of coffee bean fruits is judged by relying on naked eye observation and personal experience, which is inefficient and difficult to ensure the accuracy and repeatability of coffee bean maturity assessment.
[0004] The present application embodiment provides a method for comparing the colors of coffee beans, which includes:
[0005] Get a sample image with coffee beans and a color chart;
[0006] Segmenting the sampled image into a coffee bean region and a colorimetric card region;
[0007] Obtaining RGB domain color values of each sub-region in the colorimetric card region, performing noise pixel filtering, converting the RGB domain color values of the sub-region into HSV domain color values, and extracting the hue value of each sub-region to form a hue value set of the colorimetric card region;
[0008] Obtaining the RGB domain color value in the coffee bean area, performing noise pixel filtering, converting the RGB domain color value of the coffee bean area into an HSV domain color value, and extracting the hue value of the coffee bean area;
[0009] The hue value of the coffee bean area is compared with the hue value set of the colorimetric card area, and the hue value in the hue value set of the colorimetric card area with the smallest difference from the hue value of the coffee bean area is taken as the color of the coffee beans.
[0010] Furthermore, segmenting the image into a coffee bean area and a colorimetric card area includes:
[0011] Reading the sampled image, and performing grayscale processing on the sampled image to obtain a grayscale image;
[0012] Performing edge detection on the grayscale image to form edge lines;
[0013] The target area of the sampled image is extracted according to the edge line to form the coffee bean area and the colorimetric card area.
[0014] Furthermore, performing edge detection on the grayscale image to form edge lines includes:
[0015] Performing Gaussian filtering on the grayscale image to smooth the image and reduce noise;
[0016] Calculating the image gradient of the grayscale image after Gaussian filtering to form a gradient image;
[0017] Performing non-maximum suppression on the gradient image, retaining the local maximum value, and removing non-edge pixels;
[0018] Double threshold processing is applied to the gradient image to determine strong edge, weak edge and non-edge pixels;
[0019] By connecting the weak edge to the strong edge, a complete edge line is formed.
[0020] Furthermore, the extracting a target area from the sampled image according to the edge line to form the coffee bean area and the colorimetric card area includes:
[0021] generating an edge mask based on the edge line;
[0022] Performing a morphological operation on the edge mask to expand the edge area, wherein the morphological operation includes dilation and erosion processing;
[0023] If the edge area covers the pixels at the edge of the coffee beans or the colorimetric card, the edge mask is reduced proportionally;
[0024] The area where the coffee beans are located is extracted from the sampled image according to the edge mask to form a coffee bean area, and the area where the colorimetric card is located is extracted to form a colorimetric card area.
[0025] Furthermore, segmenting the sampled image into a coffee bean region and a colorimetric card region further includes:
[0026] The trained deep learning segmentation algorithm model is used to extract the area where the coffee beans are located from the sampled image to form a coffee bean area, and the area where the colorimetric card is located is extracted to form a colorimetric card area.
[0027] Furthermore, after the sampled image is segmented into the coffee bean region and the colorimetric card region, the method further includes:
[0028] Performing color smoothing processing on the coffee bean area and the colorimetric card area;
[0029] Determine whether there is a color abnormal region in the coffee bean region after color smoothing processing, and if so, use the coffee bean region as the target processing image; or determine whether there is a color abnormal region in the colorimetric card region after color smoothing processing, and if so, use the colorimetric card region as the target processing image;
[0030] According to the complexity and noise level of the target processed image, a region with normal color is selected as a cluster to form a plurality of clusters;
[0031] Initialize the center point of each cluster;
[0032] Assigning each pixel in the target processed image to the nearest cluster center;
[0033] Recalculate the center point of each cluster until convergence.
[0034] Furthermore, the converting the RGB domain color value of the sub-area into the HSV domain color value, and the converting the RGB domain color value of the sub-area into the HSV domain color value includes:
[0035] Get the RGB domain color value {R, G, B}, where the value range of R, G, B is [0,255];
[0036] use Normalize the RGB domain color values {R, G, B} to the range of [0, 1];
[0037] Calculate the hue value H, saturation value S, and brightness value V corresponding to the HSV domain:
[0038]
[0039] The present application embodiment provides a coffee bean color comparison device, the coffee bean color comparison device comprising:
[0040] An image acquisition module, used for acquiring a sampling image having coffee beans and a colorimetric card;
[0041] An image segmentation module, used for segmenting the sampled image into a coffee bean area and a colorimetric card area;
[0042] A colorimetric card hue value set processing module is used to obtain the RGB domain color value of each sub-region in the colorimetric card region, perform noise pixel filtering, convert the RGB domain color value of the sub-region into an HSV domain color value, and extract the hue value of each sub-region to form a hue value set of the colorimetric card region;
[0043] A coffee bean hue value processing module is used to obtain the RGB domain color value in the coffee bean area, perform noise pixel filtering, convert the RGB domain color value of the coffee bean area into an HSV domain color value, and extract the hue value of the coffee bean area;
[0044] The coffee bean color recognition module is used to compare the hue value of the coffee bean area with the hue value set of the colorimetric card area, and take the hue value with the smallest difference between the hue value of the coffee bean area and the hue value of the colorimetric card area as the coffee bean color.
[0045] An embodiment of the present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the coffee bean color comparison method described above when executing the computer program.
[0046] An embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the coffee bean color comparison method described above are implemented.
[0047] The coffee bean color comparison method, device, computer equipment and storage medium provided in the embodiments of the present application obtain a sampled image with coffee beans and a colorimetric card, segment the sampled image into a coffee bean area and a colorimetric card area, convert the RGB domain color value of each area into an HSV domain color value, and use a hue value comparison method to concentrate the hue value of the colorimetric card area and the hue value with the smallest difference from the hue value of the coffee bean area as the color of the coffee bean, thereby ensuring the accuracy and repeatability of the coffee bean maturity assessment and improving the color recognition efficiency of the coffee bean fruit. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The technical solution and other beneficial effects of the present application will be made apparent by describing in detail the specific implementation methods of the present application in conjunction with the accompanying drawings.
[0049] Figure 1 A schematic diagram of the structure of a color detection device provided in an embodiment of the present application;
[0050] Figure 2 A schematic diagram of the internal structure of a partial color detection device provided in an embodiment of the present application;
[0051] Figure 3 A logic diagram of the coffee bean color comparison method provided in an embodiment of the present application;
[0052] Figure 4 A flow chart of a coffee bean color comparison method provided in an embodiment of the present application;
[0053] Figure 5A structural block diagram of a coffee bean color comparison system provided in an embodiment of the present application;
[0054] Figure 6 This is a diagram of the internal structure of a computer device in one embodiment of the present application.
[0055] The markings in the figure are as follows:
[0056] Color detection device 10, shell 1, bottom plate 11, top plate 12, side plate 13, tray 3, image capture device 4, fixing bracket 41, camera 42, annular light source 5, color analysis device 6, display screen 61, communication interface 62, colorimetric card 7, coffee bean color comparison device 100, image acquisition module 101, image segmentation module 102, colorimetric card hue value set processing module 103, coffee bean hue value processing module 104, coffee bean color recognition module 105. DETAILED DESCRIPTION
[0057] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.
[0058] In the description of this application, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection, an electrical connection, or mutual communication; it can be a direct connection, or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0059] Example 1
[0060] like Figure 1 , Figure 2As shown, Example 1 of the present application provides a coffee bean color comparison method, which is implemented by a color detection device 10, and the color detection device 10 includes a housing 1, a tray 3, an image capture device 4, an annular light source 5, and a color analysis device 6. The housing 1 is provided with a bottom plate 11 and a top plate 12 that are arranged opposite to each other; the tray 3 is arranged on the bottom plate 11; the image capture device 4 is arranged on the top plate 12 and is arranged toward the tray 3; the annular light source 5 is arranged on the lower surface of the top plate 12 and is arranged around the image capture device 4; the color analysis device 6 is connected to the image capture device 4, and the color of the detected object is obtained by obtaining the image of the detected object in the tray 3 taken by the image capture device 4 and comparing it with the standard color. By setting the annular light source 5, the detected object in the tray 3 can be provided with an irradiation light source, and the image capture device 4 takes the image of the detected object in the tray 3 and compares it with the standard color to obtain the color of the detected object, which can ensure the accuracy and repeatability of the evaluation. The image capturing device 4 includes a fixing bracket 41 and a camera 42 . The fixing bracket 41 is fixed on the top plate 12 , and the camera 42 is fixed on the fixing bracket 41 .
[0061] The color analysis device 6 includes a display screen 61, and the display screen 61 is connected to the image capture device 4 through a communication interface 62, and the communication interface 62 includes a wireless network module and / or a wired port that supports remote data transmission and system update. The color analysis device 6 analyzes the data collected from the image capture device 4, can identify subtle changes in the color of coffee fruits, and converts the data into a color change curve, and compares it with the colorimetric card 7. The display screen 61 displays the color change curve and analysis results of the coffee beans, including the maturity prediction of the coffee fruits, the color change rate, etc. The color analysis device 6 analyzes the data collected from the image capture device 4, and can identify subtle changes in the color of the coffee fruits. The display screen 61 is connected to a local computer or data center through the communication interface 62. In the local computer or data center, more powerful data processing capabilities can be used to perform more in-depth data analysis and model optimization.
[0062] The coffee bean color comparison method provided by the present invention can detect the color of the coffee bean growth process, which not only provides an efficient and accurate monitoring method for coffee growers, but also provides a powerful tool for researchers to study the coffee bean growth process.
[0063] like Figure 3 , Figure 4 As shown, the embodiment of the present application provides a method for comparing the colors of coffee beans, which includes:
[0064] S1, obtaining a sampling image with coffee beans and a colorimetric card;
[0065] S2, dividing the sampled image into a coffee bean area and a colorimetric card area;
[0066] S3, obtaining the RGB domain color value of each sub-region in the colorimetric card region, performing noise pixel filtering, converting the RGB domain color value of the sub-region into an HSV domain color value, and extracting the hue value of each sub-region to form a hue value set of the colorimetric card region;
[0067] S4, obtaining the RGB domain color value in the coffee bean area, performing noise pixel filtering, converting the RGB domain color value of the coffee bean area into an HSV domain color value, and extracting the hue value of the coffee bean area;
[0068] S5. Compare the hue value of the coffee bean area with the hue value set of the colorimetric card area, and take the hue value in the hue value set of the colorimetric card area with the smallest difference from the hue value of the coffee bean area as the color of the coffee beans.
[0069] In step S2, it can be identified that there are sub-areas with different color distributions in the colorimetric card area, each sub-area corresponds to a color, and the color of the coffee beans can be identified by comparing the color of the coffee bean area with the colors of the sub-areas in the colorimetric card area.
[0070] HSV (Hue, Saturation, Value) is a color space created by AR Smith in 1978 based on the intuitive characteristics of color, also known as the Hexcone Model. The HSV color model refers to a subset of visible light in the three-dimensional color space of H, S, and V, which contains all colors in a certain color domain. Each color is represented by hue (Hue, H for short), saturation (S for short) and value (V for short). The color parameters in this model are: hue (H), saturation (S), and brightness (V).
[0071] The method for filtering noise pixels includes filtering all {R, G, B} sets in the color card area or the coffee bean area by using Gaussian filtering / mean filtering to obtain a denoised {R, G, B} set.
[0072] Furthermore, segmenting the image into a coffee bean area and a colorimetric card area includes:
[0073] Reading the sampled image, and performing grayscale processing on the sampled image to obtain a grayscale image;
[0074] Performing edge detection on the grayscale image to form edge lines;
[0075] The target area of the sampled image is extracted according to the edge line to form the coffee bean area and the colorimetric card area.
[0076] Furthermore, performing edge detection on the grayscale image to form edge lines includes:
[0077] Performing Gaussian filtering on the grayscale image to smooth the image and reduce noise;
[0078] Calculating the image gradient of the grayscale image after Gaussian filtering to form a gradient image;
[0079] Performing non-maximum suppression on the gradient image, retaining the local maximum value, and removing non-edge pixels;
[0080] Double threshold processing is applied to the gradient image to determine strong edge, weak edge and non-edge pixels;
[0081] By connecting the weak edge to the strong edge, a complete edge line is formed.
[0082] The image gradient of the grayscale image after Gaussian filtering is calculated by Sobel operator, which is a gradient-based edge detection algorithm that detects edges by calculating the gradient size and direction of each pixel in the image. Calculating the image gradient of the grayscale image after Gaussian filtering will obtain edge strength and direction, and the grayscale image will form a gradient image after obtaining the edge strength and direction.
[0083] Furthermore, the extracting a target area from the sampled image according to the edge line to form the coffee bean area and the colorimetric card area includes:
[0084] generating an edge mask based on the edge line;
[0085] Performing a morphological operation on the edge mask to expand the edge area, wherein the morphological operation includes dilation and erosion processing;
[0086] If the edge area covers the pixels at the edge of the coffee beans or the colorimetric card, the edge mask is reduced proportionally;
[0087] The area where the coffee beans are located is extracted from the sampled image according to the edge mask to form a coffee bean area, and the area where the colorimetric card is located is extracted to form a colorimetric card area.
[0088] The method for generating an edge mask based on the edge line is Canny edge detection, which is a template-based edge detection algorithm that detects edges by detecting local maxima in an image.
[0089] Furthermore, segmenting the sampled image into a coffee bean region and a colorimetric card region further includes:
[0090] The trained deep learning segmentation algorithm model is used to extract the area where the coffee beans are located from the sampled image to form a coffee bean area, and the area where the colorimetric card is located is extracted to form a colorimetric card area.
[0091] Among them, deep learning segmentation algorithm models include Mask-RCNN, YOLO, U-Net, and FCN models.
[0092] Furthermore, after the sampled image is segmented into the coffee bean region and the colorimetric card region, the method further includes:
[0093] Performing color smoothing processing on the coffee bean area and the colorimetric card area;
[0094] Determine whether there is a color abnormal region in the coffee bean region after color smoothing processing, and if so, use the coffee bean region as a target processing image; or determine whether there is a color abnormal region in the colorimetric card region after color smoothing processing, and if so, use the colorimetric card region as a target processing image;
[0095] According to the complexity and noise level of the target processed image, a region with normal color is selected as a cluster to form a plurality of clusters;
[0096] Initialize the center point of each cluster;
[0097] Assigning each pixel in the target processed image to the nearest cluster center;
[0098] Recalculate the center point of each cluster until convergence.
[0099] The clustering method is K-means clustering method. The colors in the area are clustered using the clustering algorithm (K-Means). After clustering, the color area of each coffee bean is obtained, and the H value of the coffee bean area is calculated and compared with the color card area to obtain the color of the coffee bean.
[0100] The color abnormality area is an area where a color mutation occurs. It can be understood that the coffee bean area or the colorimetric card area after color smoothing should be an area with uniform color. If there is an area where a color mutation occurs in the coffee bean area or the colorimetric card area, the area where the color mutation occurs is determined to be a color abnormality area.
[0101] When there are color abnormal areas, multiple clusters are formed and the center point of each cluster is calculated until convergence to filter out the noise color in the pixels of each cluster, ensuring that the obtained color area is the coffee bean area that actually needs to be detected, and selecting the point in the coffee bean area that best represents the color of the area.
[0102] The specific implementation process of forming multiple clusters and calculating the center point of each cluster until convergence is as follows.
[0103] First, a deep learning segmentation model is used to process the coffee bean image and generate the segmentation result of the target processed image. The segmentation result contains the category label of each pixel, where a specific label is assigned to the coffee bean region. By analyzing the obtained labels, each coffee bean region is extracted, and the RGB value set {R, G, B} of the pixels inside each region is calculated.
[0104] Secondly, for each coffee bean area, generate an RGB pixel matrix, including the color information of all pixels in the area. In the initialization of the K-means algorithm, set the target number of clusters K, which is usually adjusted based on the number of coffee bean areas. Preferably, each coffee bean area is set to 1 by default. Merge all extracted RGB pixel points into a unified data set and input the K-means algorithm for processing: perform the assignment of pixels to the nearest cluster center, and calculate the distance between each pixel and all cluster centers based on the Euclidean distance. Iterate the calculation of cluster centers, and continuously update the center points through clustering results until the convergence condition is reached, that is, the position of the cluster center no longer changes significantly.
[0105] Finally, the cluster center of each clustered coffee bean region is mapped back to the original coffee bean image, and the H value of the cluster center is calculated.
[0106] Furthermore, the converting the RGB domain color value of the sub-area into the HSV domain color value, and the converting the RGB domain color value of the sub-area into the HSV domain color value includes:
[0107] Get the RGB domain color value {R, G, B}, where the value range of R, G, B is [0,255];
[0108] use Normalize the RGB domain color values {R, G, B} to the range of [0, 1];
[0109] Calculate the hue value H, saturation value S, and brightness value V corresponding to the HSV domain:
[0110]
[0111] In the HSV color model, the hue value H is usually expressed as an angle value from 0 to 360 degrees, corresponding to different colors. By extracting {H} from the converted {H, S, V} set and averaging it, we can get the hue value H corresponding to the HSV domain.
[0112] R (Red Channel): Indicates the intensity of red in the image. The range is usually between 0 and 255, where 0 represents no red and 255 represents the maximum intensity of red.
[0113] G (Green Channel): Indicates the intensity of green in the image. The range is also between 0 and 255, with 0 indicating no green and 255 indicating the maximum intensity of green.
[0114] B (blue channel): represents the intensity of blue in the image. It also ranges from 0 to 255, where 0 means no blue and 255 means the maximum intensity of blue.
[0115] H (Hue Channel): Indicates the type or purity of color. Usually ranges from 0 to 360 degrees, corresponding to different color types, such as red, green, blue, etc.
[0116] S (Saturation channel): Indicates the saturation of the color, that is, the purity or grayscale of the color. The range is between 0 and 1, 0 represents grayscale, and 1 represents the purest color.
[0117] V (brightness / lightness channel): Indicates the brightness or lightness of the color. The range is between 0 and 1, with 0 representing black and 1 representing the brightest color.
[0118] The present application obtains a sampling image with coffee beans and a colorimetric card, divides the sampling image into a coffee bean area and a colorimetric card area, converts the RGB domain color value of each area into an HSV domain color value, and uses a hue value comparison method to concentrate the hue value of the colorimetric card area and the hue value with the smallest difference from the hue value of the coffee bean area as the color of the coffee bean, thereby ensuring the accuracy and repeatability of the coffee bean maturity assessment and improving the color recognition efficiency of the coffee bean fruit.
[0119] Example 2
[0120] like Figure 5 As shown, Example 2 of the present application provides a coffee bean color comparison device 100, including: an image acquisition module 101, an image segmentation module 102, a colorimetric card hue value set processing module 103, a coffee bean hue value processing module 104 and a coffee bean color recognition module 105.
[0121] The image acquisition module 101 is used to acquire a sample image having coffee beans and a colorimetric card.
[0122] The image segmentation module 102 is used to segment the sample image into a coffee bean area and a colorimetric card area.
[0123] The colorimetric card hue value set processing module 103 is used to obtain the RGB domain color value of each sub-region in the colorimetric card region, perform noise pixel filtering, convert the RGB domain color value of the sub-region into an HSV domain color value, and extract the hue value of each sub-region to form a hue value set of the colorimetric card region.
[0124] The coffee bean hue value processing module 104 is used to obtain the RGB domain color value in the coffee bean area, perform noise pixel filtering, convert the RGB domain color value of the coffee bean area into an HSV domain color value, and extract the hue value of the coffee bean area.
[0125] The coffee bean color recognition module 105 is used to compare the hue value of the coffee bean area with the hue value set of the colorimetric card area, and take the hue value in the hue value set of the colorimetric card area with the smallest difference from the hue value of the coffee bean area as the coffee bean color.
[0126] Furthermore, segmenting the image into a coffee bean area and a colorimetric card area includes:
[0127] Reading the sampled image, and performing grayscale processing on the sampled image to obtain a grayscale image;
[0128] Performing edge detection on the grayscale image to form edge lines;
[0129] The target area of the sampled image is extracted according to the edge line to form the coffee bean area and the colorimetric card area.
[0130] Furthermore, performing edge detection on the grayscale image to form edge lines includes:
[0131] Performing Gaussian filtering on the grayscale image to smooth the image and reduce noise;
[0132] Calculating the image gradient of the grayscale image after Gaussian filtering to form a gradient image;
[0133] Performing non-maximum suppression on the gradient image, retaining the local maximum value, and removing non-edge pixels;
[0134] Double threshold processing is applied to the gradient image to determine strong edge, weak edge and non-edge pixels;
[0135] By connecting the weak edge to the strong edge, a complete edge line is formed.
[0136] Furthermore, the extracting a target area from the sampled image according to the edge line to form the coffee bean area and the colorimetric card area includes:
[0137] generating an edge mask based on the edge line;
[0138] Performing a morphological operation on the edge mask to expand the edge area, wherein the morphological operation includes dilation and erosion processing;
[0139] If the edge area covers the pixels at the edge of the coffee beans or the colorimetric card, the edge mask is reduced proportionally;
[0140] The area where the coffee beans are located is extracted from the sampled image according to the edge mask to form a coffee bean area, and the area where the colorimetric card is located is extracted to form a colorimetric card area.
[0141] Furthermore, segmenting the sampled image into a coffee bean region and a colorimetric card region further includes:
[0142] The trained deep learning segmentation algorithm model is used to extract the area where the coffee beans are located from the sampled image to form a coffee bean area, and the area where the colorimetric card is located is extracted to form a colorimetric card area.
[0143] Furthermore, after the sampled image is segmented into the coffee bean region and the colorimetric card region, the method further includes:
[0144] Performing color smoothing processing on the coffee bean area and the colorimetric card area;
[0145] Determine whether there is a color abnormal region in the coffee bean region after color smoothing processing, and if so, use the coffee bean region as the target processing image; or determine whether there is a color abnormal region in the colorimetric card region after color smoothing processing, and if so, use the colorimetric card region as the target processing image;
[0146] According to the complexity and noise level of the target processed image, a region with normal color is selected as a cluster to form a plurality of clusters;
[0147] Initialize the center point of each cluster;
[0148] Assigning each pixel in the target processed image to the nearest cluster center;
[0149] Recalculate the center point of each cluster until convergence.
[0150] Furthermore, the converting the RGB domain color value of the sub-area into the HSV domain color value, and the converting the RGB domain color value of the sub-area into the HSV domain color value includes:
[0151] Get the RGB domain color value {R, G, B}, where the value range of R, G, B is [0,255];
[0152] use Normalize the RGB domain color values {R, G, B} to the range of [0, 1];
[0153] Calculate the hue value H, saturation value S, and brightness value V corresponding to the HSV domain:
[0154]
[0155] For the specific definition of the coffee bean color comparison device, please refer to the definition of the coffee bean color comparison method above, which will not be repeated here. The various modules in the above-mentioned coffee bean color comparison device can be implemented in whole or in part by software, hardware and a combination thereof. The functions of the various modules in the above-mentioned coffee bean color comparison device refer to the definition of the coffee bean color comparison method. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0156] Example 3
[0157] Embodiment 3 of the present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the coffee bean color comparison method described above when executing the computer program.
[0158] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store coffee bean color comparison data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a coffee bean color comparison method is implemented.
[0159] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0160] Example 4
[0161] Embodiment 4 of the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the coffee bean color comparison method described above are implemented.
[0162] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing related hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct RAMbus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.
[0163] The coffee bean color comparison method, device, computer equipment and storage medium provided in the embodiments of the present application obtain a sampled image with coffee beans and a colorimetric card, segment the sampled image into a coffee bean area and a colorimetric card area, convert the RGB domain color value of each area into an HSV domain color value, and use a hue value comparison method to concentrate the hue value of the colorimetric card area and the hue value with the smallest difference from the hue value of the coffee bean area as the color of the coffee bean, thereby ensuring the accuracy and repeatability of the coffee bean maturity assessment and improving the color recognition efficiency of the coffee bean fruit.
[0164] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0165] The above is a detailed introduction to a coffee bean color comparison method, device, computer equipment and storage medium provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the technical solutions and core ideas of the present application. Ordinary technicians in this field should understand that they can still modify the technical solutions recorded in the aforementioned embodiments, or replace some of the technical features therein with equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for comparing the color of coffee beans, characterized in that: include: Get a sample image with coffee beans and a color chart; Segmenting the sampled image into a coffee bean region and a colorimetric card region; Obtaining RGB domain color values of each sub-region in the colorimetric card region, performing noise pixel filtering, converting the RGB domain color values of the sub-region into HSV domain color values, and extracting the hue value of each sub-region to form a hue value set of the colorimetric card region; Obtaining the RGB domain color value in the coffee bean area, performing noise pixel filtering, converting the RGB domain color value of the coffee bean area into an HSV domain color value, and extracting the hue value of the coffee bean area; The hue value of the coffee bean area is compared with the hue value set of the colorimetric card area, and the hue value in the hue value set of the colorimetric card area with the smallest difference from the hue value of the coffee bean area is taken as the color of the coffee beans.
2. The coffee bean color comparison method according to claim 1, characterized in that: The segmenting of the image into a coffee bean area and a colorimetric card area comprises: Reading the sampled image, and performing grayscale processing on the sampled image to obtain a grayscale image; Performing edge detection on the grayscale image to form edge lines; The target area of the sampled image is extracted according to the edge line to form the coffee bean area and the colorimetric card area.
3. The coffee bean color comparison method according to claim 2, characterized in that: The performing edge detection on the grayscale image to form edge lines comprises: Performing Gaussian filtering on the grayscale image to smooth the image and reduce noise; Calculating the image gradient of the grayscale image after Gaussian filtering to form a gradient image; Performing non-maximum suppression on the gradient image, retaining the local maximum value, and removing non-edge pixels; Double threshold processing is applied to the gradient image to determine strong edge, weak edge and non-edge pixels; By connecting the weak edge to the strong edge, a complete edge line is formed.
4. The coffee bean color comparison method according to claim 3, characterized in that: The extracting the target area of the sampled image according to the edge line to form the coffee bean area and the colorimetric card area comprises: generating an edge mask based on the edge line; Performing a morphological operation on the edge mask to expand the edge area, wherein the morphological operation includes dilation and erosion processing; If the edge area covers the pixels at the edge of the coffee beans or the colorimetric card, the edge mask is reduced proportionally; The area where the coffee beans are located is extracted from the sampled image according to the edge mask to form a coffee bean area, and the area where the colorimetric card is located is extracted to form a colorimetric card area.
5. The coffee bean color comparison method according to claim 1, characterized in that: Segmenting the sampled image into a coffee bean region and a colorimetric card region further includes: The trained deep learning segmentation algorithm model is used to extract the area where the coffee beans are located from the sampled image to form a coffee bean area, and the area where the colorimetric card is located is extracted to form a colorimetric card area.
6. The coffee bean color comparison method according to claim 1, characterized in that: After the sample image is segmented into the coffee bean area and the colorimetric card area, the method further includes: Performing color smoothing processing on the coffee bean area and the colorimetric card area; Determine whether there is a color abnormal region in the coffee bean region after color smoothing processing, and if so, use the coffee bean region as the target processing image; or determine whether there is a color abnormal region in the colorimetric card region after color smoothing processing, and if so, use the colorimetric card region as the target processing image; According to the complexity and noise level of the target processed image, a region with normal color is selected as a cluster to form a plurality of clusters; Initialize the center point of each cluster; Assigning each pixel in the target processed image to the nearest cluster center; Recalculate the center point of each cluster until convergence.
7. The coffee bean color comparison method according to claim 1, characterized in that: The converting the RGB domain color value of the sub-area into the HSV domain color value, and the converting the RGB domain color value of the sub-area into the HSV domain color value comprises: Get the RGB domain color value {R, G, B}, where the value range of R, G, B is [0,255]; use Normalize the RGB domain color values {R, G, B} to the range of [0, 1]; Calculate the hue value H, saturation value S, and brightness value V corresponding to the HSV domain:
8. A coffee bean color comparison device, characterized in that: The coffee bean color comparison device comprises: An image acquisition module, used for acquiring a sampling image having coffee beans and a colorimetric card; An image segmentation module, used for segmenting the sampled image into a coffee bean area and a colorimetric card area; A colorimetric card hue value set processing module is used to obtain the RGB domain color value of each sub-region in the colorimetric card region, perform noise pixel filtering, convert the RGB domain color value of the sub-region into an HSV domain color value, and extract the hue value of each sub-region to form a hue value set of the colorimetric card region; A coffee bean hue value processing module is used to obtain the RGB domain color value in the coffee bean area, perform noise pixel filtering, convert the RGB domain color value of the coffee bean area into an HSV domain color value, and extract the hue value of the coffee bean area; The coffee bean color recognition module is used to compare the hue value of the coffee bean area with the hue value set of the colorimetric card area, and take the hue value with the smallest difference between the hue value of the coffee bean area and the hue value of the colorimetric card area as the coffee bean color.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the coffee bean color comparison method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Textile color detection method and system based on image recognition
CN114648594A
Plant color comparison method, device and equipment and storage medium
CN114840704A
Color clustering and segmentation using sigma filtering
US20020114512A1
