Corn oil quality detection method based on image processing

By adaptive grayscale division and grayscale symbiosis matrix calculation on the surface grayscale image of corn oil, the problems of time-consuming and labor-intensive and computational volume of traditional detection methods are solved, and the refinement and efficiency of corn oil quality detection are achieved.

CN119919411AActive Publication Date: 2025-05-02SHENYANG JIUDAO TECHNOLOGY CO LTD

Patent Information

Application Number
CN202510405647.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-02
Publication Date
2025-05-02
Estimated Expiration
2045-04-02

AI Technical Summary

Technical Problem

Traditional corn oil quality detection methods rely on manual visual and chemical analysis, which has problems such as time-consuming, labor-consuming and subjective. Inappropriate grayscale classification of grayscale matrix during calculation results in large calculation and low robustness.

Method used

By obtaining the grayscale image of corn oil surface, it is divided into several windows, and adaptive grayscale classification is performed according to the grayscale information and the degree of dispersion of grayscale values ​​in the window, reducing the amount of grayscale symbiosis matrix calculation, while retaining texture features.

Benefits of technology

The refinement and efficiency of corn oil quality inspection is achieved, the calculation amount is reduced, the detection efficiency is improved, and the detection accuracy is ensured.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119919411A_ABST
    Figure CN119919411A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image processing, in particular to a corn oil quality detection method based on image processing, and the method comprises the steps: obtaining a corn oil surface gray level image, and dividing the corn oil surface gray level image into a plurality of windows; obtaining the gray level change degree in the window according to the gray level information in the window and the gray level value dispersion degree; performing adaptive division on gray levels in the window according to the gray level change degree and the gray value probability distribution in the window; and obtaining a window gray-level co-occurrence matrix according to the self-adaptively divided gray levels in the window, obtaining the probability of existence of defects in the window according to the gray-level co-occurrence matrix of each window, and evaluating the quality of the corn oil. On the basis of ensuring the accuracy of corn oil product quality detection, the calculation amount is reduced, and the detection efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of image processing, and in particular to a corn oil quality detection method based on image processing. Background Art

[0002] As people pay more and more attention to food safety and quality, the refined quality detection of corn oil products is becoming more and more important. In the current industry situation, traditional corn oil quality detection methods mainly rely on manual visual inspection and chemical analysis, which are time-consuming, labor-intensive, and highly subjective. Therefore, a refined detection method for corn oil based on image processing is needed. The main defects in corn oil are turbidity, milky white, etc., showing obvious texture characteristics.

[0003] A common method for extracting image texture features is the gray level co-occurrence matrix. By calculating the relationship between different gray levels in the image, the texture features of the image can be extracted, thereby analyzing the defective area. The commonly used gray level co-occurrence matrix uniformly uses a gray level of 255, which lacks consideration of the defects and normal area features in the image. Too high a gray level will result in more computing time in the image texture calculation process. If a lower gray level is used directly, it is easy to cause the texture characteristics of the image to be not fully expressed, reducing the robustness of the algorithm. Summary of the invention

[0004] In order to solve the above problems, the present invention provides a corn oil quality detection method based on image processing, the method comprising: Acquire a grayscale image of the surface of corn oil, and divide the grayscale image of the surface of corn oil into a plurality of windows; The grayscale change degree in the window is obtained according to the grayscale information in the window and the grayscale value discreteness; The fineness of the grayscale division in the window is obtained according to the grayscale range of the grayscale in the window and the number of pixels contained in the grayscale; the threshold of the fineness of the grayscale division in the window is obtained according to the grayscale change degree in the window and the difference between the maximum grayscale value and the minimum grayscale value in the window; the original grayscale in the window is obtained; the original grayscale in the window is initially divided into grayscales according to the fineness of the grayscale division in the window and the threshold of the fineness of the grayscale division in the window, and the grayscale after the initial division in the window and the fineness of the grayscale division after the initial division in the window are obtained; the preferred degree of the grayscale division of the window after the initial grayscale division is obtained according to the fineness of the grayscale division after the initial division in the window; the grayscale after the initial division in the window is divided twice according to the preferred degree of the grayscale division of the window after the initial grayscale division, and the optimal grayscale division result of the window is obtained; The grayscale co-occurrence matrix of the window is obtained according to the optimal grayscale division result of the window; the energy of the grayscale co-occurrence matrix of the window is obtained according to the grayscale co-occurrence matrix of the window; the number of defective windows of the grayscale image of the corn oil surface is obtained according to the energy of the grayscale co-occurrence matrix of the window, and the quality detection of corn oil is completed according to the number of defective windows of the grayscale image of the corn oil surface.

