CN117474897B - Visual detection method for surface defects of charger - Google Patents

Visual detection method for surface defects of charger Download PDF

Info

Publication number
CN117474897B
CN117474897B CN202311552647.0A CN202311552647A CN117474897B CN 117474897 B CN117474897 B CN 117474897B CN 202311552647 A CN202311552647 A CN 202311552647A CN 117474897 B CN117474897 B CN 117474897B
Authority
CN
China
Prior art keywords
pixel block
pixel
combination
point
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.)
Active
Application number
CN202311552647.0A
Other languages
Chinese (zh)
Other versions
CN117474897A (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.)
Dongguan Jianglin Hardware Industry Co ltd
Original Assignee
Dongguan Jianglin Hardware Industry 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 Dongguan Jianglin Hardware Industry Co ltd filed Critical Dongguan Jianglin Hardware Industry Co ltd
Priority to CN202311552647.0A priority Critical patent/CN117474897B/en
Publication of CN117474897A publication Critical patent/CN117474897A/en
Application granted granted Critical
Publication of CN117474897B publication Critical patent/CN117474897B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • 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/11Region-based segmentation
    • 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/10Segmentation; Edge detection
    • G06T7/187Segmentation; Edge detection involving region growing; involving region merging; involving connected component labelling
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20021Dividing image into blocks, subimages or windows
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Image Analysis (AREA)

Abstract

The invention relates to the field of image defect detection, in particular to a charger surface defect visual detection method. Firstly, carrying out threshold segmentation on a gray level image on the surface of a charger, initially extracting crack segments, constructing a preset neighborhood range by taking a selected seed point as a center, and obtaining an initial pixel block of the seed point by iteratively selecting a mark point; and (3) based on the difference of the integral gray scales between the pixel blocks, iteratively combining the initial pixel blocks to the main pixel blocks, judging whether the combination is converged according to the difference of the number of pixel points in the main pixel blocks before and after each combination, if not, continuously combining the main pixel blocks, updating gray scale parameters of the main pixel blocks until the combination is converged, taking the finally combined area as a defect area, and further carrying out defect detection on the surface of the charger based on the defect area. The invention can extract more complete crack defects on the surface of the charger and improve the accuracy of detecting the defects on the surface of the charger.

Description

