Cement homogeneity detection method based on image processing
By using image processing technology to accurately analyze the characteristics of cement particles, the problem of inaccurate judgment of cement mixing uniformity by the traditional human eye has been solved, and a more efficient cement uniformity assessment has been achieved.
Patent Information
- Application Number
- CN202510431003.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-08
- Publication Date
- 2025-11-18
AI Technical Summary
Traditional methods rely on human visual observation to judge the uniformity of cement mixing, which suffers from low accuracy and interference from subjective human factors, leading to inconsistent judgments and large errors.
Using image processing technology, through image preprocessing, noise reduction, enhancement, threshold segmentation and watershed segmentation, the quantity, size and distribution of granular cement blocks are accurately analyzed to determine whether the cement is mixed evenly.
It improves the accuracy and reliability of judging the uniformity of cement mixing, reduces human error, and provides a more objective quality assessment.
Smart Images

Figure SMS_3 
Figure SMS_4 
Figure SMS_5
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of building material detection, and particularly relates to a cement homogeneity detection method based on image processing. BACKGROUND
[0002] Cement is a widely used building material, which is used in various engineering applications, such as house building, water conservancy facilities, etc. In the preparation stage, cement needs to be mixed with other materials and then stirred uniformly and sufficiently, otherwise a series of quality problems may be caused, such as insufficient cement strength leading to reduced load-bearing capacity of buildings, unstable structure causing safety hazards, and reduced impermeability leading to water seepage, etc.
[0003] Traditionally, whether cement is suitable for actual construction (such as when cement is not stirred sufficiently, usually large granular cement blocks are present) mainly depends on the observation of workers by naked eyes and the judgment combined with experience, however, this method has many deficiencies, because the precision of naked eye observation is low and is easily disturbed by human subjective factors, and the judgment results of different construction workers are inconsistent. Therefore, the present application introduces image processing technology to realize more objective and accurate evaluation by quantitatively analyzing the stirring uniformity of cement. The method for judging whether cement is stirred uniformly by using image processing technology improves the accuracy of judgment and reduces the interference of uncontrollable factors, thereby providing more reliable guarantee for the quality of construction engineering. SUMMARY
[0004] The technical problem solved by the present application is to provide a cement homogeneity detection method based on image processing, which accurately analyzes the number, size and distribution of granular cement blocks by using image processing algorithm, so as to judge whether the cement is stirred uniformly and avoid misjudgment due to human subjective factors when relying on naked eye observation, thereby improving the accuracy and reliability of judgment.
[0005] To solve the above technical problem, one technical scheme of the present application is as follows: a cement homogeneity detection method based on image processing, comprising the following steps:
[0006] S1, image preprocessing: first, an original image of three-channel RGB color of stirred cement is acquired by a camera, and then the original image is converted into a gray-scale image;
[0007] S2, image noise reduction: pepper and salt noise is eliminated by filtering technology, which can effectively remove the influence of pepper and salt noise;
[0008] S3, image enhancement: Laplace enhancement algorithm is adopted to sharpen and enhance details of the gray-scale image;
[0009] S4, threshold segmentation: the uniformly stirred cement part is called background, and the non-uniformly stirred and granular part is called the part of interest, the background and the part of interest have a gray difference, threshold segmentation is performed through the gray difference, and the non-uniformly stirred part of interest is recognized;
[0010] S5, watershed segmentation of the adhesion part: a plurality of local maximum gray value points are recognized by using a watershed segmentation method based on an extended maximum value conversion, and are combined into a unique maximum value point, so that the problem of over-segmentation is effectively solved, and accurate segmentation of the adhesion region is realized;
[0011] S6, homogeneity judgment: the extracted particles are subjected to statistical analysis of the number and area, and the uniformity of the cement is evaluated in combination with the characteristics of different types of cement, so that whether the cement is fully stirred is judged.
[0012] The application accurately analyzes the number, size and distribution of the granular cement blocks through image preprocessing, image noise reduction, image enhancement, threshold segmentation and watershed segmentation of the adhesion part, so as to judge whether the cement is uniformly stirred.
[0013] Further, the low-illumination image can be enhanced and preprocessed before the image is processed in step S1, a low-illumination image enhancement preprocessing technology based on the HSI color space of the image is adopted, and image adaptive brightening is realized.
[0014] Further, the red, green and blue three-channel values in the collected RGB image can be converted into an HSI image through a geometric derivation formula, and the formula is as follows:
[0015] hue:
[0016] wherein,
[0017] saturation:
[0018]
[0019] brightness:
[0020]
[0021] The image is globally adaptively processed by improving the Retinnex algorithm, image adaptive brightening is realized, and the formula is as follows:
[0022]
[0023] In the formula, L w is the brightness average value, L w (x,y) is the image brightness value, L wmax is the maximum brightness value, Lg (x, y) is the output result after adaptive HDR;
[0024] In order to extract the unevenly stirred cement part in the image, after the Retinnex algorithm image brightness enhancement in the HSI color space, it still needs to be restored in the RGB color space, and then processed again through the above processing steps.
[0025] Further, in step S2, the adaptive median filter is used to remove the influence of salt and pepper noise, and the specific steps are as follows:
[0026] First step: define a window W(i,j,k) centered on the pixel point p(i,j), k is the size of the window, define a k max , k max is the maximum window size, which determines the number of iterations;
[0027] Second step: calculate the maximum value, minimum value and median of the gray value in the window;
[0028] m min =min(W(i,j),k))
[0029] m max =max(W(i,j,k))
[0030] m med =med(W(i,j,k))
[0031] Third step: judge whether the center pixel is noise, and the noise judgment method is as follows:
[0032] m min <p(i,j)<m max ∧m med ≠p(i,j)
[0033] When the above conditions are not met, it is considered as noise, and the value of p(i,j) is replaced by the median m med of the window.
[0034] Fourth step: if the current pixel is noise, gradually enlarge the window size until k max , and repeat the above calculation. By using the above algorithm to traverse all pixels in the image, the influence of salt and pepper noise can be effectively removed.
[0035] Further, in step S3, the Laplace operator is a second-order differential equation. For a two-dimensional gray image f(x,y), the Laplace operator is defined as follows:
[0036]
[0037] Wherein, f(x, y) is the gray value of the image at (x, y) pixel, The Laplacian operator is represented by calculating the second-order derivative in the horizontal and vertical directions, which can accurately locate the edge position of the image, because the gray value changes greatly at the edge of the image, and the Laplacian operator will output a higher value;
[0038] For a discrete gray image, the Laplacian operator is discretized into a convolution kernel, as follows:
[0039]
[0040] The mathematical process formula of the actual gray image for Laplacian enhancement is as follows:
[0041]
[0042] Where L(i, j) is the value of the Laplacian convolution kernel, f(x+i, y+j) is the pixel value of the image at (x+i, y+j) centered at (x, y), and g(x, y) is the output enhancement result;
[0043] Laplacian enhancement highlights the boundaries and contours of the image, but reduces the overall brightness of the image. By superimposing the results of the Laplacian convolution with the original image, the overall details of the original image are preserved, and the brightness loss is within an acceptable range. The specific formula is as follows:
[0044]
[0045] In the formula, c is the enhancement coefficient, and increasing the value of c can make the edge clearer, but too large will produce additional noise.
[0046] Further, in step S4, the principle of threshold segmentation is to use the gray difference between the background area and the target value, i.e. according to the change of gray value, to convert the gray value to 0 or 1, so as to divide the image into the part of interest and the background. The mathematical formula of threshold segmentation is as follows:
[0047]
[0048] In the formula, f(x, y) represents the gray function of the pixels in the original image, g(x, y) represents the pixel function after threshold segmentation, and T is the gray threshold;
[0049] Threshold segmentation converts the gray level of pixels with a gray value less than T to 0 and eliminates them as background, and converts the gray value of pixels with a gray value greater than or equal to T to 1, thereby achieving image segmentation. The threshold T determines the accuracy of subsequent further processing. The maximum inter-class segmentation method is used to determine the threshold T, so that the segmentation threshold is obtained adaptively from the image, rather than setting a fixed value.
[0050] The calculation process of the maximum inter-class variance is as follows:
[0051] Let ω1(T) be the proportion of pixels less than the threshold T, and the calculation formula is as follows:
[0052]
[0053] Let ω2(T) be the proportion of pixels greater than or equal to the threshold T, and the calculation formula is as follows:
[0054] ω2(T) = 1 - ω1(T)
[0055] The mean values of the foreground class and the background class are defined as μ1(T), μ2(T), and the calculation formula is as follows:
[0056]
[0057] The global average value μ of the image G The calculation formula is as follows:
[0058]
[0059] The inter-class variance is the variance between the foreground class and the background class, and the calculation formula is as follows:
[0060]
[0061] Find a maximum threshold T, such that reaches the maximum, at this time, T is the segmentation threshold.
[0062] Further, morphological processing can be performed between steps S4 and S5: repeatedly applying erosion, dilation, opening operation and closing operation in image morphology to the image to be processed can effectively fill the concave and hole of the region of interest, and remove meaningless pixel blocks.
[0063] Further, the calculation formula of image erosion is as follows:
[0064]
[0065] In the formula, SE is a structural element, f b (x, y) is the original binary image, f be(x, y) is a binary image after erosion operation; the specific operation steps are that firstly, the shape and original position of the structure element SE are determined and the first pixel point with a gray value of 1 in the binary image is scanned, then the structure element is moved to the position of the pixel point, if the gray values of all the pixel points covered by the structure element are 1, the structure element is translated; if there is a pixel point with a gray value of 0 in the region covered by the structure element, the gray values of all the pixel points covered by the structure element are set to 0, then the structure element is translated and the same operation is performed next time;
[0066] The calculation formula of image dilation is as follows:
[0067]
[0068] In the formula, f bd (x, y) is a binary image after dilation operation, the operation steps of the dilation operation are similar to those of the erosion operation, firstly, the shape and original position of the structure element SE are determined, then the first pixel point with a gray value of 0 in the binary image is scanned and the structure element is moved to the position, if there is a pixel point with a gray value of 1 among the pixel points covered by the structure element, the gray values of all the pixels covered by the structure element are set to 1, then the structure element is translated.
[0069] Further, the opening and closing operation of image morphology means that the image is processed by combining and processing the erosion and dilation.
[0070] The closing operation means that the same structure element is used to perform the dilation and erosion operation on the image in sequence, the closing operation can fill small holes in the interior of the region of interest, and the closing operation formula is as follows:
[0071]
[0072] The opening operation means that the same structure element is used to perform the erosion and dilation operation on the image in sequence, which is opposite to the closing operation, the opening operation can effectively smooth the protruding part of the boundary of the region of interest, separate the connection between the regions of interest, and eliminate the pixel blocks smaller than the structure element, and the opening operation formula is as follows:
[0073]
[0074] Further, in step S5, the specific steps of the watershed algorithm based on the extended maximum value transformation include:
[0075] First step: for a given gray image F(x, y), the degree of gray change of the image is calculated, and the formula is as follows:
[0076]
[0077] In the formula, represents the degree of change of the gray value in the horizontal direction, represents the degree of change of the gray value in the vertical direction; the greater the gradient value, the more likely the place is the boundary of the contour, and the smaller the gradient value, the more likely the place is the background or uniform region; the function of calculating the image gradient is to establish the boundary;
[0078] Second step: mark the initial seed region by expanding the maximum value, and the definition of the expanding maximum value is as follows:
[0079]
[0080] In the formula, F(x, y) represents the gray value of the input image at (x, y), max 邻域(N) F(x, y)-h represents the maximum gray value in the current pixel field window N, and h is a controllable threshold value. By controlling the size of the threshold value, the number of initial seed regions can be controlled. The seed region is a "water injection" point.
[0081] Third step: execute the "water injection" process, as shown below:
[0082] F t (x, y) = min(f(x, y), max(F t-1 (x, y), Dilate(F t-1 (x, y)))
[0083] In the formula, F t (x, y) represents the "water injection" state at time t, f(x, y) represents the gray value at (x, y), and F t-1 (x, y) is the "water injection" state at time t-1, and Dilate(F t-1 (x, y)) is the update of the state at the last time by morphological dilation;
[0084] Fourth step: establish the segmentation boundary, and the definition of the boundary line is as follows:
[0085]
[0086] In the formula, D(x, y) represents the mark of whether there is a boundary line at position (x, y), 1 represents that there is a boundary line, and 0 represents that there is no boundary line; when the water injection process converges at the place with the maximum gradient, the boundary is established between these regions, so as to realize accurate image segmentation.
[0087] The expanding maximum value marks the position of the "mountain peak", which is used to guide the position of the "water injection", and the gradient defines the boundary of the graph, and the water stops flowing at the boundary, thereby generating the boundary line.
[0088] The beneficial effects of the present application have at least the following points:
[0089] The present application includes image preprocessing, image denoising, image enhancement, threshold segmentation, watershed segmentation of the adhesion part, accurate analysis of the number, size, distribution and other characteristics of the granular cement block, so as to judge whether the cement is uniformly stirred. This method provides an objective evaluation means for cement quality, avoids subjective errors generated by traditional naked eye judgment, and improves the accuracy and reliability of the judgment.
[0090] The present application improves the brightness of the image taken in the insufficient light environment through the low-illumination image enhancement preprocessing based on the HSI color space of the image, and ensures that the subsequent image processing process can maintain high efficiency and accuracy. DETAILED DESCRIPTION
[0091] The preferred embodiments of the present application are described in detail below, so that the advantages and characteristics of the present application can be more easily understood by those skilled in the art, and the protection scope of the present application can be more clearly and explicitly defined.
[0092] Embodiment: A cement homogeneity detection method based on image processing, comprising the following steps:
[0093] S1, image preprocessing: first, the original image of the three-channel RGB color of the stirred cement is acquired by the camera, and then the original image is converted into a gray image; converting the original image into a gray image can reduce the complexity of the calculation, so that the subsequent processing can be more focused on the shape features and structural features;
[0094] In step S1, the original RGB three-channel image is converted into a gray image by a weighted average method:
[0095] R=G=B=WR+VG+UB
[0096] In the formula, W, V, U respectively represent the weights of R (red), G (green) and B (blue) three different channels in the original image. When W=0.30, V=0.59, U=0.11, the most reasonable gray image can be obtained;
[0097] S2, image denoising: the image acquired by the camera has salt and pepper noise generated from the image sensor and the decoding process. The effective information in the gray image is disturbed by the salt and pepper noise, which has adverse factors on the subsequent processing, so it is necessary to eliminate the salt and pepper noise by filtering technology, that is, to smooth the gray image. The salt and pepper noise can be effectively removed by filtering technology;
[0098] In step S2, the adaptive median filter is used to remove the influence of salt and pepper noise, and the specific steps are as follows:
[0099] First step: define a window W(i,j,k) with pixel p(i,j) as the center, k is the size of the window, for example, 3x3. Define a k max , k max is the maximum window size, which determines the number of iterations;
[0100] Second step: calculate the maximum, minimum and median of the gray value in the window;
[0101] m min = min(W(i,j,k))
[0102] m max = max(W(i,j,k))
[0103] m med = med(W(i,j,k))
[0104] Third step: determine whether the center pixel is noise, the noise judgment method is as follows:
[0105] m min <p(i,j)<m max ∧m med ≠p(i,j)
[0106] When the above conditions are not met, it is considered as noise, and the value of p(i,j) is replaced by the median m med of the window.
[0107] Fourth step: if the current pixel is noise, gradually enlarge the size of the window until k max , and repeat the above calculation. By using the above algorithm to traverse all pixels in the image, the influence of salt and pepper noise can be effectively removed.
[0108] S3, image enhancement: in order to better highlight the outline information of cement and get better effect in subsequent image segmentation, the denoised image needs to be enhanced to improve image clarity and contrast, and Laplace enhancement algorithm is adopted to sharpen and enhance details of gray image;
[0109] In step S3, the Laplace operator is a second order differential equation. For a two-dimensional gray image f(x,y), the Laplace operator is defined as follows:
[0110]
[0111] Where f(x,y) is the gray value of the pixel at (x,y) in the image, The Laplacian operator is represented by calculating the second-order derivatives in the horizontal and vertical directions, and can accurately locate the edge position of the image, because the change of the gray value is very large at the edge of the image, and the Laplacian operator will output a higher value;
[0112] For a discrete gray image, the Laplacian operator is discretized into a convolution kernel, as follows:
[0113]
[0114] The mathematical process formula of the actual gray image for Laplacian enhancement is as follows:
[0115]
[0116] Where L(i,j) is the value of the Laplacian convolution kernel, f(x+i,y+j) is the pixel value of the image at (x+i,y+j) centered at (x,y), and g(x,y) is the output enhancement result;
[0117] Laplacian enhancement highlights the boundaries and contours of the image, but reduces the overall brightness of the image. By superimposing the results of the Laplacian convolution with the original image, the overall details of the original image are preserved, and the brightness loss is within an acceptable range. The specific formula is as follows:
[0118]
[0119] In the formula, c is the enhancement coefficient, and increasing the value of c can make the edge clearer, but too large will produce additional noise.
[0120] S4, threshold segmentation: the part of the uniformly stirred cement is called background, and the part of the non-uniformly stirred and granular is called the part of interest, the background and the part of interest have gray difference, and the part of interest is recognized by threshold segmentation according to the gray difference;
[0121] In step S4, the principle of threshold segmentation is to use the gray difference between the background region and the target value, i.e. to convert the gray value to 0 or 1 according to the change of the gray value, so as to divide the image into the part of interest and the background. The mathematical formula of threshold segmentation is as follows:
[0122]
[0123] In the formula, f(x,y) represents the gray function of the pixels in the original image, g(x,y) represents the pixel function after threshold segmentation, and T is the gray threshold;
[0124] The threshold segmentation transforms the gray scale of the pixels with the gray value less than T to 0 and eliminates as background, and transforms the gray scale of the pixels with the gray value greater than or equal to T to 1, so as to realize the segmentation of the image; the threshold T determines the accuracy of the subsequent further processing, the threshold T is determined by using the maximum inter-class segmentation method, the segmentation threshold is adaptively obtained from the image, instead of setting a fixed value;
[0125] The calculation process of the maximum inter-class variance is as follows:
[0126] Let ω1(T) be the proportion of the pixels less than the threshold T, and the calculation formula is as follows:
[0127]
[0128] Let ω2(T) be the proportion of the pixels greater than or equal to the threshold T, and the calculation formula is as follows:
[0129] ω2(T) = 1-ω1(T)
[0130] The mean values of the foreground class and the background class are defined as μ1(T), μ2(T), and the calculation formula is as follows:
[0131]
[0132] In the formula, L is the maximum gray scale of the pixels, and μ is the global average value of the image G The calculation formula is as follows:
[0133]
[0134] The inter-class variance is the variance between the foreground class and the background class, and the calculation formula is as follows:
[0135]
[0136] Find a maximum threshold T, so that reaches the maximum, at this time, T is the segmentation threshold.
[0137] S5, watershed segmentation of the adhesion part: a binary image of the mixed cement is obtained by threshold segmentation, the unevenly mixed cement part can be extracted, but it can be found that the unevenly mixed cement blocks are mutually adhered after magnification by using image processing software, so a suitable algorithm is needed for further segmentation; the watershed algorithm is an algorithm based on the basic principle of geographical features, and the specific principle is that the gray level of each pixel is regarded as the altitude, and the points with small gray level difference in the region are connected to form a closed region, so as to form a watershed. Accurate segmentation of the adhesion region of the image needs to set a suitable watershed ridge line, and the application adopts a watershed segmentation method based on extended maximum value transformation, identifies a plurality of local maximum gray value points, and merges them into a unique maximum value point, so as to effectively solve the problem of over-segmentation, and realize accurate segmentation of the adhesion region;
[0138] In step S5, the specific steps of the watershed algorithm based on the extended maximum value transformation include:
[0139] First step: for a given gray image F(x, y), the gray level change degree of the image is calculated, and the formula is as follows:
[0140]
[0141] In the formula, represents the change degree of the gray value in the horizontal direction gradient, represents the change degree of the gray value in the vertical direction; the greater the gradient value, the more likely it is the boundary of the contour, and the smaller the gradient value, the more likely it is the background or uniform region; the purpose of calculating the image gradient is to establish the boundary;
[0142] Second step: label the initial seed region by extending the maximum value, and the definition of the extended maximum value is as follows:
[0143]
[0144] In the formula, F(x, y) represents the gray value of the input image at (x, y), max 邻域(N) F(x, y)-h represents the maximum gray value in the current pixel field window N (for example, 4*4), and h is a controllable threshold value. By controlling the size of the threshold value, the number of initial seed regions can be controlled. The seed region is a "water injection" point.
[0145] Third step: execute the "water injection" process, and the formula is as follows:
[0146] F t (x, y) = min(f(x, y), max(F t-1 (x, y), Dilate(F t-1 (x, y)))
[0147] where F t (x,y) represents the "flood fill" state at time t, f(x,y) represents the gray value at position (x,y), F t-1 (x,y) is the "flood fill" state at time t-1, Dilate(F t-1 (x,y)) is the update of the state at the previous time by morphological dilation;
[0148] Step 4: Establish the segmentation boundary, the boundary line is defined as follows:
[0149]
[0150] where D(x,y) represents the marker of whether there is a boundary line at position (x,y), 1 represents the existence of the boundary line, and 0 represents the non-existence of the boundary line; when the flood fill process converges at the place with the largest gradient, the boundary is established between these regions, thereby realizing the accurate image segmentation.
[0151] The extended maximum value marks the position of the "mountain peak", which is used to guide the position of the "flood fill", and the gradient defines the boundary of the figure, and the water stops flowing at the boundary, thereby generating the boundary line.
[0152] S6, homogeneity judgment: through a series of secondary processing of the image, the shape of the particles in the image is smoothed, and the irregular regions of the connected boundary are connected, and then the binarization and watershed segmentation algorithm is used to extract the particles in the image which are not uniformly stirred. The extracted particles are subjected to statistical analysis of the number and area, and the uniformity of the cement is evaluated in combination with the characteristics of different types of cement, so as to judge whether the cement has been fully stirred.
[0153] The low-illumination image can be pre-processed before image processing in step S1. The traditional digital image processing method is carried out in the RGB color domain, and the color contrast of the cement mixture image is low. Therefore, the external lighting condition has a great influence on the shooting effect, and a large error may occur. In order to solve the error caused by insufficient lighting, the patent proposes a pre-processing technology based on the image HSI color space;
[0154] The HSI color model is composed of hue, saturation and brightness, which is similar to the way the human eye perceives color. In the HSI color space, brightness is an independent channel and has no direct connection with color information, and hue and saturation together determine the basic color of the image. In practical application, the adjustment of the brightness of the image will not affect its color characteristics, ensuring the flexibility of image processing. The low-illumination image enhancement pre-processing technology based on the image HSI color space is adopted to realize the self-adaptive brightening of the image.
[0155] The red, green and blue three channels (R, G, B) values in the collected RGB image can be converted into HSI image through geometric derivation formula, as follows:
[0156] Hue:
[0157] Wherein,
[0158] Saturation:
[0159]
[0160] Brightness:
[0161]
[0162] The image is subjected to global adaptive HDR processing through improved Retinnex algorithm, so as to realize adaptive brightening of the image, and the formula is as follows:
[0163]
[0164] In the formula, L w is the average value of brightness, L w (x, y) is the brightness value of the image, L wmax is the maximum value of brightness, L g (x, y) is the output result after adaptive HDR;
[0165] In order to extract the unevenly stirred cement part in the image, after the Retinnex algorithm image brightness enhancement in the HSI color space, RGB color space recovery is still needed, and then the above processing steps are subjected to secondary processing.
[0166] Morphological processing can be performed between steps S4 and S5: repeatedly applying erosion, dilation, opening operation and closing operation in image morphology to the image to be processed can effectively fill the recesses and holes of the region of interest, and remove meaningless pixel blocks; the cyclic use of these operations enhances the effect of image processing, so that the target region is more complete (in this embodiment, the threshold segmented image will have a large number of adhered or hollow regions of interest (unevenly stirred parts). By using the dilation operation of image morphology principle, the small holes inside the region of interest can be connected, in addition, by using the erosion operation, the meaningless small regions of interest can be removed, and the adhesion between the regions of interest can be disconnected.
[0167] The calculation formula of image erosion is as follows:
[0168]
[0169] In the formula, SE is a structure element, f b(x, y) is the original binary image, f be (x, y) is the binary image after the erosion operation; the structure element SE can be in various shapes, such as a cross, a circle or more self-defined shapes, SE xy is the position of the structure element. The specific operation steps are as follows: firstly, the shape and the original position of the structure element SE are determined, and the first pixel point with a gray value of 1 in the binary image is scanned, then the structure element is moved to the position of the pixel point, if the gray values of all the pixel points covered by the structure element are 1, the structure element is translated; if there is a pixel point with a gray value of 0 in the region covered by the structure element, the gray values of all the pixel points covered by the structure element are set to 0, and then the structure element is translated for the next operation.
[0170] The calculation formula of the image dilation is as follows:
[0171]
[0172] In the formula, f bd (x, y) is the binary image after the dilation operation, and the operation steps of the dilation operation are similar to those of the erosion operation, that is, firstly, the shape and the original position of the structure element SE are determined, then the first pixel point with a gray value of 0 in the binary image is scanned, and the structure element is moved to the position, if there is a pixel point with a gray value of 1 in the pixel points covered by the structure element, the gray values of all the pixels covered by the structure element are set to 1, and then the structure element is translated.
[0173] The opening and closing operation of the image morphology refers to combining and processing the image erosion and dilation;
[0174] The closing operation refers to sequentially performing the dilation and erosion operation on the image by using the same structure element, and the closing operation can fill small holes in the interior of the region of interest, and the closing operation formula is as follows:
[0175]
[0176] The opening operation refers to sequentially performing the erosion and dilation operation on the image by using the same structure element, which is opposite to the closing operation, and the opening operation can effectively smooth the protruding part of the boundary of the region of interest, separate the connection between the regions of interest, and eliminate the pixel blocks smaller than the structure element, and the opening operation formula is as follows:
[0177]
[0178] The above are only embodiments of the present application, and do not limit the patent scope of the present application, and any equivalent structural transformation made by using the present application specification, or direct or indirect application in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A method for detecting the homogeneity of cement based on image processing, characterized in that: Includes the following steps: S1. Image preprocessing: First, the original image of the cement after mixing (three-channel RGB color) is acquired by the camera, and then the original image is converted into a grayscale image. S2. Image noise reduction: Salt-and-pepper noise is eliminated through filtering techniques, which can effectively remove the influence of salt-and-pepper noise; S3. Image Enhancement: The Laplacian enhancement algorithm is used to sharpen and enhance the details of the grayscale image; S4. Threshold segmentation: The uniformly mixed cement part is called the background, and the part that is not uniformly mixed and has a granular texture is called the part of interest. There is a gray level difference between the background and the part of interest. Threshold segmentation is performed based on the gray level difference to identify the part of interest that is not uniformly mixed. S5. Watershed segmentation of the adhered region: By adopting the watershed segmentation method based on extended maximum transformation, multiple local maximum gray value points are identified and merged into a unique maximum value point, thereby effectively solving the problem of over-segmentation and achieving accurate segmentation of the adhered region. S6. Homogeneity judgment: The extracted particles are then subjected to statistical analysis of quantity and area. Combined with the characteristics of different types of cement, the uniformity of the cement is evaluated to determine whether it has been sufficiently mixed.
2. The cement homogeneity detection method based on image processing according to claim 1, characterized in that: Before image processing in step S1, low-light images can be enhanced by preprocessing. Low-light image enhancement preprocessing technology based on the image HSI color space is used to achieve adaptive brightening of the image.
3. The cement homogeneity detection method based on image processing according to claim 2, characterized in that: Through geometric derivation, the red, green, and blue channel values in the acquired RGB image can be converted into an HSI image, as shown in the following formula: tone: in, Saturation: brightness: By improving the Retinnex algorithm, global adaptive HDR processing is performed on the image to achieve adaptive image brightening. The formula is as follows: In the formula, L w L represents the average brightness. w (x,y) represents the image brightness value, L wmax L represents the maximum brightness. g (x,y) represents the output result after adaptive HDR; To extract the unevenly mixed cement portion from the image, after enhancing the image brightness using the Retinnex algorithm in the HSI color space, it is still necessary to restore the RGB color space and then perform secondary processing using the above steps.
4. The cement homogeneity detection method based on image processing according to claim 1, characterized in that: In step S2, an adaptive median filter is used to remove the influence of salt-and-pepper noise. The specific steps are as follows: Step 1: Define a window W(i,j,k) centered at pixel p(i,j), where k is the size of the window. Define a k... max k max The maximum window size determines the number of iterations; Step 2: Calculate the maximum, minimum, and median grayscale values in the window; m min =min(W(i,j,k)) m max =max(W(i,j,k)) m med =med(W(i,j,k)) Step 3: Determine if the center pixel is noise. The method for noise determination is as follows: m min <p(i,j)<m max ∧m med ≠p(i,j) If the above conditions are not met, it is considered noise, and the value of p(i,j) is replaced with the median m in the window. med ; Step 4: If the current pixel is noise, gradually increase the window size until k max The above calculation is repeated, and by using the above algorithm to traverse all pixels in the image, the influence of salt and pepper noise can be effectively removed.
5. The cement homogeneity detection method based on image processing according to claim 1, characterized in that: In step S3, the Laplacian operator is a second-order differential equation. For a two-dimensional grayscale image f(x,y), the Laplacian operator is defined as follows: Where f(x,y) is the gray value of the pixel at (x,y) in the image. The Laplacian operator, by calculating the second derivatives in the horizontal and vertical directions, can accurately locate the edge of an image. This is because the grayscale values change significantly at the edges of an image, resulting in a higher output value for the Laplacian operator. For discrete grayscale images, the Laplacian operator is discretized into a convolution kernel, as shown below: The mathematical formula for performing Laplacian enhancement on a real grayscale image is as follows: Where L(i,j) is the value of the Laplacian convolution kernel, f(x+i,y+j) is the pixel value at (x+i,y+j) centered at (x,y) in the image, and g(x,y) is the output enhancement result; Laplacian enhancement highlights image boundaries and contours, but reduces overall image brightness. By superimposing the result of Laplacian convolution onto the original image, the overall details of the original image are preserved, and the brightness loss is within an acceptable range. The specific formula is as follows: In the formula, c is the enhancement coefficient. Increasing the value of c can make the edges clearer, but too large a value will produce additional noise.
6. The cement homogeneity detection method based on image processing according to claim 1, characterized in that: In step S4, the principle of threshold segmentation is to utilize the gray-level difference between the background region and the target value, that is, to change the gray-level value to 0 or 1 based on the change of gray-level value, thereby dividing the image into the part of interest and the background. The mathematical formula for threshold segmentation is as follows: In the formula, f(x,y) represents the grayscale function of the pixels in the original image, g(x,y) represents the pixel function after thresholding, and T is the grayscale threshold. Thresholding segmentation transforms the gray levels of pixels with gray values less than T to 0 and eliminates them as background, while transforming the gray levels of pixels with gray values greater than or equal to T to 1, thereby achieving image segmentation. The threshold T determines the accuracy of subsequent processing. The maximum inter-class segmentation method is used to determine the threshold T, so that the segmentation threshold is adaptively obtained from the image, rather than setting a fixed value. The calculation process for the maximum inter-class variance is as follows: Let ω1(T) be the proportion of pixels less than the threshold T, calculated using the following formula: Let ω2(T) be the proportion of pixels that are greater than or equal to the threshold T. The calculation formula is as follows: ω2(T)=1-ω1(T) The mean values of the foreground and background classes are defined as μ1(T) and μ2(T), respectively, and are calculated using the following formulas: global average value μ of the image G The calculation formula is as follows: Between-class variance The variance between the front class and the background class is calculated using the following formula: Find the maximum threshold T such that When it reaches its maximum, T is the segmentation threshold.
7. The cement homogeneity detection method based on image processing according to claim 1, characterized in that: Morphological processing can be performed between steps S4 and S5: repeatedly applying erosion, dilation, opening and closing operations in image morphology to the image to be processed can effectively fill depressions and holes in the region of interest and remove meaningless pixel blocks.
8. The cement homogeneity detection method based on image processing according to claim 7, characterized in that: The formula for calculating image erosion is as follows: In the formula, SE is the structural element, f b (x,y) is the original binary image, f be (x,y) is the binary image after erosion. The specific operation steps are as follows: First, determine the shape and origin position of the structuring element SE and scan to obtain the first pixel with a gray value of 1 in the binary image. Then, move the structuring element to the position of this pixel. If the gray values of all the pixels in the binary image covered by the structuring element are 1, then translate the structuring element. If there are pixels with a gray value of 0 in the area covered by the structuring element, then set the gray values of all the pixels covered by the structuring element to 0, then translate the structuring element, and perform the same operation again. The formula for calculating image dilation is as follows: In the formula f bd (x,y) is the binary image after dilation. The steps of dilation and erosion are similar. First, determine the shape and origin of the structuring element SE. Then, scan the first pixel with a gray value of 0 in the binary image and move the structuring element to this position. If there is a pixel with a gray value of 1 in the pixels covered by the structuring element, then set the gray value of all pixels covered by the structuring element to 1. Then, translate the structuring element.
9. The cement homogeneity detection method based on image processing according to claim 8, characterized in that: Opening and closing operations in image morphology refer to the combination and processing of image erosion and dilation. Closing operation refers to performing dilation and erosion operations on an image sequentially using the same structuring element. Closing operation can fill small holes inside the region of interest. The formula for closing operation is as follows: Opening operation refers to performing erosion and dilation operations on an image sequentially using the same structuring element. In contrast to closing operation, opening operation effectively smooths protrusions at the boundaries of regions of interest, separates connections between regions of interest, and eliminates pixel blocks smaller than the structuring element. The opening operation formula is as follows:
10. The cement homogeneity detection method based on image processing according to claim 1, characterized in that: In step S5, the specific steps of the watershed algorithm based on the extended maximum transform include: Step 1: For a given grayscale image F(x,y), calculate the degree of grayscale variation in the image, using the following formula: In the formula This indicates the degree of change in grayscale value along the horizontal gradient. It represents the degree of change of gray values in the vertical direction; the larger the gradient value, the more likely it is to be the boundary of a contour, while the smaller the gradient value, the more likely it is to be the background or a uniform area; the purpose of calculating the image gradient is to establish boundaries. Step 2: Mark the initial seed region by expanding the maxima. The definition of the expanded maxima is as follows: In the formula, F(x,y) represents the gray value of the input image at (x,y), and max 邻域(N) F(x,y)-h represents the maximum gray value in the current pixel neighborhood window N. h is a controllable threshold. By controlling the size of the threshold, the number of initial seed regions can be controlled. Seed regions are also known as "water injection" points. Step 3: The "flooding" process is executed, and the results are as follows: F t (x,y)=min(f(x,y),max(F t-1 (x,y),Dilate(F t-1 (x,y)))) In the formula F t (x,y) represents the "watering" state at time t, f(x,y) represents the grayscale value at position (x,y), and F t-1 (x,y) represents the "watering" state at time t-1, Dilate(F t-1 (x,y)) updates the state of the previous time step through morphological dilation; Step 4: Establish the dividing boundary. The boundary line is defined by the following formula: In the formula, D(x,y) represents the marker of whether there is a boundary line at position (x,y), 1 indicates that there is a boundary line, and 0 indicates that there is no boundary line. When the irrigation process converges at the place with the largest gradient, the boundary is established between these regions, thereby achieving accurate image segmentation. The extended maxima mark the location of the "peaks" to guide the location of the "watering" points. The gradient defines the boundaries of the graph, where the water stops flowing, thus generating the dividing line.
Citation Information
Cited By
Image detection method applied to water-soluble fertilizer production
CN121391833A