[0005] Preferably, the step of obtaining the grayscale change degree in the window according to the grayscale information in the window and the grayscale value discreteness includes the following specific steps: The first The coefficient of variation of grayscale value in the window is The product of the information entropy of the grayscale values ​​in the windows is recorded as the first product; the reciprocal of the square value of the preset parameter is input into the logarithmic function with base 2 to obtain the output value, which is recorded as the first output value; the negative of the product of the first output value and the square value of the preset parameter is recorded as the first negative number; the ratio of the first product to the first negative number is recorded as the first The degree of grayscale change within a window.

[0006] Preferably, the step of obtaining the fineness of the grayscale division in the window according to the grayscale range of the grayscale in the window and the number of pixels contained in the grayscale includes the following specific steps: The window The sum of the number of grayscale values ​​of the grayscale level and 1 is recorded as the first sum value; the first sum value is added to the first The reciprocal of the product of the number of gray values ​​of the gray levels is taken as the The fineness of the grayscale division.

[0007] Preferably, the grayscale division fineness threshold of the window is obtained according to the grayscale change degree in the window and the difference between the maximum grayscale value and the minimum grayscale value in the window, and the specific steps include the following: No. The difference between the maximum grayscale value and the minimum grayscale value in the first window is recorded as the first difference; The product of the grayscale change degree in the window and the first difference is taken as the The grayscale division fineness threshold of a window.

[0008] Preferably, the initial grayscale division is performed on the original grayscale in the window according to the fineness of the grayscale division in the window and the threshold of the fineness of the grayscale division in the window to obtain the grayscale after the initial division in the window and the fineness of the grayscale division after the initial division in the window, and the specific steps include the following: For windows, in order from small to large. Arrange all the gray values ​​of the windows to get The gray value sequence of the window; first, The minimum gray value of each window is divided into a gray level, which is recorded as the first gray level. The grayscale values ​​in the grayscale value sequence of each window are divided into the first grayscale level in sequence, and after each division, the first grayscale level is calculated. The fineness of the first grayscale division of the window, if the After the jth grayscale value in the grayscale value sequence of the window is divided into the first grayscale level, the fineness of the first grayscale level division is greater than or equal to the jth grayscale value in the grayscale value sequence of the window. The grayscale division fineness threshold of the window is reached, and the division continues; if the After the jth grayscale value in the grayscale value sequence of the window is divided into the first grayscale level, the fineness of the first grayscale level division is less than that of the jth grayscale value. If the grayscale division fineness threshold of the jth window is reached, the division is stopped, and the jth grayscale value is removed from the first grayscale, and the first grayscale is recorded as a complete grayscale; finally, the removed grayscale value is used as a new grayscale and the grayscale division operation is repeated to complete the jth grayscale. The initial grayscale division of the original grayscale in the window is obtained The gray levels of all initial divisions within a window and the fineness of the gray level divisions after all initial divisions.

[0009] Preferably, the step of obtaining the preferred degree of the window grayscale division after the initial grayscale division according to the fineness of the grayscale division after the initial division in the window comprises the following specific steps: After the initial grayscale is divided In the window The fineness of the grayscale division is the same as that of the initial grayscale division. The difference between the grayscale division fineness thresholds of the windows is recorded as the first grayscale division after the initial grayscale division. In the window The initial gray level is divided into the initial difference; The inverse normalized value of the accumulated initial difference of all grayscale divisions in the window is used as the first grayscale division after the initial grayscale division. The preferred degree of grayscale division of each window.

[0010] Preferably, the grayscale after the initial division is divided twice according to the preferred degree of the window grayscale division after the initial grayscale division to obtain the optimal grayscale division result of the window, including the following specific steps: After the initial grayscale is divided Any gray level in the window is recorded as the target gray level, and the rightmost edge gray value in the target gray level is obtained and added to the gray level adjacent to the right side of the target gray level. The preferred degree of grayscale division of the window is recorded as the preferred degree of grayscale division before adding; the rightmost edge grayscale value in the target grayscale is obtained and added to the grayscale adjacent to the right side of the target grayscale after the initial grayscale division. The preferred degree of grayscale division of the window is recorded as the preferred degree of grayscale division after adding; if the preferred degree of grayscale division after adding is greater than the preferred degree of grayscale division before adding, the rightmost edge grayscale value in the target grayscale is added to the grayscale adjacent to the right side of the target grayscale; if the preferred degree of grayscale division after adding is less than or equal to the preferred degree of grayscale division before adding, the original division result is maintained; similarly, after completing the initial grayscale division, All gray levels after initial division in the window are divided into two gray levels to obtain the first The optimal grayscale segmentation result of a window.

