CN116703907A - Machine vision-based method for detecting surface defects of automobile castings - Google Patents

Machine vision-based method for detecting surface defects of automobile castings Download PDF

Info

Publication number
CN116703907A
CN116703907A CN202310976262.0A CN202310976262A CN116703907A CN 116703907 A CN116703907 A CN 116703907A CN 202310976262 A CN202310976262 A CN 202310976262A CN 116703907 A CN116703907 A CN 116703907A
Authority
CN
China
Prior art keywords
edge
pixel point
obtaining
pixel
gray
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.)
Granted
Application number
CN202310976262.0A
Other languages
Chinese (zh)
Other versions
CN116703907B (en
Inventor
方建儒
鲁超
肖庆阳
姜荣辉
张敏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Dalian Yaming Automotive Parts Co ltd
Hefei Yaming Auto Parts Co ltd
Original Assignee
Dalian Yaming Automotive Parts Co ltd
Hefei Yaming Auto Parts Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Dalian Yaming Automotive Parts Co ltd, Hefei Yaming Auto Parts Co ltd filed Critical Dalian Yaming Automotive Parts Co ltd
Priority to CN202310976262.0A priority Critical patent/CN116703907B/en
Publication of CN116703907A publication Critical patent/CN116703907A/en
Application granted granted Critical
Publication of CN116703907B publication Critical patent/CN116703907B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G01MEASURING; TESTING
    • G01NINVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
    • G01N21/00Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
    • G01N21/84Systems specially adapted for particular applications
    • G01N21/88Investigating the presence of flaws or contamination
    • G01N21/8851Scan or image signal processing specially adapted therefor, e.g. for scan signal adjustment, for detecting different kinds of defects, for compensating for structures, markings, edges
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • G06T7/0004Industrial image inspection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/13Edge detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/136Segmentation; Edge detection involving thresholding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/60Analysis of geometric attributes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01NINVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
    • G01N21/00Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
    • G01N21/84Systems specially adapted for particular applications
    • G01N21/88Investigating the presence of flaws or contamination
    • G01N21/8851Scan or image signal processing specially adapted therefor, e.g. for scan signal adjustment, for detecting different kinds of defects, for compensating for structures, markings, edges
    • G01N2021/8887Scan or image signal processing specially adapted therefor, e.g. for scan signal adjustment, for detecting different kinds of defects, for compensating for structures, markings, edges based on image processing techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10004Still image; Photographic image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30108Industrial image inspection
    • G06T2207/30164Workpiece; Machine component
    • YGENERAL 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
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Biochemistry (AREA)
  • Chemical & Material Sciences (AREA)
  • Analytical Chemistry (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Immunology (AREA)
  • Pathology (AREA)
  • Quality & Reliability (AREA)
  • Signal Processing (AREA)
  • Geometry (AREA)
  • Image Analysis (AREA)

Abstract

The application relates to the field of image processing, in particular to a machine vision-based method for detecting surface defects of an automobile casting, which comprises the following steps: collecting an image and graying to obtain an edge detection image; detecting the curve direction of a target area in each edge in the image according to the edges; obtaining mutual extension possibility according to the intersection point of the target area, and obtaining the extension trend of any edge according to the mutual extension possibility; obtaining the gray value change degree of the edge pixel points according to the gray change direction of each pixel point; obtaining the gray value change degree around the edge according to the gray value change degree of the edge pixel point and the distance between the edge pixel point and the adjacent pixel point; obtaining the possibility that any edge is a crack according to the extending trend of the edge and the gray value change degree around the edge; the crack region in the image is detected based on the likelihood that the edge is a crack. According to the application, the direction of the edge pixel point is obtained by using an image processing mode, so that the detection of cracks is improved.

Description

Machine vision-based method for detecting surface defects of automobile castings
Technical Field
The application relates to the technical field of image data processing, in particular to a machine vision-based method for detecting surface defects of an automobile casting.
Background
With the continuous development of the automobile industry, the quality requirements of automobile castings are also higher and higher. However, because of the influence of various factors, such as raw materials, processes, equipment and the like, in the manufacturing process of the automobile castings, cracks are inevitably generated in the castings, so that not only are the mechanical properties and the service life of the castings influenced, but also the safety and the environmental protection of the automobiles are negatively influenced.
In order to improve the quality and safety of the automobile castings, defect identification and detection of the castings are required. The traditional defect detection method mainly adopts threshold segmentation or edge detection based on image processing to identify defects, but in the detection process, uneven areas in a normal range can be generated due to different requirements of the casting surface on roughness, and when cracks are identified through edge detection under the condition, crack identification is interfered, and the condition of missing detection or false detection is easy to occur, so that the accuracy of crack detection is affected.
Disclosure of Invention
The application provides a machine vision-based method for detecting surface defects of an automobile casting, which aims to solve the existing problems.
The application discloses a machine vision-based method for detecting surface defects of an automobile casting, which adopts the following technical scheme:
the embodiment of the application provides a machine vision-based method for detecting surface defects of an automobile casting, which comprises the following steps of:
collecting an image of the surface of an automobile casting, and carrying out graying pretreatment to obtain all edges in a gray level image;
intercepting the edge to obtain a target area of the edge, and obtaining the tangential direction of a pixel point in the target area of the edge; acquiring the average value of tangential directions of all pixel points in a target area of the edge, and taking the average value as the curve direction of the target area;
acquiring intersection points of the curve direction of the target area on each edge and the curve directions of the target areas on all other edges, acquiring the possibility that each edge extends mutually at each intersection point, and acquiring the extending trend of each edge according to the average value of the possibility that each edge extends mutually at all intersection points;
obtaining the gray level change direction of each pixel point according to the gray level difference in the neighborhood of each pixel point, and obtaining the gray level value change degree of each edge pixel point according to the gray level change direction of each pixel point;
obtaining the gray value change degree around the edge according to the gray value change degree of each edge pixel point and the distance between the edge pixel point and the adjacent edge pixel point;
obtaining the possibility that the edge is a crack according to the extension trend of any edge and the gray value variation degree around the edge;
and obtaining a crack region in the edge detection image according to the possibility that the edge is a crack and a preset threshold value.
Further, the capturing the edge to obtain the target area of the edge, and obtaining the tangential direction of the pixel point in the target area of the edge includes the following specific steps:
selecting any one edge of the edge detection image, marking the edge as a processing edge, intercepting three pixel points close to an endpoint at one end of the processing edge, and marking the three pixel points as a target area; meanwhile, intercepting three pixel points close to the end points at the other end of the processing edge, wherein the three pixel points are marked as target areas, and the processing edge corresponds to two target areas; and obtaining a curve of the target area according to morphological corrosion in the target area, and obtaining a tangent line of each pixel point on the curve.
Further, the step of obtaining the intersection point of the curve direction of the target area on each edge and the curve directions of the target areas on all other edges to obtain the possibility that each edge extends to each other at each intersection point includes the following specific steps:
the calculation method of the possibility that the a-th edges extend to each other at the b-th intersection point is as follows:
firstly, assume that the curve direction of the target area on the a-th edge is compared with the curve direction of the target area on the edge B;
then obtaining two edge pixel points with the shortest distance between the a-th edge and the edge B, respectively marking the two edge pixel points as a first pixel point and a second pixel point, obtaining an arc length according to the first pixel point, the second pixel point and the B-th intersection point, and marking the arc length as
The possibility that the a-th edges extend to each other at the b-th intersection point can be obtained
In (1) the->Representing the angle between the curve direction of the target area in the a-th edge and the curve direction of the target area in the edge B, namely the angle corresponding to the B-th intersection point, +.>Indicating the likelihood that the a-th edges extend past each other at the b-th intersection.
Further, the step of specifically acquiring the extending trend of each edge is as follows:
the formula of the extension trend of each edge is:
in (1) the->Represents the possibility that the a-th edges extend to each other at the b-th intersection point, n a Representing the number of intersections of the target region of edge a and the target regions of other edges, P a Represents the extension trend of the a-th edge, and th represents the hyperbolic tangent function.
Further, the step of obtaining the gray scale change direction of each pixel according to the gray scale difference in the neighborhood of each pixel and obtaining the gray scale value change degree of each edge pixel according to the gray scale change direction of each pixel comprises the following specific steps:
establishing 8 neighborhoods with each edge pixel point in the gray level graph as the center, respectively subtracting gray level values of other pixel points in the neighborhoods by using gray level values of the pixel points at the center, if the difference value is negative, enabling the change direction from the pixel points at the center to the pixel points in the neighborhoods, and if the difference value is positive, enabling the change direction from the pixel points in the neighborhoods to the pixel points at the center; defining the vector direction as a change direction all the time; meanwhile, the absolute value of the gray value difference between the pixel point at the center edge and the pixel point in the neighborhood represents the vector modular length; according to the operation method of the vectors, accumulating all vectors in the neighborhood to obtain the gray scale change direction of the pixel point at the center edge;
taking th1 pixel points for each edge pixel point in the vertical direction of the gray change direction of the edge pixel point by taking the edge pixel point as the center according to the gray change direction of each edge pixel point, and taking the two sides of each pixel pointAnd obtaining a group of pixel point sets, marking the first point in the pixel point sets as a reference edge pixel point, carrying out difference on any two pixel points in the pixel point sets, then averaging to obtain the gray value change degree of each edge pixel point, wherein th1 is a preset value.
Further, the specific obtaining step of the gray value variation degree around the edge is as follows:
the formula of the gray value variation degree around the edge is:
in (1) the->Representing the gray value variation degree of the pixel point of the t-th edge on the d-th edge,/>Representing the distance from the t-th edge pixel point on the d-th edge to the next edge pixel point along the gray scale change direction,/for the gray scale change direction>The distance from the t-th edge pixel point on the d-th edge to the next edge pixel point along the reverse direction of the gray level change direction is represented, N represents the number of the edge pixel points on the d-th edge, exp represents an exponential function based on a natural number>Indicating the extent of gray value variation around the d-th edge.
Further, the specific acquisition steps of the possibility that the edge is a crack are as follows:
the formula for the likelihood of an edge being a crack is:
wherein P is a Expressed as the extending trend of the a-th edge, P c Expressed as the extension trend of the c-th edge, < >>Expressed as the degree of gray value variation around the a-th edge,/->Expressed as the degree of gray value variation around the c-th edge, f a Indicating the number of all edges except the a-th edge,indicated as possibility of crack in the a-th region,/->Representing the normalization function, the purpose of the denominator plus 1 is to prevent the denominator from being 0.
The technical scheme of the application has the beneficial effects that: the application has the following advantages compared with the prior art: by utilizing the gray level change aggregation of the edges of the cracks, the interference of the edges on crack identification formed by the rough surface of the casting is avoided through analysis among different edges, the true reliability of each edge is enhanced, and the crack identification accuracy is improved. The method has the advantages that the edges in the image are integrally analyzed through the extending relation of the edges, the situation that the edges of the segmented cracks are misjudged to be rough points is avoided, the accuracy of judging the edges of the cracks is improved, so that the cracks in the image are accurately detected, and the accuracy of detection results is greatly improved.
Drawings
In order to more clearly illustrate the embodiments of the application or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of steps of a method for detecting surface defects of an automobile casting based on machine vision.
Detailed Description
In order to further describe the technical means and effects adopted by the application to achieve the preset aim, the following is a specific implementation, structure, characteristics and effects of the machine vision-based method for detecting the surface defects of the automobile casting according to the application, which are described in detail below with reference to the accompanying drawings and the preferred embodiments. 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 application belongs.
The application provides a specific scheme of an automobile casting surface defect detection method based on machine vision, which is specifically described below with reference to the accompanying drawings.
Referring to fig. 1, a flowchart of a method for detecting defects on a surface of an automobile casting based on machine vision according to an embodiment of the application is shown, and the method includes the following steps:
step S001: and (5) collecting and preprocessing an image of the automobile casting.
Collecting the surface image data of the automobile casting by using a camera, carrying out graying pretreatment on the collected image to obtain a graying image, and then carrying out canny edge detection on the graying image to obtain an edge detection image;
step S002: and obtaining the extension possibility and the extension trend of the edge according to the pixel points at the tail end of the edge.
It should be noted that, since the gradient cannot represent the changing direction of the gray value, a new vector is defined to represent the changing direction of the gray value; because the cracks have a certain mutual extending trend, judging each edge extending trend according to the tangential direction of the direction; meanwhile, according to the direction, the gray value difference degree in the gray value change direction of each pixel point of all edges in the edge detection image is calculated, and the gray value change degree of the periphery of the whole edge is obtained; and establishing a crack region judgment formula in the edge detection image by combining a plurality of judgment conditions.
(1) And obtaining the extension possibility of any two edges according to the edge detection image.
It should be noted that, because in the process of casting an automobile, most of cracks have a tendency to tend to the same crack in two relatively close lines in the process of generating and gradually spreading due to the too fast condensation rate, that is, the two lines have a mutual extending tendency, and for any one edge, the current edge extending tendency is calculated according to the possibility of extending from other edges in two extending directions.
Specifically, with the edge detection image, for the a-th edge of the edge detection image, three pixel points close to the end point are cut at one end of the a-th edge, and the three pixel points are marked as a target area; and meanwhile, intercepting three pixel points close to the end points at the other end of the a-th edge, wherein the three pixel points are marked as target areas, so that the a-th edge corresponds to two target areas. Obtaining a curve of the target area according to morphological corrosion in the target area, obtaining a tangent line of each pixel point on the curve, and obtaining an included angle of each pixel point according to the included angle of the tangent line and the horizontal direction; because each target area has three pixel points, the included angles of the three pixel points of each target area are averaged to represent the curve direction of the target area. So far, the curve direction of the target area on all edges is obtained.
The curve direction of the two target areas on the a-th edge and the curve directions of the target areas on all other edges have a plurality of intersection points (the intersection conditions of the curve directions of the two target areas on the same edge are not considered), and the number of the intersection points is n a
The following analysis is performed, taking the b-th intersection as an example:
the edge corresponding to the B-th intersection point is denoted as an edge B, that is, the curve direction of the target area on the a-th edge is compared with the curve direction of the target area on the edge B.
Acquiring two pixel points with shortest distance between a target area pixel point in the edge a and a target area pixel point in the edge B, and acquiring the arc length of the intersection point between the two points with the shortest distance and the B, wherein the arc length is recorded as
The possibility that the a-th edges extend to each other at the b-th intersection point can be obtained
In (1) the->Representing the angle between the curve direction of the target area in the a-th edge and the curve direction of the target area in the edge B, namely the angle corresponding to the B-th intersection point, +.>Representing the length of the arc between the target area in the a-th edge and the target area in edge B +.>Indicating the likelihood that the a-th edges extend past each other at the b-th intersection.
Wherein when the included angle isThe more approaching pi, & gt>The closer to 1, the minimum arc length of three points at the same time +.>The smaller the size of the product,the larger the>The larger, i.e., larger, f indicates a greater likelihood of extending between the a-th and B-th edges, i.e., the more likely the same edge.
(2) The extension trend of each edge is obtained according to the extension possibility between any two edges.
It should be noted that since the curve direction of the target area of each edge is uncertain, both target areas of one edge are likely to be aligned withThe target areas of the edges intersect, and the number of intersection points of the two target areas of one edge intersecting the target areas of the other edge is denoted as n a . The extending trend P of the edge a can be calculated a
The extending trend P of the edge a a The formula of (c) can be expressed as:
in (1) the->Represents the possibility that the a-th edges extend to each other at the b-th intersection point, n a Representing the number of intersections of two target areas of the a-th edge and target areas of other edges, P a Represents the extension trend of the a-th edge, and th represents the hyperbolic tangent function.
Wherein, when the possibility of mutual extensionThe larger the current edge, and the fewer the number n of intersection points existing in the directions of the two target areas, the P a The closer to 1, the higher the extending tendency of the edge a is indicated.
And by analogy, the extension trend of all edges is obtained.
So far, the extending trend of all edges is obtained;
step S003: and establishing a crack identification judgment formula by combining the distribution relation of the peripheral pixel points of the edge and the interrelation between different edges.
It should be noted that, because other rough areas have larger gray scale differences in different directions, the gray scale changes of the crack areas are more concentrated and mainly show larger gray scale differences of the crack edges, the gray scale value changes of the pixel points around a plurality of edges of one crack are smaller, and all the crack areas in the image are judged and identified by calculating the gray scale value change degree of the pixel points around each area and combining the area extending trend.
(1) The gray scale variation direction of each pixel point in the edge detection image is redefined.
It should be noted that, since the gradient only finds the direction in which the gray value change rate is fast in the image, it cannot be expressed whether the gray value of the pixel point changes from small to large or from large to small. Therefore, a gray value change vector is redefined for all edge points in the edge detection result, and the gray value change direction of the edge pixel points is calculated.
Specifically, 8 neighborhoods are built for each pixel point at the edge in the gray level graph as the center, gray level differences between the center pixel point and all other pixel points in the neighborhoods are calculated respectively, namely gray level values of the other pixel points in the neighborhoods are subtracted by the gray level values of the center pixel point, the difference value is used for negatively indicating that the gray level values of the two points are changed from small to large, the change direction is from the pixel point at the center edge to the pixel point in the neighborhoods, the difference value is used for regularly indicating that the gray level value is changed from large to small, and the direction is from the pixel point in the neighborhoods to the pixel point at the center edge, namely the direction of a definition vector is always the direction from small to large. Meanwhile, the absolute value of the difference value between the gray value of the pixel point at the center edge and the gray value of the pixel point in the neighborhood represents the vector modular length, and the change direction is the vector direction. According to the operation method of the vectors, all vectors in the neighborhood are accumulated, and the gray scale change direction of the pixel point at the center edge can be obtained.
Thus, the gray scale change direction of each pixel point in the gray scale image is obtained.
The pixels in the edge are denoted edge pixels.
Specifically, according to the gray scale change direction of each edge pixel point, the distance D between the edge pixel point and the next edge pixel point along the direction is calculated, and the larger the value is, the greater the possibility of the point to be located at the edge of the crack is, and the opposite is. And meanwhile, the distance D 'from the edge pixel point in the opposite direction of the gray level change direction to the next edge pixel point is calculated, and the smaller the distance D' is, the smaller the probability that the distance D is positioned at the edge of a crack is, and the opposite is the case.
Taking th1 pixel points of each edge pixel point in the vertical direction of the gray level change trend direction by taking the pixel point as a starting point, namely taking th1/2 pixel points on two sides of the vertical direction of the gray level change trend direction respectively to obtain a group of pixel point sets. A number threshold th1 is preset, where th1=10 is taken as an example in this embodiment, and this embodiment is not specifically limited, where th1 may be determined according to the specific implementation. Calculating the gray value difference between each pixel point in the pixel point set, and obtaining the gray value change degree of the edge pixel point in the change direction of the edge pixel point
In (1) the->Representing the gray value of the ith pixel in th1 pixel set corresponding to the nth edge pixel on the nth edge,/for the nth edge pixel>Representing the gray value of the j-th pixel in th1 pixel set corresponding to the t-th edge pixel on the d-th edge,/>The gray value variation degree of the t-th edge pixel point on the edge on the d-th edge is represented.
Wherein, in the formula, the chemical formula,the gray value difference between the pixel points is represented, and the whole formula represents the average value of the gray value differences which are sequentially compared by th1 pixel points. When calculated->The larger the edge point is, the larger the difference of gray values of a plurality of pixel points is, and the gray value change degree of the pixel points is larger.
Calculating the pixel point of each edge on the same edgeObtaining the gray value variation range around the edgeDegree of
In (1) the->Representing the gray value variation degree of the pixel point of the t-th edge on the d-th edge,/>Representing the distance from the t-th edge pixel point on the d-th edge to the next edge pixel point along the gray scale change direction,/for the gray scale change direction>The distance from the t-th edge pixel point on the d-th edge to the next edge pixel point along the reverse direction of the gray level change direction is represented, N represents the number of the edge pixel points on the d-th edge, exp represents an exponential function based on a natural number>Indicating the extent of gray value variation around the d-th edge.
Wherein, the liquid crystal display device comprises a liquid crystal display device,representing the distance from the t-th edge pixel point on the d-th edge to the next edge pixel point in the opposite direction of the gray scale change direction and the distance from the t-th edge pixel point on the change direction to the next edge pixel point, when the ratio of the distance to the next edge pixel point to the gray scale change direction is smaller, the greater the possibility that the pixel point is positioned at the edge of a crack is indicated, the ratio of all the pixel points on the edge is accumulated, and when the accumulated result is smaller, the greater the possibility that the edge is the crack is indicated; at the same time, when the pixel point is in the gray level change direction, the gray value change degree of the pixel point is +>The smaller the ∈>The smaller the overall accumulated result +.>The smaller the indication the greater the likelihood that the entire region edge is cracked. Since the whole equation is inversely related, the data is programmed to [0,1 ] using an exponential exp function]. When (when)Smaller (less)>The larger and closer to 1 indicates a smaller degree of change in the gray value of the pixel points around the edge.
It should be noted that, theoretically, the distribution of the pixels around two crack areas obtained by segmenting the same crack is similar, and the area where the periphery and the periphery have mutual extending trend has a certain influence on identifying whether the current area is a crack or not for any one edge.
Specifically, for all edges, the extending trend of each edge is obtained through the calculation method of the steps; thus, for any one edge a, n exists in the curve direction of the two target areas a The crossing points, i.e. there are n a And judging the (a) th edge as the possibility Final (a) of the crack.
The formula of the probability Final (a) that the a-th region is a crack can be expressed as:
wherein P is a Expressed as the extending trend of the a-th edge, P c Expressed as the extension trend of the c-th edge, < >>Expressed as the degree of gray value variation around the a-th edge,/->Expressed as the degree of gray value variation around the c-th edge, f a Representation ofThe number of all edges except the a-th edge, < ->Indicated as possibility of crack in the a-th region,/->Representing a normalization function->The purpose of adding 1 to the denominator in the formula is to prevent the denominator from being 0.
Wherein whenThe smaller the difference between the two is, the similar gray value change degree of the peripheral pixel points is, and the +.>The larger the sum of all possible overlapping regions, i.e. +.>. At this time, when the difference between the peripheral edge of the other edge and the peripheral edge of the a-th edge is smaller, and each region includes the greater the self-extending trend of the a-th edge, the greater the probability of indicating that the a-th edge is a crack, the +.>The larger. Normalizing the final result to [0,1 ] using norm function]。
A threshold value F is preset, where the present embodiment is described by taking f=0.8 as an example, and the present embodiment is not specifically limited, where F may be determined according to the specific implementation situation. When (when)When we consider the current edge a as a crack region;
step S004: a crack region in the image is identified.
And obtaining all crack areas in the image according to the edge detection image and the possibility that the edge is a crack, so that all crack detection in the image is completed.
This embodiment is completed.
The foregoing description of the preferred embodiments of the application is not intended to be limiting, but rather is intended to cover all modifications, equivalents, alternatives, and improvements that fall within the spirit and scope of the application.

