A quality testing and analysis method for rotor flowmeter production process
By performing grayscale processing and sliding window traversal on the surface of the rotor flowmeter, crack characteristic values are calculated and adaptive optimization is carried out, the problem of inaccurate identification in the prior art is solved, and the accuracy of identification and quality classification is improved.
Patent Information
- Application Number
- CN202411362828.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-27
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2044-09-27
AI Technical Summary
The prior art, when identifying surface cracks of rotor flowmeters, details are easily lost and are disturbed by surface texture and reflection, resulting in inaccurate identification.
By obtaining the surface image of the rotor flowmeter, performing grayscale processing and sliding window traversal, calculating the grayscale correlation coefficient and gradient correlation coefficient of the local area and the cracks in the direction, performing adaptive optimization, and obtaining the final optimized texture feature value for quality classification.
It improves the accuracy of identification of surface cracks of the rotor flowmeter, enhances the accuracy of mass classification, and reduces interference to texture and reflection.
Smart Images

Figure CN119251573B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of image processing, and in particular to a quality testing and analysis method used in a rotor flowmeter production process. Background Art
[0002] Impurities or uneven materials in the rotor flowmeter during production, uneven stress in the material due to improper heat treatment (such as quenching or annealing), excessive grinding or cutting during processing may all lead to cracks in the finished product. Cracks may cause abnormal movement of the rotor of the flowmeter, thus affecting the accuracy of flow measurement. If the crack further develops into a crack, it will cause the flowmeter seal to fail and cause fluid leakage. Therefore, it is very important to identify and detect surface cracks in the rotor flowmeter.
[0003] In the prior art, a grayscale co-occurrence matrix is used to identify and detect surface cracks of a rotor flowmeter. Specifically, the feature mean values corresponding to the four directions of the pixels in each sliding window in the grayscale image of the rotor flowmeter surface are calculated to obtain a grayscale co-occurrence matrix corresponding to the grayscale image of the rotor flowmeter surface, and the surface cracks of the rotor flowmeter are judged. The rotor flowmeter is then quality-classified according to the surface cracks. However, since only the grayscale co-occurrence matrix obtained by the feature mean value in each direction is used to identify and detect surface cracks of the rotor flowmeter, many crack details are lost, making the identification of cracks on the surface of the rotor flowmeter inaccurate. In addition, since the surface of the rotor flowmeter itself has a certain texture and the surface of the flowmeter generally has a coating that is smooth and has reflections, there is a lot of interference in the judgment of surface cracks of the rotor flowmeter.
[0004] Therefore, how to improve the accuracy of surface crack identification of rotor flowmeters to improve the accuracy of rotor flowmeter quality classification has become an urgent problem to be solved. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a quality testing and analysis method for a rotor flowmeter in a production process, so as to improve the accuracy of identifying surface cracks of the rotor flowmeter, so as to improve the accuracy of quality classification of the rotor flowmeter.
[0006] An embodiment of the present invention provides a quality testing and analysis method for a rotor flowmeter production process, the method comprising the following steps:
[0007] Acquire a surface image of the rotor flowmeter, perform grayscale processing on the surface image to obtain a corresponding grayscale image, and perform sliding traversal on the grayscale image using a preset sliding window and sliding step size to obtain at least one local area, wherein one local area corresponds to one sliding window;
[0008] For any local area, a gray level co-occurrence matrix corresponding to the local area is obtained, and N initial texture feature values in a preset number of directions are obtained according to the gray level co-occurrence matrix;
[0009] For any direction, according to the pixel point positions in the local area, at least two pixel point sets in the direction are obtained, according to the gray value difference of the pixel points in each of the pixel point sets, the crack grayscale correlation coefficient in the direction is obtained, and according to the grayscale mean value of the pixel points in each of the pixel point sets, the crack gradient correlation coefficient in the direction is obtained;
[0010] According to the crack grayscale correlation coefficient and the crack gradient correlation coefficient in the direction, adaptively optimize the N initial texture feature values in the direction to obtain N optimized texture feature values, and according to the N optimized texture feature values in each direction, obtain N final optimized texture feature values of the local area;
[0011] The rotor flowmeter is quality classified according to the N final optimized texture feature values of each local area.
[0012] Preferably, obtaining the crack grayscale correlation coefficient in the direction according to the grayscale value difference of each pixel point in the pixel point set includes:
[0013] According to the grayscale value of each pixel point, a grayscale change curve corresponding to each pixel point set is constructed respectively, wherein one data point in the grayscale change curve corresponds to the grayscale value of one pixel point;
[0014] Counting the number of valley points in each of the grayscale change curves respectively, and obtaining the average number of valley points as the grayscale fluctuation coefficient in the direction;
[0015] Obtaining a grayscale similarity coefficient in the direction according to a grayscale difference between each of the trough points in each of the grayscale change curves and an adjacent data point of the trough point;
[0016] The addition result between the inverse of the grayscale fluctuation coefficient and the grayscale similarity coefficient is obtained as the crack grayscale correlation coefficient in the direction.
[0017] Preferably, obtaining the grayscale similarity coefficient in the direction according to the grayscale difference between each of the trough points in each of the grayscale change curves and the adjacent data points of the trough point includes:
[0018] For any valley point in any grayscale change curve, obtain the slope ratio between the valley point and the adjacent data points on the left and right sides of the valley point, and obtain the average slope ratio as the crack similarity corresponding to the grayscale change curve according to the slope ratio corresponding to each valley point;
[0019] According to the crack similarity corresponding to each of the grayscale change curves, an average crack similarity is obtained, and the inverse of the sum of the average crack similarity and a constant 1 is obtained, and the inverse is used as the grayscale similarity coefficient in the direction.
[0020] Preferably, obtaining the crack gradient correlation coefficient in the direction according to the grayscale mean of each pixel point in the pixel point set includes:
[0021] The grayscale means of all the pixels in each of the pixel point sets are obtained respectively, and the absolute values of the grayscale means difference between every two pixel point sets are calculated respectively to obtain the average absolute value of the difference, and the average absolute value of the difference is used as the crack gradient correlation coefficient in the direction.
[0022] Preferably, the method of adaptively optimizing N initial texture eigenvalues in the direction according to the crack grayscale correlation coefficient and the crack gradient correlation coefficient in the direction to obtain N optimized texture eigenvalues includes:
[0023] Normalizing the crack grayscale correlation coefficient and the crack gradient correlation coefficient in the direction respectively to obtain the target crack grayscale correlation coefficient and the target crack gradient correlation coefficient in the direction;
[0024] Dividing the N kinds of initial texture feature values into two categories according to the positive and negative correlation feature attributes corresponding to each of the initial texture feature values;
[0025] For any initial texture eigenvalue in any category, the target crack grayscale correlation coefficient and the target crack gradient correlation coefficient in the direction are used to adaptively optimize the initial texture eigenvalue to obtain the corresponding optimized texture eigenvalue.
[0026] Preferably, the N kinds of initial texture feature values are divided into two categories according to the positive and negative correlation feature attributes corresponding to each of the initial texture feature values, including:
[0027] For any one of the N initial texture feature values, if the positive and negative correlation feature attribute of the initial texture feature value is a positive correlation feature attribute, the initial texture feature value is classified as a first category;
[0028] If the positive-negative correlation feature attribute of the initial texture feature value is a negative correlation feature attribute, the initial texture feature value is classified as the second category.
[0029] Preferably, the step of using the target crack grayscale correlation coefficient and the target crack gradient correlation coefficient in the direction to adaptively optimize the initial texture feature value to obtain the optimized texture feature value in the direction includes:
[0030] When the initial texture eigenvalue belongs to the first category, taking the target crack grayscale correlation coefficient in the direction as a first weight, obtaining the product of the first weight and the initial texture eigenvalue as a first optimized texture eigenvalue in the direction, taking the target crack gradient correlation coefficient in the direction as a second weight, obtaining the product of the second weight and the initial texture eigenvalue as a second optimized texture eigenvalue in the direction, and obtaining the average of the first optimized texture eigenvalue and the second optimized texture eigenvalue as an optimized texture eigenvalue;
[0031] When the initial texture eigenvalue belongs to the second category, the difference between a constant 1 and the target crack grayscale correlation coefficient in the direction is obtained as a first weight, the product of the first weight and the initial texture eigenvalue is obtained as a first optimized texture eigenvalue in the direction, the difference between a constant 1 and the target crack gradient correlation coefficient in the direction is obtained as a second weight, the product of the second weight and the initial texture eigenvalue is obtained as a second optimized texture eigenvalue in the direction, and the average of the first optimized texture eigenvalue and the second optimized texture eigenvalue is obtained as the optimized texture eigenvalue.
[0032] Preferably, obtaining N kinds of final optimized texture feature values of the local area according to the N kinds of optimized texture feature values in each of the directions includes:
[0033] For any one of the N initial texture feature values, an optimized texture feature value in each of the directions is obtained, and an average optimized texture feature value is obtained as a final optimized texture feature value of the local area.
[0034] Preferably, the quality classification of the rotor flowmeter according to the N final optimized texture feature values of each local area includes:
[0035] For any local area, respectively obtain preset feature thresholds corresponding to N kinds of final optimized texture feature values of the local area, and divide the N kinds of final optimized texture feature values into a first target category and a second target category according to the categories of initial texture feature values corresponding to the N kinds of final optimized texture feature values;
[0036] If all the final optimized texture feature values in the first target category are greater than the corresponding preset feature threshold, and all the final optimized texture feature values in the second target category are less than the corresponding preset feature threshold, then the local area is marked as a crack area, otherwise, the local area is marked as a crack-free area;
[0037] If at least one local area is a crack area, all crack areas are obtained, and the rotor flowmeter is quality classified according to the areas of all crack areas;
[0038] If all local areas are crack-free areas, the quality classification result of the rotor flowmeter is high-quality.
[0039] Preferably, the quality classification of the rotor flowmeter according to the area of all crack regions includes:
[0040] The number of pixels in each crack area is counted as the area of the crack area, and the total area of all crack areas is obtained. If the total area is less than the preset crack area threshold, the quality classification result of the rotor flowmeter is good; if the total area is greater than or equal to the preset crack area threshold, the quality classification result of the rotor flowmeter is defective.
[0041] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0042] The present invention obtains a surface image of a rotor flowmeter, grayscales the surface image to obtain a corresponding grayscale image, and uses a preset sliding window and sliding step size to slide on the grayscale image to obtain at least one local area, wherein one local area corresponds to one sliding window; for any local area, a grayscale co-occurrence matrix corresponding to the local area is obtained, and N initial texture eigenvalues in a preset number of directions are obtained according to the grayscale co-occurrence matrix; for any direction, at least two sets of pixel points in the direction are obtained according to the position of pixel points in the local area, and each pixel point is obtained according to the position of each pixel point. According to the grayscale value difference of the pixel points in the set, the crack grayscale correlation coefficient in the direction is obtained, and according to the grayscale mean value of the pixel points in each of the pixel point sets, the crack gradient correlation coefficient in the direction is obtained; according to the crack grayscale correlation coefficient and the crack gradient correlation coefficient in the direction, the N initial texture eigenvalues in the direction are adaptively optimized to obtain N optimized texture eigenvalues, and according to the N optimized texture eigenvalues in each of the directions, the N final optimized texture eigenvalues of the local area are obtained; according to the N final optimized texture eigenvalues of each of the local areas, the rotor flowmeter is quality classified. Among them, since a lot of crack details will be lost when the surface cracks of the rotor flowmeter are identified by only using the grayscale co-occurrence matrix obtained by the feature mean in each direction, and since the cracks on the surface of the rotor flowmeter will also cause differences in light reflection or absorption, the identification of cracks on the surface of the rotor flowmeter is inaccurate. Therefore, the present invention first obtains all local areas of the surface grayscale image of the rotor flowmeter, and for any local area, respectively obtains the crack grayscale correlation coefficient and the crack gradient correlation coefficient corresponding to each direction in the local area, respectively as the optimization factors for each direction in the local area, optimizes multiple initial texture eigenvalues in each direction in the local area, and obtains multiple final optimized texture eigenvalues. According to all the final optimized texture eigenvalues in the grayscale image, the rotor flowmeter is quality classified, thereby improving the accuracy of identifying surface cracks of the rotor flowmeter, and further improving the accuracy of quality classification of the rotor flowmeter. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, 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 labor.
[0044] Figure 1 This is a method flow chart of a quality testing and analysis method for a rotor flowmeter production process provided by Embodiment 1 of the present invention;
[0045] Figure 2 These are all the pixels in a local area provided by the first embodiment of the present invention. DETAILED DESCRIPTION
[0046] Embodiments of the present disclosure are described in detail below, and examples of the embodiments are shown in the accompanying drawings. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present disclosure, but should not be understood as limiting the present disclosure.
[0047] It should be noted that the terms "first", "second", etc. in the specification of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure.
[0048] In order to illustrate the technical solution of the present invention, specific embodiments are provided below for illustration.
[0049] See also Figure 1 , is a method flow chart of a quality testing and analysis method for a rotor flowmeter production process provided in the first embodiment of the present invention, such as Figure 1 As shown, the method may include:
[0050] Step S101, obtain a surface image of the rotor flowmeter, grayscale the surface image to obtain a corresponding grayscale image, use a preset sliding window and sliding step size to slide traverse on the grayscale image to obtain at least one local area, wherein one local area corresponds to one sliding window.
[0051] During the production process of the rotor flowmeter, cracks may appear in the finished product due to the quality of the production materials, inappropriate heat treatment process, and reasons such as excessive grinding or cutting during the processing. The cracks will cause abnormal movement of the rotor in the rotor flowmeter, thereby affecting the accuracy of flow measurement. In order to more accurately identify cracks in the rotor flowmeter, in an embodiment of the present invention, a surface image of the rotor flowmeter is first obtained, and the surface image of the rotor flowmeter is grayed to obtain a corresponding grayscale image. The grayscale image is read using OpenCV to obtain the grayscale value of each pixel in the grayscale image. Then, taking the first pixel from the left in the obtained grayscale image as the starting point, a local area with a size of 7×7 is constructed as a sliding window in an order from left to right and from top to bottom. The sliding window is traversed on the grayscale image in an order from left to right and from top to bottom with a preset step size d to obtain Z local areas, where one local area corresponds to one sliding window.
[0052] It should be noted that since the grayscale processing technology is a well-known technology, it will not be elaborated here, and the size and step size of the sliding window set in the embodiment of the present invention are both empirical values, that is, d=1, and there is no restriction on this, and it can be set according to the implementation scenario.
[0053] Step S102: for any local area, obtain a gray level co-occurrence matrix corresponding to the local area, and obtain N types of initial texture feature values in a preset number of directions according to the gray level co-occurrence matrix.
[0054] In order to facilitate the subsequent optimization of the initial texture eigenvalues obtained by the traditional gray-level co-occurrence matrix, in an embodiment of the present invention, for any local area, the gray-level co-occurrence matrix corresponding to the local area is obtained according to the traditional gray-level co-occurrence matrix acquisition method, and five initial texture eigenvalues of the local area in four directions are obtained according to the gray-level co-occurrence matrix, where the four directions include 0°, 45°, 90° and 135°, and the five initial texture eigenvalues include an initial contrast texture eigenvalue (CON), an initial entropy texture eigenvalue (ENT), an initial uniformity texture eigenvalue (HOM), an initial energy texture eigenvalue (ASM) and an initial correlation texture eigenvalue (COR).
[0055] It should be noted that the number of initial texture feature values set in the embodiment of the present invention is an empirical value, which is not limited and can be set according to the implementation scenario, and the number of directions set is the 4 directions determined by obtaining the gray level co-occurrence matrix.
[0056] Step S103, for any direction, according to the pixel position in the local area, obtain at least two pixel point sets in the direction, according to the gray value difference of the pixels in each pixel point set, obtain the crack grayscale correlation coefficient in the direction, according to the grayscale mean of the pixels in each pixel point set, obtain the crack gradient correlation coefficient in the direction.
[0057] Since only the grayscale co-occurrence matrix obtained by the feature mean of each direction is used to identify and detect cracks on the surface of the rotor flowmeter, many crack details will be lost, making the identification of cracks on the surface of the rotor flowmeter inaccurate, and because the crack has local characteristics, that is, the grayscale values of the pixels located in the crack area are similar or change regularly in the direction of the crack extension, the grayscale fluctuation degree is small, and the grayscale value at the crack boundary is significantly different from that in the crack-free area, that is, it shows a higher gradient value. Therefore, in an embodiment of the present invention, for any direction, first, according to the pixel position in the local area, a set of all pixels in the direction is obtained, and then, according to the grayscale value difference of the pixels in each pixel set, the grayscale correlation coefficient of the crack in the direction is obtained, and finally, according to the grayscale mean of the pixels in each pixel set, the crack gradient correlation coefficient in the direction is obtained.
[0058] First, obtain all pixel sets in any direction. In order to facilitate the subsequent analysis of each pixel in each pixel set, the total number of pixels in each pixel set must be greater than or equal to 3. The specific method for obtaining all pixel sets in any direction is:
[0059] Taking the zth local area as an example, refer to Figure 2 , which is all the pixels in a local area of size 7×7. For the convenience of subsequent description, the size of the zth local area is defined as n×n, where n=7.
[0060] If the direction is 0°, then get the zth local area in the 0° direction (i.e. Figure 2 The horizontal direction) is a set of n pixels that are equal to the width of the z-th local area, that is, Figure 2 middle, is the first pixel point set in the 0° direction, is the second pixel point set in the 0° direction, and so on, to obtain the 7 pixel point sets in the 0° direction in the zth local area.
[0061] If the direction is 45°, then get the zth local area in the 45° direction (i.e. Figure 2 The diagonal direction from the upper right to the lower left in the figure is a set of 2n-5 pixels, that is, Figure 2 middle, is the first pixel set in the 45° direction, is the second pixel point set in the 45° direction, and so on, to obtain 9 pixel point sets in the 45° direction in the zth local area.
[0062] If the direction is 90°, then get the zth local area in the 90° direction (i.e. Figure 2 The vertical direction) is a set of n pixels with the same length as the zth local area, that is, Figure 2 middle, is the first pixel set in the 90° direction, is the second pixel point set in the 90° direction, and so on, to obtain the 7 pixel point sets in the 90° direction in the zth local area.
[0063] If the direction is 135°, then get the zth local area in the 135° direction (i.e. Figure 2 The diagonal direction from the upper left to the lower right in the figure is a set of 2n-5 pixels, that is, Figure 2 middle, is the first pixel point set in the 135° direction, is the second pixel point set in the 135° direction, and so on, to obtain 9 pixel point sets in the 135° direction in the z-th local area.
[0064] The step of obtaining the grayscale correlation coefficient of the crack in a direction according to the grayscale value difference of the pixel points in each pixel point set includes:
[0065] (1) According to the grayscale value of each pixel point, a grayscale change curve corresponding to each pixel point set is constructed respectively, wherein one data point in the grayscale change curve corresponds to the grayscale value of one pixel point.
[0066] In one embodiment, taking the ath direction as an example, according to the B pixel point sets obtained in step S103, according to the grayscale value of each pixel point, with the pixel point as the horizontal axis and the grayscale value corresponding to the pixel point as the vertical axis, B grayscale change curves corresponding to the B pixel point sets are constructed respectively, wherein one data point in the grayscale change curve corresponds to the grayscale value of a pixel point.
[0067] (2) Counting the number of valley points in each of the grayscale change curves respectively, and obtaining the average number of valley points as the grayscale fluctuation coefficient in the direction.
[0068] In one implementation, taking the ath direction as an example, the AMPD algorithm is used to obtain the valley points in each grayscale change curve, and the total number of valley points in B grayscale change curves is counted to obtain the average of the total number of valley points as the grayscale fluctuation coefficient in the ath direction. Then, the expression of the grayscale fluctuation coefficient in the ath direction is:
[0069]
[0070] in, represents the grayscale fluctuation coefficient in the ath direction, represents the number of valley points in the bth grayscale change curve, and B represents the total number of pixel points in the ath direction, that is, the total number of grayscale change curves in the ath direction.
[0071] It should be noted that The smaller the value is, the smaller the total number of valley points in the B grayscale change curves is, indicating that the grayscale value fluctuation degree of the pixel point in the a-th direction is smaller, that is, the greater the possibility of belonging to the crack area, and the smaller the grayscale fluctuation coefficient in the a-th direction is.
[0072] (3) Obtaining a grayscale similarity coefficient in the direction according to a grayscale difference between each of the trough points in each of the grayscale change curves and an adjacent data point of the trough point.
[0073] Specifically, for any trough point in any grayscale change curve, the slope ratio between the adjacent data points on the left and right sides of the trough point and the trough point is obtained, and according to the slope ratio corresponding to each trough point, the average slope ratio is obtained as the crack similarity corresponding to the grayscale change curve;
[0074] According to the crack similarity corresponding to each of the grayscale change curves, an average crack similarity is obtained, and the inverse of the sum of the average crack similarity and a constant 1 is obtained, and the inverse is used as the grayscale similarity coefficient in the direction.
[0075] In one implementation, taking the bth grayscale change curve in the ath direction as an example, the slope ratio between each valley point on the bth grayscale change curve and the adjacent data points on both sides of the valley point is obtained, and the average slope ratio is obtained as the crack similarity corresponding to the bth grayscale change curve. According to the crack similarities corresponding to B grayscale change curves, the grayscale similarity coefficient in the ath direction is obtained, and the expression of the grayscale similarity coefficient in the ath direction is:
[0076]
[0077]
[0078] in, represents the grayscale similarity coefficient in the ath direction, Indicates the crack similarity of the bth grayscale change curve in the ath direction, It represents the slope of the xth valley point and the left adjacent data point of the xth valley point in the bth grayscale change curve in the ath direction. It represents the slope of the xth valley point and the right adjacent data point of the xth valley point in the bth grayscale change curve in the ath direction. represents the number of valley points in the bth grayscale change curve, B represents the total number of pixel points in the ath direction, that is, the total number of grayscale change curves in the ath direction, 1 represents a constant, and || represents an absolute value.
[0079] It should be noted that The closer the value is to -1, the closer the grayscale value change law of the valley point in the bth grayscale change curve in the ath direction and the data points on both sides is to the grayscale value change law of the crack area, that is, the greater the possibility of belonging to the crack area. In order to facilitate the subsequent analysis of the obtained crack grayscale correlation coefficient, by adding a constant 1, The closer the value is to 0, the closer the grayscale value change law of the valley point and the data points on both sides of the a-th direction is to the grayscale value change law of the crack area, that is, the greater the possibility of belonging to the crack area, and the larger the grayscale similarity coefficient in the a-th direction is.
[0080] (4) Obtaining the sum of the inverse of the grayscale fluctuation coefficient and the grayscale similarity coefficient as the crack grayscale correlation coefficient in the direction.
[0081] In one implementation, taking the ath direction as an example, the grayscale correlation coefficient of the crack in the ath direction is obtained according to the grayscale fluctuation coefficient in the ath direction and the grayscale similarity coefficient in the ath direction, and the expression of the crack grayscale correlation coefficient in the ath direction is:
[0082]
[0083] in, represents the crack grayscale correlation coefficient in the ath direction, represents the grayscale similarity coefficient in the ath direction, Represents the grayscale fluctuation coefficient in the ath direction.
[0084] It should be noted that if <0, it means that all pixels in the ath direction do not belong to the crack area, and the crack grayscale correlation coefficient in the ath direction is taken as 0, that is, =0, if >0, The larger the value, the greater the possibility that the pixel point in the a-th direction belongs to the crack area, the greater the contribution to the crack grayscale correlation coefficient in the a-th direction, and the larger the value of the crack grayscale correlation coefficient in the a-th direction. The smaller the value of , the greater the possibility that the pixel point in the a-th direction belongs to the crack area, the greater the contribution to the crack grayscale correlation coefficient in the a-th direction, and the larger the value of the crack grayscale correlation coefficient in the a-th direction.
[0085] The step of obtaining the crack gradient correlation coefficient in a direction according to the grayscale mean of the pixel points in each pixel point set includes:
[0086] The grayscale means of all the pixels in each of the pixel point sets are obtained respectively, and the absolute values of the grayscale means difference between every two pixel point sets are calculated respectively to obtain the average absolute value of the difference, and the average absolute value of the difference is used as the crack gradient correlation coefficient in the direction.
[0087] In one embodiment, taking the b-th pixel point set in the a-th direction as an example, the absolute value of the difference in grayscale means between the b-th pixel point set and the b+1-th pixel point set is obtained, and the crack gradient correlation coefficient in the a-th direction is obtained according to the absolute value of the difference in grayscale means of every two adjacent pixel point sets. The expression of the crack gradient correlation coefficient in the a-th direction is:
[0088]
[0089] in, represents the crack gradient correlation coefficient in the ath direction, represents the grayscale mean of the b-th pixel set, represents the grayscale mean of the b+1th pixel set, R represents the number of all two adjacent pixel sets, and || represents the absolute value.
[0090] It should be noted that The smaller the value of is, the greater the difference between the grayscale mean of the b-th pixel set and the grayscale mean of the b+1-th pixel set is, indicating that the gradient change at the b-th pixel set is greater, that is, the greater the possibility that all pixels in the b-th pixel set belong to the crack area. The larger the value is, the greater the gradient change in the a-th direction is, and the greater the possibility that all pixels in the a-th direction belong to the crack area is, that is, the larger the crack gradient correlation coefficient in the a-th direction is.
[0091] Step S104, according to the crack grayscale correlation coefficient and the crack gradient correlation coefficient in the direction, adaptively optimize the N initial texture eigenvalues in the direction to obtain N optimized texture eigenvalues, and according to the N optimized texture eigenvalues in each direction, obtain N final optimized texture eigenvalues in the local area.
[0092] Since the crack area may cause differences in light reflection or absorption, the crack area often forms a clear contrast with the surrounding area in the grayscale image. Therefore, in the grayscale co-occurrence matrix, some eigenvalues at the crack are very different from those in the normal area. According to the actual situation, a greater weight is given to the initial texture eigenvalue in the direction where the crack exists, so that a more accurate texture eigenvalue can be obtained, thereby better performing texture feature analysis. Therefore, in the embodiment of the present invention, for any direction of any local area, first, according to the crack grayscale correlation coefficient and the crack gradient correlation coefficient in the direction, the 5 initial texture eigenvalues in the direction are adaptively optimized to obtain 5 optimized texture eigenvalues. Then, according to the N optimized texture eigenvalues in each direction, 5 final optimized texture eigenvalues of the local area are obtained.
[0093] Among them, according to the crack grayscale correlation coefficient and the crack gradient correlation coefficient in the direction, the five initial texture eigenvalues in the direction are adaptively optimized respectively to obtain five optimized texture eigenvalues, including:
[0094] (1) Normalizing the crack grayscale correlation coefficient and the crack gradient correlation coefficient in the direction respectively to obtain the target crack grayscale correlation coefficient and the target crack gradient correlation coefficient in the direction.
[0095] In one implementation, taking the ath direction as an example, the crack grayscale correlation coefficient and the crack gradient correlation coefficient in the ath direction are normalized to obtain the target crack grayscale correlation coefficient and the target crack gradient correlation coefficient in the ath direction. Then, the expressions of the target crack grayscale correlation coefficient and the target crack gradient correlation coefficient in the ath direction are respectively:
[0096]
[0097]
[0098] in, represents the grayscale correlation coefficient of the target crack in the ath direction, represents the crack grayscale correlation coefficient in the ath direction, represents the sum of the crack grayscale correlation coefficients in each direction, represents the target crack gradient correlation coefficient in the ath direction, represents the crack gradient correlation coefficient in the ath direction, Represents the sum of the crack gradient correlation coefficients in each direction.
[0099] (2) Dividing the N types of initial texture feature values into two categories according to the positive and negative correlation feature attributes corresponding to each type of initial texture feature value.
[0100] Specifically, for any one of the N types of initial texture feature values, if the positive and negative correlation feature attribute of the initial texture feature value is a positive correlation feature attribute, the initial texture feature value is classified as a first category;
[0101] If the positive-negative correlation feature attribute of the initial texture feature value is a negative correlation feature attribute, the initial texture feature value is classified as the second category.
[0102] In one embodiment, taking the i-th initial texture feature value in the a-th direction as an example, if the positive and negative correlation feature attribute of the i-th initial texture feature value is a positive correlation feature attribute (i.e., the larger the i-th initial texture feature value, the greater the possibility that all pixel points in the a-th direction belong to the crack area), the i-th initial texture feature value is classified as the first category;
[0103] If the positive and negative correlation characteristic attribute of the i-th initial texture eigenvalue is a negative correlation characteristic attribute (that is, the larger the i-th initial texture eigenvalue is, the smaller the possibility that all pixels in the a-th direction belong to the crack area is), then the i-th initial texture eigenvalue belongs to the second category.
[0104] According to the above classification method, the five initial texture eigenvalues are divided into two categories, where the first category includes the initial contrast texture eigenvalue (CON) and the initial entropy texture eigenvalue (ENT), and the second category includes the initial uniformity texture eigenvalue (HOM), the initial energy texture eigenvalue (ASM) and the initial correlation texture eigenvalue (COR).
[0105] (3) For any initial texture eigenvalue in any category, the initial texture eigenvalue is adaptively optimized using the target crack grayscale correlation coefficient and the target crack gradient correlation coefficient in the direction to obtain the corresponding optimized texture eigenvalue.
[0106] Specifically, when the initial texture eigenvalue belongs to the first category, the target crack grayscale correlation coefficient in the direction is used as a first weight, and the product of the first weight and the initial texture eigenvalue is obtained as a first optimized texture eigenvalue in the direction, the target crack gradient correlation coefficient in the direction is used as a second weight, and the product of the second weight and the initial texture eigenvalue is obtained as a second optimized texture eigenvalue in the direction, and the average of the first optimized texture eigenvalue and the second optimized texture eigenvalue is obtained as the optimized texture eigenvalue;
[0107] When the initial texture eigenvalue belongs to the second category, the difference between a constant 1 and the target crack grayscale correlation coefficient in the direction is obtained as a first weight, the product of the first weight and the initial texture eigenvalue is obtained as a first optimized texture eigenvalue in the direction, the difference between a constant 1 and the target crack gradient correlation coefficient in the direction is obtained as a second weight, the product of the second weight and the initial texture eigenvalue is obtained as a second optimized texture eigenvalue in the direction, and the average of the first optimized texture eigenvalue and the second optimized texture eigenvalue is obtained as the optimized texture eigenvalue.
[0108] In one embodiment, taking the initial contrast texture eigenvalue in the first category as an example, the target crack grayscale correlation coefficient in the ath direction is used as the first weight of the initial contrast texture eigenvalue, and the target crack gradient correlation coefficient in the ath direction is used as the second weight of the initial contrast texture eigenvalue. According to the first weight, the second weight and the initial contrast texture eigenvalue, the corresponding contrast optimized texture eigenvalue is obtained, and the expression of the contrast optimized texture eigenvalue is:
[0109]
[0110] in, represents the contrast-optimized texture feature value in the ath direction, represents the initial contrast texture eigenvalue in the ath direction, represents the grayscale correlation coefficient of the target crack in the ath direction, which is also the first weight of the initial contrast texture eigenvalue. It represents the target crack gradient correlation coefficient in the ath direction, which is also the second weight of the initial contrast texture eigenvalue.
[0111] It should be noted that The larger the value is, the deeper the grooves of the texture in the ath direction are, the clearer the visual effect is, the greater the possibility of belonging to the crack area is, and the larger the contrast optimization texture feature value in the ath direction is; The larger the value of is, the greater the possibility that the pixel point in the ath direction belongs to the crack area, and the larger the contrast optimization texture feature value in the ath direction is. The larger the value of , the greater the possibility that the pixel point in the a-th direction belongs to the crack area, and the larger the contrast-optimized texture feature value in the a-th direction.
[0112] Taking the initial uniformity texture eigenvalue in the second category as an example, the difference between the constant 1 and the target crack grayscale correlation coefficient in the ath direction is used as the first weight of the initial uniformity texture eigenvalue, and the difference between the constant 1 and the target crack gradient correlation coefficient in the ath direction is used as the second weight of the initial uniformity texture eigenvalue. According to the first weight, the second weight and the initial uniformity texture eigenvalue, the corresponding uniformity optimized texture eigenvalue is obtained, and the expression of the uniformity optimized texture eigenvalue is:
[0113]
[0114] in, represents the uniformity optimized texture eigenvalue in the ath direction, represents the initial uniform texture eigenvalue in the ath direction, represents the grayscale correlation coefficient of the target crack in the ath direction, represents the first weight of the initial uniformity texture feature value, represents the target crack gradient correlation coefficient in the ath direction, A second weight representing the initial uniformity texture feature value.
[0115] It should be noted that The larger the value is, the greater the similarity of the grayscale values of adjacent pixels in the ath direction is, the more uniform and smooth the texture is, and the smaller the possibility of belonging to the crack area is, and the larger the uniformity optimization texture feature value in the ath direction is; The larger the value of is, the more likely the pixel point in the ath direction belongs to the crack area. The smaller the value of is, the smaller the uniformity optimization texture feature value in the ath direction is; The larger the value of is, the more likely the pixel point in the ath direction belongs to the crack area. The smaller the value of is, the smaller the uniformity optimization texture feature value in the ath direction is.
[0116] Among them, according to the N optimized texture feature values in each direction, 5 final optimized texture feature values of the local area are obtained, including:
[0117] For any one of the N initial texture feature values, an optimized texture feature value in each of the directions is obtained, and an average optimized texture feature value is obtained as a final optimized texture feature value of the local area.
[0118] Similarly, according to the above method of obtaining contrast optimized texture eigenvalues and uniformity optimized texture eigenvalues, the optimized texture eigenvalues in each direction of any initial texture eigenvalue are obtained, and the average optimized texture eigenvalue is obtained as the final optimized texture eigenvalue of the z-th local area, and 5 final optimized texture eigenvalues of the z-th local area are obtained.
[0119] Step S105 , classifying the rotor flowmeter by quality according to the N final optimized texture feature values of each local area.
[0120] Since the crack area usually has higher contrast and entropy and lower uniformity, energy and correlation, in the embodiment of the present invention, the rotor flowmeter is quality classified according to the N final optimized texture feature values of each local area.
[0121] Among them, the specific method for quality classification of the rotor flowmeter according to the N final optimized texture feature values of each local area is:
[0122] For any local area, respectively obtain preset feature thresholds corresponding to N kinds of final optimized texture feature values of the local area, and divide the N kinds of final optimized texture feature values into a first target category and a second target category according to the categories of initial texture feature values corresponding to the N kinds of final optimized texture feature values;
[0123] If all the final optimized texture feature values in the first target category are greater than the corresponding preset feature threshold, and all the final optimized texture feature values in the second target category are less than the corresponding preset feature threshold, the local area is marked as a crack area, otherwise, the local area is marked as a crack-free area.
[0124] In one implementation, taking the zth local area as an example, the preset feature thresholds (i.e., contrast feature threshold Cn, entropy feature threshold Et, uniformity feature threshold Hm, energy feature threshold Ee, and correlation feature threshold Cr) corresponding to the five final optimized texture eigenvalues of the zth local area are obtained respectively, and according to the categories of the initial texture eigenvalues corresponding to the five final optimized texture eigenvalues, the five final optimized textures are divided into a first target category and a second target category respectively, wherein the first target category includes the final optimized contrast texture eigenvalue and the final optimized entropy texture eigenvalue, and the second target category includes the final optimized uniformity texture eigenvalue, the final optimized energy texture eigenvalue, and the final optimized correlation texture eigenvalue.
[0125] If the final optimized contrast texture eigenvalue in the first target category is greater than the contrast feature threshold Cn, the final optimized entropy texture eigenvalue is greater than the entropy feature threshold Et, and the final optimized uniformity texture eigenvalue in the second target category is less than the uniformity feature threshold Hm, the final optimized energy texture eigenvalue is less than the energy feature threshold Ee, and the final optimized correlation texture eigenvalue is less than the correlation feature threshold Cr, then the zth local area is marked as a crack area. Conversely, if one of the final optimized texture eigenvalues does not meet the above conditions, the zth local area is marked as a crack-free area.
[0126] It should be noted that the feature thresholds corresponding to the five final optimized texture feature values set in the embodiment of the present invention are empirical values, that is, the contrast feature threshold Cn=200, the entropy feature threshold Et=1.5, the uniformity feature threshold Hm=0.5, the energy feature threshold Ee=0.5, and the correlation feature threshold Cr=0.5. There is no restriction on this and it can be set according to the implementation scenario.
[0127] If there is at least one local area that is a crack area, all crack areas are obtained, and the rotor flowmeter is quality-classified according to the areas of all crack areas.
[0128] Specifically, the number of pixels in each crack area is counted as the area of the crack area, and the total area of all crack areas is obtained. If the total area is less than the preset crack area threshold, the quality classification result of the rotor flowmeter is good; if the total area is greater than or equal to the preset crack area threshold, the quality classification result of the rotor flowmeter is defective.
[0129] If all local areas are crack-free areas, the quality classification result of the rotor flowmeter is high-quality.
[0130] In one embodiment, if all local areas are crack-free areas, the quality classification result of the rotor flowmeter is a high-quality product.
[0131] If there is at least one local area that is a crack area, the total number of pixels in all crack areas is counted as the total area S of all crack areas. If the total area is less than the preset crack area threshold h, that is, , the quality classification result of the rotor flowmeter is good. If the total area is greater than or equal to the preset crack area threshold h, that is, , then the quality classification result of the rotor flowmeter is defective.
[0132] It should be noted that the crack area threshold value set in the embodiment of the present invention is an empirical value, that is, h=200, and there is no limitation on this, and it can be set according to the implementation scenario.
[0133] In summary, the present invention obtains a surface image of a rotor flowmeter, grayscales the surface image to obtain a corresponding grayscale image, and uses a preset sliding window and sliding step size to slide on the grayscale image to obtain at least one local area, wherein one local area corresponds to one sliding window; for any local area, a grayscale co-occurrence matrix corresponding to the local area is obtained, and N initial texture eigenvalues in a preset number of directions are obtained according to the grayscale co-occurrence matrix; for any direction, at least two sets of pixel points in the direction are obtained according to the pixel point positions in the local area, and each set of pixel points in the direction is obtained according to the grayscale co-occurrence matrix. The grayscale value difference of the pixel points in the pixel point set is used to obtain the crack grayscale correlation coefficient in the direction, and the crack gradient correlation coefficient in the direction is obtained according to the grayscale value difference of the pixel points in the pixel point set; according to the crack grayscale correlation coefficient and the crack gradient correlation coefficient in the direction, the N initial texture eigenvalues in the direction are adaptively optimized to obtain N optimized texture eigenvalues, and according to the N optimized texture eigenvalues in each direction, the N final optimized texture eigenvalues of the local area are obtained; according to the N final optimized texture eigenvalues of each local area, the rotor flowmeter is quality classified. Among them, since a lot of crack details will be lost when the surface cracks of the rotor flowmeter are identified by only using the grayscale co-occurrence matrix obtained by the feature mean in each direction, and since the cracks on the surface of the rotor flowmeter will also cause differences in light reflection or absorption, the identification of cracks on the surface of the rotor flowmeter is inaccurate. Therefore, the present invention first obtains all local areas of the surface grayscale image of the rotor flowmeter, and for any local area, respectively obtains the crack grayscale correlation coefficient and the crack gradient correlation coefficient corresponding to each direction in the local area, respectively as the optimization factors for each direction in the local area, optimizes multiple initial texture eigenvalues in each direction in the local area, and obtains multiple final optimized texture eigenvalues. According to all the final optimized texture eigenvalues in the grayscale image, the rotor flowmeter is quality classified, thereby improving the accuracy of identifying surface cracks of the rotor flowmeter, and further improving the accuracy of quality classification of the rotor flowmeter.
[0134] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention.
Claims
1. A quality test and analysis method for rotor flowmeter production process, characterized in that: The method comprises: Acquire a surface image of the rotor flowmeter, perform grayscale processing on the surface image to obtain a corresponding grayscale image, and perform sliding traversal on the grayscale image using a preset sliding window and sliding step size to obtain at least one local area, wherein one local area corresponds to one sliding window; For any local area, a gray level co-occurrence matrix corresponding to the local area is obtained, and N initial texture feature values in a preset number of directions are obtained according to the gray level co-occurrence matrix; For any direction, according to the pixel point positions in the local area, at least two pixel point sets in the direction are obtained, according to the gray value difference of the pixel points in each of the pixel point sets, the crack grayscale correlation coefficient in the direction is obtained, and according to the grayscale mean value of the pixel points in each of the pixel point sets, the crack gradient correlation coefficient in the direction is obtained; According to the crack grayscale correlation coefficient and the crack gradient correlation coefficient in the direction, adaptively optimize the N initial texture feature values in the direction to obtain N optimized texture feature values, and according to the N optimized texture feature values in each direction, obtain N final optimized texture feature values of the local area; Classifying the rotor flowmeter by quality according to the N final optimized texture feature values of each local area; The step of obtaining the crack grayscale correlation coefficient in the direction according to the grayscale value difference of each pixel point in the pixel point set includes: According to the grayscale value of each pixel point, a grayscale change curve corresponding to each pixel point set is constructed respectively, wherein one data point in the grayscale change curve corresponds to the grayscale value of one pixel point; Counting the number of valley points in each of the grayscale change curves respectively, and obtaining the average number of valley points as the grayscale fluctuation coefficient in the direction; Obtaining a grayscale similarity coefficient in the direction according to a grayscale difference between each of the trough points in each of the grayscale change curves and an adjacent data point of the trough point; Obtaining the sum of the inverse of the grayscale fluctuation coefficient and the grayscale similarity coefficient as the crack grayscale correlation coefficient in the direction; The step of obtaining the crack gradient correlation coefficient in the direction according to the grayscale mean of each pixel point in the pixel point set includes: The grayscale means of all the pixels in each of the pixel point sets are obtained respectively, and the absolute values of the grayscale means difference between every two pixel point sets are calculated respectively to obtain the average absolute value of the difference, and the average absolute value of the difference is used as the crack gradient correlation coefficient in the direction.
2. A quality testing and analysis method for rotor flowmeter production process according to claim 1, characterized in that: The step of obtaining the grayscale similarity coefficient in the direction according to the grayscale difference between each of the trough points in each of the grayscale change curves and the adjacent data points of the trough point comprises: For any valley point in any grayscale change curve, obtain the slope ratio between the valley point and the adjacent data points on the left and right sides of the valley point, and obtain the average slope ratio as the crack similarity corresponding to the grayscale change curve according to the slope ratio corresponding to each valley point; According to the crack similarity corresponding to each of the grayscale change curves, an average crack similarity is obtained, and the inverse of the sum of the average crack similarity and a constant 1 is obtained, and the inverse is used as the grayscale similarity coefficient in the direction.
3. The quality testing and analysis method for rotor flowmeter production process according to claim 1 is characterized in that: According to the crack grayscale correlation coefficient and the crack gradient correlation coefficient in the direction, adaptively optimizing the N initial texture feature values in the direction to obtain N optimized texture feature values includes: Normalizing the crack grayscale correlation coefficient and the crack gradient correlation coefficient in the direction respectively to obtain the target crack grayscale correlation coefficient and the target crack gradient correlation coefficient in the direction; Dividing the N kinds of initial texture feature values into two categories according to the positive and negative correlation feature attributes corresponding to each of the initial texture feature values; For any initial texture eigenvalue in any category, the target crack grayscale correlation coefficient and the target crack gradient correlation coefficient in the direction are used to adaptively optimize the initial texture eigenvalue to obtain the corresponding optimized texture eigenvalue.
4. A quality testing and analysis method for rotor flowmeter production process according to claim 3, characterized in that: The N kinds of initial texture feature values are divided into two categories according to the positive and negative correlation feature attributes corresponding to each of the initial texture feature values, including: For any one of the N initial texture feature values, if the positive and negative correlation feature attribute of the initial texture feature value is a positive correlation feature attribute, the initial texture feature value is classified as a first category; If the positive-negative correlation feature attribute of the initial texture feature value is a negative correlation feature attribute, the initial texture feature value is classified as the second category.
5. A quality testing and analysis method for rotor flowmeter production process according to claim 4, characterized in that: The step of using the target crack grayscale correlation coefficient and the target crack gradient correlation coefficient in the direction to adaptively optimize the initial texture feature value to obtain the optimized texture feature value in the direction includes: When the initial texture eigenvalue belongs to the first category, taking the target crack grayscale correlation coefficient in the direction as a first weight, obtaining the product of the first weight and the initial texture eigenvalue as a first optimized texture eigenvalue in the direction, taking the target crack gradient correlation coefficient in the direction as a second weight, obtaining the product of the second weight and the initial texture eigenvalue as a second optimized texture eigenvalue in the direction, and obtaining the average of the first optimized texture eigenvalue and the second optimized texture eigenvalue as an optimized texture eigenvalue; When the initial texture eigenvalue belongs to the second category, the difference between a constant 1 and the target crack grayscale correlation coefficient in the direction is obtained as a first weight, the product of the first weight and the initial texture eigenvalue is obtained as a first optimized texture eigenvalue in the direction, the difference between a constant 1 and the target crack gradient correlation coefficient in the direction is obtained as a second weight, the product of the second weight and the initial texture eigenvalue is obtained as a second optimized texture eigenvalue in the direction, and the average of the first optimized texture eigenvalue and the second optimized texture eigenvalue is obtained as the optimized texture eigenvalue.
6. The quality testing and analysis method for rotor flowmeter production process according to claim 1, characterized in that: The obtaining of N kinds of final optimized texture feature values of the local area according to the N kinds of optimized texture feature values in each of the directions includes: For any one of the N initial texture feature values, an optimized texture feature value in each of the directions is obtained, and an average optimized texture feature value is obtained as a final optimized texture feature value of the local area.
7. A quality testing and analysis method for rotor flowmeter production process according to claim 4, characterized in that: The quality classification of the rotor flowmeter according to the N kinds of final optimized texture feature values of each local area includes: For any local area, respectively obtain preset feature thresholds corresponding to N kinds of final optimized texture feature values of the local area, and divide the N kinds of final optimized texture feature values into a first target category and a second target category according to the categories of initial texture feature values corresponding to the N kinds of final optimized texture feature values; If all the final optimized texture feature values in the first target category are greater than the corresponding preset feature threshold, and all the final optimized texture feature values in the second target category are less than the corresponding preset feature threshold, then the local area is marked as a crack area, otherwise, the local area is marked as a crack-free area; If at least one local area is a crack area, all crack areas are obtained, and the rotor flowmeter is quality classified according to the areas of all crack areas; If all local areas are crack-free areas, the quality classification result of the rotor flowmeter is high-quality.
8. A quality testing and analysis method for rotor flowmeter production process according to claim 7, characterized in that: The quality classification of the rotor flowmeter according to the area of all crack regions includes: The number of pixels in each crack area is counted as the area of the crack area, and the total area of all crack areas is obtained. If the total area is less than the preset crack area threshold, the quality classification result of the rotor flowmeter is good; if the total area is greater than or equal to the preset crack area threshold, the quality classification result of the rotor flowmeter is defective.
Citation Information
Patent Citations
Intelligent floor surface detection method based on image processing
CN118072025A
Method for segmenting images by analysis of textures
FR2660459A1