[0011] Preferably, the step of obtaining the gray level co-occurrence matrix of the window according to the optimal gray level division result of the window comprises the following specific steps: The grayscale co-occurrence matrix of the corn oil surface grayscale image is calculated based on the optimal grayscale division results of all windows divided by the corn oil surface grayscale image: first, the grayscale co-occurrence matrix is ​​initialized, and each grayscale level and the grayscale value range contained in the grayscale level are recorded in the first row and the first column of the horizontal grayscale co-occurrence matrix, and then the initial values ​​of other positions in the matrix are set to zero; Secondly, the grayscale co-occurrence matrix is ​​calculated according to the grayscale situation of the pixels in the grayscale image of the corn oil surface, and the grayscale values ​​in the grayscale image window of the corn oil surface are traversed. If the grayscale value belongs to the i-th grayscale level of the grayscale division in the window, and the grayscale value of the first adjacent pixel on the right belongs to the j-th grayscale level of the grayscale division, then the count of the i-th row and j-th column in the horizontal grayscale co-occurrence matrix is ​​increased by one; all pixels in the window are traversed to obtain the grayscale co-occurrence matrix of the window.

[0012] Preferably, the method of obtaining the number of defective windows of the grayscale image of the corn oil surface according to the energy of the grayscale co-occurrence matrix of the window and completing the quality detection of the corn oil according to the number of defective windows of the grayscale image of the corn oil surface includes the following specific steps: Preset two threshold parameters According to the gray-level co-occurrence matrix of each window of the corn oil surface grayscale image, the energy of the gray-level co-occurrence matrix of each window is extracted; the energy of the gray-level co-occurrence matrix is ​​less than the threshold The window is recorded as a defect window, and the number of defect windows is counted. If the number of defect windows is greater than or equal to the preset threshold parameter , the quality of the corn oil is unqualified, otherwise, the quality of the corn oil is qualified.

[0013] Preferably, the The method for obtaining the gray value variation coefficient within a window is as follows: The first The ratio between the standard deviation and the mean of the grayscale values ​​in the first window is taken as The coefficient of variation of grayscale values ​​within a window.

[0014] The technical solution of the present invention has the beneficial effect that, in view of the problem of excessive calculation amount caused by too much grayscale division in the process of monitoring corn oil product quality using grayscale co-occurrence matrix, the present invention analyzes the degree of local grayscale change of the image, performs fine grayscale division on the corn oil defect area with drastic local grayscale change, re-divides the original grayscale into grayscale with adaptive segment number, reduces the calculation amount of grayscale co-occurrence matrix, and retains the texture characteristics of pixels. On the basis of ensuring the accuracy of corn oil product quality detection, the calculation amount is reduced and the detection efficiency is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be 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.

[0016] Figure 1 The present invention is a flowchart of the steps of a corn oil quality detection method based on image processing. DETAILED DESCRIPTION

[0017] 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 a corn oil quality detection method based on image processing proposed by the present invention, its specific implementation, structure, features and effects, in conjunction with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.

[0018] 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.

[0019] The specific scheme of the corn oil quality detection method based on image processing provided by the present invention is described in detail below with reference to the accompanying drawings.

[0020] See also Figure 1 , which shows a flowchart of a corn oil quality detection method based on image processing provided by an embodiment of the present invention, the method comprising the following steps: Step S001: Acquire a grayscale image of the surface of corn oil, and divide the grayscale image of the surface of corn oil into a plurality of windows.

[0021] Specifically, the corn oil surface image is collected and grayed to obtain the corn oil surface gray image. The corn oil surface gray image is preprocessed, including noise removal and other processing, so as to remove noise interference, so as to facilitate the subsequent improvement of the contrast of the corn oil surface gray image, so that the corn oil surface information appears more obvious. Among them, the noise removal method of the present embodiment adopts the median filter method, so as to facilitate the subsequent analysis and processing of the corn oil surface gray image. Among them, the median filter is a well-known technology and will not be described in detail here.

