CN117237350B - Real-time detection method for quality of steel castings - Google Patents
Real-time detection method for quality of steel castings Download PDFInfo
- Publication number
- CN117237350B CN117237350B CN202311509082.8A CN202311509082A CN117237350B CN 117237350 B CN117237350 B CN 117237350B CN 202311509082 A CN202311509082 A CN 202311509082A CN 117237350 B CN117237350 B CN 117237350B
- Authority
- CN
- China
- Prior art keywords
- gray level
- analysis
- image
- gray
- subinterval
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 229910000831 Steel Inorganic materials 0.000 title claims abstract description 155
- 239000010959 steel Substances 0.000 title claims abstract description 155
- 238000005266 casting Methods 0.000 title claims abstract description 154
- 238000000034 method Methods 0.000 title claims abstract description 65
- 238000011897 real-time detection Methods 0.000 title claims abstract description 9
- 238000004458 analytical method Methods 0.000 claims abstract description 211
- 238000003709 image segmentation Methods 0.000 claims abstract description 27
- 238000012216 screening Methods 0.000 claims description 42
- 230000007547 defect Effects 0.000 claims description 28
- 238000004364 calculation method Methods 0.000 claims description 7
- 230000002950 deficient Effects 0.000 claims description 7
- 101100129590 Schizosaccharomyces pombe (strain 972 / ATCC 24843) mcp5 gene Proteins 0.000 claims description 3
- 230000011218 segmentation Effects 0.000 abstract description 25
- 238000001514 detection method Methods 0.000 abstract description 6
- 229910001208 Crucible steel Inorganic materials 0.000 description 4
- 230000000694 effects Effects 0.000 description 3
- 238000012545 processing Methods 0.000 description 3
- 241001270131 Agaricus moelleri Species 0.000 description 1
- 238000012935 Averaging Methods 0.000 description 1
- 230000005856 abnormality Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000002902 bimodal effect Effects 0.000 description 1
- 230000007797 corrosion Effects 0.000 description 1
- 238000005260 corrosion Methods 0.000 description 1
- 238000011156 evaluation Methods 0.000 description 1
- 239000007769 metal material Substances 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
Classifications
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02P—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
- Y02P90/00—Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
- Y02P90/30—Computing systems specially adapted for manufacturing
Landscapes
- Image Analysis (AREA)
- Continuous Casting (AREA)
Abstract
The invention relates to the technical field of image region segmentation, in particular to a real-time detection method for the quality of steel castings. According to the method, analysis gray level is screened out for the first time from gray levels of gray level images of the surface of the steel casting, the analysis gray level of the gray level images of the surface of the steel casting is screened more carefully to obtain target gray level, a final segmentation threshold value for segmenting the gray level images of the surface of the steel casting is obtained according to pixel points corresponding to the target gray level of the gray level images of the surface of the steel casting, and the quality of the steel casting is detected based on the final segmentation threshold value. According to the invention, the gray level of the gray level image on the surface of the steel casting is screened twice, the final image segmentation threshold value is obtained based on the pixel points corresponding to the screened gray level, and the quality detection efficiency of the steel casting is improved.
Description
Technical Field
The invention relates to the technical field of image region segmentation, in particular to a real-time detection method for the quality of steel castings.
Background
The steel casting is a common mechanical part and is widely applied to various mechanical equipment. The quality of the steel castings is detected in real time, unqualified steel castings are identified, defective steel castings are prevented from participating in the processing of subsequent mechanical equipment, and the possibility of abnormality of the mechanical equipment is reduced. Therefore, the real-time detection of the quality of the steel castings is of great significance.
In the prior art, a threshold value is generally obtained directly on a steel casting surface image by using a maximum inter-class method, and a defect area and a normal surface area in the steel casting surface image are segmented based on the threshold value. In the process of utilizing the maximum inter-class variance method, traversal search is needed for all gray levels of the steel casting surface image, so that the algorithm efficiency is low, and the steel casting quality detection efficiency is low.
Disclosure of Invention
In order to solve the technical problem that the efficiency of steel casting quality detection is low because all gray levels of an image need to be searched for a segmentation threshold value, the invention aims to provide a steel casting quality real-time detection method, and the adopted technical scheme is as follows:
the invention provides a real-time detection method for the quality of a steel casting, which comprises the following steps:
acquiring a gray image of the surface of the steel casting;
screening out analysis gray levels from the gray levels of the gray level image of the surface of the steel casting according to the gray values of the pixels corresponding to each gray level of the gray level image of the surface of the steel casting and the number of pixels corresponding to the gray level adjacent to each gray level;
screening out target gray level from an analysis interval of the gray level image on the surface of the steel casting, wherein an initial interval of the analysis interval is an initial gray level interval constructed based on the analysis gray level; dividing an analysis interval into a preset number of analysis subintervals, screening out one analysis subinterval by using the threshold presence degree of the analysis subinterval, and updating the analysis interval; when the analysis interval does not meet the condition to be selected, updating the analysis interval until the updated analysis interval meets the condition to be selected; when the condition to be selected is met, taking the updated analysis gray level in the analysis interval as a target gray level;
the threshold presence degree obtaining method comprises the following steps: combining the gray difference between the pixel point corresponding to each gray level in the analysis subinterval and the pixel point in the preset neighborhood of the pixel point and the discrete degree of the number of the pixel points corresponding to the gray level in the analysis subinterval to obtain the threshold value existence degree of the analysis subinterval;
acquiring a final image segmentation threshold value for segmenting the gray level image of the surface of the steel casting according to the pixel points corresponding to the target gray level in the gray level image of the surface of the steel casting;
and detecting the quality of the steel castings based on the final image segmentation threshold.
Further, the method for screening out the analysis gray level from the gray level of the gray level image of the surface of the steel casting comprises the following steps:
based on the gray value of the pixel point corresponding to the gray level, sequentially arranging the gray levels of the gray images on the surface of the steel casting to obtain a gray level sequence; taking other gray levels except the gray level in a preset first window of each gray level in the gray level sequence as adjacent gray levels of each gray level;
acquiring a screening coefficient of each gray level of the gray level image of the surface of the steel casting according to the gray value of the pixel corresponding to each gray level of the gray level image of the surface of the steel casting and the number of pixels corresponding to the adjacent gray level of each gray level;
an image gray level interval formed by the minimum gray level and the maximum gray level of the gray level image on the surface of the steel casting is divided into two image subintervals; screening the gray level with the largest screening coefficient in each image subinterval as the target gray level of each image subinterval;
and taking the gray level which is larger than the corresponding target gray level in the first image subinterval and the gray level which is smaller than the corresponding target gray level in the second image subinterval as the analysis gray level of the gray level image of the surface of the steel casting.
Further, the calculation formula of the screening coefficient of each gray level of the gray level image of the surface of the steel casting is as follows:
the method comprises the steps of carrying out a first treatment on the surface of the Wherein C is a screening coefficient of each gray level of the gray level image on the surface of the steel casting; h is the gray value of the pixel point corresponding to each gray level of the gray level image on the surface of the steel casting; num1 is the number of pixel points corresponding to each gray level of the gray level image on the surface of the steel casting; />The number of pixel points corresponding to the ith adjacent gray level of each gray level of the gray level image of the surface of the steel casting; i is the number of adjacent gray levels for each gray level of the gray level image of the surface of the steel casting; />Is a preset value; />As a function of absolute value; exp is an exponential function based on a natural constant e.
Further, the method for acquiring the initial gray level interval comprises the following steps:
the minimum analysis gray level and the maximum analysis gray level of the gray level image of the surface of the steel casting form an initial gray level interval.
Further, the condition to be selected is that the number of gray levels in the updated analysis interval is smaller than a preset number threshold.
Further, the method for obtaining the threshold presence degree of the analysis subinterval by combining the gray level difference between the pixel point corresponding to each gray level in the analysis subinterval and the pixel point in the preset neighborhood of the pixel point and the discrete degree of the number of the pixel points corresponding to the gray level in the analysis subinterval comprises the following steps:
selecting any pixel point corresponding to each gray level in each analysis subinterval as an analysis pixel point, and taking the average value of gray values of the pixel points except the analysis pixel point in a preset second window of the analysis pixel point as a neighborhood gray value of the analysis pixel point;
and obtaining the threshold value existence degree of each analysis subinterval according to the difference between the gray value of the pixel point corresponding to each gray level in each analysis subinterval and the neighborhood gray value and the discrete degree of the number of the pixel points corresponding to the gray level in each analysis subinterval.
Further, the calculation formula of the threshold presence degree is as follows:
the method comprises the steps of carrying out a first treatment on the surface of the Wherein P is the threshold presence of each analysis subinterval; />Standard deviation of the number of pixel points corresponding to all gray levels in each analysis subinterval; k is the number of gray levels in each analysis subinterval; />The number of pixels corresponding to the kth gray level in each analysis subinterval; />The gray value of the pixel point corresponding to the kth gray level in each analysis subinterval is obtained; />The neighborhood gray level of the mth pixel point corresponding to the kth gray level in each analysis subinterval is obtained; />As a function of absolute value.
Further, the method for acquiring the final image segmentation threshold value comprises the following steps:
and taking a threshold value obtained by using a maximum inter-class variance method for the gray value of the pixel point corresponding to the target gray level of the gray image on the surface of the steel casting as a final image segmentation threshold value.
Further, the method for detecting the quality of the steel casting based on the final image segmentation threshold comprises the following steps:
taking pixel points with gray values larger than a final image segmentation threshold value in the gray images of the surface of the steel casting as defective pixel points; taking the ratio of the number of defective pixel points in the gray level image of the surface of the steel casting to the number of all pixel points as a defect judgment value;
when the defect judgment value is larger than a preset defect threshold value, the quality of the steel casting is unqualified; and when the defect judging value is smaller than or equal to the preset defect threshold value, the steel casting quality is qualified.
Further, the method for dividing the image gray level interval into two image subintervals comprises the following steps:
taking the endpoint value at the left side of the image gray level interval as the endpoint value at the left side of the first image subinterval, and taking the preset value as the endpoint value at the right side of the first image subinterval; taking the sum of the preset value and the constant 1 as the endpoint value of the left side of the second image subinterval and taking the endpoint value of the right side of the image gray level interval as the endpoint value of the right side of the second image subinterval.
The invention has the following beneficial effects:
in the embodiment of the invention, the segmentation threshold is usually positioned in the middle of the gray level histogram of the image, and the number of pixels corresponding to the gray level adjacent to the gray level corresponding to the segmentation threshold is more, so that more information is conveniently provided for the determination of the threshold, and the analysis gray level is initially screened out from the gray level of the gray level image returned from the surface of the steel casting by combining the two factors; dividing an analysis interval which is updated each time into a plurality of analysis subintervals by taking an initial gray level interval formed by the analysis gray levels as an initial interval of the analysis interval, wherein the gray level difference degree around pixels corresponding to the segmentation threshold value and the balance degree of the number of pixels corresponding to each gray level in the analysis subinterval influence the possibility that the segmentation threshold value exists in the analysis subinterval, and acquiring the threshold value existence degree of the analysis subinterval; further screening out analysis subintervals based on the threshold presence degree, updating the analysis intervals until the updated analysis intervals meet the condition to be selected, and taking the gray level in the updated analysis intervals as a target gray level; acquiring a final image segmentation threshold value based on the pixel points corresponding to the screened target gray level, and further detecting the quality of the steel casting; and gray level of gray level images on the surface of the steel casting is screened twice, so that redundant searching is avoided, and the quality detection efficiency of the steel casting is improved.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions and advantages of the prior art, the following description will briefly explain the drawings used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are only some embodiments of the invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flow chart of a method for real-time detecting quality of steel castings according to an embodiment of the present invention.
Detailed Description
An embodiment of a method for detecting the quality of a steel casting in real time comprises the following steps:
in order to further describe the technical means and effects adopted by the invention to achieve the preset aim, the following is a real-time detection method for the quality of the steel castings according to the invention, which is provided by combining the accompanying drawings and the preferred embodiment, and the specific implementation, structure, characteristics and effects thereof are described in detail below. In the following description, different "one embodiment" or "another embodiment" means that the embodiments are not necessarily the same. Furthermore, the particular features, structures, or characteristics of one or more embodiments may be combined in any suitable manner.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
The invention provides a concrete scheme of a real-time steel casting quality detection method, which is specifically described below with reference to the accompanying drawings.
Referring to fig. 1, a method flowchart of a method for detecting quality of a steel casting in real time according to an embodiment of the invention is shown, where the method includes:
step S1: and acquiring a gray level image of the surface of the steel casting.
Specifically, an industrial camera is used for shooting an image of the surface of the steel casting, and because the image is possibly affected by noise in the image acquisition process, the acquired image needs to be denoised, and then gray-scale processing is carried out to obtain a gray-scale image of the surface of the steel casting.
In the embodiment of the present invention, a non-local mean denoising algorithm is selected for denoising, and a weighted averaging algorithm is used for graying, and the specific method is not described herein, and is a technical means well known to those skilled in the art.
Step S2: and screening out the analysis gray level from the gray level of the gray level image of the surface of the steel casting according to the gray value of the pixel point corresponding to each gray level of the gray level image of the surface of the steel casting and the number of the pixel points corresponding to the gray level adjacent to each gray level.
And acquiring a gray level histogram of the gray level image of the surface of the steel casting, and acquiring the gray level of the gray level image of the surface of the steel casting according to the gray level histogram. In the gray level histogram of the image, the part of gray levels at two sides of the edge of the histogram usually does not contain main information of foreground and background in the gray level image of the surface of the steel casting, and in order to reduce the calculation amount, the part of gray levels needs to be removed.
The defects on the surface of the steel casting are cracks and oxide layers, and both defects can cause brightness change of the surface of the steel casting, so that the number of pixels corresponding to gray levels adjacent to gray levels in an image is changed, and the analysis gray levels of the gray level image on the surface of the steel casting are obtained based on the factors.
Preferably, the specific acquisition method for analyzing the gray level is as follows: based on the gray value of the pixel point corresponding to the gray level, sequentially arranging the gray levels of the gray images on the surface of the steel casting to obtain a gray level sequence; taking other gray levels except the gray level in a preset first window of each gray level in the gray level sequence as adjacent gray levels of each gray level; acquiring a screening coefficient of each gray level of the gray level image of the surface of the steel casting according to the gray value of the pixel corresponding to each gray level of the gray level image of the surface of the steel casting and the number of pixels corresponding to the adjacent gray level of each gray level; an image gray level interval formed by the minimum gray level and the maximum gray level of the gray level image on the surface of the steel casting is divided into two image subintervals; screening the gray level with the largest screening coefficient in each image subinterval as the target gray level of each image subinterval; and taking the gray level which is larger than the corresponding target gray level in the first image subinterval and the gray level which is smaller than the corresponding target gray level in the second image subinterval as the analysis gray level of the gray level image of the surface of the steel casting.
It should be noted that, the preset first window is a one-dimensional window, that is, the width of the preset first window is 1, and the width thereof needs to satisfyA is a positive integer. In the embodiment of the invention, the size of the preset first window takes an empirical value +.>And each gray level in the gray level sequence is positioned at the center of the preset first window.
And combining the gray value of the pixel corresponding to each gray level of the gray image of the surface of the steel casting and the number of the pixel corresponding to the adjacent gray level of each gray level to obtain a screening coefficient of each gray level of the gray image of the surface of the steel casting, wherein the calculation formula of the screening coefficient is as follows:
wherein C is a screening coefficient of each gray level of the gray level image on the surface of the steel casting; h is the gray value of the pixel point corresponding to each gray level of the gray level image on the surface of the steel casting; num1 is the number of pixel points corresponding to each gray level of the gray level image on the surface of the steel casting;the number of pixel points corresponding to the ith adjacent gray level of each gray level of the gray level image of the surface of the steel casting; i is gray scale image of the surface of the steel castingThe number of adjacent gray levels for each gray level of the image; YH is a preset value, and takes an experience value 128; />As a function of absolute value; exp is an exponential function based on a natural constant e.
Since the segmentation threshold obtained by using the maximum inter-class variance method for the image is usually located at the trough position in the middle of the double peaks in the gray level histogram of the image, that is, the segmentation threshold is more intensively distributed in the middle of the gray level range, the preset value YH in the embodiment of the invention takes the checked value 128, and an implementer can set the threshold according to specific situations. When (when)When the gray level is larger, the gray level is closer to the two sides of the gray histogram, and the gray value of the pixel point corresponding to the gray level is a segmentation threshold value; the lower the likelihood, the greater the likelihood of being culled, the greater the screening coefficient C for the gray level.
The area of the defect area in the gray level image of the surface of the steel casting is smaller, and when the number of pixel points corresponding to each gray level is equalThe smaller the gray level, the greater the gray level probability of the pixel point whose gray level is the defective position, the greater the gray level screening coefficient C. The number of pixels corresponding to the adjacent gray level of each gray level>And when the pixel point corresponding to the gray level is smaller, the information provided for determining the segmentation threshold value is less, the accuracy of the segmentation threshold value evaluation is lower, and the greater the possibility of being eliminated, the greater the screening coefficient C of the gray level.
An image gray level section composed of the minimum gray level and the maximum gray level of the gray level image of the surface of the steel casting is divided into two image subsections based on the preset value YH.
The method for acquiring the image subinterval comprises the following steps: taking the endpoint value at the left side of the image gray level interval as the endpoint value at the left side of the first image subinterval, and taking the preset value as the endpoint value at the right side of the first image subinterval; taking the sum of the preset value and the constant 1 as the endpoint value of the left side of the second image subinterval and taking the endpoint value of the right side of the image gray level interval as the endpoint value of the right side of the second image subinterval.
As one example: if the image gray level interval isThe first image subinterval is +.>The first image subinterval is +.>. Assuming that 50 is the gray level with the largest screening coefficient in the first image subinterval and 200 is the gray level with the largest screening coefficient in the second image subinterval, the gray level between the gray level 50 and the gray level 200 is used as the analysis gray level of the gray image of the surface of the steel casting. It should be noted that the gray level is a positive integer.
Step S3: screening out target gray level from an analysis interval of the gray level image on the surface of the steel casting, wherein an initial interval of the analysis interval is an initial gray level interval constructed based on the analysis gray level; dividing an analysis interval into a preset number of analysis subintervals, screening out one analysis subinterval by using the threshold presence degree of the analysis subinterval, and updating the analysis interval; when the analysis interval does not meet the condition to be selected, updating the analysis interval until the updated analysis interval meets the condition to be selected; and when the condition to be selected is met, taking the updated analysis gray level in the analysis interval as the target gray level.
And S3, carrying out preliminary rough screening on the gray level of the gray level image on the surface of the steel casting, wherein the screened analysis gray level number is relatively large, and more careful screening is needed, namely screening the target gray level from the analysis gray level of the gray level image on the surface of the steel casting.
The minimum analysis gray level and the maximum analysis gray level of the gray level image of the surface of the steel casting form an initial gray level interval, and the initial gray level interval is assumed to be. Screening out target gray level from analysis interval of gray level image of steel casting surface, wherein initial interval of analysis interval is initial gray level interval, and analyzing interval +.>Dividing into a preset number of analysis subintervals.
The specific method for dividing the analysis interval into a preset number B of analysis subintervals comprises the following steps: the left endpoint value and the right endpoint value of the analysis interval are sequentially as followsAnd->A value obtained by rounding the ratio of the difference between the two end values of the analysis interval and the preset number is used as a subinterval length value +.>,/>Rounding up the symbol; analysis interval is based on subinterval length value L>Sequentially dividing into a preset number of analysis subintervals, wherein the analysis subintervals are sequentially +.>,/>,And so on, add>The method comprises the steps of carrying out a first treatment on the surface of the Since the gray level is an integer, the analysis subinterval corresponds to +.>,,/>And so on, add>。
In the embodiment of the invention, the preset number is measured to have an empirical value of 2, and the analysis interval is analyzedDivided into two analysis subintervals, subinterval length value +.>The two analysis subintervals are in turn: />,The method comprises the steps of carrying out a first treatment on the surface of the Acquisition->Threshold presence of->,/>Threshold presence of->The method comprises the steps of carrying out a first treatment on the surface of the The greater the threshold presence degree P, the greater the likelihood of a segmentation threshold being present within the analysis subinterval; by->And->Analysis subinterval bisection with maximum threshold presence of (2)Updating analysis interval if->The updated analysis interval is。
Updated analysis intervalThe number of the inner gray level is 75, and the updated analysis interval is judgedWhether the number of the inner gray levels is smaller than a preset number threshold value or not, if not, acquiring a subinterval length valueThe updated analysis interval +.>Divided into +.>And (3) withTwo analysis subintervals. Acquisition->Threshold presence of->,/>Threshold presence of->The method comprises the steps of carrying out a first treatment on the surface of the If->The updated analysis interval is +.>。
Updated analysis intervalThe number of inner gray levels is 38, judging +.>Whether the number of the inner gray levels is smaller than a preset number threshold, if not, obtaining a subinterval length value +.>The updated analysis interval +.>Divided into->And->Two analysis subintervals. Acquisition ofThreshold presence of->,/>Threshold presence of->The method comprises the steps of carrying out a first treatment on the surface of the If->The updated analysis interval is +.>。
And the like, taking the updated gray level in the analysis interval as the target gray level until the number of the gray levels in the updated analysis interval is smaller than a preset number threshold value.
In the embodiment of the invention, the preset number of threshold values take the experience value of 10, and an implementer can set the threshold values according to specific situations.
The gray level in the analysis section is the analysis gray level of the gray image of the surface of the steel casting.
Step S4: the method for acquiring the threshold presence degree comprises the following steps: and combining the gray level difference between the pixel point corresponding to each gray level in the analysis subinterval and the pixel point in the preset neighborhood of the pixel point and the discrete degree of the number of the pixel points corresponding to the gray level in the analysis subinterval to obtain the threshold value existence degree of the analysis subinterval.
The brightness of the surface of the steel casting is changed due to the defect of the surface, gray level contrast can occur in the image, and the threshold value existence degree of the analysis subinterval is obtained by combining the gray level difference between the pixel point corresponding to each gray level in the analysis subinterval and the pixel point in the preset neighborhood of the analysis subinterval and the discrete degree of the number of the pixel points corresponding to the gray level in the analysis subinterval.
Selecting any pixel point corresponding to each gray level in each analysis subinterval as an analysis pixel point, and taking the average value of gray values of the pixel points except the analysis pixel point in a preset second window of the analysis pixel point as a neighborhood gray value of the analysis pixel point; and obtaining the threshold value existence degree of each analysis subinterval according to the difference between the gray value of the pixel point corresponding to each gray level in each analysis subinterval and the neighborhood gray value and the discrete degree of the number of the pixel points corresponding to the gray level in each analysis subinterval.
In the embodiment of the invention, the size of the preset second window of the analysis pixel point takes an empirical valueThe implementer can set up by himself according to the specific circumstances.
The calculation formula of the threshold presence degree of each analysis subinterval is as follows:
wherein P is the threshold presence of each analysis subinterval;standard deviation of the number of pixel points corresponding to all gray levels in each analysis subinterval; k is the number of gray levels in each analysis subinterval; />The number of pixels corresponding to the kth gray level in each analysis subinterval; />The gray value of the pixel point corresponding to the kth gray level in each analysis subinterval is obtained; />A neighborhood gray value of an mth pixel point corresponding to a kth gray level in each analysis subinterval; />As a function of absolute value.
When (when)When the gray scale difference between the pixel point corresponding to the kth gray scale in the analysis subinterval and the surrounding pixel points is larger, the gray scale fluctuation around the pixel points is obvious; and->The larger the number of pixels around the pixel corresponding to the kth gray level in the analysis subinterval, the larger the number of pixels with larger gray level fluctuation, the larger the possibility that the gray level of the pixel corresponding to the kth gray level in the analysis subinterval is the segmentation threshold value, and the larger the probability that the gray level of the pixel corresponding to the kth gray level in the analysis subinterval is the segmentation threshold value>The larger the threshold presence degree P is, the larger it is. />For the possible analysis of the presence of segmentation threshold values in the analysis subinterval based on the single gray level of the analysis subinterval, for the overall trend of the analysis subinterval, the method comprises the following stepsAll gray levels within the analysis subinterval are analyzed identically, i.e. +.>。
The distribution threshold of the image is usually located at the trough position of the bimodal position in the gray level histogram, and the surrounding fluctuation of the position is obvious. When analyzing standard deviation of pixel numbers corresponding to all gray scales in the subintervalThe smaller the distribution of the number of the pixels corresponding to the gray level in the analysis subinterval is, the less obvious the fluctuation of the analysis subinterval at the position corresponding to the gray level histogram is, and the smaller the possibility that the segmentation threshold is positioned in the analysis subinterval is, the smaller the threshold existence degree P is.
Step S5: and acquiring a final image segmentation threshold value for segmenting the gray level image of the surface of the steel casting according to the pixel points corresponding to the target gray level in the gray level image of the surface of the steel casting.
And taking a threshold value obtained by using a maximum inter-class variance method for the gray value of the pixel point corresponding to the target gray level of the gray image on the surface of the steel casting as a final image segmentation threshold value. The maximum inter-class variance method is a well-known technique for those skilled in the art, and is not described herein.
Step S6: and detecting the quality of the steel castings based on the final image segmentation threshold.
The cast steel is a high-strength, wear-resistant and corrosion-resistant metal material, the color of the cast steel is usually gray or black, and when defects such as cracks or oxide layers on the surface of the cast steel are illuminated, the gray value of the defect position in the gray image on the surface of the cast steel is larger due to reflection of light.
Therefore, taking the pixel point with the gray value larger than the final image segmentation threshold value in the gray image of the surface of the steel casting as a defect pixel point; and taking the ratio of the number of defective pixel points in the gray level image of the surface of the steel casting to the number of all pixel points as a defect judgment value. When the defect judgment value is larger than a preset defect threshold value, the quality of the steel casting is unqualified; and when the defect judging value is smaller than or equal to the preset defect threshold value, the steel casting quality is qualified.
In the embodiment of the invention, the preset defect threshold value takes an empirical value of 0.1, and an implementer can set the preset defect threshold value according to specific conditions.
The present invention has been completed.
In summary, in the embodiment of the present invention, the analysis gray level is first selected from the gray levels of the gray level image of the surface of the steel casting, the analysis gray level of the gray level image of the surface of the steel casting is more carefully selected to obtain the target gray level, the final segmentation threshold value for segmenting the gray level image of the surface of the steel casting is obtained according to the pixel point corresponding to the target gray level of the gray level image of the surface of the steel casting, and the quality of the steel casting is detected based on the final segmentation threshold value. According to the invention, the gray level of the gray level image on the surface of the steel casting is screened twice, the final image segmentation threshold value is obtained based on the pixel points corresponding to the screened gray level, and the quality detection efficiency of the steel casting is improved.
An embodiment of a steel casting image segmentation method comprises the following steps:
the steel casting is a common mechanical part and is widely applied to various mechanical equipment. When the surface of the steel casting has defects such as cracks and oxide layers, the image of the surface of the steel casting has obvious gray scale difference, and the image can be divided into a defect area and a normal area. In the prior art, a threshold value is generally obtained by directly utilizing a maximum inter-class method on a steel casting surface image, a defect area and a normal area in the steel casting surface image are segmented based on the threshold value, and all gray levels of the steel casting surface image need to be subjected to traversal search in the process of utilizing the maximum inter-class variance method, so that the algorithm efficiency is low.
In order to solve the technical problem that the image segmentation efficiency of a steel casting is low due to the fact that all gray levels of an image need to be traversed when an image segmentation threshold value is acquired, the invention aims to provide a steel casting image segmentation method, and the adopted technical scheme is as follows:
step S1: acquiring a gray image of the surface of the steel casting;
step S2: screening out analysis gray levels from the gray levels of the gray level image of the surface of the steel casting according to the gray values of the pixels corresponding to each gray level of the gray level image of the surface of the steel casting and the number of pixels corresponding to the gray level adjacent to each gray level;
step S3: screening out target gray level from an analysis interval of the gray level image on the surface of the steel casting, wherein an initial interval of the analysis interval is an initial gray level interval constructed based on the analysis gray level; dividing an analysis interval into a preset number of analysis subintervals, screening out one analysis subinterval by using the threshold presence degree of the analysis subinterval, and updating the analysis interval; when the analysis interval does not meet the condition to be selected, updating the analysis interval until the updated analysis interval meets the condition to be selected; when the condition to be selected is met, taking the updated analysis gray level in the analysis interval as a target gray level;
step S4: the threshold presence degree obtaining method comprises the following steps: combining the gray difference between the pixel point corresponding to each gray level in the analysis subinterval and the pixel point in the preset neighborhood of the pixel point and the discrete degree of the number of the pixel points corresponding to the gray level in the analysis subinterval to obtain the threshold value existence degree of the analysis subinterval;
step S5: and acquiring a final image segmentation threshold value for segmenting the gray level image of the surface of the steel casting according to the pixel points corresponding to the target gray level in the gray level image of the surface of the steel casting.
The embodiment of the invention provides a steel casting image segmentation method, which has the following technical effects:
in the embodiment of the invention, the segmentation threshold is usually positioned in the middle of the gray level histogram of the image, and the number of pixels corresponding to the gray level adjacent to the gray level corresponding to the segmentation threshold is more, so that more information is conveniently provided for the determination of the threshold, and the analysis gray level is initially screened out from the gray level of the gray level image returned from the surface of the steel casting by combining the two factors; dividing an analysis interval which is updated each time into a plurality of analysis subintervals by taking an initial gray level interval formed by the analysis gray levels as an initial interval of the analysis interval, wherein the gray level difference degree around pixels corresponding to the segmentation threshold value and the balance degree of the number of pixels corresponding to each gray level in the analysis subinterval influence the possibility that the segmentation threshold value exists in the analysis subinterval, and acquiring the threshold value existence degree of the analysis subinterval; further screening out analysis subintervals based on the threshold presence degree, updating the analysis intervals until the updated analysis intervals meet the condition to be selected, and taking the gray level in the updated analysis intervals as a target gray level; and acquiring a final image segmentation threshold value based on the pixel points corresponding to the screened target gray level, and screening the gray level of the gray level image on the surface of the steel casting twice, so that redundant searching is avoided, and the acquisition efficiency of the final image segmentation threshold value is improved.
The steps S1 to S5 are already described in detail in the foregoing embodiment of the method for detecting the quality of a steel casting in real time, and will not be described in detail.
It should be noted that: the sequence of the embodiments of the present invention is only for description, and does not represent the advantages and disadvantages of the embodiments. The processes depicted in the accompanying drawings do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments.
Claims (4)
1. A method for detecting the quality of a steel casting in real time is characterized by comprising the following steps:
acquiring a gray image of the surface of the steel casting;
screening out analysis gray levels from the gray levels of the gray level image of the surface of the steel casting according to the gray values of the pixels corresponding to each gray level of the gray level image of the surface of the steel casting and the number of pixels corresponding to the gray level adjacent to each gray level;
screening out target gray level from an analysis interval of the gray level image on the surface of the steel casting, wherein an initial interval of the analysis interval is an initial gray level interval constructed based on the analysis gray level; dividing an analysis interval into a preset number of analysis subintervals, screening out one analysis subinterval by using the threshold presence degree of the analysis subinterval, and updating the analysis interval; when the analysis interval does not meet the condition to be selected, updating the analysis interval until the updated analysis interval meets the condition to be selected; when the condition to be selected is met, taking the updated analysis gray level in the analysis interval as a target gray level;
the threshold presence degree obtaining method comprises the following steps: combining the gray difference between the pixel point corresponding to each gray level in the analysis subinterval and the pixel point in the preset neighborhood of the pixel point and the discrete degree of the number of the pixel points corresponding to the gray level in the analysis subinterval to obtain the threshold value existence degree of the analysis subinterval;
acquiring a final image segmentation threshold value for segmenting the gray level image of the surface of the steel casting according to the pixel points corresponding to the target gray level in the gray level image of the surface of the steel casting;
detecting the quality of the steel casting based on a final image segmentation threshold;
the method for screening out the analysis gray level from the gray level of the gray level image on the surface of the steel casting comprises the following steps:
based on the gray value of the pixel point corresponding to the gray level, sequentially arranging the gray levels of the gray images on the surface of the steel casting to obtain a gray level sequence; taking other gray levels except the gray level in a preset first window of each gray level in the gray level sequence as adjacent gray levels of each gray level;
acquiring a screening coefficient of each gray level of the gray level image of the surface of the steel casting according to the gray value of the pixel corresponding to each gray level of the gray level image of the surface of the steel casting and the number of pixels corresponding to the adjacent gray level of each gray level;
an image gray level interval formed by the minimum gray level and the maximum gray level of the gray level image on the surface of the steel casting is divided into two image subintervals; screening the gray level with the largest screening coefficient in each image subinterval as the target gray level of each image subinterval;
the gray level in the first image subinterval which is larger than the corresponding target gray level and the gray level in the second image subinterval which is smaller than the corresponding target gray level are used as the analysis gray level of the gray level image of the surface of the steel casting;
the calculation formula of the screening coefficient of each gray level of the gray level image of the surface of the steel casting is as follows:
the method comprises the steps of carrying out a first treatment on the surface of the Wherein C is a screening coefficient of each gray level of the gray level image on the surface of the steel casting; h is the gray value of the pixel point corresponding to each gray level of the gray level image on the surface of the steel casting; num1 is the number of pixel points corresponding to each gray level of the gray level image on the surface of the steel casting; />The number of pixel points corresponding to the ith adjacent gray level of each gray level of the gray level image of the surface of the steel casting; i is the number of adjacent gray levels for each gray level of the gray level image of the surface of the steel casting; />YH is equal to 128 at a preset value; />As a function of absolute value; exp is an exponential function based on a natural constant e;
the method for acquiring the initial gray level interval comprises the following steps:
forming an initial gray level interval by the minimum analysis gray level and the maximum analysis gray level of the gray level image of the surface of the steel casting;
the condition to be selected is that the number of gray levels in the updated analysis interval is smaller than a preset number threshold;
the method for acquiring the threshold value existence degree of the analysis subinterval by combining the gray level difference between the pixel point corresponding to each gray level in the analysis subinterval and the pixel point in the preset neighborhood of the pixel point and the discrete degree of the number of the pixel points corresponding to the gray level in the analysis subinterval comprises the following steps:
selecting any pixel point corresponding to each gray level in each analysis subinterval as an analysis pixel point, and taking the average value of gray values of the pixel points except the analysis pixel point in a preset second window of the analysis pixel point as a neighborhood gray value of the analysis pixel point;
acquiring the threshold value existence degree of each analysis subinterval according to the difference between the gray value of the pixel point corresponding to each gray level in each analysis subinterval and the neighborhood gray value of the pixel point corresponding to the gray level in each analysis subinterval and the discrete degree of the number of the pixel points corresponding to the gray level in each analysis subinterval;
the calculation formula of the threshold presence degree is as follows:
the method comprises the steps of carrying out a first treatment on the surface of the Wherein P is the threshold presence of each analysis subinterval;standard deviation of the number of pixel points corresponding to all gray levels in each analysis subinterval; k is the number of gray levels in each analysis subinterval; />The number of pixels corresponding to the kth gray level in each analysis subinterval; />The gray value of the pixel point corresponding to the kth gray level in each analysis subinterval is obtained; />The neighborhood gray level of the mth pixel point corresponding to the kth gray level in each analysis subinterval is obtained; />As a function of absolute value.
2. The method for detecting the quality of the steel castings in real time according to claim 1, wherein the method for acquiring the final image segmentation threshold value comprises the following steps:
and taking a threshold value obtained by using a maximum inter-class variance method for the gray value of the pixel point corresponding to the target gray level of the gray image on the surface of the steel casting as a final image segmentation threshold value.
3. The method for detecting the quality of the steel castings in real time according to claim 1, wherein the method for detecting the quality of the steel castings based on the final image segmentation threshold comprises the following steps:
taking pixel points with gray values larger than a final image segmentation threshold value in the gray images of the surface of the steel casting as defective pixel points; taking the ratio of the number of defective pixel points in the gray level image of the surface of the steel casting to the number of all pixel points as a defect judgment value;
when the defect judgment value is larger than a preset defect threshold value, the quality of the steel casting is unqualified; and when the defect judging value is smaller than or equal to the preset defect threshold value, the steel casting quality is qualified.
4. The method for real-time detection of steel casting quality according to claim 1, wherein the method for dividing the image gray level interval into two image subintervals comprises the steps of:
taking the endpoint value at the left side of the image gray level interval as the endpoint value at the left side of the first image subinterval, and taking the preset value as the endpoint value at the right side of the first image subinterval; taking the sum of the preset value and the constant 1 as the endpoint value of the left side of the second image subinterval and taking the endpoint value of the right side of the image gray level interval as the endpoint value of the right side of the second image subinterval.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311509082.8A CN117237350B (en) | 2023-11-14 | 2023-11-14 | Real-time detection method for quality of steel castings |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311509082.8A CN117237350B (en) | 2023-11-14 | 2023-11-14 | Real-time detection method for quality of steel castings |
Publications (2)
Publication Number | Publication Date |
---|---|
CN117237350A CN117237350A (en) | 2023-12-15 |
CN117237350B true CN117237350B (en) | 2024-01-26 |
Family
ID=89098766
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311509082.8A Active CN117237350B (en) | 2023-11-14 | 2023-11-14 | Real-time detection method for quality of steel castings |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117237350B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117764981B (en) * | 2024-01-11 | 2024-05-10 | 东莞市中钢模具有限公司 | Injection mold quality on-line measuring system based on machine vision |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103578095A (en) * | 2012-07-24 | 2014-02-12 | 南京理工大学 | Multi-threshold-value segmentation method based on gray level histogram |
CN104537673A (en) * | 2015-01-09 | 2015-04-22 | 西安电子科技大学 | Infrared image segmentation method based on multiple threshold values and self-adaptation fuzzy clustering |
CN107248159A (en) * | 2017-08-04 | 2017-10-13 | 河海大学常州校区 | A kind of metal works defect inspection method based on binocular vision |
CN109115785A (en) * | 2018-08-08 | 2019-01-01 | 长沙理工大学 | A kind of casting grinding quality determining method, device and its application method |
CN114937055A (en) * | 2022-03-31 | 2022-08-23 | 江苏益捷思信息科技有限公司 | Image self-adaptive segmentation method and system based on artificial intelligence |
CN114943848A (en) * | 2022-07-25 | 2022-08-26 | 南通德晋昌光电科技有限公司 | Crack identification method in nickel screen laser cladding process |
CN115272321A (en) * | 2022-09-28 | 2022-11-01 | 山东军冠纺织有限公司 | Textile defect detection method based on machine vision |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113610767A (en) * | 2021-07-14 | 2021-11-05 | 温州大学 | Medical image multi-threshold segmentation method based on improved goblet sea squirt group algorithm |
-
2023
- 2023-11-14 CN CN202311509082.8A patent/CN117237350B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103578095A (en) * | 2012-07-24 | 2014-02-12 | 南京理工大学 | Multi-threshold-value segmentation method based on gray level histogram |
CN104537673A (en) * | 2015-01-09 | 2015-04-22 | 西安电子科技大学 | Infrared image segmentation method based on multiple threshold values and self-adaptation fuzzy clustering |
CN107248159A (en) * | 2017-08-04 | 2017-10-13 | 河海大学常州校区 | A kind of metal works defect inspection method based on binocular vision |
CN109115785A (en) * | 2018-08-08 | 2019-01-01 | 长沙理工大学 | A kind of casting grinding quality determining method, device and its application method |
CN114937055A (en) * | 2022-03-31 | 2022-08-23 | 江苏益捷思信息科技有限公司 | Image self-adaptive segmentation method and system based on artificial intelligence |
CN114943848A (en) * | 2022-07-25 | 2022-08-26 | 南通德晋昌光电科技有限公司 | Crack identification method in nickel screen laser cladding process |
CN115272321A (en) * | 2022-09-28 | 2022-11-01 | 山东军冠纺织有限公司 | Textile defect detection method based on machine vision |
Non-Patent Citations (2)
Title |
---|
Dongheng Xie,et al.A fast threshold segmentation method for forth image base on the pixel distribution characteristic.《PLOS ONE》.2019,全文. * |
脑出血CT图像分割与三维重建方法研究;周秀东;《中国优秀硕士学位论文全文数据库 医药卫生科技辑》;第2022年卷(第03期);E070-286 * |
Also Published As
Publication number | Publication date |
---|---|
CN117237350A (en) | 2023-12-15 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN114529549B (en) | Cloth defect labeling method and system based on machine vision | |
CN115311292B (en) | Strip steel surface defect detection method and system based on image processing | |
CN115829883B (en) | Surface image denoising method for special-shaped metal structural member | |
CN116758083B (en) | Quick detection method for metal wash basin defects based on computer vision | |
CN114862849B (en) | Aluminum alloy plate film coating effect evaluation method based on image processing | |
CN115082418B (en) | Precise identification method for automobile parts | |
CN117237350B (en) | Real-time detection method for quality of steel castings | |
CN117351019B (en) | Welding defect detection method | |
CN115294120A (en) | Valve surface quality detection method based on image recognition | |
CN114219805B (en) | Intelligent detection method for glass defects | |
CN115131354B (en) | Laboratory plastic film defect detection method based on optical means | |
CN116823822B (en) | Ship sheet metal part welding defect detection method based on visual characteristics | |
CN115294159B (en) | Method for dividing corroded area of metal fastener | |
CN116883408B (en) | Integrating instrument shell defect detection method based on artificial intelligence | |
CN116152242B (en) | Visual detection system of natural leather defect for basketball | |
CN115689948B (en) | Image enhancement method for detecting cracks of building water supply pipeline | |
CN116137036B (en) | Gene detection data intelligent processing system based on machine learning | |
CN114782329A (en) | Bearing defect damage degree evaluation method and system based on image processing | |
CN115311289A (en) | Method for detecting oil stain defects of plain-color cloth | |
CN114998333B (en) | Computer vision detection method and system for light source characteristics | |
CN118225803B (en) | Visual detection method for appearance of blade surface of bulldozer | |
CN117808796B (en) | Gear surface damage detection method based on computer vision | |
CN117252874B (en) | Visual detection method for production quality of plastic mold | |
CN116664584B (en) | Intelligent feedback regulating system for production of thin-wall zinc alloy die casting die | |
CN117078676B (en) | Breaking hammer shell visual detection method based on image processing |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |