Disclosure of Invention
The invention provides a flour quality visual detection system based on flour bran star identification, which aims to solve the problems of strong human subjectivity, expensive detection instrument, difficulty in popularization and low whiteness detection precision in the existing bran star detection method in flour, and adopts the following specific technical scheme:
one embodiment of the present invention provides a flour quality visual inspection system based on flour bran star identification, the system comprising:
the data acquisition module acquires a flour image, and the flour image is preprocessed and then grayed to obtain a flour gray image;
the image color difference degree calculation module is used for dividing the flour gray level image into segmented images with equal size, calculating the gray level entropy of each segmented image, obtaining the obvious gray level entropy of each gray level according to the number of each gray level in the segmented image and the gray level entropy of the segmented image, and obtaining the color difference degree of each segmented image according to the obvious gray level entropy of each gray level and the average value of all the obvious gray level entropy, wherein the color difference degree is recorded as first color difference degree;
the pixel point non-aggregation degree acquisition module is used for clustering each segmented image to obtain a clustering center of each iteration of the clustering, and obtaining a measurement distance from each pixel point in the segmented image to the clustering center during each iteration, obtaining a difference value of measurement distances of the same pixel point in two continuous clusters and recording the difference value as a measurement distance change amplitude value, and obtaining the amplitude significance value of each pixel point according to Euclidean distance between two clustering center points of adjacent iteration times in all iterations and the measurement distance change amplitude value of the same pixel point in the two continuous clusters and obtaining the non-aggregation degree of each pixel point according to the difference between the amplitude significance value of each pixel point and the average value of the amplitude significance values of all pixel points;
the local flour bran star content acquisition module is used for acquiring an updating radius of each pixel point according to the non-aggregation degree of each pixel point in the segmented image, the maximum value of the non-aggregation degree and the side length of the segmented image, updating the segmented image according to the updating radius corresponding to each pixel point, calculating the color difference degree of the updated segmented image to be a second color difference degree, obtaining the color change difference degree corresponding to each pixel point according to the difference between the first color difference degree and the second color difference degree, judging whether the pixel point is a bran star pixel point according to the color change difference degree of each pixel point and obtaining a bran star determination factor, and obtaining the local bran star content of the segmented image according to the bran star determination factor;
the flour quality detection module is used for obtaining the local bran star content of each block image, adding the local bran star content of all the block images to obtain the total content of the flour bran star, and detecting the flour quality according to the total content of the flour bran star.
Preferably, the method for dividing the flour gray level image into the segmented images with equal size comprises the following steps:
uniformly dividing the flour image into C square quick-dividing images with equal size, wherein the size of the block image is W.times.W, when the square of the C square.times.W just covers the flour gray level image, a plurality of combinations (C, W) are obtained, and the obtained maximum W is taken as the side length of the block image.
Preferably, the method for obtaining the color difference degree of each segmented image according to the significant gray entropy of each gray level and the average value of all the significant gray entropy comprises the following steps:
in the method, in the process of the invention,
is the gray value of pixel i,
is the significant gray entropy of pixel i, the meaning of M is that there are M unequal gray values in the segmented image c,
is the mean of the M gray scale significant gray scale entropies,
the color difference of the block image c is expressed and is denoted as a first color difference.
Preferably, the method for obtaining the amplitude significance value of each pixel point according to the euclidean distance between two clustering center points of adjacent iteration times in all iterations and the measurement distance change amplitude of the same pixel point in two continuous clusters comprises the following steps:
in the method, in the process of the invention,
is the Euclidean distance between the v iteration and the v+1 iteration corresponding to the cluster center movement,
is the total number of iterations at the end of the clustering of the segmented image c,
the magnitude of the change of the distance between the pixel point f of the v th iteration and the v+1 th iteration and the center point measurement of the two clusters is represented,
representing the magnitude saliency value of the f-th pixel.
Preferably, the method for obtaining the update radius of each pixel point according to the non-aggregation degree of each pixel point in the segmented image, the maximum value of the non-aggregation degree and the side length of the segmented image comprises the following steps:
in the method, in the process of the invention,
is the maximum value of the degree of non-aggregation of the pixel points in the segmented image c,
is the degree of non-aggregation of the pixel point f,
is the side length of the tile image c,
the update radius.
Preferably, the method for updating the segmented image through the update radius corresponding to each pixel point and calculating the color difference of the updated segmented image to be recorded as the second color difference comprises the following steps:
obtaining updated radius
After that, obtain
The center point of the square area is the same as the center point of the segmented image, the gray values of all pixel points in the square area are converted into the gray value of the pixel point f, the gray values of the pixel points belonging to the square area in the segmented image are replaced, an updated segmented image is obtained, the updated segmented image is calculated to obtain new color difference degree, and the new color difference degree is recorded as second color difference degree.
Preferably, the calculating method of the local bran star content of the segmented image comprises the following steps:
in the method, in the process of the invention,
a factor is determined for the bran-star for pixel f,
is the total number of pixels in the tile image c,
the local content of bran star of the c-th segmented image is represented.
The beneficial effects of the invention are as follows: the invention provides a flour quality visual detection system based on flour bran star identification, wherein the traditional whiteness detection method is influenced by a wheat storage factor, and the accuracy of a flour detection result processed by long-term stored wheat is lower. Aiming at the problems of the traditional detection method, the color difference degree is constructed based on the distribution condition of the pixels with different gray levels in the flour image, the color difference degree considers the change condition of gray entropy in the segmented image and the distribution difference between the pixels with different gray levels, and the color significance has the beneficial effect of being applicable to the detection of the bran star with any color. Secondly, according to the characteristics of weak aggregation characteristics of bran-star pixels and remarkable aggregation characteristics of flour pixels in the block diagram, the non-aggregation degree is constructed through the influence of different pixels on the update amplitude of the clustering center, and the non-aggregation degree has the beneficial effects that for flour bran-star with any size, the influence degree of the bran-star pixels on the update of the clustering center can be accurately obtained, so that the problem of low detection precision when the flour bran-star is similar to the flour raw materials is avoided.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Referring to fig. 1, a flowchart of a flour quality visual inspection system based on identification of bran stars according to an embodiment of the present invention is shown, the system includes:
the data acquisition module, in this embodiment, installs an industrial CCD camera above the raw material powder grinding discharge position, acquires flour images using the camera, and it is noted that the obtained flour images are RGB images. In addition, during the image capturing and transmitting process, interference noise inevitably exists, including interference noise caused by processing machines and during the transmitting process, and the noise not only reduces the image quality, but also affects the detection result of the flour bran star on the flour image. Therefore, in order to reduce noise interference and improve image quality, it is necessary to perform denoising processing on the acquired flour image. In the field of image processing, the commonly used denoising methods are divided into two categories, namely denoising based on a filter and denoising based on a model. The proposal adopts bilateral filtering denoising technology to preprocess the collected flour image. The bilateral filtering denoising technology is a known technology, and the specific process is not described in detail. And carrying out graying treatment on the denoised flour image to obtain a gray level image of the flour image, namely a flour gray level image.
The image color difference calculating module, in this embodiment, the detection object is a flour bran star, and the gray value of the pixel points belonging to the flour bran star in the finished flour image is larger than that of the normal flour pixel points. For processed flours, the coarser the particle size of the flour, the greater the number of bran-star in the flour, the greater the size of the bran-star, and the worse the color of the flour; the smaller the particle size of the flour, the smaller the number of bran stars in the flour, the smaller the body shape of the bran stars, and the even and white color of the flour. Therefore, the invention considers that the entropy value graph is obtained by mapping and transforming the gray entropy of the local area in the collected flour image, and the difference condition of pixels in the local area is primarily judged according to the magnitude of the gray entropy value, and the gray entropy is the image entropy of the gray image.
Firstly, after a flour gray level image is obtained, the flour image is uniformly divided into C segmented images with equal size, the size of each segmented image is W, for all C, W when the two conditions are met, the C squares with W are enabled to cover the flour gray level image exactly, a plurality of combinations (C and W) are obtained, the obtained maximum W is taken as the side length of the segmented image, and for the flour image and the segmented image, flour bran stars are unevenly and randomly distributed. The gray entropy is an image characteristic calculated according to the distribution condition of gray values of pixels in an image, whether the image is a block image or a flour image, compared with the gray values of the pixels of the bran star, the gray values of the pixels of the bran star are smaller, the gray values of the pixels of the flour are larger, and in general, the number of the pixels of the flour in the flour formed by processing raw materials is larger than that of the pixels of the bran star, so that for the block image, the number of the pixels of the flour is larger than that of the pixels of the bran star, if the bran star appears in a large amount of flour, the corresponding gray entropy changes, and the color of the block image also changes.
Further, the gray entropy of each segmented image is obtained, and the formula is as follows:
in the method, in the process of the invention,
meaning that the number of pixels having a gray value u in all pixels in the segmented image c is a ratio,
is the gray entropy of the segmented image c.
It should be noted that, in this embodiment, each of the different gray values is calculated as a gray level. Further, the color difference is obtained by changing all gray levels in the segmented image, so that the significant gray entropy of each gray level in the segmented image is obtained according to the gray entropy of the segmented image, and the formula is as follows:
is that the gray value in the segmented image c is
N is the number of pixels in the segmented image c,
is the significant gray entropy of pixel i, i is the i-th pixel in the segmented image c,
is the gray value of pixel i,
is the gray entropy of the segmented image c.
Further, the color difference degree of the segmented image is obtained through the remarkable gray entropy of each gray level, and the formula is as follows:
where M means that there are M unequal gray values in the segmented image c, each of which corresponds to one gray level,
is the mean of the M gray scale significant gray scale entropies,
the color difference of the block image c is expressed, and the color difference at this time is recorded as a first color difference. The color difference degree is the color difference of pixel points in the segmented image, the gray values of the pixel points in the segmented image are different, the corresponding color difference degree is smaller, the color displayed by the segmented image is smaller, and the possibility of the presence of flour bran is lower.
The non-aggregation degree acquisition module of the pixels is used for blocking the flour image, if the occupation ratio of the flour pixels in the area is larger for each corresponding area of the blocked image, the similarity among the flour pixels is larger, namely the aggregation characteristic of the flour pixels is obvious, the white possibility of the whole area in the flour image is larger, and for the flour bran star distributed randomly, the aggregation characteristic is not obvious in the blocked image.
Firstly, for each segmented image, K-means clustering is used for clustering pixels through the position of an iterative clustering center, for a large number of flour pixels in the segmented image, the pixels have higher similarity, the segmented image has higher local density, in each clustering center point position iteration process, if all the pixels in the segmented image are flour pixels, the clustering is stopped quickly, the updating amplitude of each clustering center point is very small, and if bran star pixels exist in the segmented image, the updating amplitude of each clustering center point is relatively large because the bran star pixels influence the determination of the clustering center point. In this embodiment, the number of initial cluster centers of K-means clustering is 2, the iteration stop condition is that the two clustering results do not change any more, the measurement distance between the pixel point and the cluster center point in the iteration process is the gray level difference value of two pixel points, the K-means clustering is a known technology, and the specific process is not described in detail.
Further, the measurement distance from any pixel point to the clustering center point in any two iterative processes is obtained, wherein the smaller the measurement distance difference is, the smaller the change of the clustering center point is, and the formula for obtaining the measurement distance change amplitude is as follows:
in the method, in the process of the invention,
is the clustering center of the cluster where the pixel point f is located after the v-th iteration in the clustering process,
is the pixel point f after the (v+1) th iteration in the clustering processAt the center of the cluster,
is the pixel point f and the center point after the v th iteration
Is a measure of the distance of (1),
is the pixel point f and the central point after the v+1th iteration
Is a measure of the distance of (1),
the magnitude of the change in the measured distance between the pixel point f of the v th iteration and the v+1 th iteration and the center point of the two clusters is represented.
Further, according to the measurement distance change amplitude value obtained by each pixel point in all iterative processes, the amplitude significance value of each pixel point is obtained, and the formula is as follows:
in the method, in the process of the invention,
is the Euclidean distance between the v iteration and the v+1 iteration corresponding to the cluster center movement,
is the total number of iterations at the end of the clustering of the segmented image c,
the magnitude of the change of the distance between the pixel point f of the v th iteration and the v+1 th iteration and the center point measurement of the two clusters is represented,
representing the magnitude saliency value of the f-th pixel.
Further, according to the average value of the amplitude significant values of all the pixels in the segmented image c, the non-aggregation degree of each pixel is obtained by taking the difference between the amplitude significant value of each pixel and the average value of the amplitude significant values, and the formula is as follows:
in the method, in the process of the invention,
represents the magnitude saliency value of the f-th pixel,
is the average of the amplitude saliency values of all pixels in the segmented image c,
indicating the degree of non-aggregation of the f-th pixel.
The non-aggregation degree reflects the possibility of aggregation characteristics of pixel points in the segmented image, in the process of clustering the segmented image, the update of the clustering center is determined according to the measurement distance from all samples to the clustering center, if the segmented image contains the wheat bran star, the measurement distance between the bran star pixel points and the clustering center is larger, the next update of the clustering center can move to the aggregation area of the bran star pixel points, and because the distribution of the bran star pixel points is scattered, the clustering center moves for a plurality of times,
the value of (c) will be larger,
the larger the value of (2), the more the measured distance change of the bran-star pixel points before and after updating is larger than the moving distance of the clustering center, the non-aggregation degree
The larger the pixel point f has key influence on the updating amplitude of the clustering center, the more likely the pixel point f corresponds to the pixel point in the bran star area of the flour, and the corresponding aggregation characteristicThe less pronounced.
And the local content acquisition module of the wheat bran star is used for respectively acquiring the color difference degree corresponding to each segmented image and the non-aggregation degree of each pixel point in the segmented image according to the steps for the preprocessed wheat flour image. For a segmented image c, the degree of color difference
Reflecting the number of gray levels in the segmented image c and the uniformity of the distribution of each gray level pixel point due to the color difference
The larger the patch image c, the greater the likelihood that the wheat bran star is present. On the other hand, the degree of non-aggregation
The larger the image, the less obvious the aggregate feature corresponding to the pixel point f in the segmented image c, the more likely the pixel point f will be the pixel point in the corresponding bran star area of the flour.
Firstly, selecting an updating radius to update each segmented image, taking a square area with the updating radius as a side length as an updating area, and finding out a pixel point with the largest non-aggregation degree from pixel points in each segmented image, wherein the non-aggregation degree of the pixel points is recorded as
Obtaining a plurality of update radiuses by using the maximum non-aggregation degree and the non-aggregation degree of each pixel point of the segmented image, wherein the update radius obtaining mode is as follows:
in the method, in the process of the invention,
is the maximum value of the degree of non-aggregation of the pixel points in the segmented image c,
is the minimum value of the non-aggregation degree of the pixel points in the segmented image c,
is the degree of non-aggregation of the pixel point f,
is the side length of the tile image c,
that is, update radius, thus obtaining
Is a square region of (1), wherein
The larger the pixel point f is more likely to be the bran-star flour pixel point, the more contrast in the image should be amplified, which is beneficial to improving the accuracy of subsequent detection.
The bran star and color are not fixed in size, for some relatively dull or smaller bran stars, if it is
Setting a threshold value may ignore the above-mentioned non-contrast-significant pixels of bran-star, for example pixels on the intersection edge of bran-star and flour. The purpose of the update is to amplify the contrast of the bran-star pixels. In the updating process, the gray value of the pixel points in a certain range around the bran-star pixel point is consistent with the bran-star pixel point, so that the pixel points on the bran-star which are relatively dim or small in area are more obvious in the image.
Further, it will
The center point of the segmented image is taken as the midpoint of the square area, all pixel points in the square area are updated to be gray values of the pixel point f, and after updating, new color difference is obtained according to the calculation step of the color difference
The color difference is recorded as a second color difference, and a color change difference is obtained, which is calculated as follows:
in the method, in the process of the invention,
a first color difference degree representing a c-th block image,
a second color difference degree representing a c-th block image,
and representing the color change difference degree of the c-th segmented image after the f-th pixel point is updated.
After updating the pixel points, if the pixel points are bran-star pixel points, the more the updated surrounding pixel points consistent with the gray value of the updated pixel points, the color difference degree in the updated divided image
The larger the thus, that is, the degree of variation in color change
The larger the pixel point f, the more likely it is a bran-star pixel point.
If the color difference is the bran-star pixel point, the updated color difference is equivalent to the bran-star pixel point,
if the color is the flour pixel, the updated color is equal to the bran star pixel, the color difference is reduced,
. The bran-star pixel point can be judged more accurately.
Further, normalizing the color change difference degree corresponding to each pixel after updating, and setting colorJudgment threshold
In the present embodiment, it is noted that
0.3, record
Determining a factor for the bran-star of pixel f if
,
At this time, the pixel point f is considered to be the bran-star pixel point, if
,
At this time, the pixel point f is considered to be a non-bran-star pixel point. The formula is as follows:
the local content of bran star of the segmented image c can thus be obtained:
in the method, in the process of the invention,
a factor is determined for the bran-star for pixel f,
is the total number of pixels in the tile image c,
the local content of bran star of the c-th segmented image is represented. The local content of the bran-star is the duty ratio of the number of the bran-star pixels in all pixels of the block image, and the bran-star is obtained by matchingAnd replacing and updating pixel points in the block images, calculating the variation of the color difference degree of the block images before and after updating, and determining the value of the bran star determining factor according to the variation. The greater the local content of bran star, the greater the content of flour bran star in the segmented image.
The flour quality detection module is used for respectively calculating the color difference degree of the segmented images and the non-aggregation degree of each pixel point in the segmented images according to the C segmented images obtained by segmenting the flour images in the steps, further, acquiring the local bran star content corresponding to each segmented image according to the calculation results of the two indexes, and respectively marking as
、
、…、
…、
。
Adding the calculated results of the C local contents to obtain the average value of the total content of the flour bran star in the flour image, and marking the average value as
. According to the classification of flour grades, obtaining the acceptable bran star content range of flour in the flour of each grade, wherein the bran star content range of the top grade flour is [0,0.05 ]]The bran star content of the inferior flour is in the range of [0.05,1 ]]Respectively detecting the total content of the wheat bran star
Comparing with the bran star content range of the flour of each grade of flour, if
The detected flour is recorded as the top-grade flour within the acceptable bran content range of the top-grade flour if
The detected flour is marked as the inferior flour in the acceptable bran star content range of the inferior flour.
The foregoing description of the preferred embodiments of the invention is not intended to be limiting, but rather is intended to cover all modifications, equivalents, alternatives, and improvements that fall within the spirit and scope of the invention.