[0022] Due to the turbidity defects inside corn oil, the diffusion inside corn oil is slow, which will show strong texture characteristics in the grayscale image of corn oil surface. Grayscale co-occurrence matrix is ​​a commonly used method to extract image texture features. The traditional grayscale co-occurrence matrix is ​​directly calculated based on the grayscale level of 255, which can obtain finer image texture features. However, the overall grayscale range of corn oil image is small, and there are many areas of no interest. Directly using the grayscale level of 255 will cause a lot of waste of computing time and increase the amount of calculation in the subsequent defect extraction process. If a smaller grayscale level is rashly used to calculate the grayscale co-occurrence matrix, a large number of texture characteristics of the area of ​​interest in the image will be lost, reducing the robustness of the algorithm. Therefore, the grayscale image of corn oil surface is windowed, and the complexity of the grayscale value in the window is calculated to set the grayscale level of the window with high complexity to be more refined, and then the final division of grayscale is obtained according to the probability distribution of grayscale values ​​in the image. While reducing the subsequent calculation amount, the texture characteristics in the grayscale image of corn oil surface are retained.

[0023] Preset a parameter , wherein this embodiment is based on The present embodiment is not specifically limited. It depends on the specific implementation situation.

[0024] In order to better obtain the local information of the grayscale image of the corn oil surface, the grayscale image of the corn oil surface is divided into several windows; in this embodiment, the window of the preset size is set to , the implementer can adjust it according to the actual situation, and it is not limited here. The window starts to slide at the upper left corner of the grayscale image of the corn oil surface until it stops at the lower right corner of the grayscale image of the corn oil surface, and the sliding step is w. Among them, the size of the window should be set in combination with the size of the grayscale image of the corn oil surface, so that the number of windows in the grayscale image of the corn oil surface is an integer, and the window can completely divide the grayscale image of the corn oil surface. For the special case that the boundary pixels in the grayscale image of the corn oil surface cannot form a window, the window of the boundary pixels is superimposed with other windows.

[0025] At this point, all windows divided by the grayscale image of the corn oil surface are obtained.

[0026] Step S002: Obtain the grayscale change degree in the window according to the grayscale information in the window and the grayscale value discreteness.

[0027] It should be noted that the grayscale value variation degree in the window can be obtained according to the grayscale discreteness degree in the window. The grayscale value variation coefficient of the window can be directly calculated to represent the discreteness degree of the grayscale value in the window. Then the information entropy of the grayscale value in the window is calculated. The information entropy can indicate how much information the grayscale value in the window contains. According to the information entropy in the window and the grayscale discreteness degree, the grayscale variation degree in each window is obtained. According to the grayscale variation degree, a window with a large amount of information and a relatively dispersed grayscale value distribution can be obtained.

[0028] Specifically, get the The specific method for the grayscale change degree within a window is: The first The ratio between the standard deviation and the mean of the grayscale values ​​in the first window is taken as The coefficient of variation of gray value within a window; The first The coefficient of variation of grayscale value in the window is The product of the information entropy of the grayscale values ​​in the windows is recorded as the first product; the reciprocal of the square value of the preset parameter is input into the logarithmic function with base 2 to obtain the output value, which is recorded as the first output value; the negative of the product of the first output value and the square value of the preset parameter is recorded as the first negative number; the ratio of the first product to the first negative number is recorded as the first The degree of grayscale change within a window; The specific formula is: In the formula, Indicates The degree of grayscale change within a window; Indicates The gray value variation coefficient within the window represents the The discrete degree of gray value of each window; Indicates The information entropy of the grayscale value in the window represents the Grayscale information of a window; are preset parameters.

[0029] Among them, The information entropy of the gray value in the window The calculation expression is: In the formula, Indicates The information entropy of the gray value in a window; Indicates Gray value in the window The frequency of occurrence.

[0030] Among them, the gray value variation coefficient within the window and the information entropy of the gray value within the window are existing well-known technologies and will not be described in detail here.

[0031] Step S003: Adaptively divide the grayscale levels in the window according to the grayscale variation degree and grayscale value probability distribution in the window.

[0032] It should be noted that in this embodiment, the gray value and the gray level are not the same, they are two concepts, please pay attention to distinguish. The gray value is the original image division standard with a value range of 255, and the gray level is the gray level classification in the gray level co-occurrence matrix formed by combining some gray values ​​in the 255 gray values ​​together to calculate the gray level co-occurrence matrix. A gray level may contain one or more gray values. In this embodiment, the gray level is of indefinite length.

