Agricultural product skin defect detection system based on image detection
By designing a multi-module agricultural product skin defect detection system, the problem of insufficient detection speed caused by the large amount of image data to be detected is solved, and efficient and accurate agricultural product detection is achieved.
Patent Information
- Application Number
- CN202410762614.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-13
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2044-06-13
AI Technical Summary
In real-time online detection, due to the large amount of data in the image to be detected, the detection speed cannot meet the online production, and it is impossible to effectively solve the shortcomings of traditional detection methods in rapid detection and accuracy.
A skin defect detection system for agricultural products based on image detection is designed, including a data acquisition module, an environmental compensation adjustment module, a local area type matching module, a feature area extraction module and a defect detection module. Through environmental compensation of grayscale images, local area type matching and feature area extraction, detection efficiency and accuracy are improved.
It effectively suppresses the effect of dark or bright light in local areas in the image, improves the accuracy of detection of skin defects in agricultural products, and greatly improves the detection rate and efficiency through coarse positioning and local refinement methods.
Smart Images

Figure CN118747735B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of image detection, and in particular to an agricultural product surface defect detection system based on image detection. Background Art
[0002] The existing technology CN114354628B "A method for detecting defects in root and tuber agricultural products based on machine vision" mainly includes the following steps: S1, image capture; S2, image preprocessing; S3, image analysis; S4, command sending. The surface defects of agricultural products are detected by machine vision to achieve fast and accurate screening. The method of the present invention has simple steps and high execution efficiency. It relies on the common drop-type conveying mechanism of root and tuber crops to capture the falling process, which can obtain a more comprehensive image with high recognition accuracy and good surface defect detection capability.
[0003] The prior art CN105004737B "Fruit surface defect detection method based on adaptive improved gradient information" removes the background of the RGB color image and binarizes it, extracts the edge separately and dilates it once to obtain the contour edge dilation image, converts the color image into a grayscale image and then calculates the normalized gradient image, then uses the gradient histogram statistics to realize the adaptive improvement of the gradient information and automatically calculates the image segmentation threshold, obtains the improved gradient binarization image through image threshold segmentation, subtracts the contour edge dilation image from the improved gradient binarization image to obtain the difference image, and finally performs dilation, hole filling, corrosion and median filtering on the difference image to obtain the fruit surface defect image. The present invention overcomes the situation of uneven brightness of the spherical surface and detects surface defects with different brightness characteristics; the image segmentation threshold is adaptively calculated and obtained without manual selection.
[0004] With the rapid development of digital image processing technology and the improvement of people's quality requirements for agricultural products, traditional manual inspection can no longer obtain satisfactory inspection results due to many reasons. Therefore, machine vision inspection technology is increasingly valued by people. However, in real-time online inspection, the amount of data of the images to be inspected is very large, resulting in the inspection speed cannot meet the requirements of online production. In order to solve the above technical problems, an agricultural product skin defect detection system based on image detection is now provided. Summary of the invention
[0005] In order to solve the above technical problems, the object of the present invention is to provide an agricultural product skin defect detection system based on image detection, comprising a monitoring center, wherein the monitoring center is communicatively connected with a data acquisition module, an environmental compensation adjustment module, a local area type matching module, a feature area extraction module and a defect detection module;
[0006] The data acquisition module is used to collect image data of agricultural products, mark the acquisition time, and set the acquisition cycle;
[0007] The environmental compensation adjustment module is used to obtain the grayscale image of the agricultural product and perform real-time environmental compensation adjustment on the grayscale image;
[0008] The local area type matching module is used to classify each local area in the grayscale image into types and obtain the type of each local area;
[0009] The feature region extraction module is used to set a feature extraction method according to each local region type, and extract a feature local region in each local region according to the feature extraction method, wherein the feature extraction method includes a full extraction method, a dynamic interval extraction method and a random extraction method;
[0010] The defect detection module is used to detect the characteristic local area and determine whether the agricultural product is qualified according to the detection result.
[0011] Furthermore, the process of the environmental compensation adjustment module acquiring the grayscale image of the agricultural product and performing real-time environmental compensation adjustment on the grayscale image includes:
[0012] Preset the template image data of the current acquisition cycle, perform denoising and grayscale preprocessing on the image data of the agricultural products in the current acquisition cycle and the template image data, and obtain a grayscale image and a template grayscale image;
[0013] Quantify the grayscale value of each pixel in the grayscale image and the grayscale image of the multi-angle template into discrete grayscale levels, preset the size of the local area, divide the grayscale image and the grayscale image of the multi-angle template into several local areas according to the size of the local area, and use the image alignment technology to align the pixels of the grayscale image and the grayscale image of the multi-angle template;
[0014] The average grayscale level of each local area in the grayscale image and the multi-angle template grayscale image is obtained, and the grayscale compensation proportional coefficient of each local area in the grayscale image is obtained according to the average grayscale level of each local area in the grayscale image and the multi-angle template grayscale image. The grayscale level of each pixel point in the grayscale image is adjusted according to the grayscale compensation proportional coefficient to generate the adjusted grayscale level of each pixel point in the grayscale image.
[0015] Furthermore, the local region type matching module classifies each local region in the grayscale image into a type, and the process of obtaining the type of each local region includes:
[0016] According to the adjusted grayscale levels of each pixel point in each local area in the grayscale image, a grayscale fluctuation coefficient of each local area and a correlation coefficient between each local area and an adjacent local area are obtained;
[0017] A grayscale fluctuation coefficient threshold and a correlation coefficient threshold are preset, and a local area whose correlation coefficient is less than the correlation coefficient threshold is marked as a distinguished local area;
[0018] Mark the local area whose grayscale fluctuation coefficient is greater than or equal to the grayscale fluctuation coefficient threshold and whose correlation coefficient is greater than or equal to the correlation coefficient threshold as a complex local area;
[0019] A local area whose grayscale fluctuation coefficient is less than the grayscale fluctuation coefficient threshold and whose correlation coefficient is greater than or equal to the correlation coefficient threshold is marked as a normal local area.
[0020] Furthermore, the process of extracting the characteristic local area from the local area by the characteristic area extraction module according to the random extraction method includes:
[0021] If there are several normal local areas in the grayscale image, obtain several normal local areas of the grayscale image to construct a normal local area set, and set the feature extraction method of the normal local area set to a random extraction method;
[0022] According to the number of normal local regions in the normal local region set and the total number of local regions in the grayscale image, a random extraction method feature number u is obtained, u normal local regions are randomly selected from the normal local region set, and the normal local regions are marked as feature local regions.
[0023] Furthermore, the process of extracting the characteristic local area from the local area by the characteristic area extraction module according to all extraction modes includes:
[0024] If there are several complex local regions in the grayscale image, several complex local regions of the grayscale image are obtained to construct a complex local region set, and the feature extraction method of the normal local region set is set to the full extraction method;
[0025] All complex local regions are selected from the complex local region set, and all complex local regions are marked as feature local regions.
[0026] Furthermore, the process of extracting the characteristic local regions from each local region by the characteristic region extraction module according to the dynamic interval extraction method includes:
[0027] If there are several distinguishing local areas in the grayscale image, a Euclidean distance threshold is set, the geometric center pixel points of each distinguishing local area of the grayscale image are obtained, the Euclidean distance between the geometric center pixel points of each distinguishing local area is obtained, several distinguishing local areas whose Euclidean distances are less than the Euclidean distance are aggregated to construct a high-frequency distinguishing coverage area, and the distinguishing local areas whose Euclidean distances with the geometric center pixel points of other distinguishing local areas are greater than the Euclidean distance threshold are marked as individual distinguishing local areas;
[0028] The feature extraction method of each high-frequency distinguishing coverage area and the individual case distinguishing local area is set to a dynamic interval extraction method, and the local areas around each high-frequency distinguishing coverage area and the individual case distinguishing local area are extracted according to the dynamic interval extraction method, and the local areas are marked as feature local areas, and the local areas include distinguishing local areas, normal local areas and complex local areas.
[0029] Furthermore, the process of extracting each high-frequency distinguished coverage area and the local area around the individual distinguished local area by the feature area extraction module according to the dynamic interval extraction method includes:
[0030] Obtain the number of differentiated local areas and the total number of local areas included in the high-frequency differentiated coverage area, obtain the differentiation density of the high-frequency differentiated coverage area according to the number of differentiated local areas and the total number of local areas, and set the interval amount K and the number of interval extraction features P of the high-frequency differentiated coverage area according to the differentiation density;
[0031] Extract each distinguished local area in the high-frequency distinguished coverage area and mark it as a characteristic local area. Starting from each distinguished local area, select a local area every K local areas and mark the local area as a characteristic local area until P characteristic local areas are extracted in the high-frequency distinguished coverage area.
[0032] Set the number of features G and the interval S for extracting the fixed intervals of the case distinguishing local area, construct an exponential model in which the interval S of the case distinguishing local area increases exponentially with the increase of the Euclidean distance between the geometric center pixel point of the marked feature local area and the geometric center pixel point of the case distinguishing local area, mark the case distinguishing local area as the feature local area, start from the case distinguishing local area, select a local area separated by S local areas and mark the local area as the feature local area, and input the interval S into the exponential model to obtain the interval S1, start from the feature local area, select a local area separated by S1 local areas and mark the local area as the feature local area, and input the interval S1 into the exponential model to obtain the interval S2, and so on, until G feature local areas are extracted around the case distinguishing local area.
[0033] Furthermore, the process in which the defect detection module detects the characteristic local area and determines whether the agricultural product is qualified according to the detection result includes:
[0034] The texture feature set of each characteristic local area in the grayscale image is extracted by using the grayscale co-occurrence matrix technology, and the template texture feature set of each local area in the template grayscale image is obtained at the same time. The texture similarity threshold is preset, and the texture feature set of each characteristic local area is compared with the corresponding template texture feature set to obtain the texture similarity of each characteristic local area;
[0035] If the texture similarity of each feature local area is greater than or equal to the texture similarity threshold, the agricultural product is marked as a qualified product;
[0036] If there is a feature local area whose texture similarity is less than the texture similarity threshold, the feature local area is marked as a defective area, and the texture feature set of the local area adjacent to the defective area is extracted by using the gray level co-occurrence matrix technology, and the template texture feature set corresponding to the texture feature set of the adjacent local area is obtained, and the texture feature set of the adjacent local area is compared with the corresponding template texture feature set to obtain the texture similarity of each adjacent local area. If there is an adjacent local area whose texture similarity is less than the texture similarity threshold, the adjacent local area is marked as a defective area, and the texture feature set of the local area adjacent to the defective area is obtained, and the template texture feature set corresponding to the adjacent local area is obtained, and the texture feature set of the adjacent local area is compared with the corresponding template texture feature set, and so on, until the local area adjacent to the defective area is not marked as a defective area, and the area of the defective area is obtained;
[0037] If there is a defective area in the agricultural product, the agricultural product will be marked as a substandard product, and the defect level of the substandard product will be generated according to the area of the defective area.
[0038] Compared with the prior art, the present invention has the following beneficial effects:
[0039] 1. In many cases, due to changes in the surrounding light environment, the template image data of qualified agricultural products pre-taken on the actual production line will inevitably differ from the agricultural products on the actual production line. Therefore, the present invention obtains the grayscale compensation ratio coefficient of each local area in the grayscale image according to the average grayscale level of each local area in the grayscale image and the multi-angle template grayscale image, and then multiplies each pixel value of the grayscale image by the grayscale compensation ratio coefficient, which effectively suppresses the influence of dark or bright light in each local area of the image on the grayscale of the image, thereby ensuring the accuracy of agricultural product skin defect detection.
[0040] 2. Compared with the traditional full-pixel feature comparison efficiency, in order to improve the detection rate, the present invention adopts a rough positioning and local refinement method. For distinguishing local areas, a dynamic interval extraction method is adopted, a full extraction method is adopted for complex local areas, and a random extraction method is adopted for normal local areas. If there are defects in the image to be detected, the approximate position of the defect and partial defects can be detected, and then the defect position can be grown to the surrounding area, so as to completely detect the area of the defect, which can greatly improve the detection rate of agricultural products, and then improve the detection efficiency of agricultural products. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1This is a schematic diagram of an agricultural product skin defect detection system based on image detection according to an embodiment of the present application. DETAILED DESCRIPTION
[0042] The following is a clear and complete description of the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not 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.
[0043] like Figure 1 As shown, the agricultural product skin defect detection system based on image detection includes a monitoring center, and the monitoring center is communicatively connected with a data acquisition module, an environmental compensation adjustment module, a local area type matching module, a feature area extraction module and a defect detection module;
[0044] The data acquisition module is used to collect image data of agricultural products, mark the acquisition time, and set the acquisition cycle;
[0045] The environmental compensation adjustment module is used to obtain the grayscale image of the agricultural product and perform real-time environmental compensation adjustment on the grayscale image;
[0046] The local area type matching module is used to classify each local area in the grayscale image into types and obtain the type of each local area;
[0047] The feature region extraction module is used to set a feature extraction method according to each local region type, and extract a feature local region in each local region according to the feature extraction method, wherein the feature extraction method includes a full extraction method, a dynamic interval extraction method and a random extraction method;
[0048] The defect detection module is used to detect the characteristic local area and determine whether the agricultural product is qualified according to the detection result.
[0049] It should be further explained that, in the specific implementation process, the environmental compensation adjustment module obtains the grayscale image of the agricultural product, and performs real-time environmental compensation adjustment on the grayscale image, including:
[0050] Preset the template image data of the current acquisition cycle, perform denoising and grayscale preprocessing on the image data of the agricultural products in the current acquisition cycle and the template image data, and obtain a grayscale image and a template grayscale image;
[0051] It should be noted that the image data of agricultural products captured by the data acquisition module may have noise problems. Therefore, in one embodiment of the present invention, after the image data is obtained, it is necessary to perform image preprocessing operations on it to improve the quality of the image data so as to obtain image data for subsequent analysis. Improving the image quality through image preprocessing operations is an image processing method well known to those skilled in the art. In the embodiment of the invention, the noise in the image is removed by a Gaussian filtering method, and then the image data is equalized to improve the contrast within the image, and the image data is grayed to convert the color image into a grayscale image. The graying process is usually achieved by averaging the weights of the color channels, wherein denoising and equalization processing and graying are technical means well known to those skilled in the art, and the specific steps are not repeated here. Other image preprocessing methods may also be used in other embodiments of the present invention, which are not limited here.
[0052] Quantify the grayscale value of each pixel in the grayscale image and the grayscale image of the multi-angle template into discrete grayscale levels, preset the size of the local area, divide the grayscale image and the grayscale image of the multi-angle template into several local areas according to the size of the local area, and use the image alignment technology to align the pixels of the grayscale image and the grayscale image of the multi-angle template;
[0053] The average grayscale level of each local area in the grayscale image and the multi-angle template grayscale image is obtained, and the grayscale compensation proportional coefficient of each local area in the grayscale image is obtained according to the average grayscale level of each local area in the grayscale image and the multi-angle template grayscale image. The grayscale level of each pixel point in the grayscale image is adjusted according to the grayscale compensation proportional coefficient to generate the adjusted grayscale level of each pixel point in the grayscale image.
[0054] It should be further explained that, in the specific implementation process, the calculation formula for obtaining the grayscale compensation ratio coefficient of each local area in the grayscale image according to the average grayscale level of each local area in the grayscale image and the multi-angle template grayscale image is:
[0055]
[0056] Wherein, df represents the grayscale compensation ratio coefficient of the local area, s represents the average grayscale level of the local area in the grayscale image, sd represents the average grayscale level of the local area in the multi-angle template grayscale image, and b represents the adjustment coefficient;
[0057] The calculation formula for adjusting the grayscale level of each pixel in the grayscale image according to the grayscale compensation ratio coefficient is:
[0058] hj * = df × hj;
[0059] Among them, hj represents the gray level, hj *Indicates the gray level after adjustment.
[0060] In many cases, due to changes in the surrounding light environment, the template image data of qualified agricultural products pre-taken on the actual production line will inevitably differ from the agricultural products on the actual production line. Therefore, the present invention obtains the grayscale compensation proportional coefficient of each local area in the grayscale image based on the average grayscale level of each local area in the grayscale image and the multi-angle template grayscale image, and then multiplies each pixel value of the grayscale image by the grayscale compensation proportional coefficient, thereby effectively suppressing the impact of dark or bright light in each local area of the image on the grayscale of the image, thereby ensuring the accuracy of agricultural product skin defect detection.
[0061] It should be further explained that, in a specific implementation process, the local region type matching module classifies each local region in the grayscale image into types, and the process of obtaining the type of each local region includes:
[0062] According to the adjusted grayscale level of each pixel point in each local area in the grayscale image, a grayscale fluctuation coefficient of each local area and a correlation coefficient between each local area and an adjacent local area are obtained;
[0063] A grayscale fluctuation coefficient threshold and a correlation coefficient threshold are preset, and a local area whose correlation coefficient is less than the correlation coefficient threshold is marked as a distinguished local area;
[0064] Mark the local area whose grayscale fluctuation coefficient is greater than or equal to the grayscale fluctuation coefficient threshold and whose correlation coefficient is greater than or equal to the correlation coefficient threshold as a complex local area;
[0065] A local area whose grayscale fluctuation coefficient is less than the grayscale fluctuation coefficient threshold and whose correlation coefficient is greater than or equal to the correlation coefficient threshold is marked as a normal local area.
[0066] It should be further explained that, in the specific implementation process, according to the gray level of each pixel point in each local area in the gray image after adjustment, the calculation formula for obtaining the gray fluctuation coefficient of each local area and the correlation coefficient between each local area and the adjacent local area is:
[0067]
[0068] Among them, JKL represents the grayscale fluctuation coefficient of the local area, D x represents the gray level of the x-th pixel in the local area, DA represents the average gray level of the local area, n represents the total number of pixels, and θ represents the conversion coefficient;
[0069]
[0070] Among them, γ represents the correlation coefficient, D(i, j) represents the grayscale level of the pixel in the i-th row and j-th column in the local area, m, r represent the number of rows and columns of pixels in the local area, V(i, j) represents the grayscale level of the pixel in the i-th row and j-th column in the adjacent local area, and δ represents the conversion coefficient.
[0071] It should be further explained that, in a specific implementation process, the process of extracting the characteristic local region from the local region by the characteristic region extraction module according to the random extraction method includes:
[0072] If there are several normal local areas in the grayscale image, obtain several normal local areas of the grayscale image to construct a normal local area set, and set the feature extraction method of the normal local area set to a random extraction method;
[0073] According to the number of normal local regions in the normal local region set and the total number of local regions in the grayscale image, a random extraction method feature number u is obtained, u normal local regions are randomly selected from the normal local region set, and the normal local regions are marked as feature local regions.
[0074] It should be further explained that, in a specific implementation process, the process of extracting the characteristic local region from the local region by the characteristic region extraction module according to all extraction modes includes:
[0075] If there are several complex local regions in the grayscale image, several complex local regions of the grayscale image are obtained to construct a complex local region set, and the feature extraction method of the normal local region set is set to the full extraction method;
[0076] Select all complex local regions from the complex local region set, and mark all complex local regions as feature local regions;
[0077] It should be further explained that, in a specific implementation process, the process of extracting the characteristic local regions in each local region by the characteristic region extraction module according to the dynamic interval extraction method includes:
[0078] If there are several distinguishing local areas in the grayscale image, a Euclidean distance threshold is set, the geometric center pixel points of each distinguishing local area of the grayscale image are obtained, the Euclidean distance between the geometric center pixel points of each distinguishing local area is obtained, several distinguishing local areas whose Euclidean distances are less than the Euclidean distance are aggregated to construct a high-frequency distinguishing coverage area, and the distinguishing local areas whose Euclidean distances with the geometric center pixel points of other distinguishing local areas are greater than the Euclidean distance threshold are marked as individual distinguishing local areas;
[0079] The feature extraction method of each high-frequency distinguishing coverage area and the individual case distinguishing local area is set to a dynamic interval extraction method, and the local areas around each high-frequency distinguishing coverage area and the individual case distinguishing local area are extracted according to the dynamic interval extraction method, and the local areas are marked as feature local areas, and the local areas include distinguishing local areas, normal local areas and complex local areas.
[0080] It should be further explained that, in a specific implementation process, the process in which the feature region extraction module extracts each high-frequency distinguished coverage region and the local region around the individual distinguished local region according to the dynamic interval extraction method includes:
[0081] Obtain the number of differentiated local areas and the total number of local areas included in the high-frequency differentiated coverage area, obtain the differentiation density of the high-frequency differentiated coverage area according to the number of differentiated local areas and the total number of local areas, and set the interval amount K and the number of interval extraction features P of the high-frequency differentiated coverage area according to the differentiation density;
[0082] It should be noted that the calculation formula for obtaining the differentiation density of the high-frequency differentiation coverage area according to the number of differentiated local areas and the total number of local areas is:
[0083]
[0084] It should be noted that the process of setting the interval K of the high-frequency distinction coverage area and the number P of interval extraction features according to the distinction density is as follows:
[0085] An interval comparison table is pre-constructed, the interval comparison table including interval amounts and interval extraction feature quantities corresponding to different distinction densities, and the interval amount K and interval extraction feature quantity P of the high-frequency distinction coverage area are obtained according to the distinction density and the interval comparison table.
[0086] Extract each distinguished local area in the high-frequency distinguished coverage area and mark it as a characteristic local area. Starting from each distinguished local area, select a local area every K local areas and mark the local area as a characteristic local area until P characteristic local areas are extracted in the high-frequency distinguished coverage area.
[0087] It should be noted that starting from each distinguished local area, a local area is selected every K local areas. The specific process is to select eight directions of up, down, left, right and diagonal directions of the distinguished local area, select a local area every K local areas from each direction and distinguish the local area, and mark the local area as a feature local area;
[0088] Set the number of features G and the interval S for extracting the fixed intervals of the case distinguishing local area, construct an exponential model in which the interval S of the case distinguishing local area increases exponentially with the increase of the Euclidean distance between the geometric center pixel point of the marked feature local area and the geometric center pixel point of the case distinguishing local area, mark the case distinguishing local area as the feature local area, start from the case distinguishing local area, select a local area separated by S local areas and mark the local area as the feature local area, and input the interval S into the exponential model to obtain the interval S1, start from the feature local area, select a local area separated by S1 local areas and mark the local area as the feature local area, and input the interval S1 into the exponential model to obtain the interval S2, and so on, until G feature local areas are extracted around the case distinguishing local area.
[0089] It should be noted that the calculation formula of the exponential model is:
[0090] S1=e 1+αS ;
[0091] SN=e 1+αS(N-1) ; N = 2, 3, ..., G-1;
[0092] Wherein, SN represents the interval, e represents the exponent, and α represents the bias coefficient.
[0093] It should be noted that, starting from the local area distinguishing the individual cases, a local area is selected every S local areas, and the selection direction is eight directions of up, down, left, right and diagonal directions of the local area distinguishing the individual cases, and then a local area is selected every S local areas in each direction and the local area is marked as a feature local area, and the feature local area is subsequently selected and the direction of the local area is consistent with the direction of the local area distinguishing the individual cases where the feature local area is located. For example, starting from the local area distinguishing the individual cases, a local area is selected every S local areas in the left direction and the local area is marked as a feature local area SD, then the interval S is input into the exponential model to obtain the interval S1, starting from the feature local area SD, a local area is selected every S1 local areas in the left direction and the local area is marked as a feature local area.
[0094] It should be further explained that, in the specific implementation process, the defect detection module detects the characteristic local area, and the process of judging whether the agricultural product is qualified according to the detection result includes:
[0095] The texture feature set of each characteristic local area in the grayscale image is extracted by using the grayscale co-occurrence matrix technology, and the template texture feature set of each local area in the template grayscale image is obtained at the same time. The texture similarity threshold is preset, and the texture feature set of each characteristic local area is compared with the corresponding template texture feature set to obtain the texture similarity of each characteristic local area;
[0096] If the texture similarity of each feature local area is greater than or equal to the texture similarity threshold, the agricultural product is marked as a qualified product;
[0097] If there is a feature local area whose texture similarity is less than the texture similarity threshold, the feature local area is marked as a defective area, and the texture feature set of the local area adjacent to the defective area is extracted using the gray level co-occurrence matrix technology, and the template texture feature set corresponding to the texture feature set of the adjacent local area is obtained, and the texture feature set of the adjacent local area is compared with the corresponding template texture feature set to obtain the texture similarity of each adjacent local area. If there is an adjacent local area whose texture similarity is less than the texture similarity threshold, the adjacent local area is marked as a defective area, and the texture feature set of the local area adjacent to the defective area is obtained, and the template texture feature set corresponding to the adjacent local area is obtained, and the texture feature set of the adjacent local area is compared with the corresponding template texture feature set, and so on, until the local area adjacent to the defective area is not marked as a defective area, the area of the defective area is obtained.
[0098] If there is a defective area in the agricultural product, the agricultural product will be marked as a substandard product, and the defect level of the substandard product will be generated according to the area of the defective area.
[0099] It should be noted that, in the specific implementation process, the texture feature set of each feature local area is compared with the corresponding template texture feature set to obtain the texture similarity of each feature local area. The specific process is:
[0100] Based on the calculated gray level co-occurrence matrix, a series of texture features are extracted, and a texture feature set is constructed according to the texture features, and the texture features include:
[0101] Contrast: It is a statistical feature that describes the contrast of pixels at different gray levels in an image. It is a feature that measures the roughness of the image texture and reflects the clarity of the image and the depth of the texture grooves. The deeper the texture grooves, the greater the contrast and the clearer the visual effect. On the contrary, when the contrast is small, the grooves are shallow and the effect is blurred.
[0102] Energy: describes the uniformity of the grayscale distribution of pixels in an image, measures the randomness contained in the image, and shows the complexity of the image. When all values of the co-occurrence matrix are equal or the pixel values show the greatest randomness, the entropy is the largest;
[0103] Homogeneity: describes the similarity of the gray levels of adjacent pixels in the image; reflects the homogeneity of the image texture and measures the local changes in the image texture. A large value indicates that there is a lack of changes between different areas of the image texture and the local texture is very uniform.
[0104] Inverse variance: reflects the clarity and regularity of the texture. The texture is clear and regular.
[0105] The calculation formula of texture similarity of feature local area is:
[0106]
[0107]
[0108] Among them, s represents the texture similarity between the feature local area and the template texture feature set, d represents the contrast between the feature local area and the template texture feature set, ws represents the energy of the feature local area, wd represents the energy of the template texture feature set, es represents the homogeneity of the feature local area, ed represents the homogeneity of the template texture feature set, rs represents the inverse variance of the feature local area, rd represents the inverse variance of the template texture feature set, and a1, a2, a3 and a4 represent weight factors.
[0109] The above embodiments are only used to illustrate the technical method of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical method of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical method of the present invention.
Claims
1. An agricultural product skin defect detection system based on image detection, including a monitoring center, characterized in that: The monitoring center is communicatively connected with a data acquisition module, an environmental compensation adjustment module, a local area type matching module, a feature area extraction module and a defect detection module; The data acquisition module is used to collect image data of agricultural products, mark the acquisition time, and set the acquisition cycle; The environmental compensation adjustment module is used to obtain the grayscale image of the agricultural product and perform real-time environmental compensation adjustment on the grayscale image; The local area type matching module is used to classify each local area in the grayscale image into types and obtain the type of each local area; The feature region extraction module is used to set a feature extraction method according to each local region type, and extract a feature local region in each local region according to the feature extraction method, wherein the feature extraction method includes a full extraction method, a dynamic interval extraction method and a random extraction method; The defect detection module is used to detect the characteristic local area and determine whether the agricultural product is qualified according to the detection result; The process of the environmental compensation adjustment module acquiring the grayscale image of the agricultural product and performing real-time environmental compensation adjustment on the grayscale image includes: Preset the template image data of the current acquisition cycle, perform denoising and grayscale preprocessing on the image data of agricultural products in the current acquisition cycle and the template image data, and obtain a grayscale image and a multi-angle template grayscale image; Quantify the grayscale value of each pixel in the grayscale image and the grayscale image of the multi-angle template into discrete grayscale levels, preset the size of the local area, divide the grayscale image and the grayscale image of the multi-angle template into several local areas according to the size of the local area, and use the image alignment technology to align the pixels of the grayscale image and the grayscale image of the multi-angle template; Obtaining the average grayscale level of each local area in the grayscale image and the multi-angle template grayscale image, obtaining the grayscale compensation ratio coefficient of each local area in the grayscale image according to the average grayscale level of each local area in the grayscale image and the multi-angle template grayscale image, adjusting the grayscale level of each pixel in the grayscale image according to the grayscale compensation ratio coefficient, and generating the adjusted grayscale level of each pixel in the grayscale image; The local area type matching module classifies each local area in the grayscale image into types, and the process of obtaining the type of each local area includes: According to the adjusted grayscale level of each pixel point in each local area in the grayscale image, a grayscale fluctuation coefficient of each local area and a correlation coefficient between each local area and an adjacent local area are obtained; A grayscale fluctuation coefficient threshold and a correlation coefficient threshold are preset, and a local area whose correlation coefficient is less than the correlation coefficient threshold is marked as a distinguished local area; Mark the local area whose grayscale fluctuation coefficient is greater than or equal to the grayscale fluctuation coefficient threshold and whose correlation coefficient is greater than or equal to the correlation coefficient threshold as a complex local area; Mark the local area whose grayscale fluctuation coefficient is less than the grayscale fluctuation coefficient threshold and whose correlation coefficient is greater than or equal to the correlation coefficient threshold as a normal local area; The defect detection module detects the characteristic local area and determines whether the agricultural product is qualified according to the detection result, including: The texture feature set of each characteristic local area in the grayscale image is extracted by using the grayscale co-occurrence matrix technology, and the template texture feature set of each local area in the template grayscale image is obtained at the same time. The texture similarity threshold is preset, and the texture feature set of each characteristic local area is compared with the corresponding template texture feature set to obtain the texture similarity of each characteristic local area; If the texture similarity of each feature local area is greater than or equal to the texture similarity threshold, the agricultural product is marked as a qualified product; The process in which the defect detection module detects the characteristic local area and determines whether the agricultural product is qualified according to the detection result also includes: If there is a feature local area whose texture similarity is less than the texture similarity threshold, the feature local area is marked as a defective area, and the texture feature set of the local area adjacent to the defective area is extracted by using the gray level co-occurrence matrix technology, and the template texture feature set corresponding to the texture feature set of the adjacent local area is obtained, and the texture feature set of the adjacent local area is compared with the corresponding template texture feature set to obtain the texture similarity of each adjacent local area. If there is an adjacent local area whose texture similarity is less than the texture similarity threshold, the adjacent local area is marked as a defective area, and the texture feature set of the local area adjacent to the defective area is obtained, and the template texture feature set corresponding to the adjacent local area is obtained, and the texture feature set of the adjacent local area is compared with the corresponding template texture feature set, and so on, until the local area adjacent to the defective area is not marked as a defective area, and the area of the defective area is obtained; If there is a defective area in the agricultural product, the agricultural product will be marked as an unqualified product, and the defect level of the unqualified product will be generated according to the area of the defective area.
2. The agricultural product skin defect detection system based on image detection according to claim 1 is characterized in that: The process of extracting the characteristic local area in the local area by the characteristic area extraction module according to the random extraction method includes: If there are several normal local areas in the grayscale image, obtain several normal local areas of the grayscale image to construct a normal local area set, and set the feature extraction method of the normal local area set to a random extraction method; According to the number of normal local regions in the normal local region set and the total number of local regions in the grayscale image, a random extraction method feature number u is obtained, u normal local regions are randomly selected from the normal local region set, and the normal local regions are marked as feature local regions.
3. The agricultural product skin defect detection system based on image detection according to claim 2 is characterized in that: The process of extracting the characteristic local area in the local area by the characteristic area extraction module according to all extraction modes includes: If there are several complex local regions in the grayscale image, several complex local regions of the grayscale image are obtained to construct a complex local region set, and the feature extraction method of the normal local region set is set to the full extraction method; All complex local regions are selected from the complex local region set, and all complex local regions are marked as feature local regions.
4. The agricultural product skin defect detection system based on image detection according to claim 3 is characterized in that: The process of extracting the characteristic local area in each local area by the characteristic area extraction module according to the dynamic interval extraction method includes: If there are several distinguishing local areas in the grayscale image, a Euclidean distance threshold is set, the geometric center pixel points of each distinguishing local area of the grayscale image are obtained, the Euclidean distance between the geometric center pixel points of each distinguishing local area is obtained, several distinguishing local areas whose Euclidean distances are less than the Euclidean distance are aggregated to construct a high-frequency distinguishing coverage area, and the distinguishing local areas whose Euclidean distances with the geometric center pixel points of other distinguishing local areas are greater than the Euclidean distance threshold are marked as individual distinguishing local areas; The feature extraction method of each high-frequency distinguishing coverage area and the individual case distinguishing local area is set to a dynamic interval extraction method, and the local areas around each high-frequency distinguishing coverage area and the individual case distinguishing local area are extracted according to the dynamic interval extraction method, and the local areas are marked as feature local areas, and the local areas include distinguishing local areas, normal local areas and complex local areas.
5. The agricultural product skin defect detection system based on image detection according to claim 4 is characterized in that: The process of extracting each high-frequency distinguished coverage area and the local area around the individual distinguished local area by the feature area extraction module according to the dynamic interval extraction method includes: Obtain the number of differentiated local areas and the total number of local areas included in the high-frequency differentiated coverage area, obtain the differentiation density of the high-frequency differentiated coverage area according to the number of differentiated local areas and the total number of local areas, and set the interval amount K and the number of interval extraction features P of the high-frequency differentiated coverage area according to the differentiation density; Extract each distinguished local area in the high-frequency distinguished coverage area and mark it as a characteristic local area. Starting from each distinguished local area, select a local area every K local areas and mark the local area as a characteristic local area until P characteristic local areas are extracted in the high-frequency distinguished coverage area.
6. The agricultural product skin defect detection system based on image detection according to claim 5 is characterized in that: The process in which the feature region extraction module extracts each high-frequency distinction coverage region and the local region around the individual distinction local region according to the dynamic interval extraction method also includes: Set the number of features G and the interval S for extracting the fixed intervals of the case distinguishing local area, construct an exponential model in which the interval S of the case distinguishing local area increases exponentially with the increase of the Euclidean distance between the geometric center pixel point of the marked feature local area and the geometric center pixel point of the case distinguishing local area, mark the case distinguishing local area as the feature local area, start from the case distinguishing local area, select a local area separated by S local areas and mark the local area as the feature local area, and input the interval S into the exponential model to obtain the interval S1, start from the feature local area, select a local area separated by S1 local areas and mark the local area as the feature local area, and input the interval S1 into the exponential model to obtain the interval S2, and so on, until G feature local areas are extracted around the case distinguishing local area.
Citation Information
Patent Citations
Fruit Surface Defect Detection Method Based on Adaptive Improved Gradient Information
CN105004737B
A Machine Vision-Based Defect Detection Method for Root and Tuber Agricultural Products
CN114354628B
Defect detection method and device and computer readable storage medium
CN112767396A
Product surface defect detection method and device, computer equipment and medium
CN114862776A