Visual detection method for surface defects of charger
Technical Field
The invention relates to the field of image defect detection, in particular to a charger surface defect visual detection method.
Background
The charger is used as a matching device of electronic products, and defects such as cracks and the like on the surface of the charger are inevitably generated in the production process, so that the quality of the charger is required to be detected in order to ensure that a user can safely and effectively use the charger, and the defect detection on the surface of the charger is more important.
The image segmentation technique is generally used in the related art to extract defective areas on the surface of the charger. However, in the production process, the depths of the crack defects on the surface of the charger at different positions are greatly different, so that the difference of gray values of pixel points at different positions is too large, and the direct image segmentation of the image on the surface of the charger often causes the loss of a part of defects, so that a complete crack defect area is not obtained, and the accuracy of detecting the defects on the surface of the charger is reduced.
Disclosure of Invention
In order to solve the technical problem that the complete crack defect area is often not obtained through the prior art so as to reduce the accuracy of the detection of the crack defects on the surface of the charger, the invention aims to provide a visual detection method for the surface defects of the charger, which adopts the following technical scheme:
The invention provides a visual detection method for surface defects of a charger, which comprises the following steps:
Acquiring a gray image of the surface of a charger; threshold segmentation is carried out on the gray level image to obtain crack segments on the surface of the charger;
taking a pixel point at the end point of each crack segment as a seed point in the gray image, and obtaining an initial pixel block of each seed point according to gray differences between the seed point and other pixel points in a preset neighborhood range;
Obtaining gray parameters of the corresponding initial pixel blocks according to gray values of all pixel points in each initial pixel block; randomly selecting an initial pixel block as a main pixel block, and combining the main pixel block with other initial pixel blocks according to the difference of the gray scale parameters to obtain a combined judgment pixel block; judging whether the merging is converged according to the difference of the number of pixel points in the main pixel blocks before and after each merging and the judging pixel blocks, if not, taking the judging pixel blocks as new main pixel blocks, updating the gray scale parameters of the new main pixel blocks after the merging, continuing the merging, and otherwise, stopping the merging; judging the area corresponding to the pixel blocks after stopping merging as a defect area;
And carrying out defect detection on the surface of the charger based on the defect area.
Further, the obtaining the initial pixel block of each seed point according to the gray level difference between the seed point and other pixel points in the preset neighborhood range includes:
taking any seed point as a marking point, and carrying out negative correlation normalization on the absolute value of the gray value difference value of each other pixel point in the marking point and a preset neighborhood range to obtain the pixel point similarity between the marking point and the corresponding other pixel point;
determining whether the pixel point similarity between the marking point and other pixel points in the preset neighborhood range meets a preset condition;
If the preset condition is met, taking other pixel points corresponding to the maximum value of the pixel point similarity as the next marking point, and continuously executing the selection process in the preset neighborhood range of the next marking point;
If the preset condition is not met, stopping selecting the next marking point, and taking the obtained area formed by all the marking points as an initial pixel block of the corresponding seed point;
traversing all the seed points to obtain an initial pixel block of each seed point.
Further, determining whether the pixel point similarity between the marking point and other pixel points in the preset neighborhood range meets the preset condition includes:
if the maximum value of the pixel point similarity in the preset neighborhood range is larger than a preset similarity threshold value, a preset condition is met;
If the maximum value of the pixel point similarity in the preset neighborhood range is not greater than the preset similarity threshold value, the preset condition is not met.
Further, the obtaining the gray scale parameter of the corresponding initial pixel block according to the gray scale values of all the pixel points in each initial pixel block includes:
And taking the average value of the gray values of all pixel points in each initial pixel block as the gray parameter of the corresponding initial pixel block.
Further, the merging the main pixel block and other initial pixel blocks according to the difference of the gray scale parameters, and obtaining the merged judgment pixel block includes:
Taking other initial pixel blocks which are coincident with the edge of the main pixel block as adjacent pixel blocks of the main pixel block;
Carrying out negative correlation normalization on absolute values of differences of gray parameters of the main pixel blocks and each adjacent pixel block to obtain block similarity between the main pixel blocks and the corresponding adjacent pixel blocks before each combination;
the adjacent pixel blocks with the block similarity larger than a preset merging threshold value are used as mergeable pixel blocks of a main pixel block;
And taking the whole area formed by all the combinable pixel blocks and the main pixel blocks as a judgment pixel block after each combination.
Further, the determining whether the merging converges according to the difference between the number of the pixel points in the main pixel block and the number of the pixel points in the judging pixel block before and after each merging includes:
Taking the difference value between the number of the pixel points in the judgment pixel block after each combination and the number of the pixel points in the main pixel block before the combination as the quantity change amplitude before and after each combination;
Taking the ratio of the quantity change amplitude to the quantity of pixel points in the main pixel block before combination as the quantity change rate before and after combination each time;
If the quantity change rate is larger than a preset change rate threshold, merging is not converged, otherwise merging is converged.
Further, the updating the gray scale parameters of the combined new main pixel block includes:
Taking the average value of the gray values of all pixel points in the new main pixel block after each combination as the integral gray of the new main pixel block after combination;
taking the absolute value of the difference value of the gray scale parameters of each combinable pixel block of the main pixel block before each combination of the integral gray scale as the integral gray scale difference;
taking the absolute value of the difference value between the number of the pixels in the new main pixel block after each combination and the number of the pixels in each combinable pixel block of the main pixel block before combination as the difference of the number of the pixels;
Taking the sum of the integral gray level difference and the pixel point quantity difference as the difference degree between the new combined main pixel block and the corresponding combinable pixel block before combining;
Taking the distance between the center point of the new main pixel block after each combination and the center point of each combinable pixel block of the main pixel block before combination as a distance parameter between the new main pixel block after combination and the corresponding combinable pixel block before combination;
Obtaining the variation degree before and after each combination according to the difference degree and the distance parameter between the new combined main pixel block and all the combinable pixel blocks before the combination;
And taking the product value of the change degree and the integral gray value as the gray parameter of the new main pixel block after each combination.
Further, the obtaining the degree of change before and after each merging according to the degree of difference between the new main pixel block after merging and all the combinable pixel blocks before merging and the distance parameter includes:
Taking the product value of the difference degree and the distance parameter corresponding to each new main pixel block after each combination and each combinable pixel block before combination as a change index between the new main pixel block after combination and the combinable pixel block corresponding to the new main pixel block before combination;
And normalizing the average value of the change indexes between the new main pixel block after combination and all the combinable pixel blocks before combination to obtain the change degree before and after each combination.
Further, the defect detection on the surface of the charger based on the defect area includes:
and taking the result of smoothing filter treatment of the defect area as a crack area of the surface of the charger.
Further, the threshold segmentation method is Ojin threshold segmentation.
The invention has the following beneficial effects:
according to the invention, the image is directly segmented to obtain the complete crack defect, so that the accuracy of detecting the defect on the surface of the charger is reduced, therefore, the method firstly carries out threshold segmentation on the gray level image on the surface of the charger to obtain the crack segment, thus the crack region on the surface of the charger is initially extracted, and the fact that the initially extracted crack segment is not continuous and part of crack defects are not detected due to the fact that the depths of the crack defects at different positions are greatly different is considered, so that seed points selected from the gray level image are divided into the same initial pixel block, and the subsequent merging of the initial pixel block is facilitated; and then, reflecting the gray characteristic of each initial pixel block through the acquired gray parameters, merging the main pixel block with other initial pixel blocks according to the difference of the gray parameters, thereby extracting more complete crack defects in the follow-up process, reflecting whether the merging is converged according to the difference of the number of pixel points in the main pixel blocks before and after each merging, judging whether to continue iterative merging, updating the gray parameters of the new main pixel blocks after the merging under the condition that the merging can be continued, improving the accuracy of the follow-up merging, and extracting more complete defect areas on the surface of the charger after the iterative merging is finished, thereby improving the accuracy of the surface defects of the charger.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions and advantages of the prior art, the following description will briefly explain the drawings used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are only some embodiments of the invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flowchart of a visual inspection method for surface defects of a charger according to an embodiment of the present invention;
FIG. 2 is a grayscale image of a charger surface provided in one embodiment of the invention;
fig. 3 is a binary image of a gray scale image subjected to threshold segmentation according to an embodiment of the present invention.
Detailed Description
In order to further describe the technical means and effects adopted by the invention to achieve the preset aim, the following description refers to the specific implementation, structure, characteristics and effects of a visual inspection method for surface defects of a charger according to the invention in combination with the accompanying drawings and 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 invention belongs.
The following specifically describes a specific scheme of the visual detection method for the surface defects of the charger provided by the invention with reference to the accompanying drawings.
Referring to fig. 1, a flowchart of a method for detecting surface defects of a charger according to an embodiment of the invention is shown, where the method includes:
step S1: acquiring a gray image of the surface of a charger; and carrying out threshold segmentation on the gray level image to obtain a crack segment in the gray level image.
The charger is used as matching equipment of electronic products in various aspects, defects such as cracks and the like are inevitably formed on the surface of the charger in the production process, in order to ensure that a user can safely and effectively use the charger, the defects on the surface of the charger are required to be detected, in the prior art, the cracks on the surface of an object are usually identified and extracted by utilizing image segmentation and neural network technology, but in the production process, the difference of pixel gray values at different positions of the cracks is caused by different depths of the cracks on the surface of the charger, and the complete crack defects cannot be obtained through the prior art, so that the accuracy of detecting the defects on the surface of the charger is reduced.
In the embodiment of the invention, firstly, a CCD camera is used for shooting the surface with cracks of a charger, an original image of the surface of the charger is acquired, and the acquired original image is usually a multi-channel color image, so that the calculation amount of subsequent image processing is reduced, the processing speed is improved, the acquired original image is subjected to graying processing in one embodiment of the invention and is converted into a single-channel gray image, and referring to fig. 2, fig. 2 is a gray image of the surface of the charger provided by one embodiment of the invention; in order to reduce the influence of noise on subsequent defect detection, median filtering processing is performed on the gray image to improve the effectiveness and reliability of subsequent image processing analysis, it should be noted that the graying processing and median filtering processing are all technical means well known to those skilled in the art, and are not described herein.
After denoising pretreatment is performed on a gray image on the surface of a charger, the gray image can be firstly segmented by using an Ojin threshold segmentation algorithm, so that crack defects on the surface of the charger are initially extracted, the difference of pixel gray values at different positions is overlarge due to the fact that the depths of cracks on the surface of the charger are large at the different positions, the initially extracted crack defects are further represented as a plurality of discontinuous crack segments, referring to fig. 3, fig. 3 shows a binary image of the gray image subjected to threshold segmentation provided by one embodiment of the invention, after the threshold segmentation, crack areas on the surface of the charger are not continuous but represent a plurality of segments, namely crack segments, and the cracks at the tail end parts of the cracks are not successfully detected due to the fact that the depths of the cracks at the tail end parts of the cracks in the gray image are shallow. It should be noted that, the oxford threshold segmentation algorithm is a technical means well known to those skilled in the art, and will not be described herein.
After the crack segments on the surface of the charger are initially extracted, the gray level image can be further analyzed based on the crack segments in the follow-up process, so that more complete crack defects are extracted.
Step S2: and taking the pixel point at the end point of each crack segment as a seed point in the gray level image, and obtaining an initial pixel block of each seed point according to gray level difference between the seed point and other pixel points in a preset neighborhood range.
According to the method, the device and the system, the integral crack defect on the surface of the charger cannot be obtained after the gray level image is subjected to threshold segmentation, so that the embodiment of the invention is based on the extracted crack segmentation, the pixel point position at the end point of each crack segmentation in the binary image subjected to threshold segmentation is mapped into the corresponding gray level image, the pixel point at the corresponding position in the gray level image is taken as a seed point, a preset neighborhood range is built by taking the seed point as the center, and the rest pixel points are selected iteratively based on the gray level difference between the seed point and other pixel points in the preset neighborhood range, so that the initial pixel block of each seed point is obtained, the pixel points similar to the gray level value of the seed point are divided into the same initial pixel block, the subsequent merging of the initial pixel blocks is facilitated, and the integral crack defect is extracted. In one embodiment of the present invention, the size of the preset neighborhood range is set to 3×3, and the specific value of the size of the preset neighborhood range may also be set by the practitioner according to the specific implementation scenario, which is not limited herein.
Preferably, in one embodiment of the present invention, the method for acquiring the initial pixel block of each seed point specifically includes:
Taking any seed point as a marking point, and carrying out negative correlation normalization on the absolute value of the gray value difference value of each other pixel point in the marking point and a preset neighborhood range to obtain the pixel point similarity between the marking point and the corresponding other pixel point; if the maximum value of the pixel similarity in the preset neighborhood range is larger than the preset similarity threshold, taking other pixel corresponding to the maximum value of the pixel similarity as the next marking point, and continuously executing the selection process in the preset neighborhood range of the next marking point; if the maximum value of the pixel point similarity in the preset neighborhood range is not greater than the preset similarity threshold value, stopping selecting the next marking point, and taking the obtained area formed by all the marking points as an initial pixel block of the corresponding seed point; traversing all seed points to obtain an initial pixel block of each seed point, wherein in one embodiment of the present invention, a preset similarity threshold is set to 0.65, and a specific value of the preset similarity threshold may also be set by an implementer according to a specific implementation scenario, which is not limited herein.
The selection process of the mark points is illustrated: after a certain seed point is selected as a marking point, a preset neighborhood range is built by taking the marking point as a center, the pixel point similarity between each other pixel point in the preset neighborhood range and the marking point is calculated, if the maximum value of the pixel point similarity is larger than a preset similarity threshold value, the other pixel points corresponding to the maximum value of the pixel point similarity in the preset neighborhood range are used as new marking points, then the preset neighborhood range is built by taking the new marking point as the center, the new marking point is continuously selected in the preset neighborhood range in the same way until the maximum value of the pixel point similarity in the preset neighborhood range is not larger than the preset similarity threshold value, the area formed by all the selected marking points is used as an initial pixel block of the seed point, and the initial pixel blocks of other seed points are obtained in the same way.
The expression of pixel similarity in one embodiment of the present invention may specifically be, for example:
Ct=exp(-|G-Gt|)
C t represents the similarity of the pixel points between the marking point at the center in the preset neighborhood range and the t other pixel points; g represents the gray value of a marking point at the center in a preset neighborhood range, namely the gray value of a pixel point at the center in the preset neighborhood range; g t represents the gray value of the t other pixel points except the central mark point in the preset neighborhood range; exp () represents an exponential function based on a natural constant e for normalization processing, and || represents taking an absolute value.
In the process of obtaining the pixel point similarity between the mark point and other pixel points, the pixel point similarity C t is used for reflecting the approaching degree of the gray value between a certain other pixel point and the mark point in a preset neighborhood range, and the larger the pixel point similarity C t is, the closer the gray value between the two is, so that the pixel point which is relatively close to the gray value of the corresponding seed point is selected by using the pixel point similarity; the smaller the G-G t | represents the difference of gray values between the mark point and some other pixel point, which means that the closer the gray values between the mark point and the corresponding other pixel point are, the greater the pixel point similarity C t between the mark point and the corresponding other pixel point is, in order to facilitate evaluation analysis of the degree of gray value proximity between the pixel points, in one embodiment of the present invention, the normalization process of negative correlation is performed on the G-G t | by using an exponential function based on a natural constant e, thereby limiting the pixel point similarity C t within the range of [0,1 ].
After the initial pixel block of each seed point is obtained through iterative selection of the mark points, the gray value of the pixel point in the initial pixel block is relatively close to the gray value of the corresponding seed point, so that the initial pixel block can be analyzed in the follow-up process, the complete crack defect is extracted, and the accuracy of detecting the surface defect of the charger is improved.
Step S3: obtaining gray parameters of the corresponding initial pixel blocks according to gray values of all pixel points in each initial pixel block; randomly selecting an initial pixel block as a main pixel block, and combining the main pixel block with other initial pixel blocks according to the difference of gray scale parameters to obtain a combined judgment pixel block; judging whether the merging is converged according to the difference of the number of pixel points in the main pixel blocks before and after each merging and the judging pixel blocks, if not, taking the judging pixel blocks as new main pixel blocks, updating the gray scale parameters of the new main pixel blocks after the merging, continuing the merging, and otherwise, stopping the merging; and taking the region corresponding to the judged pixel block after the merging is stopped as a defect region.
The aim of the embodiment of the invention is to extract the complete crack defect of the surface of the charger, so that the initial pixel blocks with similar gray scale characteristics are iteratively combined in the embodiment of the invention, thereby extracting more complete crack defects, firstly, the gray scale parameters of the corresponding initial pixel blocks can be obtained according to the gray scale values of all pixel points in each initial pixel block, the gray scale characteristics of different initial pixel blocks are reflected through the gray scale parameters, and the subsequent combination of the initial pixel blocks based on the gray scale parameters is facilitated.
Preferably, since the gray values of the respective pixels in each initial pixel block are relatively close, in one embodiment of the present invention, the average value of the gray values of all the pixels in each initial pixel block is used as the gray parameter of the corresponding initial pixel block, and the overall gray characteristic of each initial pixel block is reflected by the gray parameter, so that T i is represented as the gray parameter of the i-th initial pixel block in the subsequent steps for facilitating the subsequent calculation.
After the gray scale parameter of each initial pixel block is obtained, in order to facilitate iterative merging of the initial pixel blocks in the following, one initial pixel block can be selected as a main pixel block at will, in the following iterative merging process, other initial pixel blocks meeting the conditions can be continuously iteratively merged to the main pixel block based on the main pixel block, so that more complete crack defects are extracted, and therefore, other initial pixel blocks meeting the merging conditions can be merged to the main pixel block based on the difference of gray scale parameters between the main pixel block and other initial pixel blocks, and the judgment pixel block after each merging is obtained, thereby completing the iterative merging process.
Preferably, in one embodiment of the present invention, the method for acquiring the judgment pixel block after each merging specifically includes:
Because the obtained initial pixel blocks are irregular areas, and a plurality of other initial pixel blocks which are overlapped with the edges of the main pixel blocks exist around the main pixel blocks, in order to ensure that the judgment pixel blocks after each iteration combination are a continuous area, the other initial pixel blocks which are overlapped with the edges of the main pixel blocks can be used as adjacent pixel blocks of the main pixel blocks; carrying out negative correlation normalization on absolute values of differences of gray parameters of the main pixel blocks and each adjacent pixel block to obtain block similarity between the main pixel blocks and the corresponding adjacent pixel blocks before each combination; adjacent pixel blocks with the block similarity larger than a preset merging threshold value are used as mergeable pixel blocks of the main pixel blocks; and taking the whole area formed by all the combinable pixel blocks and the main pixel block as the judgment pixel block after each combination, and further expanding the area of the main pixel block. In one embodiment of the present invention, the preset merge threshold is set to 0.7, and the specific value of the preset merge threshold may also be set by an implementer according to a specific implementation scenario, which is not limited herein. The expression of the block similarity may specifically be, for example:
F(k,i)=exp(-|Tk-T(k,i)|)
Wherein F (k,i) represents a block similarity between the main pixel block and the corresponding i-th neighboring pixel block before the k-th merging; t k represents the gray scale parameter of the main pixel block before the kth merging, and the gray scale parameter of the main pixel block before the first merging is the gray scale parameter of the selected initial pixel block; t (k,i) represents the gray scale parameter of the ith adjacent pixel block of the main pixel block before the kth merging; exp () represents an exponential function based on a natural constant e for normalization processing; the absolute value is taken.
In the process of obtaining the block similarity between the main pixel block and the corresponding adjacent pixel block before each merging, the block similarity F (k,i) is used for reflecting the similarity degree of gray scale characteristics between the main pixel block and the corresponding adjacent pixel block before each merging, and the larger the block similarity F (k,i) is, the larger the similarity degree between the main pixel block and the corresponding adjacent pixel block is, the greater the possibility that the adjacent pixel block is merged into the main pixel block is, and the main pixel block and the adjacent pixel block are merged through the block similarity, so that the more complete crack defects can be extracted later; the smaller the |t k-T(k,i) | is, the smaller the difference of the gray scale characteristics between the main pixel block and the corresponding adjacent pixel block is, and further, the greater the degree of similarity between the main pixel block and the corresponding adjacent pixel block is, the greater the block similarity F (k,i) is, in order to facilitate evaluation analysis of the degree of similarity between the main pixel block and the adjacent pixel block, in one embodiment of the present invention, the negative correlation normalization process is performed on |g-G t | using an exponential function based on a natural constant e, thereby limiting the block similarity F (k,i) within the range of [0,1 ].
Because the merging process of the main pixel block and the initial pixel block is an iterative process, the method and the device need to set iteration termination conditions, and avoid overlarge extracted crack defects caused by excessive merging of the initial pixel blocks, and because the number of pixel points in the judgment pixel block obtained after each merging is increased, whether merging is achieved or not can be reflected according to the difference of the number of the pixel points in the main pixel block and the judgment pixel block before and after each merging, and whether the merging needs to be continued or not is judged.
Preferably, in one embodiment of the present invention, the method for determining whether the merging converges specifically includes:
taking the difference value between the number of the pixel points in the judgment pixel block after each combination and the number of the pixel points in the main pixel block before the combination as the quantity change amplitude before and after each combination; taking the ratio of the quantity change amplitude to the quantity of pixel points in the main pixel block before combination as the quantity change rate before and after each combination; if the number change rate is greater than the preset change rate threshold, merging is not converged, otherwise merging is converged, and in one embodiment of the present invention, the preset change rate threshold is set to 0.1, and the specific value of the preset change rate threshold may also be set by an implementer according to a specific implementation scenario, which is not limited herein. The expression of the rate of change of the number may specifically be, for example:
Wherein U k represents the number change rate before and after the kth merging; s k represents the number of pixel points in the k-th combined judgment pixel block; s k denotes the number of pixels in the main pixel block before the kth merge.
In the process of acquiring the quantity change rate before and after each merging, the quantity change rate U k is used for judging whether the iterative merging reaches convergence or not, if the quantity change rate U k is larger than a preset change rate threshold value, the iterative merging needs to be continued, otherwise, the iterative merging needs to be stopped; in the iterative merging process of the main pixel block, the number of the pixels in the main pixel block after each merging is increased, the change of the number of the pixels in the main pixel block in the initial merging stage is relatively large, and the change of the number of the pixels in the judging pixel block after merging is gradually reduced along with the merging, so that the increasing degree of the number of the pixels before and after each merging is reflected through the number change amplitude S k-Sk, the number change amplitude is compared with the number S k of the pixels in the main pixel block before the merging at this time, and the number change rate U k of the number of the pixels in the main pixel block before and after the merging at this time is obtained to judge whether the iterative merging is converged or not.
When the combination of the main pixel blocks does not reach convergence, the main pixel blocks need to be continuously combined, so that if the combination does not reach convergence, the judging pixel block is used as a new main pixel block, and in order to combine the initial pixel blocks belonging to the crack defect area into the main pixel block as much as possible, so as to extract more complete crack defects, the gray scale parameters of the combined new main pixel block need to be updated, so that the final combination effect is improved.
Preferably, in one embodiment of the present invention, the method for updating the gray scale parameters of the combined new main pixel block specifically includes:
Taking the average value of the gray values of all pixel points in the new main pixel block after each combination as the integral gray of the new main pixel block after combination; taking the absolute value of the difference value between the integral gray scale and the gray scale parameter of each combinable pixel block of the main pixel block before each combination as the integral gray scale difference; taking the absolute value of the difference value between the number of the pixels in the new main pixel block after each combination and the number of the pixels in each combinable pixel block of the main pixel block before combination as the difference of the number of the pixels; taking the sum of the integral gray level difference and the pixel point quantity difference as the difference degree between the new main pixel block after combination and the corresponding combinable pixel block before combination; taking the distance between the center point of the new main pixel block after each combination and the center point of each combinable pixel block of the main pixel block before combination as a distance parameter between the new main pixel block after combination and the corresponding combinable pixel block before combination; taking the product value of the difference degree and the distance parameter corresponding to each combinable pixel block after the combination of the new main pixel block and each combinable pixel block before the combination as a change index between the new main pixel block after the combination and the combinable pixel block corresponding to the combination; normalizing the average value of the change indexes between the new combined main pixel block and all the combinable pixel blocks before combining to obtain the change degree before and after combining; taking the product value of the variation degree and the integral gray value as the gray parameter of the new main pixel block after each combination, it should be noted that the center points of the main pixel block and the combinable pixel block can be obtained through connected domain analysis, and the connected domain analysis is a technical means well known to those skilled in the art, and will not be described herein. The expression of the gray scale parameter of the new main pixel block after merging may specifically be, for example:
Wherein T k represents the gray scale parameter of the new main pixel block after the kth merging; Representing the average value of the gray values of the pixel points in the new main pixel block after the k-th merging, namely the integral gray of the new main pixel block after the k-th merging; m k represents the degree of variation before and after the kth merge; n k represents the number of combinable pixel blocks corresponding to the main pixel block before the kth combination; q (k,j) represents the degree of difference between the new main pixel block after the kth merging and the jth combinable pixel block corresponding to the main pixel block before the kth merging; d (k,j) represents the distance between the center point of the new main pixel block after the kth merging and the center point of the jth combinable pixel block corresponding to the main pixel block before the kth merging, namely a distance parameter; t (k,j) represents the gray scale parameter of the j-th combinable pixel block corresponding to the main pixel block before the k-th combination; s k represents the number of pixel points in the new main pixel block after the kth merging; s (k,j) represents the number of pixel points in the j-th combinable pixel block corresponding to the main pixel block before the k-th combination; norm [ ] represents the normalization function.
It should be noted that, since the merging is an iterative process, the gray parameter T k of the new main pixel block after the kth merging is equal to the gray parameter T k+1 of the main pixel block before the kth+1th merging, that is, T k =Tk+1.
In the process of acquiring gray parameters of a new main pixel block after each combination, the embodiment of the invention obtains the variation degree M k before and after each combination by analyzing the difference of gray features, the difference of the number of pixel points and the distance between the new main pixel block after combination and the corresponding combinable pixel block before combination and utilizes the variation degree M k to obtain the integral gray of the new main pixel block after the combinationCorrecting to obtain a gray parameter T k of the new main pixel block after the combination; /(I)For the integral gray scale difference between the new main pixel block after combination and the corresponding combinable pixel block before combination, the larger the integral gray scale difference is, the larger the difference of integral gray scale characteristics of the two is, the larger the difference degree Q (k,j) is, the larger the difference degree S k-S(k,j) is the difference of the number of pixel points between the new main pixel block after combination and the corresponding combinable pixel block before combination, and the larger the difference of the number of pixel points is, the larger the difference degree Q (k,j) is; meanwhile, taking the distance parameter d (k,j) between the center point of the new main pixel block after combination and the center point of the corresponding combinable pixel block before combination into consideration, taking the product value of the difference degree Q (k,j) and the distance parameter d (k,j) as a change index Q (k,j)×d(k,j), integrating the change indexes between the new main pixel block after combination and all the combinable pixel blocks before combination, normalizing the average value to obtain the change degree M k before and after combination, limiting the change degree M k in the range of [0,1], and facilitating the use of the change degree M k pair/>And performing weight correction.
And iteratively merging the main pixel blocks through the process, so that the area range of the main pixel blocks is continuously enlarged, and stopping the merging process when the merging reaches convergence, and stopping the area corresponding to the merged judgment pixel blocks as a defect area.
Step S4: and performing defect detection on the surface of the charger based on the defect area.
The defect area extracted by the iterative merging process of the main pixel block is the crack defect area of the surface of the charger, so that the problem that the complete crack area cannot be detected due to different depths of the surface of the charger at different positions of the crack defect is avoided.
In summary, in the embodiment of the invention, firstly, a gray image on the surface of a charger is subjected to threshold segmentation, a crack segment on the surface of the charger is initially extracted, then, a pixel point at the end point of the crack segment is taken as a seed point in the gray image, a preset neighborhood range is constructed by taking the seed point as the center, and an initial pixel block of each seed point is obtained by iteratively selecting a mark point; and further analyzing the gray scale characteristics of the initial pixel blocks to obtain gray scale parameters of the initial pixel blocks, iteratively combining the initial pixel blocks to the main pixel blocks based on the difference between the gray scale parameters, judging whether the combination is converged according to the difference of the number of pixel points in the main pixel blocks before and after each combination, if not, continuing to combine the main pixel blocks, and updating the gray scale parameters of the main pixel blocks until the combination is converged, taking the finally combined area as a defect area, and further carrying out defect detection on the surface of the charger based on the defect area.
It should be noted that: the sequence of the embodiments of the present invention is only for description, and does not represent the advantages and disadvantages of the embodiments. The processes depicted in the accompanying drawings do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments.