[0033] It should be noted that, according to the grayscale variation within the window, a window with a large grayscale discreteness and a large amount of information can be obtained. The grayscale of such a window should be divided more finely to better retain the texture features in the windows, while the grayscale division of the window with a low grayscale variation can be rougher. In addition, since the distribution of grayscale values ​​in each window of the grayscale image of the corn oil surface may not be uniform, the grayscale of indefinite length is determined by dynamically dividing the grayscale, which reduces the amount of calculation of subsequent calculations without affecting the calculation results; for a window with a certain number of pixels, the fineness of the grayscale division is mainly reflected by the grayscale range of the divided grayscale and the number of pixels contained in each grayscale.

[0034] Specifically, for any window, the The fineness of the grayscale division is the same as that of the The grayscale range of the grayscale level and the The specific method for calculating the number of pixels contained in a gray level is: The window The sum of the number of grayscale values ​​of the grayscale level and 1 is recorded as the first sum value; the first sum value is added to the first The reciprocal of the product of the number of gray values ​​of the gray levels is taken as the The fineness of the grayscale division; The specific formula is: In the formula, Indicates the window The fineness of the grayscale division; Indicates the window The number of gray values ​​in gray levels; Indicates that the gray value in the window belongs to The number of pixels in each gray level.

[0035] Among them, the finer the division of any gray level in the window, the smaller the grayscale range of the gray level in the window and the fewer the number of pixels contained in the gray level; conversely, the coarser the division of the gray level, the larger the grayscale range of the gray level in the window and the more the number of pixels contained in the gray level.

[0036] It should be noted that when the grayscale in any window is dynamically divided, the grayscale division fineness threshold can be set according to the grayscale change degree in the window to dynamically determine the appropriate grayscale size.

[0037] Specifically, for The specific method of determining the threshold value of grayscale division of a window is as follows: No. The difference between the maximum grayscale value and the minimum grayscale value in the first window is recorded as the first difference; The product of the grayscale change degree in the window and the first difference is taken as the The grayscale division fineness threshold of each window; The specific formula is: In the formula, Indicates The grayscale division fineness threshold of each window; Indicates The degree of grayscale change within a window; Indicates The difference between the maximum grayscale value and the minimum grayscale value in a window.

[0038] The grayscale division fineness threshold is used to limit the grayscale division level. When the fineness of any grayscale division in the window is greater than the grayscale division fineness threshold, it means that the grayscale division meets the fineness requirement. Then, the original grayscale in the window is initially divided into grayscales according to the grayscale division fineness threshold of the window.

[0039] For A window is created, and the specific operation of performing initial grayscale division on the original grayscale in the window is as follows: In order from smallest to largest, Arrange all the gray values ​​of the windows to get The gray value sequence of the window; first, The minimum gray value of each window is divided into a gray level, which is recorded as the first gray level. The grayscale values ​​in the grayscale value sequence of each window are divided into the first grayscale level in sequence, and after each division, the first grayscale level is calculated. The fineness of the first grayscale division of the window, if the After the jth grayscale value in the grayscale value sequence of the window is divided into the first grayscale level, the fineness of the first grayscale level division is greater than or equal to the jth grayscale value in the grayscale value sequence of the window. The grayscale division fineness threshold of the window is reached, and the division continues; if the After the jth grayscale value in the grayscale value sequence of the window is divided into the first grayscale level, the fineness of the first grayscale level division is less than that of the jth grayscale value. If the grayscale division fineness threshold of the jth window is reached, the division is stopped, and the jth grayscale value is removed from the first grayscale, and the first grayscale is recorded as a complete grayscale; finally, the removed grayscale value is used as a new grayscale and the grayscale division operation is repeated to complete the jth grayscale. The initial grayscale division of the original grayscale in the window is obtained The gray levels of all initial divisions within a window and the fineness of the gray level divisions after all initial divisions.

[0040] The grayscale division fineness obtained through the above operation is generally greater than the fineness threshold, which can ensure that the grayscale co-occurrence matrix corresponding to the grayscale can retain better texture features.

[0041] It should be noted that the initial grayscale division of the original grayscale in the window may result in deviation in the division of the grayscale values ​​at adjacent locations between two grayscales, so the grayscale after the initial division needs to be traversed again for adjustment.

