Intelligent detection method of salted duck egg product quality based on visual features
Through visual feature analysis, combining grayscale value differences and local feature values, the real defect edge pixel points of salted duck eggs were screened out, solving the problem of low detection efficiency in the existing technology, and achieving accurate quality detection of salted duck egg products.
Patent Information
- Application Number
- CN202411398326.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-09
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2044-10-09
AI Technical Summary
In the quality inspection of salted duck eggs, the detection efficiency of fine crack defects and spot defects is low, resulting in inaccurate defect detection and affecting the product quality detection effect.
Using intelligent detection methods based on visual features, the real defect edge pixel points are selected by obtaining the surface image and reference frame image of salt duck eggs, the gray value difference and local gray value of the blocked area, and the real defect edge pixel points are selected, combining the blocked area and surface. The difference in the grayscale value of the image, the defect degree value is obtained, and the product quality level is determined.
It improves the accuracy and efficiency of product defect detection, can fully reflect surface characteristics, accurately detect small cracks and spot defects, and improves the accuracy of product quality inspection.
Smart Images

Figure CN118917745B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of image color feature analysis, and in particular to an intelligent detection method for salted duck egg product quality based on visual features. Background Art
[0002] Salted duck eggs, also known as salted eggs, pickled eggs or flavored eggs, are egg products made from fresh duck eggs that are pickled with salt. The quality of salted duck egg products should meet hygiene standards and food safety requirements to prevent food safety problems caused by quality problems of salted duck egg products. Quality testing of salted duck egg products can help manufacturers discover unqualified products in a timely manner, which is conducive to providing high-quality salted duck egg products.
[0003] In order to improve the efficiency of salted duck egg product quality inspection, the existing technology usually uses computer vision technology to inspect the quality of salted duck egg products. The computer vision system can detect the appearance, shape, color and other features of salted duck eggs through highly accurate algorithms and models to determine the quality of salted duck egg products. However, the surface defects of salted duck egg products may include fine crack defects and spot defects. Due to the different characteristics of fine crack defects and spot defects, the existing computer vision technology usually needs to detect one defect separately. However, detecting defects separately will lead to low defect detection efficiency and ignore the influence of another defect, resulting in low defect detection efficiency and inaccurate defect detection. The defect detection effect of salted duck egg products is not good, which will affect the effect of salted duck egg product quality inspection. Summary of the invention
[0004] In order to solve the technical problem that the prior art has poor effect on defect detection of salted duck egg products and affects the effect of quality detection of salted duck egg products, the object of the present invention is to provide an intelligent detection method for salted duck egg product quality based on visual features, and the technical scheme adopted is as follows:
[0005] A method for intelligently detecting the quality of salted duck egg products based on visual features, the method comprising the following steps:
[0006] Acquire a salted duck egg surface image and a reference frame image;
[0007] Acquire multiple block areas of the salted duck egg surface image; acquire regional defect degree values of the block areas according to the gray value difference of the pixel points in the block areas, and the gray value difference between the block areas and the reference frame image; in the salted duck egg surface image, filter out the block defect areas according to the regional defect degree values of all the block areas;
[0008] The pixel points in the block defect area are used as the pixel points to be analyzed; the surrounding pixels of the pixel points to be analyzed in the preset surrounding area are determined; in the preset surrounding area of the pixel points to be analyzed, according to the gray value difference between the pixel points to be analyzed and the surrounding pixels, the local gray value difference value of the pixel points to be analyzed is obtained; according to the local gray value difference value of the pixel points to be analyzed, the gray value difference between the pixel points in the block defect area to which the pixel points to be analyzed belong and the pixel points in the salted duck egg surface image, the defect edge feature value of the pixel points to be analyzed is obtained; in the salted duck egg surface image, according to the defect edge feature values of all the pixel points to be analyzed, each real defect edge pixel point in each pixel points to be analyzed is screened out;
[0009] In the surface image of salted duck eggs, the quality inspection results of salted duck eggs are determined based on all real defect edge pixels.
[0010] Furthermore, the method for obtaining the regional defect degree value specifically includes:
[0011] The regional defect degree value is obtained according to the regional defect degree value formula, and the regional defect degree value formula includes:
[0012] ;in, is the regional defect degree value of the block area; is the maximum grayscale value of the pixel points in the block area; is the minimum grayscale value of the pixel points in the block area; is the total number of all pixels in the reference frame image; In the reference frame image, The gray value of each pixel; In the block area, The gray value of each pixel; is the total number of all pixels in the block area; is the normalization function; is the absolute value symbol.
[0013] Furthermore, the method for obtaining the local grayscale difference value specifically includes:
[0014] In the preset surrounding area of the pixel to be analyzed, calculating the absolute value of the grayscale value difference between the grayscale value of the pixel to be analyzed and the surrounding pixels, to obtain the local feature difference value corresponding to the surrounding pixels;
[0015] The average of the local feature difference values of all surrounding pixels corresponding to the pixel to be analyzed is calculated to obtain the local grayscale difference value of the pixel to be analyzed.
[0016] Furthermore, the method for obtaining the defect edge feature value specifically includes:
[0017] The defect edge eigenvalue is obtained according to the defect edge eigenvalue formula, and the defect edge eigenvalue formula includes:
[0018] ;in, The pixel to be analyzed The defect edge characteristic value of The pixel to be analyzed The local grayscale difference value; is a preset local difference threshold; For the pixel to be analyzed The pixel to be analyzed in the defective block area The total number of pixels with the same grayscale value; is the pixel to be analyzed in the surface image of the salted duck egg The total number of pixels with the same gray value; is the normalization function; Brackets for Iverson.
[0019] Furthermore, the method for obtaining the block area specifically includes:
[0020] According to preset division specifications, the surface image of the salted duck egg is equally divided into a plurality of block areas.
[0021] Furthermore, the method for obtaining the block defect area specifically includes:
[0022] In the salted duck egg surface image, each block area whose regional defect degree value is greater than a preset defect threshold is marked as each block defect area.
[0023] Furthermore, the method for obtaining the preset surrounding area specifically includes:
[0024] The preset surrounding area is a rectangular window constructed with the pixel to be analyzed as the center of the rectangular window and a preset size as the side length of the rectangular window.
[0025] Furthermore, the method for obtaining the real defect edge pixel points specifically includes:
[0026] In the salted duck egg surface image, each pixel point to be analyzed whose defect edge feature value is greater than a preset defect edge threshold is marked as each suspected defect edge pixel point;
[0027] Determine a preset reference range of suspected defect edge pixels; within the preset reference range of suspected defect edge pixels, use the total number of suspected defect edge pixels as a continuous feature value of the suspected defect edge pixels;
[0028] The suspected defect edge pixel points whose continuous characteristic values are greater than the preset continuous characteristic values are marked as real defect edge pixel points.
[0029] Furthermore, the method for obtaining the preset reference range specifically includes:
[0030] The preset reference range is a rectangular window constructed with the suspected defect edge pixel point as the center of the rectangular window and the preset reference specification as the size of the rectangular window.
[0031] Furthermore, the method for obtaining the salted duck egg product quality test results includes:
[0032] In the surface image of the salted duck egg, the total number of all real defect edge pixel points is used as the characteristic defect value of the salted duck egg product; the characteristic defect value of the salted duck egg product is normalized to obtain the defect degree value of the salted duck egg product;
[0033] When the defect degree value of the salted duck egg product in the surface image of the salted duck egg is less than the first set parameter, the quality grade of the salted duck egg product is judged to be excellent; when the defect degree value of the salted duck egg product in the surface image of the salted duck egg is not less than the first set parameter and less than the second set parameter, the quality grade of the salted duck egg product is judged to be good; when the defect degree value of the salted duck egg product in the surface image of the salted duck egg is not less than the second set parameter, the quality grade of the salted duck egg product is judged to be unqualified.
[0034] The present invention has the following beneficial effects:
[0035] The present invention is mainly aimed at accurately detecting defects of salted duck egg products. First of all, considering that the salted duck egg is approximately ellipsoidal, if the surface defects of the salted duck egg are detected only through a certain angle, defects at unobserved angles will be ignored. Therefore, the present invention comprehensively collects the surface of the salted duck egg product to obtain the salted duck egg surface image. The salted duck egg surface image can comprehensively reflect the characteristics of the salted duck egg surface, and at the same time, the surface characteristics of the salted duck egg at a certain angle can be accurately reflected through the reference frame image.
[0036] Since there are fine crack defects and spot defects on the surface defects, and the characteristics of fine crack defects and spot defects are different, if only one of the defects is detected, the existence of the other defect may be ignored. The defect detection of the present invention is not aimed at a single surface defect, but detects both fine crack defects and spot defects, thereby improving the accuracy of defect detection and the efficiency of defect detection. Considering that the defects in the surface image of salted duck eggs show regional distribution, in order to reduce the complexity of subsequent analysis, multiple block areas of the surface image of salted duck eggs are obtained; in order to screen out the block areas with defects, first, according to the gray value difference of the pixel points in the block area, and the gray value difference between the block area and the reference frame image, the regional defect degree value of the block area is obtained; the regional defect degree value reflects the possibility of defects in the area, and then according to the regional defect degree values of all block areas, the block defect area is screened out. The block defect area is the block area with defects, for subsequent analysis of the defect degree of the salted duck eggs.
[0037] Considering that the block defect area is a block area with defects, the block defect area may include fine crack defects and spot defects, and may also include normal duck egg surface areas. In order to more accurately determine the quality of salted duck egg products, due to the presence of fine crack defects and spot defects in salted duck eggs, in the corresponding salted duck egg surface image, the defects present a regional distribution. Since there are edges in the defective area, there are too many pixel points on the defective edge, and the quality of the salted duck egg product is often poor. Therefore, the present invention needs to determine the real defective edge pixel points. There are two types of edges in the block area, one is the edge caused by the defect, and the other is the outer edge of the block area caused by dividing the block area; considering that the grayscale values of the edge caused by the defect and the surrounding area are significantly different, the local grayscale difference value of the pixel to be analyzed is obtained; the smaller the local grayscale difference value, the smaller the The larger the grayscale value difference between the pixel to be analyzed and the surrounding area is, the greater the possibility that the pixel to be analyzed is an edge pixel generated by a defect is. At the same time, taking into account the local grayscale difference value of the pixel to be analyzed and the small proportion of defects in the image, the defect edge eigenvalue of the pixel to be analyzed is further obtained. The larger the defect edge eigenvalue is, the greater the defect edge of the pixel to be analyzed is, and the greater the possibility that the pixel to be analyzed is an edge pixel generated by a defect is. Taking into account the defect edge of the pixel to be analyzed and the continuity of the edge of the defect, the real defect edge pixel is obtained, and the real defect edge pixel can accurately characterize the real defect edge pixels of fine crack defects and spot defects, thereby accurately reflecting the defect degree of fine crack defects and spot defects, and improving the accuracy of salted duck egg product quality inspection. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0039] Figure 1 A flow chart of a method for intelligently detecting the quality of salted duck egg products based on visual features provided by one embodiment of the present invention;
[0040] Figure 2 An image of a process of acquiring an initial image of the surface of a salted duck egg provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0041] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of the intelligent detection method for salted duck egg product quality based on visual features proposed by the present invention, its specific implementation method, structure, characteristics and effects thereof, as follows. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, the specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.
[0042] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
[0043] The specific scheme of the intelligent detection method for salted duck egg product quality based on visual features provided by the present invention is described in detail below with reference to the accompanying drawings.
[0044] See also Figure 1 , which shows a flow chart of a method for intelligent detection of salted duck egg product quality based on visual features provided by an embodiment of the present invention, the method comprising the following steps:
[0045] Step S1, obtaining a salted duck egg surface image and a reference frame image.
[0046] The present invention is mainly aimed at accurately detecting defects of salted duck egg products. First of all, considering that the salted duck egg is approximately ellipsoidal, if the surface defects of the salted duck egg are detected only through a certain angle, defects at unobserved angles will be ignored. Therefore, the present invention comprehensively collects the surface of the salted duck egg product to obtain the salted duck egg surface image. The salted duck egg surface image can comprehensively reflect the characteristics of the salted duck egg surface, and at the same time, the surface characteristics of the salted duck egg at a certain angle can be accurately reflected through the reference frame image.
[0047] Specifically, the present invention selects a suitable collection location and makes the camera maintain a suitable shooting distance and angle to ensure that the surface of the salted duck egg can be clearly collected, and continuously shoots the surface of the salted duck egg within a preset sampling time, during which the salted duck egg will continue to rotate, and stops shooting after the preset sampling time ends to obtain a sampled video. According to the frame number of the camera, the sampled video of the preset sampling time is split into a batch of frame pictures, for example, the video frame number is Frame, you can get The frames are superimposed into an image to obtain the initial image of the surface of the salted duck egg. Figure 2 , which shows an image of a process of obtaining an initial image of the surface of a salted duck egg provided by an embodiment of the present invention. In an embodiment of the present invention, the preset sampling time is 1 second, and the implementer can set it according to the implementation scenario. In an embodiment of the present invention, any frame image is used as the initial frame image to reflect the surface characteristics of the salted duck egg at a certain angle.
[0048] Since the collected initial image and initial frame image of the salted duck egg surface have noise, the noise will affect the subsequent judgment of the quality of the salted duck egg, so the initial image and initial frame image of the salted duck egg surface are subjected to denoising operation to obtain the denoised image and denoised frame image of the salted duck egg surface. The denoised image and denoised frame image of the salted duck egg surface are grayed to obtain the surface image and reference frame image of the salted duck egg. The surface image of the salted duck egg can fully reflect the surface characteristics of the salted duck egg, and the reference frame image can accurately reflect the surface characteristics of the salted duck egg at a certain angle, so as to facilitate the subsequent observation of defects. The embodiment of the present invention adopts bilateral filtering to reduce the noise of the image, and the implementer can set it according to the actual situation. In other embodiments of the present invention, the denoised frame image can also be spliced, and the overall surface image of the salted duck egg obtained after splicing is used as the surface image of the salted duck egg. The image splicing method is a technical means well known to those skilled in the art, and will not be described in detail here.
[0049] It should be noted that, in order to facilitate calculation, all indicator data involved in the calculation in the embodiment of the present invention are preprocessed to eliminate the dimension effect. The specific means of eliminating the dimension effect are technical means well known to those skilled in the art and are not limited here.
[0050] Step S2, obtaining multiple block areas of the salted duck egg surface image; obtaining regional defect degree values of the block areas according to the gray value differences of pixel points in the block areas, and the gray value differences between the block areas and the reference frame image; in the salted duck egg surface image, filtering out the block defect areas according to the regional defect degree values of all the block areas.
[0051] Since surface defects include fine crack defects and spot defects, and the characteristics of fine crack defects and spot defects are different, if only one of the defects is detected, the existence of the other defect may be ignored. The defect detection of the present invention is not aimed at a single surface defect, but detects both fine crack defects and spot defects, thereby improving the accuracy of defect detection and the efficiency of defect detection.
[0052] Since the shell surface of a high-quality salted duck egg is smooth and clean, the color is uniform, there are no cracks or spots, and there are no surface defects from which angle it is observed. Therefore, even if the frame images need to be superimposed in the process of obtaining the surface image of a high-quality salted duck egg, the surface image of a high-quality salted duck egg is still an image with uniform color; for salted duck eggs with surface defects, whether they are salted duck eggs with small crack defects or spot defects, the frame images need to be superimposed in the process of obtaining the corresponding salted duck egg surface images, but when multiple consecutive frame images are superimposed, an effect similar to motion blur will be produced, which will stretch the original small defects and thereby complete the enlargement of the defects, making the defects in the surface image of the defective salted duck egg present a regional distribution. Considering that the defects in the surface image of salted duck eggs show regional distribution, in order to reduce the complexity of subsequent analysis, multiple block areas of the surface image of salted duck eggs are obtained; in order to screen out the block areas with defects, first, according to the gray value difference of the pixels in the block area, and the gray value difference between the block area and the reference frame image, the regional defect degree value of the block area is obtained; the regional defect degree value reflects the possibility of defects in the area, and then according to the regional defect degree values of all block areas, the block defect area is screened out. The block defect area is the block area with defects, which is used for the subsequent analysis of the defect degree of salted duck eggs.
[0053] Preferably, considering that analyzing the entire image will increase the complexity of the analysis, the image is divided into blocks to obtain the block regions. In one embodiment of the present invention, the method for obtaining the block regions specifically includes:
[0054] According to the preset division specifications, the surface image of the salted duck egg is equally divided into multiple block areas. The preset division specification is 15*15, and the implementer can set it according to the implementation scenario. By analyzing the block areas, the block areas with defects can be determined later, avoiding the analysis of the block areas without defects, which increases the complexity of the analysis.
[0055] In other embodiments of the present invention, K-means clustering (K-means clustering algorithm) may be performed on the pixels according to the grayscale values of the pixels to obtain multiple block areas. It should be noted that K-means clustering is a prior art well known to those skilled in the art, and only the method of clustering the pixels according to the grayscale values of the pixels is briefly described here. A brief process of multiple block areas: In the surface image of salted duck eggs, K pixels are randomly selected as the initial cluster centers, and the distance measurement value between two pixels is calculated according to the gray value and Euclidean distance between the two pixels; clustering is performed according to the distance measurement value from the pixel to each cluster center point to obtain multiple block areas.
[0056] Preferably, in order to analyze the defect degree of the block area, the regional defect degree value of the block area is obtained. In one embodiment of the present invention, the method for obtaining the regional defect degree value specifically includes:
[0057] The regional defect degree value is obtained according to the regional defect degree value formula, and the regional defect degree value formula includes:
[0058] ;in, is the regional defect degree value of the block area; is the maximum gray value of the pixel in the block area; is the minimum gray value of the pixel in the block area; is the total number of all pixels in the reference frame image; In the reference frame image, The gray value of each pixel; In the block area, The gray value of each pixel; is the total number of all pixels in the block area; is the normalization function; is the absolute value symbol.
[0059] In the regional defect degree value formula, it is considered that in the salted duck egg surface image, the block area without defects is often uniform in color, and the block area with defects is uneven in color. It reflects the difference in grayscale values in the block area. The greater the difference, the greater the possibility of defects in the block area, and the greater the regional defect degree value of the block area. Considering that the surface color of a single salted duck egg is relatively uniform, but the surface color depth of different salted duck eggs is different, and the defects on the surface of salted duck eggs are often few, the grayscale value of the salted duck egg surface can reflect the grayscale characteristic value of the normal area without defects. is the mean value of the grayscale values of all pixels in the reference frame image. Since the reference frame image can accurately reflect the surface features of the salted duck egg at a certain angle, the mean value reflects the grayscale value of the normal surface of the salted duck egg. It reflects the difference between the grayscale value of the pixel point in the block area and the grayscale value of the normal surface of the salted duck egg. The larger the difference, the more likely the pixel point in the block area is a defective pixel point, and the greater the regional defect degree value of the block area; It reflects the difference between the overall grayscale value of the block area and the grayscale value of the normal surface of the salted duck egg. The larger the difference, the more likely the block area is to be a defective area. The regional defect degree value reflects the possibility of defects in the block area. The larger the regional defect degree value, the more likely the block area is to be a defective area.
[0060] Preferably, in order to screen out defective block regions, in one embodiment of the present invention, a method for obtaining defective block regions specifically includes:
[0061] Since the regional defect degree value reflects the possibility of defects in the block area, in the surface image of the salted duck egg, each block area whose regional defect degree value is greater than the preset defect threshold is marked as each block defect area. The block defect area is a block area with defects. In one embodiment of the present invention, the preset defect threshold is 0.8, and the implementer can set it according to the implementation scenario.
[0062] Step S3, taking the pixel points in the block defect area as the pixel points to be analyzed; determining the surrounding pixels of the pixel points to be analyzed in the preset surrounding area; in the preset surrounding area of the pixel points to be analyzed, obtaining the local grayscale difference value of the pixel points to be analyzed according to the grayscale value difference between the pixel points to be analyzed and the surrounding pixels; obtaining the defect edge feature value of the pixel points to be analyzed according to the local grayscale difference value of the pixel points to be analyzed and the grayscale value difference between the block defect area to which the pixel points to be analyzed belong and the pixel points in the salted duck egg surface image; in the salted duck egg surface image, screening out each real defect edge pixel point in each pixel points to be analyzed according to the defect edge feature values of all the pixels to be analyzed.
[0063] Considering that the block defect area is a block area with defects, the block defect area may include fine crack defects and spot defects, and may also include normal duck egg surface areas. In order to more accurately determine the quality of salted duck egg products, due to the presence of salted duck eggs with fine crack defects and spot defects, in the corresponding salted duck egg surface image, the defects present a regional distribution. Since there are edges in the defective area, there are too many pixel points on the defective edge, and the quality of salted duck egg products is often poor. The present invention needs to determine the real defective edge pixel points. The prior art can detect the pixel points of the defective edge by the edge detection method. However, the edge detection method is difficult to fully detect all defective edges, and the edge detection method usually depends on the adjustment of parameters. Incorrect parameter selection may cause edge omission or false alarm. In addition, the edge detection algorithm may be sensitive to the width of the edge, and the edge detection algorithm is often difficult to ideally detect the pixel points of the defective edge. Taking into account the existence of edges caused by defects in the block area, there is an obvious difference in grayscale values between the edges caused by defects and the surrounding areas, and the local grayscale difference value of the pixel to be analyzed is obtained; the larger the local grayscale difference value, the greater the difference in grayscale values between the pixel to be analyzed and the surrounding areas, and the greater the possibility that the pixel to be analyzed is an edge pixel caused by defects; at the same time, taking into account the local grayscale difference value of the pixel to be analyzed and the small proportion of defects in the image, the defect edge feature value of the pixel to be analyzed is further obtained; the larger the defect edge feature value, the greater the defect edge nature of the pixel to be analyzed, and the greater the possibility that the pixel to be analyzed is an edge pixel caused by defects; according to the defect edge nature of the pixel to be analyzed and the continuity of the defect edge, the real defect edge pixel is obtained, and the real defect edge pixel can accurately characterize the real defect edge pixels of small crack defects and spot defects.
[0064] Specifically, in order to analyze the possibility that the pixels in the block defect area are real defect edge pixels, the pixels in the block defect area are used as pixels to be analyzed; the characteristics of the pixels in the surrounding area of the pixels to be analyzed are studied, and then the possibility that the pixels to be analyzed are real defect edge pixels is analyzed.
[0065] Preferably, in order to study the characteristics of the pixels in the surrounding area of the pixel to be analyzed, a preset surrounding area of the pixel to be analyzed is first constructed. In one embodiment of the present invention, the method for obtaining the preset surrounding area specifically includes:
[0066] Taking the pixel to be analyzed as the central pixel, a preset surrounding area of size Q*Q is constructed, where Q is the preset size, and all the pixels to be analyzed in the preset surrounding area except the central pixel are taken as surrounding pixels. In one embodiment of the present invention, the preset size is 3, which can be set by the implementer according to the implementation scenario.
[0067] Preferably, considering that the grayscale values of the edge where the defect is generated and the surrounding area are significantly different, the local grayscale difference value of the pixel to be analyzed is obtained, and the method for obtaining the local grayscale difference value specifically includes:
[0068] In a preset surrounding area of the pixel to be analyzed, the absolute value of the grayscale value difference between the pixel to be analyzed and the surrounding pixels is calculated to obtain the local feature difference value corresponding to the surrounding pixels;
[0069] Calculate the average of the local feature difference values of all surrounding pixels corresponding to the pixel to be analyzed to obtain the local grayscale difference value of the pixel to be analyzed.
[0070] The local grayscale difference value is obtained according to the local grayscale difference value formula, and the local grayscale difference value formula includes:
[0071] ;in, The pixel to be analyzed The local grayscale difference value; The pixel to be analyzed Gray value of For the pixel to be analyzed The total number of all surrounding pixels in the preset surrounding area; For the pixel to be analyzed In the preset surrounding area, The grayscale value of the surrounding pixels.
[0072] In the local grayscale difference value formula, considering the large difference in grayscale values between the defect area and the normal duck egg area, there is an obvious difference in grayscale values between the edge where the defect occurs and the surrounding area. It reflects the grayscale value difference between the pixel to be analyzed and all surrounding pixels. The larger the difference, the more obvious the grayscale value difference between the pixel to be analyzed and the surrounding area, and the greater the possibility that the pixel to be analyzed is an edge pixel caused by a defect. The local grayscale difference value represents the grayscale value difference between the pixel to be analyzed and the surrounding area. The larger the local grayscale difference value, the greater the possibility that the pixel to be analyzed is an edge pixel caused by a defect.
[0073] Preferably, in order to analyze the defect edge of the pixel to be analyzed, the pixel to be analyzed is obtained. In one embodiment of the present invention, a method for obtaining a defect edge feature value specifically includes:
[0074] The defect edge eigenvalue is obtained according to the defect edge eigenvalue formula, and the defect edge eigenvalue formula includes:
[0075] ;in, The pixel to be analyzed The defect edge eigenvalue of The pixel to be analyzed The local grayscale difference value; is a preset local difference threshold; For the pixel to be analyzed The pixel to be analyzed in the block defect area The total number of pixels with the same grayscale value; is the pixel to be analyzed in the surface image of the salted duck egg The total number of pixels with the same gray value; is the normalization function; It is an Iverson bracket. It should be noted that the Iverson bracket is a special mathematical notation. If the condition in the Iverson bracket If satisfied, the value is 1; otherwise, the value is 0. and The specific method of obtaining is: The gray value of the pixel to be analyzed is taken as the first gray value to be analyzed; In the defective block area, the total number of pixels whose grayscale values are the first grayscale value to be analyzed is counted as ; In the salted duck egg surface image, count the total number of pixels whose grayscale values are the first grayscale value to be analyzed as In one embodiment of the present invention, the preset local difference threshold is 13, and the implementer can set it according to the implementation scenario.
[0076] In the defect edge eigenvalue formula, the local grayscale difference value Represents the grayscale value difference between the pixel to be analyzed and the surrounding area. The larger the local grayscale difference value, the greater the possibility that the pixel to be analyzed is an edge pixel caused by a defect. When , it means that the grayscale value of the pixel to be analyzed is close to that of the surrounding area, and the pixel to be analyzed is not an edge pixel where a defect occurs. The value is 0; in the surface image of salted duck eggs, the proportion of pixels in the defective area is small, and the proportion of pixels in the normal area is large; It reflects the ratio between the number of pixels of the first gray value in the block defect area and the number of salted duck egg surface images. If the pixel is a defective pixel, then the number is relatively small in the surface image of the salted duck egg, and the number is relatively large in the defective area of the block. The larger the ratio, the more likely the pixel to be analyzed is a pixel in the defective area, and the larger the defect edge feature value. Considering that the grayscale value difference between the pixel to be analyzed and the surrounding area corresponding to the defect edge area and the normal area adjacent to the defect edge is relatively large, the corresponding The area may be 1; the normal area adjacent to the defect edge affects the accuracy of defect analysis. The defect edge feature value combines and The larger the defect edge feature value is, the stronger the defect edge is, the smaller the possibility that the pixel to be analyzed is a pixel in the normal area adjacent to the defect edge is, and the greater the possibility that the pixel to be analyzed is a pixel in the defect edge area is.
[0077] Preferably, according to the defect edge of the pixel to be analyzed and the continuity of the defect edge, the real defect edge pixel point is obtained. In one embodiment of the present invention, the method for obtaining the real defect edge pixel point specifically includes:
[0078] Considering that the defect edge characteristic value represents the defect edge of the pixel to be analyzed, in the surface image of the salted duck egg, each pixel to be analyzed whose defect edge characteristic value is greater than the preset defect edge threshold is marked as each suspected defect edge pixel; the suspected defect edge pixel reflects the pixel with obvious defect edge. In one embodiment of the present invention, the preset defect edge threshold is 0.9, and the implementer can set it according to the implementation scenario.
[0079] Considering that crack defects and spot defects cannot exist in only one row or one position, the defect edge should also be continuously distributed. First, the surrounding area of the suspected defect edge pixel point is determined, and a preset reference range of the suspected defect edge pixel point is constructed to analyze the continuous distribution characteristics of the suspected defect edge pixel point. Preferably, in one embodiment of the present invention, the method for obtaining the preset reference range specifically includes:
[0080] The preset reference range is a rectangular window constructed with the suspected defect edge pixel point as the center of the rectangular window and the preset reference specification as the size of the rectangular window. In one embodiment of the present invention, the preset reference specification is 3*3, and the implementer can set it according to the implementation scenario.
[0081] Determine a preset reference range of suspected defect edge pixels; within the preset reference range of suspected defect edge pixels, use the total number of suspected defect edge pixels as a continuous feature value of the suspected defect edge pixels;
[0082] The suspected defect edge pixel points whose continuous eigenvalues are greater than the preset continuous eigenvalues are marked as real defect edge pixel points. Real defect edge pixel points are pixel points with large and continuous defect edges, which can accurately characterize real defect edge pixels. In one embodiment of the present invention, the preset continuous eigenvalue is 3, and the implementer can set it according to the implementation scenario.
[0083] Step S4, determining the salted duck egg product quality inspection result based on all real defect edge pixel points in the salted duck egg surface image.
[0084] Through the above steps, the real defect edge pixels of fine crack defects and spot defects can be accurately characterized, thereby accurately reflecting the defect degree of fine crack defects and spot defects, and improving the accuracy of salted duck egg product quality inspection.
[0085] Preferably, the defects are regionally distributed. Since there are edges in the defective area, there are too many pixels at the defective edge, and the quality of the salted duck egg product is often poor. The quality inspection result of the salted duck egg product is determined based on all the real defective edge pixels. In one embodiment of the present invention, the method for obtaining the quality inspection result of the salted duck egg product includes:
[0086] In the surface image of the salted duck egg, the total number of all real defect edge pixels is used as the characteristic defect value of the salted duck egg product; the characteristic defect value of the salted duck egg product is normalized to obtain the defect degree value of the salted duck egg product. In one embodiment of the present invention, the characteristic defect value of the salted duck egg product is normalized by a standard normalization method, which is not limited here.
[0087] When the salted duck egg product defect degree value of the salted duck egg surface image is less than the first setting parameter, the quality grade of the salted duck egg product is determined to be excellent; when the salted duck egg product defect degree value of the salted duck egg surface image is not less than the first setting parameter and less than the second setting parameter, the quality grade of the salted duck egg product is determined to be good; when the salted duck egg product defect degree value of the salted duck egg surface image is not less than the second setting parameter, the quality grade of the salted duck egg product is determined to be unqualified. In this embodiment, the value of the first setting parameter is set to 0.13, the value of the second setting parameter is set to 0.25, and the value of the third setting parameter is set to 0.45. The implementer can set it according to the implementation scenario. So far, the quality test result of the salted duck egg product is determined.
[0088] In summary, the embodiment of the present invention provides an intelligent detection method for salted duck egg product quality based on visual features. First, according to the gray value difference of the pixel points in the block area, and the gray value difference between the block area and the reference frame image, the regional defect degree value of the block area is obtained; then the block defect area is screened out; the local gray difference value of the pixel point to be analyzed is obtained; according to the local gray difference value of the pixel point to be analyzed, the gray value difference between the block defect area to which the pixel point to be analyzed belongs and the pixel point in the surface image of the salted duck egg, the defect edge feature value of the pixel point to be analyzed is obtained; then each real defect edge pixel point in each pixel point to be analyzed is screened out, and the salted duck egg product quality detection result is finally determined. In the embodiment of the present invention, the degree of defect is accurately reflected by the real defect edge pixel point, and the accuracy of salted duck egg product quality detection is improved.
[0089] It should be noted that the sequence of the above embodiments of the present invention is only for description and does not represent the advantages and disadvantages of the embodiments. The processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0090] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.
Claims
1. A method for intelligent detection of salted duck egg product quality based on visual features, characterized in that: The method comprises the following steps: Acquire a salted duck egg surface image and a reference frame image; Acquire multiple block areas of the salted duck egg surface image; acquire regional defect degree values of the block areas according to the gray value difference of the pixel points in the block areas, and the gray value difference between the block areas and the reference frame image; in the salted duck egg surface image, filter out the block defect areas according to the regional defect degree values of all the block areas; The pixel points in the block defect area are used as the pixel points to be analyzed; the surrounding pixels of the pixel points to be analyzed in the preset surrounding area are determined; in the preset surrounding area of the pixel points to be analyzed, according to the gray value difference between the pixel points to be analyzed and the surrounding pixels, the local gray value difference value of the pixel points to be analyzed is obtained; according to the local gray value difference value of the pixel points to be analyzed, the gray value difference between the pixel points in the block defect area to which the pixel points to be analyzed belong and the pixel points in the salted duck egg surface image, the defect edge feature value of the pixel points to be analyzed is obtained; in the salted duck egg surface image, according to the defect edge feature values of all the pixel points to be analyzed, each real defect edge pixel point in each pixel points to be analyzed is screened out; In the surface image of salted duck eggs, the quality inspection result of salted duck eggs is determined according to all real defect edge pixels; The method for obtaining the regional defect degree value specifically includes: The regional defect degree value is obtained according to the regional defect degree value formula, and the regional defect degree value formula includes: ;in, is the regional defect degree value of the block area; is the maximum grayscale value of the pixel points in the block area; is the minimum grayscale value of the pixel points in the block area; is the total number of all pixels in the reference frame image; In the reference frame image, The gray value of each pixel; In the block area, The gray value of each pixel; is the total number of all pixels in the block area; is the normalization function; is the absolute value symbol; The method for obtaining the local grayscale difference value specifically includes: In the preset surrounding area of the pixel to be analyzed, calculating the absolute value of the grayscale value difference between the grayscale value of the pixel to be analyzed and the surrounding pixels, to obtain the local feature difference value corresponding to the surrounding pixels; Calculate the average of the local feature difference values of all surrounding pixels corresponding to the pixel to be analyzed to obtain the local grayscale difference value of the pixel to be analyzed; The method for obtaining the defect edge feature value specifically includes: The defect edge eigenvalue is obtained according to the defect edge eigenvalue formula, and the defect edge eigenvalue formula includes: ;in, The pixel to be analyzed The defect edge characteristic value of The pixel to be analyzed The local grayscale difference value; is a preset local difference threshold; For the pixel to be analyzed The pixel point to be analyzed in the block defect area The total number of pixels with the same grayscale value; is the pixel to be analyzed in the surface image of the salted duck egg The total number of pixels with the same gray value; is the normalization function; Brackets for Iverson.
2. A method for intelligent detection of salted duck egg product quality based on visual features according to claim 1, characterized in that: The method for obtaining the block area specifically includes: According to preset division specifications, the surface image of the salted duck egg is equally divided into a plurality of block areas.
3. A method for intelligent detection of salted duck egg product quality based on visual features according to claim 1, characterized in that: The method for obtaining the block defect area specifically includes: In the salted duck egg surface image, each block area whose regional defect degree value is greater than a preset defect threshold is marked as each block defect area.
4. A method for intelligent detection of salted duck egg product quality based on visual features according to claim 1, characterized in that: The method for obtaining the preset surrounding area specifically includes: The preset surrounding area is a rectangular window constructed with the pixel to be analyzed as the center of the rectangular window and a preset size as the side length of the rectangular window.
5. The intelligent detection method for salted duck egg product quality based on visual features according to claim 1 is characterized in that: The method for obtaining the real defect edge pixel points specifically includes: In the salted duck egg surface image, each pixel point to be analyzed whose defect edge feature value is greater than a preset defect edge threshold is marked as each suspected defect edge pixel point; Determine a preset reference range of suspected defect edge pixels; within the preset reference range of suspected defect edge pixels, use the total number of suspected defect edge pixels as a continuous feature value of the suspected defect edge pixels; The suspected defect edge pixel points whose continuous characteristic values are greater than the preset continuous characteristic values are marked as real defect edge pixel points.
6. The method for intelligent detection of salted duck egg product quality based on visual features according to claim 5, characterized in that: The method for obtaining the preset reference range specifically includes: The preset reference range is a rectangular window constructed with the suspected defect edge pixel point as the center of the rectangular window and the preset reference specification as the size of the rectangular window.
7. The method for intelligent detection of salted duck egg product quality based on visual features according to claim 1, characterized in that: The method for obtaining the quality test results of salted duck egg products includes: In the surface image of the salted duck egg, the total number of all real defect edge pixel points is used as the characteristic defect value of the salted duck egg product; the characteristic defect value of the salted duck egg product is normalized to obtain the defect degree value of the salted duck egg product; When the defect degree value of the salted duck egg product in the surface image of the salted duck egg is less than the first set parameter, the quality grade of the salted duck egg product is judged to be excellent; when the defect degree value of the salted duck egg product in the surface image of the salted duck egg is not less than the first set parameter and less than the second set parameter, the quality grade of the salted duck egg product is judged to be good; when the defect degree value of the salted duck egg product in the surface image of the salted duck egg is not less than the second set parameter, the quality grade of the salted duck egg product is judged to be unqualified.