Claims (6)

1. A method for visually inspecting a surface defect of a charger, the method comprising:
Acquiring a gray image of the surface of a charger; threshold segmentation is carried out on the gray level image to obtain crack segments on the surface of the charger;
taking a pixel point at the end point of each crack segment as a seed point in the gray image, and obtaining an initial pixel block of each seed point according to gray differences between the seed point and other pixel points in a preset neighborhood range;
Obtaining gray parameters of the corresponding initial pixel blocks according to gray values of all pixel points in each initial pixel block; randomly selecting an initial pixel block as a main pixel block, and combining the main pixel block with other initial pixel blocks according to the difference of the gray scale parameters to obtain a combined judgment pixel block; judging whether the merging is converged according to the difference of the number of pixel points in the main pixel blocks before and after each merging and the judging pixel blocks, if not, taking the judging pixel blocks as new main pixel blocks, updating the gray scale parameters of the new main pixel blocks after the merging, continuing the merging, and otherwise, stopping the merging; judging the area corresponding to the pixel blocks after stopping merging as a defect area;
Performing defect detection on the surface of the charger based on the defect area;
The obtaining the initial pixel block of each seed point according to the gray level difference between the seed point and other pixel points in the preset neighborhood range comprises the following steps:
taking any seed point as a marking point, and carrying out negative correlation normalization on the absolute value of the gray value difference value of each other pixel point in the marking point and a preset neighborhood range to obtain the pixel point similarity between the marking point and the corresponding other pixel point;
determining whether the pixel point similarity between the marking point and other pixel points in the preset neighborhood range meets a preset condition;
If the preset condition is met, taking other pixel points corresponding to the maximum value of the pixel point similarity as the next marking point, and continuously executing the selection process in the preset neighborhood range of the next marking point;
If the preset condition is not met, stopping selecting the next marking point, and taking the obtained area formed by all the marking points as an initial pixel block of the corresponding seed point;
Traversing all seed points to obtain an initial pixel block of each seed point;
The determining whether the pixel point similarity between the marking point and other pixel points in the preset neighborhood range meets the preset condition comprises the following steps:
if the maximum value of the pixel point similarity in the preset neighborhood range is larger than a preset similarity threshold value, a preset condition is met;
if the maximum value of the pixel point similarity in the preset neighborhood range is not greater than the preset similarity threshold value, the preset condition is not met;
the obtaining the gray scale parameters of the corresponding initial pixel blocks according to the gray scale values of all the pixel points in each initial pixel block comprises the following steps:
Taking the average value of the gray values of all pixel points in each initial pixel block as the gray parameter of the corresponding initial pixel block;
Combining the main pixel block and other initial pixel blocks according to the difference of the gray scale parameters, and obtaining the combined judgment pixel block comprises the following steps:
Taking other initial pixel blocks which are coincident with the edge of the main pixel block as adjacent pixel blocks of the main pixel block;
Carrying out negative correlation normalization on absolute values of differences of gray parameters of the main pixel blocks and each adjacent pixel block to obtain block similarity between the main pixel blocks and the corresponding adjacent pixel blocks before each combination;
the adjacent pixel blocks with the block similarity larger than a preset merging threshold value are used as mergeable pixel blocks of a main pixel block;
And taking the whole area formed by all the combinable pixel blocks and the main pixel blocks as a judgment pixel block after each combination.
2. The visual inspection method of surface defects of a charger according to claim 1, wherein said determining whether the merging converges based on the difference between the number of pixel points in the main pixel block and the judgment pixel block before and after each merging comprises:
Taking the difference value between the number of the pixel points in the judgment pixel block after each combination and the number of the pixel points in the main pixel block before the combination as the quantity change amplitude before and after each combination;
Taking the ratio of the quantity change amplitude to the quantity of pixel points in the main pixel block before combination as the quantity change rate before and after combination each time;
If the quantity change rate is larger than a preset change rate threshold, merging is not converged, otherwise merging is converged.
3. The method of claim 1, wherein updating the gray scale parameters of the combined new main pixel block comprises:
Taking the average value of the gray values of all pixel points in the new main pixel block after each combination as the integral gray of the new main pixel block after combination;
taking the absolute value of the difference value of the gray scale parameters of each combinable pixel block of the main pixel block before each combination of the integral gray scale as the integral gray scale difference;
taking the absolute value of the difference value between the number of the pixels in the new main pixel block after each combination and the number of the pixels in each combinable pixel block of the main pixel block before combination as the difference of the number of the pixels;
Taking the sum of the integral gray level difference and the pixel point quantity difference as the difference degree between the new combined main pixel block and the corresponding combinable pixel block before combining;
Taking the distance between the center point of the new main pixel block after each combination and the center point of each combinable pixel block of the main pixel block before combination as a distance parameter between the new main pixel block after combination and the corresponding combinable pixel block before combination;
Obtaining the variation degree before and after each combination according to the difference degree and the distance parameter between the new combined main pixel block and all the combinable pixel blocks before the combination;
and taking the product value of the variation degree and the integral gray scale as the gray scale parameter of the new main pixel block after each combination.
4. A method for visually inspecting surface defects of a charger according to claim 3, wherein said obtaining the degree of variation before and after each combination based on the degree of difference between the new main pixel block after combination and all the combinable pixel blocks before combination and the distance parameter comprises:
Taking the product value of the difference degree and the distance parameter corresponding to each new main pixel block after each combination and each combinable pixel block before combination as a change index between the new main pixel block after combination and the combinable pixel block corresponding to the new main pixel block before combination;
And normalizing the average value of the change indexes between the new main pixel block after combination and all the combinable pixel blocks before combination to obtain the change degree before and after each combination.
5. The visual inspection method of surface defects of a charger according to claim 1, wherein said detecting defects of the surface of the charger based on said defective areas comprises:
and taking the result of smoothing filter treatment of the defect area as a crack area of the surface of the charger.
6. The visual inspection method of surface defects of a charger according to claim 1, wherein the threshold segmentation method is oxford threshold segmentation.
CN202311552647.0A 2023-11-21 2023-11-21 Visual detection method for surface defects of charger Active CN117474897B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311552647.0A CN117474897B (en) 2023-11-21 2023-11-21 Visual detection method for surface defects of charger

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311552647.0A CN117474897B (en) 2023-11-21 2023-11-21 Visual detection method for surface defects of charger