Claims (7)

1. The method for detecting the surface defects of the automobile castings based on machine vision is characterized by comprising the following steps of:
collecting an image of the surface of an automobile casting, and carrying out graying pretreatment to obtain all edges in a gray level image;
intercepting the edge to obtain a target area of the edge, and obtaining the tangential direction of a pixel point in the target area of the edge; acquiring the average value of tangential directions of all pixel points in a target area of the edge, and taking the average value as the curve direction of the target area;
acquiring intersection points of the curve direction of the target area on each edge and the curve directions of the target areas on all other edges, acquiring the possibility that each edge extends mutually at each intersection point, and acquiring the extending trend of each edge according to the average value of the possibility that each edge extends mutually at all intersection points;
obtaining the gray level change direction of each pixel point according to the gray level difference in the neighborhood of each pixel point, and obtaining the gray level value change degree of each edge pixel point according to the gray level change direction of each pixel point;
obtaining the gray value change degree around the edge according to the gray value change degree of each edge pixel point and the distance between the edge pixel point and the adjacent edge pixel point;
obtaining the possibility that the edge is a crack according to the extension trend of any edge and the gray value variation degree around the edge;
and obtaining a crack region in the edge detection image according to the possibility that the edge is a crack and a preset threshold value.
2. The method for detecting the surface defects of the automobile castings based on machine vision according to claim 1, wherein the steps of intercepting the edges to obtain target areas of the edges and obtaining tangential directions of pixel points in the target areas of the edges comprise the following specific steps:
selecting any one edge of the edge detection image, marking the edge as a processing edge, intercepting three pixel points close to an endpoint at one end of the processing edge, and marking the three pixel points as a target area; meanwhile, intercepting three pixel points close to the end points at the other end of the processing edge, wherein the three pixel points are marked as target areas, and the processing edge corresponds to two target areas; and obtaining a curve of the target area according to morphological corrosion in the target area, and obtaining a tangent line of each pixel point on the curve.
3. The method for detecting surface defects of an automobile casting based on machine vision according to claim 1, wherein the step of obtaining intersections of the curved direction of the target area on each edge and the curved directions of the target areas on all other edges to obtain the possibility that each edge extends to each other at each intersection comprises the following specific steps:
the calculation method of the possibility that the a-th edges extend to each other at the b-th intersection point is as follows:
firstly, assume that the curve direction of the target area on the a-th edge is compared with the curve direction of the target area on the edge B;
then obtaining two edge pixel points with the shortest distance between the a-th edge and the edge B, respectively marking the two edge pixel points as a first pixel point and a second pixel point, obtaining an arc length according to the first pixel point, the second pixel point and the B-th intersection point, and marking the arc length as
The possibility that the a-th edges extend to each other at the b-th intersection point can be obtained
In (1) the->Representing the angle between the curve direction of the target area in the a-th edge and the curve direction of the target area in the edge B, namely the angle corresponding to the B-th intersection point, +.>Indicating the likelihood that the a-th edges extend past each other at the b-th intersection.
4. The method for detecting the surface defects of the automobile castings based on machine vision according to claim 1, wherein the step of specifically acquiring the extending trend of each edge is as follows:
the formula of the extension trend of each edge is:
in (1) the->Represents the possibility that the a-th edges extend to each other at the b-th intersection point, n a Representing the number of intersections of the target region of edge a and the target regions of other edges, P a Represents the extension trend of the a-th edge, and th represents the hyperbolic tangent function.
5. The method for detecting the surface defects of the automobile castings based on the machine vision according to claim 1, wherein the method for obtaining the gray scale change direction of each pixel point according to the gray scale difference in the neighborhood of each pixel point and obtaining the gray scale value change degree of each edge pixel point according to the gray scale change direction of each pixel point comprises the following specific steps:
establishing 8 neighborhoods with each edge pixel point in the gray level graph as the center, respectively subtracting gray level values of other pixel points in the neighborhoods by using gray level values of the pixel points at the center, if the difference value is negative, enabling the change direction from the pixel points at the center to the pixel points in the neighborhoods, and if the difference value is positive, enabling the change direction from the pixel points in the neighborhoods to the pixel points at the center; defining the vector direction as a change direction all the time; meanwhile, the absolute value of the gray value difference between the pixel point at the center edge and the pixel point in the neighborhood represents the vector modular length; according to the operation method of the vectors, accumulating all vectors in the neighborhood to obtain the gray scale change direction of the pixel point at the center edge;
taking th1 pixel points for each edge pixel point in the vertical direction of the gray change direction of the edge pixel point by taking the edge pixel point as the center according to the gray change direction of each edge pixel point, and taking the two sides of each pixel pointAnd obtaining a group of pixel point sets, marking the first point in the pixel point sets as a reference edge pixel point, carrying out difference on any two pixel points in the pixel point sets, then averaging to obtain the gray value change degree of each edge pixel point, wherein th1 is a preset value.
6. The method for detecting the surface defects of the automobile castings based on the machine vision according to claim 1, wherein the specific obtaining step of the gray value variation degree around the edge is as follows:
the formula of the gray value variation degree around the edge is:
in (1) the->Representing the gray value variation degree of the pixel point of the t-th edge on the d-th edge,/>Representing the distance from the t-th edge pixel point on the d-th edge to the next edge pixel point along the gray scale change direction,/for the gray scale change direction>The distance from the t-th edge pixel point on the d-th edge to the next edge pixel point along the reverse direction of the gray level change direction is represented, N represents the number of the edge pixel points on the d-th edge, exp represents an exponential function based on a natural number>Indicating the extent of gray value variation around the d-th edge.
7. The machine vision-based method for detecting surface defects of an automobile casting according to claim 1, wherein the specific obtaining step of the possibility that the edge is a crack is as follows:
the formula for the likelihood of an edge being a crack is:
wherein P is a Expressed as the extending trend of the a-th edge, P c Expressed as the extension trend of the c-th edge, < >>Expressed as the degree of gray value variation around the a-th edge,/->Expressed as the degree of gray value variation around the c-th edge, f a Represents the number of all edges except the a-th edge,/->Indicated as possibility of crack in the a-th region,/->Representing the normalization function, the purpose of the denominator plus 1 is to prevent the denominator from being 0.
CN202310976262.0A 2023-08-04 2023-08-04 Machine vision-based method for detecting surface defects of automobile castings Active CN116703907B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310976262.0A CN116703907B (en) 2023-08-04 2023-08-04 Machine vision-based method for detecting surface defects of automobile castings

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310976262.0A CN116703907B (en) 2023-08-04 2023-08-04 Machine vision-based method for detecting surface defects of automobile castings