[0042] Specifically, for the first grayscale division A window is created, and the specific operation of performing secondary grayscale division on the grayscale after the initial division in the window is as follows: First, the specific method of obtaining the preferred degree of grayscale division of the window according to the fineness of each grayscale division of the window is: After the initial grayscale is divided In the window The fineness of the grayscale division is the same as that of the initial grayscale division. The difference between the grayscale division fineness thresholds of the windows is recorded as the first grayscale division after the initial grayscale division. In the window The initial gray level is divided into the initial difference; The inverse normalized value of the accumulated initial difference of all grayscale divisions in the window is used as the first grayscale division after the initial grayscale division. The degree of preference of the grayscale division of each window; The specific formula is: In the formula, Indicates the first grayscale division after The degree of preference of the grayscale division of each window; Indicates the first grayscale division after In the window The fineness of the grayscale division; Indicates the first grayscale division after The grayscale division fineness threshold of each window; Indicates The number of gray levels in the window after the initial gray level division; Represents an exponential function with a natural constant as base.

[0043] Secondly, the initial gray level is divided into Any gray level in the window is recorded as the target gray level, and the rightmost edge gray value in the target gray level is obtained and added to the gray level adjacent to the right side of the target gray level. The preferred degree of grayscale division of the window is recorded as the preferred degree of grayscale division before adding; the rightmost edge grayscale value in the target grayscale is obtained and added to the grayscale adjacent to the right side of the target grayscale after the initial grayscale division. The preferred degree of grayscale division of the window is recorded as the preferred degree of grayscale division after adding; if the preferred degree of grayscale division after adding is greater than the preferred degree of grayscale division before adding, the rightmost edge grayscale value in the target grayscale is added to the grayscale adjacent to the right side of the target grayscale; if the preferred degree of grayscale division after adding is less than or equal to the preferred degree of grayscale division before adding, the original division result is maintained; similarly, after completing the initial grayscale division, All gray levels after initial division in the window are divided into two gray levels to obtain the first The optimal grayscale segmentation result of a window.

[0044] Similarly, the optimal grayscale division results of all windows of the corn oil surface grayscale image division are obtained.

[0045] Step S004: Obtain the window grayscale co-occurrence matrix according to the grayscale co-occurrence matrix of each window, obtain the probability of defects existing in the window according to the grayscale co-occurrence matrix of each window, and evaluate the quality of corn oil.

[0046] Specifically, the grayscale co-occurrence matrix of the corn oil surface grayscale image is calculated according to the optimal grayscale division results of all windows divided by the corn oil surface grayscale image. First, the grayscale co-occurrence matrix is ​​initialized, and each grayscale level and the grayscale value range contained in the grayscale level are recorded in the first row and the first column of the horizontal grayscale co-occurrence matrix, and then the initial values ​​of other positions of the matrix are set to zero.

[0047] Secondly, the grayscale co-occurrence matrix is ​​calculated according to the grayscale situation of the pixels in the grayscale image of the corn oil surface. The grayscale values ​​in the grayscale image window of the corn oil surface are traversed. If the grayscale value belongs to the i-th grayscale of the grayscale division in the window, and the grayscale value of the first pixel on the right belongs to the j-th grayscale of the grayscale division, then the count of the i-th row and j-th column in the horizontal grayscale co-occurrence matrix is ​​increased by 1. All pixels in the window are traversed to obtain the grayscale co-occurrence matrix of the window.

[0048] It should be noted that the energy of the grayscale co-occurrence matrix of the window is a measure of the stability of the grayscale change of the window texture, reflecting the uniformity of the window grayscale distribution and the texture coarseness. The smaller the energy value, the more likely it is that the current window texture is a texture with a large degree of change, and it is more likely to belong to the defect area of ​​the corn oil surface grayscale image.

[0049] Preset two threshold parameters , wherein this embodiment is based on The present embodiment is not specifically limited. It depends on the specific implementation situation.

[0050] Specifically, according to the gray-level co-occurrence matrix of each window of the corn oil surface grayscale image, the energy of the gray-level co-occurrence matrix of each window is extracted; the energy of the gray-level co-occurrence matrix is ​​less than the threshold The window is recorded as a defect window, and the number of defect windows is counted. If the number of defect windows is greater than or equal to the preset threshold parameter , the quality of the corn oil is unqualified, otherwise, the quality of the corn oil is qualified.

[0051] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A corn oil quality detection method based on image processing, characterized in that: The method comprises the following steps: Acquire a grayscale image of the surface of corn oil, and divide the grayscale image of the surface of corn oil into a plurality of windows; The grayscale change degree in the window is obtained according to the grayscale information in the window and the grayscale value discreteness; The fineness of the grayscale division in the window is obtained according to the grayscale range of the grayscale in the window and the number of pixels contained in the grayscale; the threshold of the fineness of the grayscale division in the window is obtained according to the grayscale change degree in the window and the difference between the maximum grayscale value and the minimum grayscale value in the window; the original grayscale in the window is obtained; the original grayscale in the window is initially divided into grayscales according to the fineness of the grayscale division in the window and the threshold of the fineness of the grayscale division in the window, and the grayscale after the initial division in the window and the fineness of the grayscale division after the initial division in the window are obtained; the preferred degree of the grayscale division of the window after the initial grayscale division is obtained according to the fineness of the grayscale division after the initial division in the window; the grayscale after the initial division in the window is divided twice according to the preferred degree of the grayscale division of the window after the initial grayscale division, and the optimal grayscale division result of the window is obtained; The grayscale co-occurrence matrix of the window is obtained according to the optimal grayscale division result of the window; the energy of the grayscale co-occurrence matrix of the window is obtained according to the grayscale co-occurrence matrix of the window; the number of defective windows of the grayscale image of the corn oil surface is obtained according to the energy of the grayscale co-occurrence matrix of the window, and the quality detection of corn oil is completed according to the number of defective windows of the grayscale image of the corn oil surface.

2. The corn oil quality detection method based on image processing according to claim 1, characterized in that: The step of obtaining the grayscale change degree in the window according to the grayscale information in the window and the grayscale value discreteness includes the following specific steps: The first The coefficient of variation of grayscale value in the window is The product of the information entropy of the grayscale values ​​in the windows is recorded as the first product; the reciprocal of the square value of the preset parameter is input into the logarithmic function with base 2 to obtain the output value, which is recorded as the first output value; The negative of the product of the first output value and the square value of the preset parameter is recorded as the first negative number; the ratio of the first product to the first negative number is recorded as the first The degree of grayscale change within a window.

3. The corn oil quality detection method based on image processing according to claim 1, characterized in that: The method of obtaining the fineness of the grayscale division in the window according to the grayscale range of the grayscale in the window and the number of pixels contained in the grayscale includes the following specific steps: The window The sum of the number of grayscale values ​​of the grayscale level and 1 is recorded as the first sum value; the first sum value is added to the first The reciprocal of the product of the number of gray values ​​of the gray levels is taken as the The fineness of the grayscale division.

4. The corn oil quality detection method based on image processing according to claim 1, characterized in that: The grayscale division fineness threshold of the window is obtained according to the grayscale change degree in the window and the difference between the maximum grayscale value and the minimum grayscale value in the window, and the specific steps include the following: No. The difference between the maximum grayscale value and the minimum grayscale value in the first window is recorded as the first difference; The product of the grayscale change degree in the window and the first difference is taken as the The grayscale division fineness threshold of a window.

5. The corn oil quality detection method based on image processing according to claim 1, characterized in that: The method of performing initial grayscale division on the original grayscale in the window according to the fineness of the grayscale division in the window and the fineness threshold of the grayscale division in the window to obtain the grayscale after the initial division in the window and the fineness of the grayscale division after the initial division in the window includes the following specific steps: For windows, in order from small to large. Arrange all the gray values ​​of the windows to get the The gray value sequence of the window; first, The minimum gray value of each window is divided into a gray level, which is recorded as the first gray level. The grayscale values ​​in the grayscale value sequence of each window are divided into the first grayscale level in sequence, and after each division, the first grayscale level is calculated. The fineness of the first grayscale division of the window, if the After the jth grayscale value in the grayscale value sequence of the window is divided into the first grayscale level, the fineness of the first grayscale level division is greater than or equal to the jth grayscale value in the grayscale value sequence of the window. The grayscale division fineness threshold of the window is reached, and the division continues; if the After the jth grayscale value in the grayscale value sequence of the window is divided into the first grayscale level, the fineness of the first grayscale level division is less than that of the jth grayscale value. If the grayscale division fineness threshold of the jth window is reached, the division is stopped, and the jth grayscale value is removed from the first grayscale, and the first grayscale is recorded as a complete grayscale; finally, the removed grayscale value is used as a new grayscale and the grayscale division operation is repeated to complete the jth grayscale. The initial grayscale division of the original grayscale in the window is obtained The gray levels of all initial divisions within a window and the fineness of the gray level divisions after all initial divisions.