Publications (2)

Publication Number Publication Date
CN117474897A CN117474897A (en) 2024-01-30
CN117474897B true CN117474897B (en) 2024-05-28

Family

ID=89634672

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311552647.0A Active CN117474897B (en) 2023-11-21 2023-11-21 Visual detection method for surface defects of charger

Country Status (1)

Country Link
CN (1) CN117474897B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109598726A (en) * 2018-10-26 2019-04-09 哈尔滨理工大学 A kind of adapting to image target area dividing method based on SLIC
CN109801295A (en) * 2018-12-26 2019-05-24 西安电子科技大学 Image partition method based on secondary restricted area growth method
CN114463355A (en) * 2022-03-03 2022-05-10 常州大学 Image segmentation method fusing super pixel block and integral nested edge
CN115861317A (en) * 2023-02-27 2023-03-28 深圳市伟利达精密塑胶模具有限公司 Plastic mold production defect detection method based on machine vision
CN116030034A (en) * 2023-02-21 2023-04-28 青岛精锐机械制造有限公司 Visual identification method for valve surface defects
CN116823811A (en) * 2023-08-25 2023-09-29 汶上县誉诚制衣有限公司 Functional jacket surface quality detection method
CN117011297A (en) * 2023-10-07 2023-11-07 惠州市凯默金属制品有限公司 Aluminum alloy automobile accessory die defect detection method based on image processing

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10489903B2 (en) * 2015-04-27 2019-11-26 Wuhan Wuda Zoyon Science And Technology Co., Ltd. Stepwise refinement detection method for pavement cracks

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109598726A (en) * 2018-10-26 2019-04-09 哈尔滨理工大学 A kind of adapting to image target area dividing method based on SLIC
CN109801295A (en) * 2018-12-26 2019-05-24 西安电子科技大学 Image partition method based on secondary restricted area growth method
CN114463355A (en) * 2022-03-03 2022-05-10 常州大学 Image segmentation method fusing super pixel block and integral nested edge
CN116030034A (en) * 2023-02-21 2023-04-28 青岛精锐机械制造有限公司 Visual identification method for valve surface defects
CN115861317A (en) * 2023-02-27 2023-03-28 深圳市伟利达精密塑胶模具有限公司 Plastic mold production defect detection method based on machine vision
CN116823811A (en) * 2023-08-25 2023-09-29 汶上县誉诚制衣有限公司 Functional jacket surface quality detection method
CN117011297A (en) * 2023-10-07 2023-11-07 惠州市凯默金属制品有限公司 Aluminum alloy automobile accessory die defect detection method based on image processing