Publications (2)

Publication Number Publication Date
CN116703907A true CN116703907A (en) 2023-09-05
CN116703907B CN116703907B (en) 2023-10-27

Family

ID=87829719

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310976262.0A Active CN116703907B (en) 2023-08-04 2023-08-04 Machine vision-based method for detecting surface defects of automobile castings

Country Status (1)

Country Link
CN (1) CN116703907B (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116993742A (en) * 2023-09-28 2023-11-03 中色(天津)新材料科技有限公司 Nickel alloy rolling defect detection method based on machine vision
CN117078667A (en) * 2023-10-13 2023-11-17 山东克莱蒙特新材料科技有限公司 Mineral casting detection method based on machine vision
CN117095004A (en) * 2023-10-20 2023-11-21 金成技术股份有限公司 Excavator walking frame main body welding deformation detection method based on computer vision
CN117124139A (en) * 2023-10-26 2023-11-28 合肥亚明汽车部件有限公司 Visual detection method for intelligent machine tool cutter abrasion
CN117173641A (en) * 2023-11-02 2023-12-05 南通苏禾车灯配件有限公司 Autonomous car washing monitoring method based on machine vision
CN117197130A (en) * 2023-11-03 2023-12-08 山东太阳耐磨件有限公司 Driving tooth angle defect identification method based on machine vision
CN117237368A (en) * 2023-11-16 2023-12-15 临沂市公路事业发展中心兰陵县中心 Bridge crack detection method and system
CN117788300A (en) * 2024-02-23 2024-03-29 中国医学科学院北京协和医院 Image enhancement optimization method for ureteroscope lithotripsy
CN117893543A (en) * 2024-03-18 2024-04-16 辽宁云也智能信息科技有限公司 Visual-assistance-based pavement crack intelligent detection method and system

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2011100341A (en) * 2009-11-06 2011-05-19 Kanto Auto Works Ltd Method of detecting edge and image processing apparatus
WO2018165753A1 (en) * 2017-03-14 2018-09-20 University Of Manitoba Structure defect detection using machine learning algorithms
CN115063423A (en) * 2022-08-18 2022-09-16 启东市嘉信精密机械有限公司 Mechanical casting cold and hot crack self-adaptive identification method based on computer vision
CN115100171A (en) * 2022-07-11 2022-09-23 常宝云 Steel die welding defect detection method and system based on machine vision
CN115797358A (en) * 2023-02-10 2023-03-14 济宁安泰矿山设备制造有限公司 Metal shell automatic welding defect detection method based on machine vision
CN115908411A (en) * 2023-01-06 2023-04-04 山东水利建设集团有限公司 Concrete curing quality analysis method based on visual detection
CN116012384A (en) * 2023-03-28 2023-04-25 梁山水泊胶带股份有限公司 Method for detecting surface defects of whole-core flame-retardant conveying belt
CN116385434A (en) * 2023-06-02 2023-07-04 同济检测(济宁)有限公司 Intelligent detection method for precast beam cracks

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2011100341A (en) * 2009-11-06 2011-05-19 Kanto Auto Works Ltd Method of detecting edge and image processing apparatus
WO2018165753A1 (en) * 2017-03-14 2018-09-20 University Of Manitoba Structure defect detection using machine learning algorithms
CN115100171A (en) * 2022-07-11 2022-09-23 常宝云 Steel die welding defect detection method and system based on machine vision
CN115063423A (en) * 2022-08-18 2022-09-16 启东市嘉信精密机械有限公司 Mechanical casting cold and hot crack self-adaptive identification method based on computer vision
CN115908411A (en) * 2023-01-06 2023-04-04 山东水利建设集团有限公司 Concrete curing quality analysis method based on visual detection
CN115797358A (en) * 2023-02-10 2023-03-14 济宁安泰矿山设备制造有限公司 Metal shell automatic welding defect detection method based on machine vision
CN116012384A (en) * 2023-03-28 2023-04-25 梁山水泊胶带股份有限公司 Method for detecting surface defects of whole-core flame-retardant conveying belt
CN116385434A (en) * 2023-06-02 2023-07-04 同济检测(济宁)有限公司 Intelligent detection method for precast beam cracks

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
宋榕榕: ""基于深度学习的表面缺陷检测算法研究"", 《知网》, no. 2 *

Cited By (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116993742A (en) * 2023-09-28 2023-11-03 中色(天津)新材料科技有限公司 Nickel alloy rolling defect detection method based on machine vision
CN116993742B (en) * 2023-09-28 2023-12-22 中色(天津)新材料科技有限公司 Nickel alloy rolling defect detection method based on machine vision
CN117078667B (en) * 2023-10-13 2024-01-09 山东克莱蒙特新材料科技有限公司 Mineral casting detection method based on machine vision
CN117078667A (en) * 2023-10-13 2023-11-17 山东克莱蒙特新材料科技有限公司 Mineral casting detection method based on machine vision
CN117095004A (en) * 2023-10-20 2023-11-21 金成技术股份有限公司 Excavator walking frame main body welding deformation detection method based on computer vision
CN117095004B (en) * 2023-10-20 2024-01-12 金成技术股份有限公司 Excavator walking frame main body welding deformation detection method based on computer vision
CN117124139A (en) * 2023-10-26 2023-11-28 合肥亚明汽车部件有限公司 Visual detection method for intelligent machine tool cutter abrasion
CN117124139B (en) * 2023-10-26 2024-01-09 合肥亚明汽车部件有限公司 Visual detection method for intelligent machine tool cutter abrasion
CN117173641A (en) * 2023-11-02 2023-12-05 南通苏禾车灯配件有限公司 Autonomous car washing monitoring method based on machine vision
CN117173641B (en) * 2023-11-02 2024-03-05 南通苏禾车灯配件有限公司 Autonomous car washing monitoring method based on machine vision
CN117197130A (en) * 2023-11-03 2023-12-08 山东太阳耐磨件有限公司 Driving tooth angle defect identification method based on machine vision
CN117197130B (en) * 2023-11-03 2024-01-26 山东太阳耐磨件有限公司 Driving tooth angle defect identification method based on machine vision
CN117237368A (en) * 2023-11-16 2023-12-15 临沂市公路事业发展中心兰陵县中心 Bridge crack detection method and system
CN117237368B (en) * 2023-11-16 2024-01-26 临沂市公路事业发展中心兰陵县中心 Bridge crack detection method and system
CN117788300A (en) * 2024-02-23 2024-03-29 中国医学科学院北京协和医院 Image enhancement optimization method for ureteroscope lithotripsy
CN117788300B (en) * 2024-02-23 2024-05-10 中国医学科学院北京协和医院 Image enhancement optimization method for ureteroscope lithotripsy
CN117893543A (en) * 2024-03-18 2024-04-16 辽宁云也智能信息科技有限公司 Visual-assistance-based pavement crack intelligent detection method and system
CN117893543B (en) * 2024-03-18 2024-05-10 辽宁云也智能信息科技有限公司 Visual-assistance-based pavement crack intelligent detection method and system

Also Published As

Publication number Publication date
CN116703907B (en) 2023-10-27

Similar Documents

Publication Publication Date Title
CN116703907B (en) Machine vision-based method for detecting surface defects of automobile castings
CN115170576B (en) Aluminum pipe surface defect detection method based on machine vision
CN114862862B (en) Pump body cold shut defect identification method and system based on image processing
CN108647572B (en) Lane departure early warning method based on Hough transform
CN109682839B (en) Online detection method for surface defects of metal arc-shaped workpiece
CN115082462B (en) Method and system for detecting appearance quality of fluid conveying pipe
CN115984284B (en) X-ray ship body weld image detection method for ship maintenance
CN115829883A (en) Surface image denoising method for dissimilar metal structural member
CN116740070B (en) Plastic pipeline appearance defect detection method based on machine vision
CN116385445B (en) Visual technology-based electroplated hardware flaw detection method
CN116977358B (en) Visual auxiliary detection method for corrugated paper production quality
CN115690108A (en) Aluminum alloy rod production quality evaluation method based on image processing
CN116758084B (en) Intelligent detection method for welding defects of sheet metal parts based on image data
CN115049664A (en) Vision-based ship engine fitting defect detection method
CN115294159B (en) Method for dividing corroded area of metal fastener
CN115797358A (en) Metal shell automatic welding defect detection method based on machine vision
CN116523923B (en) Battery case defect identification method
CN115063407B (en) Scratch and crack identification method for annular copper gasket
CN116503403B (en) Defect detection method of metal cutting tool bit based on image processing
CN114742788A (en) Copper bar defect detection method and system based on machine vision
CN115359053A (en) Intelligent detection method and system for defects of metal plate
CN115063423A (en) Mechanical casting cold and hot crack self-adaptive identification method based on computer vision
CN112508913A (en) Cable section edge detection method based on image detection
CN107516315B (en) Tunneling machine slag tapping monitoring method based on machine vision
CN113077437A (en) Workpiece quality detection method and system

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