Metal bar surface quality detection method and system
Through an adaptive threshold segmentation algorithm based on image chunking, the grayscale changes and gradient changes of the metal rod surface are analyzed, and the overlap rate is adjusted to achieve more accurate quality detection, which solves the problem of difficult to identify small cracks in the prior art and improves the problem of improving The accuracy and efficiency of the detection are achieved.
Patent Information
- Application Number
- CN202411570995.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2044-11-06
AI Technical Summary
The prior art is difficult to accurately identify and detect small cracks on the surface of metal rods, resulting in low accuracy of quality detection results.
Adaptive threshold segmentation algorithm based on image chunking is adopted to analyze the degree of grayscale change and gradient change consistency in image blocks, calculate the initial demand factor for overlap rate of the initial image block, and pass the grayscale histogram of the overlapping block group. Adjust the overlap rate for more accurate quality inspection.
The accuracy of surface quality detection of metal rods is improved, especially in detecting microcracks, reducing the error of detection results and algorithm redundancy.
Smart Images

Figure CN119090878B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image data processing, and in particular to a metal bar surface quality detection method and system. Background Art
[0002] Metal bars are widely used in the fields of construction, automobiles, aviation, etc., and play an important role in the production of related industries. For example, in the construction industry, the quality of metal bars is directly related to the stability and safety of the building. In the automobile industry, the quality of metal bars is directly related to the safety, durability and comfort of the car. Therefore, in the production and application of metal bars, it is necessary to increase the intensity and accuracy of quality inspection to ensure the quality and reliability of metal bars.
[0003] The prior art for quality inspection of metal materials mostly tends to process images of metal materials and obtain their quality inspection results through image details. For example, a patent application document with publication number CN113298809A discloses a composite material ultrasonic image defect detection method based on deep learning and superpixel segmentation. This method extracts a defect target detection bounding box, uses a superpixel segmentation method to perform pixel-level segmentation on the composite material ultrasonic inspection image, and obtains a number of superpixel segmentation sub-regions. The part of the superpixel segmentation sub-region containing the defect located inside the defect target detection bounding box is retained and merged as the final defect area, and finally the minimum circumscribed rectangle of the final defect area is fitted as the final defect detection result.
[0004] During quality inspection, a special type of crack may exist on the surface of metal bars. It is usually small and difficult to observe with the naked eye, but it will affect the mechanical properties of the material. The superpixel segmentation method cannot accurately identify such cracks, resulting in low accuracy of the quality inspection results based on this method.
[0005] Based on this, how to accurately obtain the surface quality test results of metal bars is a technical problem that needs to be solved urgently by technical personnel in this field. Summary of the invention
[0006] In order to solve the technical problem of how to accurately obtain metal bar surface quality detection results, the present invention provides a metal bar surface quality detection method and system.
[0007] In a first aspect, the present invention provides a method for detecting the surface quality of a metal bar, which adopts the following technical solution:
[0008] A method for detecting the surface quality of a metal bar comprises the following steps:
[0009] The grayscale image of the metal bar area is divided into multiple initial image blocks; the initial requirement factor of the initial image block for the overlap rate is obtained by the grayscale change degree in the initial image block and the angle between the gradient direction and the horizontal direction corresponding to the gradient change pixel point; the overlapping block of the initial image block is obtained by presetting the overlapping rate, the overlapping block and the next overlapping block are taken as an overlapping block group, and the requirement factor of the overlapping block group for the overlap rate is calculated:
[0010] ;
[0011] In the formula, Indicates The overlapping block group's demand factor for the overlapping rate, , Respectively represent The initial demand factor of one overlapping block and another overlapping block in the overlapping block group, , Respectively represent The number of pixels contained in the maximum peak and the minimum peak in the grayscale histogram of the overlapping area in the overlapping block group, , Respectively represent The number of pixels contained in the maximum peak and minimum peak in the grayscale histogram of the overlapping block groups, Indicates The initial requirement factor for the overlap ratio of the overlapping areas in the overlapping block groups, represents the hyperparameter, represents the linear normalization function, represents an exponential function with e as the base; the overlap rate requirement factor of the overlapping block group and the preset threshold The overlap rate is adjusted based on the comparison result to assist in obtaining the quality inspection result of the metal bar surface.
[0012] The present invention realizes the quality detection of the surface of metal bars through an adaptive threshold segmentation algorithm based on image segmentation. In this process, the present invention takes into account that the fixed overlap rate in the algorithm will lead to low accuracy of the detection result or algorithm redundancy. Therefore, the initial requirement factor of the image block for the overlap rate is accurately obtained by analyzing the intensity of the grayscale change and the consistency of the gradient change in the image block, which effectively improves the accuracy of the surface quality detection of the metal bar; on this basis, the present invention further obtains the requirement factor of the overlapping block group for the overlap rate through the grayscale histogram in the overlapping block group, and realizes the precise adjustment of the overlap rate according to the grayscale characteristics of the overlapping blocks, thereby improving the accuracy of microcrack detection, and further effectively improving the accuracy of the surface quality detection of the metal bar.
[0013] According to a metal bar surface quality detection method provided by the present invention, the grayscale image of the metal bar area is divided into multiple initial image blocks, which also includes: collecting the metal bar image by vertical photography of a high-definition industrial camera, and obtaining the metal bar grayscale image by grayscale processing the metal bar image; extracting the metal bar area grayscale image from the metal bar grayscale image by using an FCN semantic segmentation model; and dividing the metal bar area grayscale image into multiple initial image blocks by presetting the size of the initial image block.
[0014] The present invention takes into account that the background image in the grayscale image of the metal bar will affect the accuracy of the metal bar surface quality detection result. Therefore, the grayscale image of the key metal bar area is extracted through the semantic segmentation model, which effectively improves the accuracy of the metal bar surface quality detection.
[0015] According to a metal bar surface quality detection method provided by the present invention, the initial requirement factor of the initial image block for the overlap rate satisfies the relationship:
[0016] ;
[0017] In the formula, Indicates The initial requirement factor for the overlap ratio of the initial image blocks, Indicates The number of grayscale value types in the initial image block, Indicates The number of pixels in the initial image block, , Respectively represent The maximum grayscale value and the minimum grayscale value in the initial image blocks, represents the hyperparameter, Indicates The variance of the sine value of the angle between the gradient direction and the horizontal direction corresponding to the gradient change pixel in the initial image block.
[0018] The present invention provides an accurate method for calculating the initial requirement factor of the overlap rate of the initial image block. Through the intensity and consistency of the grayscale changes in the initial image block, the possibility of the existence of cracks in the initial image block can be accurately obtained, and the initial requirement factor of the overlap rate of the initial image block can be accurately obtained.
[0019] According to a metal bar surface quality detection method provided by the present invention, the overlap rate requirement factor of the overlapping block group and the preset threshold value The overlap ratio is adjusted based on the comparison results, including: , will The overlap rate of the overlapping block groups is increased by 5% as the new overlap rate, and the calculation , until and / or the overlap ratio is equal to 50%, the adjusted overlap ratio is recorded as the target overlap ratio of the overlapping block group; if , will The overlapping rate of overlapping block groups is taken as the target overlapping rate; if , will The overlap ratio of the overlapping block groups is reduced by 5% as the new overlap ratio, and the calculation , until And / or the overlap rate is equal to 0%, and the adjusted overlap rate is recorded as the target overlap rate of the overlapping block group.
[0020] According to a metal bar surface quality detection method provided by the present invention, the overlap rate requirement factor of the overlapping block group and the preset threshold value The overlap rate is adjusted based on the comparison result to assist in obtaining the quality inspection result of the metal bar surface, including: completing block overlap of the grayscale image of the metal bar area through the target overlap rate of each overlapping block group to obtain multiple target image blocks; using the grayscale mean value of the pixel points in the target image block as the segmentation threshold of the target image block, binarizing the pixel points in the target image block to obtain the quality inspection result of the metal bar surface.
[0021] The present invention can accurately segment the normal area and the crack area in the target image block through binarization processing, thereby accurately obtaining the quality detection result of the metal bar surface.
[0022] According to a metal bar surface quality detection method provided by the present invention, the gradient direction corresponding to the gradient change pixel point is obtained by a Sobel operator.
[0023] According to a metal bar surface quality detection method provided by the present invention, the quality detection result of the metal bar surface is obtained, and then the following steps are further included: marking the crack image in the grayscale image of the metal bar area and issuing crack prompt information externally.
[0024] The present invention takes into account that the grayscale image information in the metal bar area is relatively large, which is not conducive to the staff to obtain cracks in time. Therefore, by marking the crack image and sending out crack prompt information, the staff can be prompted to accurately obtain the crack image location and make relevant processing in time.
[0025] In a second aspect, the present invention provides a metal bar surface quality detection system, which adopts the following technical solution:
[0026] A metal bar surface quality detection system comprises: a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the above-mentioned metal bar surface quality detection method is implemented.
[0027] By adopting the above technical solution, the above-mentioned metal bar surface quality detection method is generated into a computer program and stored in a memory so as to be loaded and executed by a processor, thereby making a terminal device based on the memory and the processor for easy use.
[0028] The present invention has the following technical effects:
[0029] Based on the above technical scheme, when the present invention realizes the quality inspection of the metal bar surface through the adaptive threshold segmentation algorithm based on image segmentation, it is considered that the fixed overlap rate in the algorithm will lead to low accuracy of the detection result or algorithm redundancy. Therefore, the initial requirement factor of the image block for the overlap rate is accurately obtained by analyzing the intensity of the grayscale change and the consistency of the gradient change in the image block, thereby effectively improving the accuracy of the metal bar surface quality inspection; on this basis, the present invention further obtains the requirement factor of the overlapping block group for the overlap rate through the grayscale histogram in the overlapping block group, thereby improving the accuracy of microcrack detection, thereby effectively improving the accuracy of the metal bar surface quality inspection. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] By reading the detailed description below with reference to the accompanying drawings, the above and other purposes, features and advantages of the exemplary embodiments of the present invention will become readily understood. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-restrictive manner, and the same or corresponding reference numerals represent the same or corresponding parts.
[0031] Figure 1 A schematic flow chart of a method for detecting surface quality of a metal bar provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0032] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0033] It should be understood that when the terms "first", "second", etc. are used in the claims, descriptions, and drawings of the present invention, they are only used to distinguish different objects, rather than to describe a specific order. The terms "include" and "comprise" used in the description and claims of the present invention indicate the presence of the described features, wholes, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or their collections.
[0034] It should be noted that when quality testing metal bars, there may be a special type of crack on the surface of the metal bar, which is usually small and difficult to observe with the naked eye, but will affect the mechanical properties of the material. Conventional image segmentation methods cannot accurately identify such cracks, resulting in low accuracy of quality inspection results based on this.
[0035] Based on this, the embodiment of the present invention discloses a metal bar surface quality detection method, which detects crack defects on the surface of the metal bar through an adaptive threshold segmentation algorithm based on image segmentation, so as to obtain the quality detection result of the metal bar containing cracks. Figure 1 As shown, Figure 1 A schematic flow chart of a metal bar surface quality detection method provided in an embodiment of the present invention comprises the following steps S1 to S4.
[0036] S1: Divide the grayscale image of the metal bar area into multiple initial image blocks.
[0037] Among them, the grayscale image of the metal bar area can be equally divided into multiple initial image blocks according to the size of the preset initial image block; the size of the initial image block can be preset to 20×20, and can be set according to actual needs. The embodiment of the present invention does not impose too many restrictions on this.
[0038] By way of example, in an embodiment of the present invention, the grayscale image of the metal bar area is divided into multiple initial image blocks, which also includes: acquiring the metal bar image by vertical photography with a high-definition industrial camera, and obtaining the metal bar grayscale image by grayscale processing the metal bar image; extracting the metal bar area grayscale image from the metal bar grayscale image using the FCN semantic segmentation model; and dividing the metal bar area grayscale image into multiple initial image blocks by presetting the size of the initial image block.
[0039] Among them, the specific steps of obtaining a metal bar grayscale image by grayscale processing the metal bar image, and extracting a metal bar area grayscale image from the metal bar grayscale image using a semantic segmentation full convolutional network (FCN) can be achieved through existing technologies, and the embodiments of the present invention are not described in detail here.
[0040] In this way, the embodiment of the present invention can ensure the geometric accuracy and measurement accuracy of the metal bar image by vertically photographing the metal bar image with a high-definition industrial camera, so that the metal material presents a real shape and size, which is convenient for the subsequent processing of the metal bar surface image. The metal bar area grayscale image is extracted from the metal bar grayscale image through the FCN semantic segmentation model to avoid the interference of the background image in the metal bar grayscale image on the detection result, thereby effectively improving the accuracy of the quality detection result.
[0041] It should be noted that after the grayscale image of the metal bar area is divided into multiple initial image blocks based on the above steps, the adaptive threshold segmentation algorithm based on image segmentation will use a fixed overlap rate between image blocks to overlap the image blocks to ensure the integrity and continuity of crack detection. However, the fixed overlap rate will affect the effect of image overlap. If the overlap rate is set too high for some image blocks, algorithm redundancy may occur; if the overlap rate is too low, it will be difficult to detect microcracks, thereby affecting the accuracy of quality detection.
[0042] Based on this, the embodiment of the present invention obtains the initial requirement factor of the overlap rate of the image blocks by analyzing the image features of each image block, and adjusts the overlap rate according to the initial requirement factor, so as to achieve accurate overlap of the image blocks and realize accurate detection of the quality of the metal rod material, that is, execute the following steps.
[0043] S2: Obtain the initial requirement factor of the overlap rate of the initial image block through the grayscale change degree in the initial image block and the angle between the gradient direction and the horizontal direction corresponding to the gradient change pixel point.
[0044] It should be noted that when analyzing the image features of the initial image block, the embodiment of the present invention takes into account that the extension direction of the crack defect on the surface of the metal bar in a small area is usually relatively consistent, and the presence of the crack defect will also cause the grayscale change in the small area to be more drastic than the grayscale change in the area without the crack defect, that is, the more frequent the grayscale change in the initial image block and the more consistent the gradient change direction in each initial image block, the greater the primary demand factor of the initial image block for the overlap rate. Based on this, the initial demand factor of the initial image block for the overlap rate can be obtained by obtaining the grayscale change degree in the initial image block and the gradient change corresponding to the gradient change pixel point.
[0045] For example, in an embodiment of the present invention, the gradient direction corresponding to the gradient-changing pixel point is obtained by using a Sobel operator.
[0046] The specific step of obtaining the gradient direction corresponding to the gradient-changed pixel point by using a Sobel operator (Sobel operator for short) can be implemented by the prior art, and will not be elaborated in detail in the embodiment of the present invention.
[0047] It can be understood that the gradient change pixel point is the pixel point with gradient change in the initial image block.
[0048] For example, in the embodiment of the present invention, the initial requirement factor of the initial image block for the overlap rate is determined by the grayscale change degree in the initial image block and the gradient change corresponding to the gradient change pixel point. For details, see the following relationship:
[0049] ;
[0050] In the formula, Indicates The initial requirement factor for the overlap ratio of the initial image blocks, Indicates The number of grayscale value types in the initial image block, Indicates The number of pixels in the initial image block, , Respectively represent The maximum grayscale value and the minimum grayscale value in the initial image blocks, represents the hyperparameter, Indicates The variance of the sine value of the angle between the gradient direction and the horizontal direction corresponding to the gradient change pixel in the initial image block, Represents an exponential function with base e.
[0051] In the above formula, the existence of the hyperparameter is to prevent the formula from being meaningless. The value of the hyperparameter can be set to 0.01, and can be set specifically according to actual needs. The embodiment of the present invention does not impose too many restrictions on this.
[0052] Indicates The ratio of the number of grayscale value types in the initial image block to the total number of pixels. The larger the ratio, the The more frequent the grayscale changes in an initial image block, the greater the possibility of the existence of a crack defect. In order to ensure the integrity and continuity of the crack area detection, the greater the initial requirement factor for the overlap rate.
[0053] Indicates The grayscale values of all pixels in the initial image block are extremely different. The larger the value, the The higher the credibility of the frequent changes in the image grayscale in the initial image block, the larger the corresponding initial demand factor.
[0054] The smaller the The higher the consistency of the gradient change pixels in the initial image block, the The higher the possibility that an initial image block has cracks, the greater the initial requirement factor for the overlap rate is in order to ensure the integrity and continuity of the crack area detection.
[0055] Based on the above steps, the image features in the initial image blocks are analyzed to obtain the initial demand factors of each initial image block in the grayscale image of the metal bar area.
[0056] It should be further explained that the cracks on the surface of metal bars are special crack defects. Microcracks may exist at the ends and branches of the cracks. Although the microcracks are small, they are located in areas of stress concentration, which will significantly reduce the strength and toughness of the material, thereby causing the material to break. If the overlap rate is adjusted directly based on the initial demand factor of the initial image block obtained in the above steps, such microcracks may not be accurately detected. Based on this, in order to more accurately obtain the quality inspection results of the metal bar surface, it is necessary to further analyze the overlapping blocks formed after the initial image blocks overlap, and accurately obtain the demand factor through the grayscale expression of the pixels in the overlapping blocks to detect microcracks, that is, continue to perform the following steps.
[0057] S3: Obtain an overlapping block of the initial image block by presetting an overlapping rate, regard the overlapping block and the next overlapping block as an overlapping block group, and calculate a requirement factor of the overlapping rate of the overlapping block group.
[0058] For example, the overlap rate may be preset to 20%; the overlap rate may be specifically set according to actual needs, and the embodiment of the present invention does not impose too many limitations thereon.
[0059] The specific step of obtaining the overlapping blocks of the initial image blocks through the overlapping ratio can be implemented by the prior art, and will not be described in detail in the embodiment of the present invention.
[0060] It should be noted that in order to further improve the accuracy of surface quality detection of metal bars, the embodiment of the present invention obtains overlapping blocks by overlapping the initial image blocks based on the overlap rate, and then accurately obtains the requirement factor of the overlapping block group for the overlap rate by analyzing the grayscale histogram in the overlapping blocks and the initial requirement factor between adjacent overlapping blocks.
[0061] Take the overlapping block group as an example: there are three overlapping blocks of the initial image blocks, wherein the first overlapping block and the second overlapping block form the first overlapping block group; and the second overlapping block and the third overlapping block form the second overlapping block group.
[0062] It can be understood that the overlapping block at the third edge in the above example does not have a corresponding next overlapping block. For such overlapping blocks, an edge detection algorithm can be used to fill in and process the edge overlapping blocks to ensure the retention and accuracy of edge information. The specific steps of the edge detection algorithm filling process can be implemented through existing technologies and will not be described in detail in the embodiments of the present invention.
[0063] After each overlapping block group is obtained based on the above steps, the requirement factor of the overlapping block group for the overlap rate can be obtained based on the grayscale histogram in the overlapping block group and the initial requirement factor of the overlapping block group.
[0064] For example, in the embodiment of the present invention, the requirement factor of the overlapping block group for the overlapping rate is determined, and the specific details can be referred to the following relational expression:
[0065] ;
[0066] In the formula, Indicates The overlapping block group's demand factor for the overlapping rate, , Respectively represent The initial demand factor of one overlapping block and another overlapping block in the overlapping block group, , Respectively represent The number of pixels contained in the maximum peak and the minimum peak in the grayscale histogram of the overlapping area in the overlapping block group, , Respectively represent The number of pixels contained in the maximum peak and minimum peak in the grayscale histogram of the overlapping block groups, Indicates The initial requirement factor for the overlap ratio of the overlapping areas in the overlapping block groups, represents the hyperparameter, represents the linear normalization function, Represents an exponential function with base e.
[0067] It can be understood that the maximum peak and the minimum peak in the grayscale histogram are the larger peak and the smaller peak in the grayscale histogram bimodal respectively. The calculation method of the initial requirement factor of the overlap rate of the overlapping block and the overlapping area in the overlapping block group is similar to the calculation method of the initial requirement factor of the overlap rate of the initial image block, which will not be repeated here.
[0068] In the above formula, Indicates The sum of the initial demand factors of one overlapping block and another overlapping block in the overlapping block group. The larger the value, the higher the initial demand factor. The greater the possibility of crack defects in an overlapping block group, the greater the demand factor for the overlap rate.
[0069] Indicates There is a possibility that there are microcracks or crack branches and ends in the overlapping block groups, among which, Indicates The number of pixels contained in the maximum peak and minimum peak in the grayscale histogram of the overlapping area of the overlapping block group is the same as that of the first The difference in the number of pixels contained in the maximum peak and the minimum peak in the grayscale histogram of the overlapping block groups is smaller, which means that the grayscale characteristics of the overlapping area are more similar to the grayscale characteristics of the overlapping block group, that is, the more consistent the structure of the overlapping area is with other areas in the overlapping block group, the greater the possibility of the existence of microcracks or crack branches and ends in the overlapping block group, and the corresponding demand factor for the overlap rate is also greater. The smaller the The less obvious the grayscale features of the overlapping areas of the overlapping block groups are, the greater the possibility that microcracks or crack branches and ends exist in the corresponding overlapping block groups, and the greater the demand factor for the overlap rate is.
[0070] Based on the above steps, by accurately analyzing the cracks and microcracks in the metal bar surface image, the demand factor of each overlapping block group for the overlap rate can be accurately obtained, thereby achieving accurate adjustment of the overlap rate, that is, continuing to perform the following steps.
[0071] S4: adjusting the overlap rate by comparing the overlap rate requirement factor of the overlap block group with a preset threshold value to assist in obtaining the quality inspection result of the metal bar surface.
[0072] The preset threshold It can be 0.6; the threshold can be set according to actual needs, and the embodiment of the present invention does not impose too many restrictions here.
[0073] It should be noted that, based on the above steps, the requirement factor of each overlapping block group for the overlapping rate can be obtained, and based on the comparison result of the requirement factor of the overlapping block group for the overlapping rate with the preset threshold, the overlapping rate can be accurately adjusted.
[0074] For example, in the embodiment of the present invention, the overlap rate requirement factor of the overlapping block group is compared with the preset threshold value. The overlap ratio is adjusted based on the comparison results, including the following possible situations:
[0075] In one possible scenario, In this case, The overlap rate of the overlapping block groups is increased by 5% as the new overlap rate, and the calculation , until And / or the overlap ratio is equal to 50%, and the adjusted overlap ratio is recorded as the target overlap ratio of the overlapping block group.
[0076] In another possible scenario, In this case, The overlap rate of the overlapping block groups is taken as the target overlap rate.
[0077] In another possible scenario, In this case, The overlap ratio of the overlapping block groups is reduced by 5% as the new overlap ratio, and the calculation , until And / or the overlap ratio is equal to 0%, and the adjusted overlap ratio is recorded as the target overlap ratio of the overlapping block group.
[0078] After adjusting the overlap rate based on the above method to obtain the target overlap rate of each overlapping block group, the grayscale image of the metal bar area can be re-blocked and overlapped based on the target overlap rate, so that the quality inspection result of the metal bar surface can be accurately obtained based on the accurate block overlap result.
[0079] It should be further explained that there is a difference in the grayscale between the crack image and the normal image. Due to the physical damage, the crack area appears as an area with lower grayscale value on the image, while the normal area appears as an area with higher grayscale value. Therefore, the target image block obtained by re-segmentation through binarization processing can accurately distinguish the crack image from the normal image.
[0080] For example, in the embodiment of the present invention, the overlap rate requirement factor of the overlapping block group is compared with the preset threshold value. The overlap rate is adjusted based on the comparison result to assist in obtaining the quality inspection result of the metal bar surface, including: completing the block overlap of the grayscale image of the metal bar area through the target overlap rate of each overlapping block group to obtain multiple target image blocks; using the grayscale mean of the pixels in the target image block as the segmentation threshold of the target image block, binarizing the pixels in the target image block to obtain the quality inspection result of the metal bar surface.
[0081] Take an example to illustrate that the target overlap rate of each overlapping block group is used to complete the block overlap of the grayscale image of the metal bar area to obtain the target image block: if the target overlap rate of an overlapping block group is 30%, that is, one overlapping block in the overlapping block group has a 30% common area with another overlapping block, and the overlapping direction is horizontal, that is, the overlapping area (common area) occupies 30% of the right side of one overlapping block and 30% of the left side of another overlapping block. Similarly, another overlapping block in the first overlapping block group is also an overlapping block in the second overlapping block group, and the overlap is completed in the above manner until the overlap of all overlapping block groups is completed.
[0082] Among them, the specific steps of completing block overlap of the grayscale image of the metal bar area through the target overlap rate of each overlapping block group to obtain multiple target image blocks can be achieved by existing technologies, and the embodiments of the present invention are not described in detail here.
[0083] It is understandable that when the grayscale image of the metal bar area is divided and overlapped by the target overlap rate of each overlapping block group, since the values of the target overlap rates of each overlapping block group are not exactly the same, some pixels may not have corresponding target image blocks when they are re-divided and overlapped.
[0084] Based on this, in order to accurately obtain the quality inspection results of the metal bar surface, the remaining pixels can also be processed based on the above steps until the segmentation of all pixels is completed, and finally multiple target image blocks are obtained and binarized.
[0085] Specifically, when the pixel points in the target image block are binarized to obtain the quality inspection result of the metal bar surface, the pixel points in the target image block that are greater than the segmentation threshold can be marked as 0 and recorded as the normal area; the pixel points in the target image block that are not greater than the segmentation threshold can be marked as 1 and recorded as the crack area.
[0086] Based on the above steps, a crack image in the metal bar surface image can be obtained. On this basis, in order to facilitate observation by the staff, the embodiment of the present invention can also mark the crack image.
[0087] For example, in an embodiment of the present invention, a quality inspection result of the metal bar surface is obtained, and then the method further includes: marking a crack image in a grayscale image of the metal bar region and sending out crack prompt information.
[0088] The prompt information may include the position of the crack image and the total number of pixels, etc., which may be set according to actual needs, and the embodiment of the present invention does not impose too many restrictions on this.
[0089] In this way, the embodiment of the present invention can prompt the staff to make relevant processing in time by marking the crack image and sending out the crack prompt information.
[0090] It can be seen that in the embodiment of the present invention, when determining the quality inspection result of the metal bar surface, the grayscale image of the metal bar area can be divided into a plurality of initial image blocks; the initial demand factor of the initial image block for the overlap rate is obtained by the grayscale change degree in the initial image block and the angle between the gradient direction corresponding to the gradient change pixel point and the horizontal direction; the overlapping block of the initial image block is obtained by the preset overlap rate, the overlapping block and the next overlapping block are taken as an overlapping block group, and the demand factor of the overlapping block group for the overlap rate is calculated; the demand factor of the overlapping block group for the overlap rate is compared with the preset threshold value The overlap ratio is adjusted based on the comparison results to assist in obtaining the quality inspection results of the metal bar surface.
[0091] In this way, the embodiment of the present invention realizes the quality detection of the metal bar surface through an adaptive threshold segmentation algorithm based on image segmentation. In this process, the embodiment of the present invention takes into account that the fixed overlap rate in the algorithm will lead to low accuracy of the detection result or algorithm redundancy. Therefore, the initial requirement factor of the image block for the overlap rate is accurately obtained by analyzing the intensity of the grayscale change and the consistency of the gradient change in the image block, thereby effectively improving the accuracy of the metal bar surface quality detection; on this basis, the embodiment of the present invention further obtains the requirement factor of the overlapping block group for the overlap rate through the grayscale histogram in the overlapping block group, and realizes the precise adjustment of the overlap rate according to the grayscale characteristics of the overlapping blocks, thereby improving the accuracy of microcrack detection, and further effectively improving the accuracy of the metal bar surface quality detection.
[0092] An embodiment of the present invention further discloses a metal bar surface quality detection system, comprising a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, a metal bar surface quality detection method provided by the present invention is implemented.
[0093] The above system also includes other components well known to those skilled in the art, such as a communication bus and a communication interface, and their configuration and functions are known in the art, so they will not be described in detail here.
[0094] In the present invention, the aforementioned memory may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, apparatus, or device. For example, a computer-readable storage medium may be any suitable magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory RRAM, a dynamic random access memory DRAM, a static random access memory SRAM, an enhanced dynamic random access memory EDRAM, a high bandwidth memory HBM, a hybrid memory cube HMC, etc., or any other medium that can be used to store the required information and can be accessed by an application, a module, or both. Any such computer storage medium may be part of a device or accessible or connectable to a device.
[0095] Although this specification has shown and described a number of embodiments of the present invention, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Those skilled in the art will conceive of many modifications, changes and alternatives without departing from the ideas and spirit of the present invention. It should be understood that in the practice of the present invention, various alternatives to the embodiments of the present invention described herein may be employed.
[0096] The above are all preferred embodiments of the present invention, and are not intended to limit the protection scope of the present invention. Therefore, any equivalent changes made based on the structure, shape, and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for detecting the surface quality of a metal bar, characterized in that: include: Divide the grayscale image of the metal bar region into a plurality of initial image blocks; The initial demand factor of the initial image block is obtained by the grayscale change degree in the initial image block and the angle between the gradient direction and the horizontal direction corresponding to the gradient change pixel point, and the gradient change pixel point is the pixel point with gradient change in the initial image block; The overlapping block of the initial image block is obtained by presetting the overlapping rate, and the overlapping block and the next overlapping block are taken as an overlapping block group, and the overlapping rate requirement factor of the overlapping block group is calculated: ; In the formula, Indicates The demand factor of overlapping block groups for the overlapping rate, , Respectively represent The initial demand factor of one overlapping block and another overlapping block in the overlapping block group, , Respectively represent The number of pixels contained in the maximum peak and the minimum peak in the grayscale histogram of the overlapping area in the overlapping block group, , Respectively represent The number of pixels contained in the maximum peak and minimum peak in the grayscale histogram of the overlapping block groups, Indicates The initial demand factor for the overlapping areas in the overlapping block groups, represents the hyperparameter, represents the linear normalization function, represents an exponential function with e as the base; the overlap rate requirement factor of the overlapping block group and the preset threshold The overlap rate is adjusted based on the comparison result to assist in obtaining the quality inspection result of the metal bar surface.
2. A metal bar surface quality detection method according to claim 1, characterized in that: The step of dividing the grayscale image of the metal bar region into a plurality of initial image blocks also includes: Collecting a metal bar image by vertical photography with a high-definition industrial camera, and obtaining a metal bar grayscale image by gray-scaling the metal bar image; The FCN semantic segmentation model is used to extract the grayscale image of the metal bar area from the grayscale image of the metal bar; the grayscale image of the metal bar area is divided into multiple initial image blocks by presetting the size of the initial image block.
3. A metal bar surface quality detection method according to claim 1, characterized in that: The initial demand factor of the initial image block satisfies the relationship: ; In the formula, Indicates The initial demand factor of the initial image blocks, Indicates The number of grayscale value types in the initial image block, Indicates The number of pixels in the initial image block, , Respectively represent The maximum grayscale value and the minimum grayscale value in the initial image blocks, represents the hyperparameter, Indicates The variance of the sine value of the angle between the gradient direction and the horizontal direction corresponding to the gradient change pixel in the initial image block.
4. A metal bar surface quality detection method according to claim 1, characterized in that: The overlap rate requirement factor of the overlapping block group and the preset threshold The overlap ratio is adjusted based on the comparison results, including: like , will The overlap rate of the overlapping block groups is increased by 5% as the new overlap rate, and the calculation , until Or the overlap ratio is equal to 50%, and the adjusted overlap ratio is recorded as the target overlap ratio of the overlapping block group; like , will The overlapping rate of the overlapping block groups is taken as the target overlapping rate; like , will The overlap ratio of the overlapping block groups is reduced by 5% as the new overlap ratio, and the calculation , until Or the overlap rate is equal to 0%, and the adjusted overlap rate is recorded as the target overlap rate of the overlapping block group.
5. A metal bar surface quality detection method according to claim 4, characterized in that: The overlap rate requirement factor of the overlapping block group and the preset threshold The overlap ratio is adjusted based on the comparison results to assist in obtaining the quality inspection results of the metal bar surface, including: The grayscale image of the metal bar area is overlapped by blocks according to the target overlap rate of each overlapping block group to obtain a plurality of target image blocks; The grayscale mean value of the pixels in the target image block is used as the segmentation threshold of the target image block, and the pixels in the target image block are binarized to obtain the quality detection result of the metal bar surface.
6. A metal bar surface quality detection method according to claim 1, characterized in that: The gradient direction corresponding to the gradient change pixel point is obtained by using the Sobel operator.
7. A metal bar surface quality detection method according to claim 1, characterized in that: The method further comprises: obtaining the quality inspection result of the metal bar surface; The crack image in the grayscale image of the metal bar area is marked and crack prompt information is sent out.
8. A metal bar surface quality detection system, characterized in that: include: A processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, a metal bar surface quality detection method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Composite ultrasonic image defect detection method based on deep learning and superpixel segmentation
CN113298809A
Steel plate outer surface defect online detection method based on machine vision
CN113155839A
Sewing machine surface paint spraying abnormity detection method and system
CN114998215A