Also Published As

Publication number Publication date
CN117474897A (en) 2024-01-30

Similar Documents

Publication Publication Date Title
CN116721106B (en) Profile flaw visual detection method based on image processing
US11580647B1 (en) Global and local binary pattern image crack segmentation method based on robot vision
CN114842017A (en) HDMI cable surface quality detection method and system
CN108154519A (en) Dividing method, device and the storage medium of eye fundus image medium vessels
CN109472788B (en) Method for detecting flaw on surface of airplane rivet
CN114118144A (en) Anti-interference accurate aerial remote sensing image shadow detection method
CN109781737B (en) Detection method and detection system for surface defects of hose
CN111667470B (en) Industrial pipeline flaw detection inner wall detection method based on digital image
CN112258444A (en) Elevator steel wire rope detection method
CN117689655B (en) Metal button surface defect detection method based on computer vision
CN116883408B (en) Integrating instrument shell defect detection method based on artificial intelligence
CN116137036A (en) Gene detection data intelligent processing system based on machine learning
CN116452589B (en) Intelligent detection method for surface defects of artificial board based on image processing
CN116660286A (en) Wire harness head peeling measurement and defect detection method and system based on image segmentation
CN112884746A (en) Character defect intelligent detection algorithm based on edge shape matching
CN114332081B (en) Textile surface abnormity determination method based on image processing
CN113313107A (en) Intelligent detection and identification method for multiple types of diseases on cable surface of cable-stayed bridge
CN114943744A (en) Edge detection method based on local Otsu thresholding
CN111667473A (en) Insulator hydrophobicity grade judging method based on improved Canny algorithm
KR20080079798A (en) Method of face detection and recognition
CN111310899B (en) Power defect identification method based on symbiotic relation and small sample learning
CN117593540A (en) Pressure injury staged identification method based on intelligent image identification technology
CN115564705B (en) Burr detection precision enhancement method and system for precision standard component
CN117474897B (en) Visual detection method for surface defects of charger
CN110443790B (en) Cartilage identification method and system in medical image

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