Pepper detection method and device based on image processing, terminal and storage medium
Through image processing-based methods, the appearance shape and color characteristics of peppers are automatically obtained, which solves the problems of strong subjectivity and low efficiency of manual detection, and achieves efficient, accurate grading and quality control of peppers.
Patent Information
- Application Number
- CN202411046995.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-01
- Publication Date
- 2024-11-22
AI Technical Summary
In the prior art, pepper detection relies on artificial sensory testing, which is subjective, inefficient, and lacks consistency, and cannot adapt to modern efficient production needs.
Using an image-based processing method, the pepper images are collected, the appearance shape parameters and color characteristics are obtained, and the peppers are automatically graded according to the preset grading standards to realize automatic detection of peppers.
It improves the efficiency and consistency of pepper detection, reduces manual errors, improves the accuracy and standardization of test results, can effectively distinguish high-quality, qualified and unqualified peppers, and improves the accuracy of pepper quality control.
Smart Images

Figure CN119007191A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image recognition, and in particular to a pepper detection method, device, terminal and storage medium based on image processing. Background Art
[0002] Since peppers face mechanical damage and breakage during the production process from harvesting to processing into products, humidity changes, and color degradation caused by exposure to light and air during natural drying, the same batch of products has significant differences in size and color, affecting the quality and market acceptance of the final product. The existing technology for detecting appearance shape and color mainly relies on manual sensory inspection, which has the disadvantages of strong subjectivity, low efficiency, lack of consistency, and difficulty in adapting to the needs of modern efficient production. Summary of the invention
[0003] The purpose of the embodiments of the present application is to provide a pepper detection method, device, equipment and storage medium based on image processing, so as to solve the technical problems in the prior art that pepper detection through manual detection is highly subjective, inefficient, lacks consistency and cannot be produced efficiently.
[0004] In a first aspect, the present invention provides a pepper detection method based on image processing, comprising:
[0005] Collecting pepper images, and obtaining appearance shape parameters of each pepper according to the pepper images;
[0006] Acquire color features of each of the peppers according to the pepper image;
[0007] The peppers are graded according to the appearance shape parameters and the color characteristics to obtain a graded test result.
[0008] In an optional implementation manner, acquiring the appearance shape parameters of each pepper according to the pepper image includes:
[0009] Preprocessing the pepper image according to a preset image processing method to obtain a processed pepper image;
[0010] The processed pepper image is analyzed by a preset image analysis method to obtain appearance shape parameters of each pepper, wherein the appearance shape parameters include the length and width of the pepper.
[0011] In an optional implementation manner, acquiring the color feature of each pepper according to the pepper image includes:
[0012] Analyze the pepper image to obtain color components of the pepper, wherein the color components include a first color component, a second color component, and a third color component;
[0013] The color characteristics of the corresponding pepper are calculated according to each of the color components, wherein the color characteristics include a key color component proportion and a key color component characteristic value.
[0014] In an optional embodiment, the first color component is a red component, the second color component is a green component, the third color component is a blue component, the key color component ratio includes a red component ratio, the key color component feature value includes a red component feature value, and the color feature of the corresponding pepper is calculated according to each of the color components, including:
[0015] The red component ratio is calculated according to formula 1;
[0016] Formula 1:
[0017] Among them, P is the proportion of red component, R is the red component, G is the green component, and B is the blue component;
[0018] The red component characteristic value is calculated according to formula 2;
[0019] Formula 2:
[0020] Among them, S is the eigenvalue of the red component.
[0021] In an optional embodiment, grading each of the peppers according to each of the appearance shape parameters and each of the color characteristics to obtain a grading test result includes:
[0022] The width-to-length ratio of each of the peppers is calculated by using each of the appearance shape parameters;
[0023] Based on the preset grading standard, each pepper is graded according to the width-to-length ratio and the color characteristics to obtain a corresponding grading test result.
[0024] In an optional embodiment, the step of grading the peppers according to the width-to-length ratio and the color characteristics based on a preset grading standard to obtain corresponding grading test results includes:
[0025] When the width-to-length ratio is within the numerical range from the first preset threshold to the second preset threshold, the red component proportion is greater than or equal to the first preset proportion threshold, and the color feature is greater than or equal to the first preset feature threshold, the corresponding pepper is detected as a qualified pepper;
[0026] When the width-to-length ratio is within the numerical range from the second preset threshold to the third preset threshold, the red component proportion is greater than the second preset proportion threshold, and the color feature is greater than the second preset feature threshold, the corresponding pepper is detected as a high-quality pepper;
[0027] When the width-to-length ratio is less than the fourth preset threshold or the red component proportion is less than the first preset proportion threshold or the color feature is less than the first preset feature threshold, the corresponding pepper is detected as unqualified pepper.
[0028] In an optional embodiment, it also includes:
[0029] The detection result is marked in the corresponding image area of each pepper in a preset display mode.
[0030] In a second aspect, the present invention provides a pepper detection device based on image processing, comprising:
[0031] An acquisition module, used for acquiring pepper images and obtaining appearance shape parameters of each pepper according to the pepper images;
[0032] An acquisition module, used for acquiring color features of each of the peppers according to the pepper image;
[0033] The detection module is used to grade the peppers according to the appearance shape parameters and the color characteristics to obtain a graded detection result.
[0034] In a third aspect, the present invention provides a terminal, comprising: a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, it is used to implement the pepper detection method based on image processing as described in the above-mentioned embodiment.
[0035] In a fourth aspect, the present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, is used to implement the pepper detection method based on image processing as described in the aforementioned embodiment. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the technical solution of the present invention, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and should not be regarded as limiting the scope of protection of the present invention. In each of the drawings, similar components are numbered similarly.
[0037] Figure 1 A schematic diagram of a process of pepper detection method based on image processing is shown;
[0038] Figure 2 A schematic diagram of pepper appearance parameters in an implementation is shown;
[0039] Figure 3 Another schematic diagram of a pepper detection method based on image processing is shown;
[0040] Figure 4 A schematic diagram of pepper image processing in an implementation is shown;
[0041] Figure 5 Another schematic diagram of the process of pepper detection method based on image processing is shown;
[0042] Figure 6 Another schematic diagram of a pepper detection method based on image processing is shown;
[0043] Figure 7 A schematic diagram of the structure of a pepper detection device based on image processing is shown;
[0044] Figure 8 A schematic diagram of the structure of the terminal is shown.
[0045] Icons: 700 - pepper detection device based on image processing; 701 - acquisition module; 702 - acquisition module; 703 - detection module; 800 - terminal; 801 - transceiver; 802 - processor; 803 - memory. DETAILED DESCRIPTION
[0046] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.
[0047] The components of the embodiments of the present invention generally described and shown in the drawings herein may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0048] Hereinafter, the terms "including", "having" and their cognates, which may be used in various embodiments of the present invention, are intended only to indicate specific features, numbers, steps, operations, elements, components or combinations of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or combinations of the foregoing items or adding the possibility of one or more features, numbers, steps, operations, elements, components or combinations of the foregoing items.
[0049] Furthermore, the terms “first”, “second”, “third”, etc. are merely used for distinguishing descriptions and are not to be understood as indicating or implying relative importance.
[0050] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art to which the various embodiments of the present invention belong. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present invention.
[0051] At present, the use of manual sensory inspection to detect the appearance, color and overall condition of peppers not only requires a large amount of manpower to maintain a stable inspection state for a long time, but also has the problems of strong subjectivity, low efficiency and lack of consistency.
[0052] In response to the above technical problems, the embodiments of the present invention provide a pepper detection method, device, terminal and storage medium based on image processing, aiming to solve the technical problems in the prior art that pepper detection through manual detection is highly subjective, inefficient, lacks consistency and cannot be efficiently produced.
[0053] Example 1
[0054] like Figure 1 As shown, Figure 1 It is a flow chart of the pepper detection method based on image processing provided in this application.
[0055] The embodiment of the present invention provides a pepper detection method based on image processing, including steps S100-S300, and each step is described below.
[0056] Step S100: collecting pepper images, and obtaining appearance shape parameters of each pepper according to the pepper images.
[0057] Specifically, the original image in the figure, i.e., the captured pepper image, is an image containing a preset number of peppers and a vernier caliper placed flat on a measuring board. One implementation method in this embodiment is to select 100 peppers and place them flat on the measuring board, with the heads of the peppers facing each other, and the tails of the peppers next to the heads of the peppers, without overlapping or leaving any gaps, and evenly spread the 100 peppers on a white background without overlapping. When capturing images, a vernier caliper is placed at the captured area to obtain the appearance size parameters of the peppers and realize the conversion between pixel values and actual distances. The appearance shape parameters include but are not limited to the length, width and area of the peppers, such as Figure 2 As shown, the length is the length of the pepper, that is, the distance from the top of the fruit to the base (L), and the width is the distance at the widest cross section of the pepper body (h).
[0058] In the present embodiment, obtaining the appearance shape parameters of each pepper according to the pepper image specifically refers to performing image processing on the collected pepper image according to a preset image processing method, and the image processing includes but is not limited to: cropping the image to remove unnecessary edge areas, graying and binarizing the image, and other operations to identify the contours of peppers, and using a filter (such as a Gaussian filter) to remove noise; and then analyzing the pepper image after image processing by a preset image analysis method to obtain the appearance shape parameters of each pepper in the pepper image.
[0059] In this embodiment, the collected pepper image is processed according to a preset image processing method, preferably by adjusting the contrast and critical value of the pepper image through Image J software to distinguish the pepper from the background; the image-processed pepper image is analyzed by a preset image analysis method, preferably by analyzing and processing the pepper image through Image J software to obtain data on the length, width and area of each pepper in the pepper image. Image J software is a public image processing software developed by the National Institutes of Health and based on the Java programming language. By performing image processing based on Image J, adjusting the contrast and setting a suitable threshold, the pepper can be effectively separated from the background, thereby improving the accuracy of the measurement. In addition, the measurement tasks of multiple peppers can be processed in batches, reducing the need for manual intervention, and accurately obtaining key data such as the length, width and area of the pepper, providing a basis for subsequent quality control or variety analysis.
[0060] Specifically, Figure 3 As shown, in one implementation of this embodiment, step S100 includes steps S110-S120, and each step is described below:
[0061] Step S110: pre-processing the pepper image according to a preset image processing method to obtain a processed pepper image.
[0062] Specifically, the preset image processing method is preferably to adjust the contrast and critical value of the pepper image through Image J software, and the preprocessing includes adjusting the image for image processing.
[0063] In this embodiment, if Figure 4As shown, the image processing of the collected pepper image according to the preset image processing method is preferably to adjust the pepper image contrast and critical value through Image J software to distinguish the pepper from the background. The specific steps include: firstly importing the original image into Image J software, operating the Image command through the Image J software, then selecting the Type command, and then selecting the 8bit command to convert the original image into a grayscale image, and then executing the Image command, Adjust command, Brightness / Contrast command, Auto command and Apply command in sequence to adjust the contrast between the pepper and the background, thereby converting the grayscale image into an enhanced contrast image, and finally executing the Image command, Adjust command, Threshold command and Apply command in sequence to adjust the critical value so that the edge of the pepper is clearly distinguished from the background, thereby converting the enhanced contrast image into a binary image, and then separating the pepper from the background, thereby improving the accuracy of the measurement.
[0064] Step S120: Analyze the processed pepper image by a preset image analysis method to obtain appearance shape parameters of each pepper, wherein the appearance shape parameters include the length and width of the pepper.
[0065] Specifically, the preset image analysis method is to analyze and process the pepper image through Image J software, and the analysis and processing operation includes analyzing the pepper image information, and processing the pepper image information to obtain the length and width of the corresponding pepper.
[0066] In this embodiment, the pepper image after image processing is analyzed by a preset image analysis method, preferably by Image J software, to obtain the data of the length, width and area of each pepper in the pepper image. The specific steps include: drawing a straight line of a preset length in the pepper image along the scale of the vernier caliper in the image by Image J software, and then setting the scale by executing the Analyze command and the Set Scale command in sequence, setting the actual length and unit corresponding to the preset length in the window, realizing the conversion between the pixel value and the actual distance, and then clicking the command to set the required measurement parameters Analyze→Set Measurements (area, Feret's Diameter), and finally, setting the window by executing the Analyze command and the Analyze particles command in sequence, setting the size range to be measured to 0.5~Infinity, and setting the range to be measured to be greater than 0.5cm 2, impurity particles smaller than this value can be removed, thereby further separating them from background noise, and then clicking OK to obtain the measurement parameter results, that is, the length, width and area data corresponding to all peppers in the pepper image, to achieve batch processing of multiple pepper measurement tasks and reduce the need for manual intervention.
[0067] Step S200, obtaining color features of each of the peppers according to the pepper image.
[0068] Specifically, the color features include the proportion of the red component and the color component characteristic value. The red component proportion refers to the proportion of the red channel intensity in the pepper color to the overall color channel intensity of red, green and blue. The color component characteristic value refers to the proportion of the red channel intensity in the pepper color to the overall color channel intensity of green and blue.
[0069] In this embodiment, the pepper image is analyzed by Image J software to obtain the color component value of the pepper, which specifically includes the red component, the green component and the blue component; the color characteristics of the corresponding pepper are calculated according to the color component values, including the proportion of the red component and the color component characteristic value, so that the pepper grading standard is determined and converted into machine language, so that the pepper detection is more accurate and objective.
[0070] Specifically, Figure 5 As shown, in one implementation of this embodiment, step S210 includes steps S210-S220, and each step is described below:
[0071] Step S210: Analyze the pepper image to obtain color components of the pepper, wherein the color components include a first color component, a second color component, and a third color component.
[0072] Specifically, in one implementation of the present embodiment, the pepper image is analyzed by Image J software to obtain a color histogram of each pepper in the pepper image, and directly obtain component data of each color channel of each pepper, including a first color component, a second color component, and a third color component.
[0073] In this embodiment, the Image command, Analyze command, Tolls command and Color Histogram command are executed in sequence through Image J software to obtain the color histogram of each pepper, and then the color components of each pepper image are obtained, and the intensity data of each color component are extracted respectively, which is used to provide data basis for detecting peppers.
[0074] Step S220: Calculate the color characteristics of the corresponding pepper according to each of the color components, wherein the color characteristics include the proportion of key color components and the characteristic values of key color components.
[0075] Specifically, color features are data support for grading peppers during the detection process, including key color component proportions and key color component feature values.
[0076] In this embodiment, the color characteristics of each pepper are obtained by calculating the key color component proportion and the key color component feature value, so as to quantify the color characteristics of the pepper to describe the overall color intensity and saturation of the pepper, and then to detect the quality of the pepper.
[0077] Specifically, in an implementation of this embodiment, step S220 includes:
[0078] Step S221: Calculate the red component ratio according to Formula 1;
[0079] Formula 1:
[0080] Among them, P is the proportion of red component, R is the red component, G is the green component, and B is the blue component;
[0081] Step S222: Calculate the red component characteristic value according to Formula 2;
[0082] Formula 2:
[0083] Among them, S is the eigenvalue of the red component.
[0084] Specifically, the first color component is a red component, the second color component is a green component, the third color component is a blue component, the key color component ratio includes the red component ratio, the key color component eigenvalue includes the red component eigenvalue, P is the red component ratio, R is the red component, G is the green component, and B is the blue component. In the RGB color space, each color is represented by three integer values ranging from 0 to 255. The red component ratio refers to the ratio of the red component in the three colors, that is, the ratio of the red component in the total value of the red component, the green component, and the blue component, and the red component eigenvalue refers to the ratio of the red component in the total value of the green component and the blue component.
[0085] In this embodiment, the color characteristics of the corresponding pepper are calculated according to each color component, specifically, the red component ratio is calculated according to Formula 1, Formula 1: Wherein, P is the proportion of red component, R is the red component, G is the green component, and B is the blue component; the characteristic value of the red component is calculated according to Formula 2: Among them, S is the eigenvalue of the red component.
[0086] In this embodiment, the red component proportion and the red component characteristic value are calculated by the color components of each pepper to obtain the color characteristics of each pepper, which helps to describe the overall color intensity and saturation of the pepper, thereby quantifying the color characteristics of the pepper for detecting the quality of the pepper.
[0087] Step S300, grading each of the peppers according to each of the appearance shape parameters and each of the color characteristics to obtain a grading detection result.
[0088] In this embodiment, each pepper is graded according to each appearance shape parameter and each color feature to obtain a graded detection result, which means that the width-to-length ratio of each pepper is calculated through the appearance shape parameter, and each pepper is graded according to the width-to-length ratio and color feature of each pepper based on a preset grading standard to obtain a grading detection result corresponding to each pepper, thereby realizing batch detection of peppers, reducing detection costs, and avoiding artificial sensory detection errors and subjective deviations.
[0089] Specifically, Figure 6 As shown, in one implementation of this embodiment, step S310 includes steps S310-S320, and each step is described below:
[0090] Step S310: Calculate the width-to-length ratio of each of the peppers using the appearance shape parameters.
[0091] Specifically, the aspect ratio refers to the ratio of the width, i.e. the distance at the widest cross section of the pepper body (h), to the length, i.e. the distance from the top of the fruit to the base (L).
[0092] In this embodiment, the width-to-length ratio of each pepper is used to obtain the width-to-length ratio of the corresponding pepper, i.e., h / L. Calculating the width-to-length ratio of the pepper can quantify the shape of the pepper, which is helpful in describing the morphological characteristics of the pepper. By comparing the width-to-length ratios of different peppers, the consistency and diversity of their shapes can be evaluated.
[0093] Step S320: Classifying each pepper according to the width-to-length ratio and the color feature based on a preset grading standard to obtain a corresponding grading detection result.
[0094] Specifically, the preset classification standard includes a width-to-length ratio threshold and each color feature threshold.
[0095] In this embodiment, each pepper is graded according to the width-to-length ratio and color characteristics using a preset grading standard to obtain a grading detection result for each pepper.
[0096] Specifically, in an implementation of this embodiment, step S320 includes:
[0097] Step S321: When the width-to-length ratio is within the numerical range from the first preset threshold to the second preset threshold, the red component proportion is greater than or equal to the first preset proportion threshold, and the color component characteristic value is greater than or equal to the first preset characteristic threshold, the corresponding pepper is detected as a qualified pepper;
[0098] Step S322: When the width-to-length ratio is within the numerical range from the second preset threshold to the third preset threshold, the red component proportion is greater than the second preset proportion threshold, and the color component feature value is greater than the second preset feature threshold, the corresponding pepper is detected as a high-quality pepper;
[0099] Step S323: When the width-to-length ratio is less than the third preset threshold or the red component proportion is less than the first preset proportion threshold or the color component characteristic value is less than the first preset characteristic threshold, the corresponding pepper is detected as unqualified pepper.
[0100] Specifically, the first preset threshold is preferably: 0.4, the second preset threshold is preferably: 0.2, the third preset threshold is preferably: 0.15, the first preset ratio threshold is preferably: 90%, the second preset ratio threshold is preferably: 99%, the first preset feature threshold is preferably: 0.853, and the second preset feature threshold is preferably: 1.336.
[0101] In this embodiment, the peppers are graded and screened in combination with their width-to-length ratio and color characteristics to obtain high-quality peppers, qualified peppers and unqualified peppers. The criteria for judging high-quality peppers are: width-to-length ratio of 0.15-0.2, proportion of red pixels>99%, and R / (G+B)>1.336; the criteria for judging qualified peppers are: width-to-length ratio of 0.2-0.4, proportion of red pixels≥90%, and R / (G+B)≥0.853; the criteria for judging unqualified peppers are: width-to-length ratio of <0.15, proportion of red pixels<90%, and R / (G+B)<0.853. That is, when the width-to-length ratio is between 0.4 and 0.2, the proportion of the red component is greater than or equal to 90%, and the color component eigenvalue is greater than or equal to 0.853, the corresponding pepper is detected as a qualified pepper; when the width-to-length ratio is between 0.2 and 0.15, the proportion of the red component is greater than 99%, and the color component eigenvalue is greater than 1.366, the corresponding pepper is detected as a high-quality pepper; when the width-to-length ratio is less than 0.15 or the proportion of the red component is less than 90% or the color component eigenvalue is less than 0.853, the corresponding pepper is detected as an unqualified pepper, thereby converting the pepper grading standard into machine language, facilitating automatic grading, and improving detection efficiency.
[0102] Specifically, in an implementation of this embodiment, it also includes:
[0103] Step S400: marking the detection result in the corresponding image area of each pepper in a preset display mode.
[0104] Specifically, the preset display method includes but is not limited to marking and displaying the detection results in the form of boundary boxes or label texts of different colors.
[0105] In this embodiment, each pepper detection result is marked on the original image through a preset display method, providing a visual display, which is conducive to the subsequent screening and processing of peppers and also provides technical support for automated pepper detection.
[0106] The application adopts the above technical solution to achieve the following effects:
[0107] The present application provides a pepper detection method based on image processing, the method comprising: collecting pepper images, obtaining appearance shape parameters of each pepper according to the pepper images; obtaining color features of each pepper according to the pepper images; grading each pepper according to each appearance shape parameter and each color feature, and obtaining a grading detection result; the present application extracts color features of peppers based on image processing, thereby detecting peppers according to quantized color features, thereby realizing automatic grading of peppers, effectively improving the efficiency and consistency of pepper detection, not only greatly avoiding human errors due to visual physiology, but also improving the accuracy and standardization of the results, effectively distinguishing high-quality peppers, qualified peppers and unqualified peppers, and improving the accuracy of pepper quality control.
[0108] Example 2
[0109] In addition, the present application provides a pepper detection device 700 based on image processing, and its functional module diagram is as follows: Figure 7 As shown, the pepper detection device 700 based on image processing includes:
[0110] The acquisition module 701 is used to acquire pepper images and obtain appearance shape parameters of each pepper according to the pepper images;
[0111] An acquisition module 702 is used to acquire color features of each pepper according to the pepper image;
[0112] The detection module 703 is used to grade the peppers according to the appearance shape parameters and the color characteristics to obtain a graded detection result.
[0113] The pepper detection device 700 based on image processing provided in this embodiment can implement the pepper detection method based on image processing provided in Embodiment 1, and will not be described again here to avoid repetition.
[0114] Example 3
[0115] In addition, an embodiment of the present application provides a terminal, including a memory and a processor, wherein the memory stores a pepper detection program based on image processing, and when the pepper detection program based on image processing is run on the processor, the pepper detection method based on image processing provided in Example 1 is executed.
[0116] For details, see Figure 8 The terminal 800 includes: a transceiver 801, a bus interface and a processor 802, wherein the processor 802 is used to: collect pepper images, and obtain the appearance shape parameters of each pepper according to the pepper images; obtain the color characteristics of each pepper according to the pepper images; and grade each pepper according to each appearance shape parameter and each color characteristic to obtain a graded detection result.
[0117] In one embodiment, the processor 802 is further used to: pre-process the pepper image according to a preset image processing method to obtain a processed pepper image; analyze the processed pepper image by a preset image analysis method to obtain appearance shape parameters of each pepper, wherein the appearance shape parameters include the length and width of the pepper.
[0118] In one embodiment, the processor 802 is also used to: analyze the pepper image to obtain color components of the pepper, wherein the color components include a first color component, a second color component, and a third color component; calculate the color features of the corresponding pepper based on each of the color components, wherein the color features include a key color component ratio and a key color component feature value.
[0119] In one implementation, the processor 802 is further configured to: calculate the red component ratio according to Formula 1; Formula 1: Wherein, P is the proportion of red component, R is the red component, G is the green component, and B is the blue component; the characteristic value of the red component is calculated according to Formula 2; Formula 2: Among them, S is the eigenvalue of the red component.
[0120] In one embodiment, the processor 802 is further used to: calculate the width-to-length ratio of each of the peppers through each of the appearance shape parameters; grade each pepper according to the width-to-length ratio and the color characteristics based on a preset grading standard to obtain a corresponding grading detection result.
[0121] In one embodiment, the processor 802 is further used to: when the width-to-length ratio is within the numerical range of a first preset threshold to a second preset threshold, the proportion of the red component is greater than or equal to the first preset proportion threshold, and the color feature is greater than or equal to the first preset feature threshold, the corresponding pepper is detected as a qualified pepper; when the width-to-length ratio is within the numerical range of a second preset threshold to a third preset threshold, the proportion of the red component is greater than the second preset proportion threshold, and the color feature is greater than the second preset feature threshold, the corresponding pepper is detected as a high-quality pepper; when the width-to-length ratio is less than a fourth preset threshold or the proportion of the red component is less than the first preset proportion threshold or the color feature is less than the first preset feature threshold, the corresponding pepper is detected as an unqualified pepper.
[0122] In one embodiment, the processor 802 is further configured to: mark the detection result in a corresponding image area of each pepper in a preset display manner.
[0123] In the embodiment of the present invention, the terminal 800 further includes: a memory 803. Figure 8 In the embodiment, the bus architecture may include any number of interconnected buses and bridges, specifically linking together various circuits of one or more processors represented by processor 802 and memory represented by memory 803. The bus architecture may also link together various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. The bus interface provides an interface. The transceiver 801 may be a plurality of components, namely, a transmitter and a receiver, providing a unit for communicating with various other devices on a transmission medium. The processor 802 is responsible for managing the bus architecture and general processing, and the memory 803 may store data used by the processor 802 when performing operations.
[0124] The terminal 800 provided in the embodiment of the present invention can execute the steps of the pepper detection method based on image processing provided in the above method embodiment 1, which will not be described again here to avoid repetition.
[0125] The terminal provided in this embodiment collects pepper images, obtains appearance shape parameters of each pepper according to the pepper images; obtains color features of each pepper according to the pepper images; grades each pepper according to the appearance shape parameters and the color features to obtain a graded detection result, and extracts color features of the peppers based on image processing, thereby detecting the peppers according to the quantized color features, thereby realizing automatic grading of peppers, effectively improving the efficiency and consistency of pepper detection, and can not only greatly avoid human errors due to visual physiology, but also improve the accuracy and standardization of the results, effectively distinguish between high-quality peppers, qualified peppers and unqualified peppers, and improve the accuracy of pepper quality control.
[0126] Example 4
[0127] The present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the pepper detection method based on image processing provided in Example 1 is implemented.
[0128] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and structure diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the structure diagram and / or the flow chart, and the combination of boxes in the structure diagram and / or the flow chart, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0129] In addition, the functional modules or units in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.
[0130] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0131] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
Claims
1. A pepper detection method based on image processing, It is characterized in that include: Collecting pepper images, and obtaining appearance shape parameters of each pepper according to the pepper images; Acquire color features of each of the peppers according to the pepper image; The peppers are graded according to the appearance shape parameters and the color characteristics to obtain a graded test result.
2. The pepper detection method based on image processing according to claim 1, It is characterized in that The step of obtaining the appearance shape parameters of each pepper according to the pepper image includes: Preprocessing the pepper image according to a preset image processing method to obtain a processed pepper image; The processed pepper image is analyzed by a preset image analysis method to obtain appearance shape parameters of each pepper, wherein the appearance shape parameters include the length and width of the pepper.
3. The pepper detection method based on image processing according to claim 1, It is characterized in that The step of acquiring the color feature of each pepper according to the pepper image includes: Analyze the pepper image to obtain color components of the pepper, wherein the color components include a first color component, a second color component, and a third color component; The color characteristics of the corresponding pepper are calculated according to each of the color components, wherein the color characteristics include a key color component proportion and a key color component characteristic value.
4. The pepper detection method based on image processing according to claim 3, It is characterized in that The first color component is a red component, the second color component is a green component, the third color component is a blue component, the key color component ratio includes a red component ratio, the key color component feature value includes a red component feature value, and the color feature of the corresponding pepper is calculated according to each of the color components, including: The red component ratio is calculated according to formula 1; Formula 1: Among them, P is the proportion of red component, R is the red component, G is the green component, and B is the blue component; The red component characteristic value is calculated according to formula 2; Formula 2: Among them, S is the eigenvalue of the red component.
5. The pepper detection method based on image processing according to claim 4, It is characterized in that The step of grading the peppers according to the appearance shape parameters and the color characteristics to obtain a grading test result includes: The width-to-length ratio of each of the peppers is calculated by using each of the appearance shape parameters; Based on the preset grading standard, each pepper is graded according to the width-to-length ratio and the color characteristics to obtain a corresponding grading test result.
6. The pepper detection method based on image processing according to claim 5, It is characterized in that The step of grading each pepper according to the width-to-length ratio and the color feature based on a preset grading standard to obtain a corresponding grading test result includes: When the width-to-length ratio is within the numerical range from the first preset threshold to the second preset threshold, the red component proportion is greater than or equal to the first preset proportion threshold, and the color feature is greater than or equal to the first preset feature threshold, the corresponding pepper is detected as a qualified pepper; When the width-to-length ratio is within the numerical range from the second preset threshold to the third preset threshold, the red component proportion is greater than the second preset proportion threshold, and the color feature is greater than the second preset feature threshold, the corresponding pepper is detected as a high-quality pepper; When the width-to-length ratio is less than the fourth preset threshold or the red component proportion is less than the first preset proportion threshold or the color feature is less than the first preset feature threshold, the corresponding pepper is detected as unqualified pepper.
7. The pepper detection method based on image processing according to claim 6, It is characterized in that Also includes: The detection result is marked in the corresponding image area of each pepper in a preset display mode.
8. A pepper detection device based on image processing, It is characterized in that include: An acquisition module, used for acquiring pepper images and obtaining appearance shape parameters of each pepper according to the pepper images; An acquisition module, used for acquiring color features of each of the peppers according to the pepper image; The detection module is used to grade the peppers according to the appearance shape parameters and the color characteristics to obtain a graded detection result.
9. A terminal, It is characterized in that include: A processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, it is used to implement the pepper detection method based on image processing as described in any one of claims 1-7.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it is used to implement the pepper detection method based on image processing as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Apple grading method and system based on machine vision
CN110276386A
Evaluation method for aging performance of natural rubber
CN116754467A
Cited By
Measurement method and device for quantifying wrinkle degree of pepper fruits
CN119672703A