6. The corn oil quality detection method based on image processing according to claim 1, characterized in that: The method of obtaining the preferred degree of the window grayscale division after the initial grayscale division according to the fineness of the grayscale division after the initial division in the window comprises the following specific steps: After the initial grayscale is divided In the window The fineness of the grayscale division is the same as that of the initial grayscale division. The difference between the grayscale division fineness thresholds of the windows is recorded as the first grayscale division after the initial grayscale division. In the window The initial difference of grayscale divisions; After the initial grayscale is divided The inverse normalized value of the accumulated initial difference of all grayscale divisions in the window is used as the first grayscale division after the initial grayscale division. The preferred degree of grayscale division of each window.

7. The corn oil quality detection method based on image processing according to claim 1, characterized in that: The method of performing secondary division of the grayscale after the initial division in the window according to the preferred degree of the grayscale division of the window after the initial grayscale division to obtain the optimal grayscale division result of the window includes the following specific steps: After the initial grayscale is divided Any gray level in the window is recorded as the target gray level, and the rightmost edge gray value in the target gray level is obtained and added to the gray level adjacent to the right side of the target gray level. The preferred degree of grayscale division of the window is recorded as the preferred degree of grayscale division before adding; the rightmost edge grayscale value in the target grayscale is obtained and added to the grayscale adjacent to the right side of the target grayscale after the initial grayscale division. The preferred degree of grayscale division of each window is recorded as the preferred degree of grayscale division after adding; if the preferred degree of grayscale division after adding is greater than the preferred degree of grayscale division before adding, the rightmost edge grayscale value in the target grayscale is added to the grayscale adjacent to the right side of the target grayscale; if the preferred degree of grayscale division after adding is less than or equal to the preferred degree of grayscale division before adding, the original division result is maintained; Similarly, after completing the initial grayscale division All gray levels after initial division in the window are divided into two gray levels to obtain the first The optimal grayscale segmentation result of a window.

8. The corn oil quality detection method based on image processing according to claim 1, characterized in that: The step of obtaining the gray level co-occurrence matrix of the window according to the optimal gray level division result of the window includes the following specific steps: The grayscale co-occurrence matrix of the corn oil surface grayscale image is calculated based on the optimal grayscale division results of all windows divided by the corn oil surface grayscale image: first, the grayscale co-occurrence matrix is ​​initialized, and each grayscale level and the grayscale value range contained in the grayscale level are recorded in the first row and the first column of the horizontal grayscale co-occurrence matrix, and then the initial values ​​of other positions in the matrix are set to zero; Secondly, the grayscale co-occurrence matrix is ​​calculated according to the grayscale situation of the pixels in the grayscale image of the corn oil surface, and the grayscale values ​​in the grayscale image window of the corn oil surface are traversed. If the grayscale value belongs to the i-th grayscale level of the grayscale division in the window, and the grayscale value of the first adjacent pixel on the right belongs to the j-th grayscale level of the grayscale division, then the count of the i-th row and j-th column in the horizontal grayscale co-occurrence matrix is ​​increased by one; all pixels in the window are traversed to obtain the grayscale co-occurrence matrix of the window.

9. The corn oil quality detection method based on image processing according to claim 1, characterized in that: The method of obtaining the number of defective windows of the grayscale image of the corn oil surface according to the energy of the grayscale co-occurrence matrix of the window and completing the quality detection of the corn oil according to the number of defective windows of the grayscale image of the corn oil surface includes the following specific steps: Preset two threshold parameters According to the gray-level co-occurrence matrix of each window of the corn oil surface grayscale image, the energy of the gray-level co-occurrence matrix of each window is extracted; the energy of the gray-level co-occurrence matrix is ​​less than the threshold The window is recorded as a defect window, and the number of defect windows is counted. If the number of defect windows is greater than or equal to the preset threshold parameter , the quality of the corn oil is unqualified, otherwise, the quality of the corn oil is qualified.

10. The corn oil quality detection method based on image processing according to claim 2, characterized in that: The said The method for obtaining the gray value variation coefficient within a window is as follows: The first The ratio between the standard deviation and the mean of the grayscale values ​​in the first window is taken as The coefficient of variation of grayscale values ​​within a window.

Citation Information

Patent Citations

  • Electric spindle fault diagnosis method and device based on deconvolution imaging

    CN112966560A

  • Detection method and detection equipment for building external wall thermal insulation material

    CN114882038A

  • Forest defect area detection method and device based on remote sensing image and storage medium

    CN116385375A

  • Intelligent detection method for quality of lead screw

    CN116523913A

  • Defect detection method for coating layer of whole-core high-pattern conveyor belt

    CN116740056A

Cited By

  • Trans-department civil administration data sharing safety monitoring system

    CN121170704A