CN115619793B - Power adapter appearance quality detection method based on computer vision - Google Patents

Power adapter appearance quality detection method based on computer vision Download PDF

Info

Publication number
CN115619793B
CN115619793B CN202211644898.7A CN202211644898A CN115619793B CN 115619793 B CN115619793 B CN 115619793B CN 202211644898 A CN202211644898 A CN 202211644898A CN 115619793 B CN115619793 B CN 115619793B
Authority
CN
China
Prior art keywords
frequency
power adapter
detected
gray
difference
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
CN202211644898.7A
Other languages
Chinese (zh)
Other versions
CN115619793A (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.)
Shenzhen Abp Technology Co ltd
Original Assignee
Shenzhen Abp Technology 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 Shenzhen Abp Technology Co ltd filed Critical Shenzhen Abp Technology Co ltd
Priority to CN202211644898.7A priority Critical patent/CN115619793B/en
Publication of CN115619793A publication Critical patent/CN115619793A/en
Application granted granted Critical
Publication of CN115619793B publication Critical patent/CN115619793B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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
    • G06T5/00Image enhancement or restoration
    • G06T5/40Image enhancement or restoration by the use of histogram techniques
    • G06T5/90

Abstract

The invention relates to the technical field of image processing, in particular to a power adapter appearance quality detection method based on computer vision. The method comprises the following steps: obtaining a frequency spectrum diagram of the power adapter to be detected based on a gray level image of the power adapter to be detected, constructing a frequency histogram based on frequencies corresponding to all pixel points in the frequency spectrum diagram so as to obtain an initial cut-off frequency, obtaining a target cut-off frequency according to gradient values of pixel points in a circle corresponding to the initial cut-off frequency in the frequency spectrum diagram and pixel points in the gray level image of the power adapter to be detected, further obtaining high-frequency information and low-frequency information corresponding to all pixel points in the gray level image of the power adapter to be detected, and calculating a frequency domain difference coefficient; and obtaining a spatial domain difference coefficient based on the texture corresponding to the gray level image of the power adapter to be detected, and further judging the appearance quality grade of the power adapter to be detected. The invention improves the detection precision of the appearance quality of the power adapter.

Description

Power adapter appearance quality detection method based on computer vision
Technical Field
The invention relates to the technical field of image processing, in particular to a power adapter appearance quality detection method based on computer vision.
Background
With the continuous deepening of scientific research problems and the further improvement of the manufacturing level of industrial processes, the appearance of ultra-large scale integrated circuits leads related intelligent devices such as current mobile phones, computers, projectors and the like to be increased increasingly and simultaneously, a plurality of intelligent functions are correspondingly increased, and great convenience is brought to daily life. However, the rated operating voltages of the intelligent devices are not different, the intelligent devices need to work normally under the corresponding voltages, and in order to convert the daily 220V alternating current voltage for household use into the corresponding rated operating voltage of the intelligent devices, the intelligent devices are usually provided with power adapters. The power adapter volume is less usually, and some quality problems that exist on its surface are difficult to discover, but power adapter surface has quality problems and probably influences power adapter inner structure occasionally to make power adapter cause relevant trouble, cause great property economic loss to daily production life, cause the incident even, consequently, need carry out surface quality to it after power adapter production is accomplished and detect. In the existing method, the cut-off frequency of a filter is manually set at first, then a high-frequency region and a low-frequency region in a surface image of a power adapter are obtained based on the filter, the high-frequency region is analyzed, and the appearance quality detection of the power adapter is completed, but the extraction of high-frequency information is directly influenced when the manually set cut-off frequency is too high or too low, so that the accuracy of an extraction result is not high, and the detection precision of the appearance quality of the power adapter is reduced.
Disclosure of Invention
In order to solve the problems that the existing method has low extraction precision and affects the detection result of the appearance quality of the power adapter when the high-frequency region of the spectrogram of the power adapter is extracted based on the manually set cut-off frequency, the invention aims to provide a power adapter appearance quality detection method based on computer vision, and the adopted technical scheme is as follows:
the invention provides a power adapter appearance quality detection method based on computer vision, which comprises the following steps:
acquiring a gray level image of a power adapter to be detected and a gray level image of a standard power adapter;
obtaining a spectrogram of the power adapter to be detected based on the gray level image of the power adapter to be detected; acquiring the frequency corresponding to each pixel point in the spectrogram, constructing a frequency histogram corresponding to the power adapter to be detected based on the frequency, acquiring an initial cut-off frequency according to the frequency histogram, and acquiring a target cut-off frequency according to the gradient values of pixel points in a circle corresponding to the initial cut-off frequency in the spectrogram and pixel points in a gray level image of the power adapter to be detected; obtaining high-frequency information and low-frequency information corresponding to each pixel point in the gray-scale image of the power adapter to be detected according to the target cut-off frequency;
obtaining a frequency domain difference coefficient corresponding to the power adapter to be detected based on high-frequency information and low-frequency information corresponding to each pixel point in the gray-scale image of the power adapter to be detected and high-frequency information and low-frequency information corresponding to each pixel point in the gray-scale image of the standard power adapter; obtaining a space domain difference coefficient corresponding to the power adapter to be detected based on the texture corresponding to the gray level image of the power adapter to be detected and the texture corresponding to the gray level image of the standard power adapter;
and judging the appearance quality grade of the power adapter to be detected based on the frequency domain difference coefficient and the space domain difference coefficient.
Preferably, the obtaining of the target cutoff frequency according to the gradient values of the pixel points in the circle corresponding to the initial cutoff frequency in the spectrogram and the pixel points in the gray scale image of the power adapter to be detected includes:
marking the pixel points with gradient values larger than a gradient threshold value in the gray level image of the power adapter to be detected as target pixel points, and counting the number of the target pixel points; calculating the ratio of the number of target pixel points to the total number of pixel points in the gray image of the power adapter to be detected as a defective pixel point ratio coefficient;
recording a circle corresponding to the initial cut-off frequency in the spectrogram as a first target circle, and obtaining a high-frequency ratio corresponding to the initial cut-off frequency according to a gray value of each pixel point in the first target circle and a gray value of each pixel point in a gray image of the power adapter to be detected;
calculating the absolute value of the difference value between the high-frequency ratio corresponding to the initial cut-off frequency and the defective pixel point ratio coefficient, recording the absolute value as a first absolute value, judging whether the first absolute value is smaller than a difference threshold value, and if so, taking the initial cut-off frequency as a target cut-off frequency; if the difference value is larger than or equal to the target cut-off frequency, taking the difference value obtained by subtracting the preset frequency from the initial cut-off frequency as the first cut-off frequency, calculating a high-frequency ratio corresponding to the first cut-off frequency, judging whether the absolute value of the difference value between the high-frequency ratio corresponding to the first cut-off frequency and the ratio coefficient of the defective pixel point is smaller than a difference threshold value, and if the absolute value is smaller than the difference threshold value, taking the first cut-off frequency as the target cut-off frequency; and if the absolute value is larger than or equal to the difference threshold, reducing the first cut-off frequency by a preset frequency, and repeating the steps until the obtained absolute value is smaller than the difference threshold, and recording the finally obtained frequency as the target cut-off frequency.
Preferably, obtaining a high frequency ratio corresponding to the initial cut-off frequency according to the gray value of each pixel point in the first target circle and the gray value of each pixel point in the gray image of the power adapter to be detected includes:
calculating the sum of gray values corresponding to all pixel points in the first target circle, recording the sum as a first characteristic index, calculating the sum of gray values of all pixel points in a gray image of the power adapter to be detected, recording the sum as a second characteristic index, calculating the ratio of the first characteristic index to the second characteristic index, recording the ratio as a first ratio, and taking the difference value of a constant 1 and the first ratio as a high-frequency ratio corresponding to the initial cut-off frequency.
Preferably, the obtaining of the frequency domain difference coefficient corresponding to the power adapter to be detected based on the high frequency information and the low frequency information corresponding to each pixel point in the grayscale image of the power adapter to be detected and the high frequency information and the low frequency information corresponding to each pixel point in the grayscale image of the standard power adapter includes:
calculating difference indexes and cosine distances corresponding to all pixel points in the gray-scale image of the power adapter to be detected based on high-frequency information and low-frequency information corresponding to all pixel points in the gray-scale image of the power adapter to be detected and high-frequency information and low-frequency information corresponding to all pixel points in the gray-scale image of the standard power adapter;
taking the product of the difference index corresponding to each pixel point in the gray-scale image of the power adapter to be detected and the corresponding cosine distance as the frequency spectrum difference corresponding to each pixel point;
and calculating the sum of the frequency spectrum differences corresponding to all the pixel points in the gray level image of the power adapter to be detected, and taking the sum as the frequency domain difference coefficient corresponding to the power adapter to be detected.
Preferably, calculating a difference index corresponding to each pixel point in the grayscale image of the power adapter to be detected includes:
in gray scale image of power adapter to be detected
Figure DEST_PATH_IMAGE001
Each pixel point:
calculating the high-frequency information corresponding to the pixel point to adapt to the standard power supplyIn the gray scale image of the device
Figure 96569DEST_PATH_IMAGE001
The absolute value of the difference value of the high-frequency information corresponding to each pixel point is used as a first difference; calculating the low frequency information corresponding to the pixel point and the gray scale image of the standard power adapter
Figure 200660DEST_PATH_IMAGE001
The absolute value of the difference value of the low-frequency information corresponding to each pixel point is used as a second difference; taking the product of the first difference and the high-frequency weight as a high-frequency difference, and taking the product of the second difference and the low-frequency weight as a low-frequency difference; and taking the sum of the high-frequency difference and the low-frequency difference as a difference index corresponding to the pixel point.
Preferably, calculating the cosine distance corresponding to each pixel point in the gray scale image of the power adapter to be detected includes:
in gray scale image of power adapter to be detected
Figure 918081DEST_PATH_IMAGE001
Each pixel point:
constructing a frequency domain vector corresponding to the pixel point according to the high-frequency information and the low-frequency information corresponding to the pixel point; in grayscale images from standard power adapters
Figure 500241DEST_PATH_IMAGE001
Constructing high-frequency information and low-frequency information corresponding to each pixel point in gray scale image of standard power adapter
Figure 986717DEST_PATH_IMAGE001
Frequency domain vectors corresponding to the pixel points; calculating the frequency domain vector corresponding to the pixel point and the gray level image of the standard power adapter
Figure 996130DEST_PATH_IMAGE001
And the cosine distance of the frequency domain vector corresponding to each pixel point is used as the cosine distance corresponding to the pixel point.
Preferably, the obtaining an initial cut-off frequency according to the frequency histogram includes: and taking the frequency corresponding to the first trough position in the frequency histogram as an initial cut-off frequency.
Preferably, the obtaining of the airspace difference coefficient corresponding to the power adapter to be detected based on the texture corresponding to the grayscale image of the power adapter to be detected and the texture corresponding to the grayscale image of the standard power adapter includes:
recording a gray level co-occurrence matrix corresponding to a gray level image of a power adapter to be detected as a gray level co-occurrence matrix to be analyzed, and recording a gray level co-occurrence matrix corresponding to a gray level image of a standard power adapter as a standard gray level co-occurrence matrix; according to the gray level co-occurrence matrix to be analyzed and the standard gray level co-occurrence matrix, calculating a spatial domain difference coefficient corresponding to the power adapter to be detected by adopting the following formula:
Figure DEST_PATH_IMAGE002
wherein, the first and the second end of the pipe are connected with each other,
Figure DEST_PATH_IMAGE003
the spatial domain difference coefficient corresponding to the power adapter to be detected,
Figure DEST_PATH_IMAGE004
for the number of rows of the gray level co-occurrence matrix to be analyzed,
Figure DEST_PATH_IMAGE005
for the number of columns of the gray level co-occurrence matrix to be analyzed,
Figure DEST_PATH_IMAGE006
for the first in the gray level co-occurrence matrix to be analyzed
Figure DEST_PATH_IMAGE007
Go to the first
Figure DEST_PATH_IMAGE008
The values of the columns are such that,
Figure DEST_PATH_IMAGE009
is the mean value of the elements in the gray level co-occurrence matrix to be analyzed,
Figure DEST_PATH_IMAGE010
is the first in the standard gray level co-occurrence matrix
Figure 964961DEST_PATH_IMAGE007
Go to the first
Figure 350811DEST_PATH_IMAGE008
The values of the columns are such that,
Figure DEST_PATH_IMAGE011
is the mean of the elements in the standard gray level co-occurrence matrix,
Figure DEST_PATH_IMAGE012
for the gray level co-occurrence matrix to be analyzed,
Figure DEST_PATH_IMAGE013
is a standard gray-level co-occurrence matrix,
Figure DEST_PATH_IMAGE014
in the form of a function of the variance,
Figure DEST_PATH_IMAGE015
for the variance of the elements in the gray level co-occurrence matrix to be analyzed,
Figure DEST_PATH_IMAGE016
is the variance of the elements in the normal gray level co-occurrence matrix.
Preferably, the determining the appearance quality grade of the power adapter to be detected based on the frequency domain difference coefficient and the space domain difference coefficient includes:
calculating the sum of the frequency domain difference coefficient and the space domain difference coefficient as an overall difference coefficient; taking the sum of the constant 1 and the overall difference coefficient as a third characteristic index; taking the ratio of the overall difference coefficient to the third characteristic index as a defect index of the power adapter to be detected;
judging whether the defect index is less than or equal to a first defect threshold value, and if the defect index is less than or equal to the first defect threshold value, judging that the appearance quality grade of the power adapter to be detected is three grades; if the defect index is greater than the second defect threshold value, judging whether the defect index is less than or equal to the second defect threshold value, if the defect index is less than or equal to the second defect threshold value, judging that the appearance quality grade of the power adapter to be detected is two-grade, and if the defect index is greater than the second defect threshold value, judging that the appearance quality grade of the power adapter to be detected is one-grade; the first defect threshold is less than the second defect threshold.
The invention has at least the following beneficial effects:
the method analyzes the power adapter to be detected from two angles of a frequency domain and an airspace, and when analyzing the frequency domain information of the power adapter to be detected, the method considers that under the normal condition, a high-frequency region in a gray scale image of the power adapter to be detected is a region with unevenly transformed surface of the power adapter, and the regions have higher possibility of defects, so that the method distinguishes the high-frequency information and the low-frequency information based on cut-off frequency, and considers that the extraction accuracy of the high-frequency information and the low-frequency information can be directly influenced by the over-high or over-low set cut-off frequency, so the method firstly converts the gray scale image of the power adapter to be detected in the airspace into the frequency domain to obtain a corresponding frequency spectrogram; the method comprises the steps of obtaining the frequency of each pixel point based on a frequency spectrogram, constructing a corresponding frequency histogram, and enabling the frequency histogram to reflect the frequency distribution condition of the surface of the power adapter to be detected more intuitively, analyzing the frequency histogram to obtain an initial cut-off frequency, obtaining high-frequency information and low-frequency information corresponding to each pixel point in a gray image of the power adapter to be detected based on the optimal cut-off frequency according to the pixel points in a circle corresponding to the initial cut-off frequency in the frequency spectrogram and the gradient value of the pixel points in the gray image of the power adapter to be detected, wherein the high-frequency information and the low-frequency information are higher in extraction precision, and further the detection accuracy of the appearance quality of the subsequent power adapter to be detected can be effectively guaranteed; according to the method, the frequency domain difference coefficient corresponding to the power adapter to be detected is calculated according to the high-frequency information and the low-frequency information corresponding to each pixel point in the gray-scale image of the power adapter to be detected, the frequency domain difference coefficient reflects the difference condition of the frequency domain information of the power adapter to be detected and the standard power adapter, and the larger the frequency domain difference coefficient is, the higher the possibility that the surface of the power adapter to be detected has defects is; when the airspace information of the power adapter to be detected is analyzed, the airspace difference coefficient corresponding to the power adapter to be detected is obtained based on the texture corresponding to the grayscale image of the power adapter to be detected and the texture corresponding to the grayscale image of the standard power adapter, the airspace difference coefficient reflects the difference condition of the airspace information of the power adapter to be detected and the standard power adapter, and the larger the airspace difference coefficient is, the higher the possibility that the surface of the power adapter to be detected has defects is; according to the method, the appearance quality of the power adapter to be detected is comprehensively evaluated by combining the frequency domain information and the spatial domain information of the power adapter to be detected, and the appearance quality of the power adapter to be detected is judged based on the frequency domain difference coefficient and the spatial domain difference coefficient.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions and advantages of the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a flowchart of a method for detecting appearance quality of a power adapter based on computer vision according to the present invention.
Detailed Description
To further illustrate the technical means and effects of the present invention for achieving the predetermined objects, the following detailed description will be made on the method for detecting the appearance quality of a power adapter based on computer vision according to the present invention with reference to the accompanying drawings and preferred embodiments.
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 describes a specific scheme of the power adapter appearance quality detection method based on computer vision in detail with reference to the accompanying drawings.
The embodiment of the power adapter appearance quality detection method based on computer vision comprises the following steps:
the embodiment proposes a power adapter appearance quality detection method based on computer vision, and as shown in fig. 1, the power adapter appearance quality detection method based on computer vision of the embodiment includes the following steps:
s1, acquiring a gray level image of a power adapter to be detected and a gray level image of a standard power adapter.
The specific scenario addressed by the present embodiment is as follows: the method comprises the steps of collecting a surface image of a to-be-detected power adapter after production is finished by a camera, then obtaining cut-off frequency in a self-adaptive mode, extracting high-frequency information and low-frequency information in the surface image of the to-be-detected power adapter by a filter, analyzing frequency domain information of the to-be-detected power adapter according to the high-frequency information and the low-frequency information in the surface image of the to-be-detected power adapter, analyzing airspace information of the to-be-detected power adapter based on a gray image of the to-be-detected power adapter and a gray image of a standard power adapter, and further evaluating the quality of the to-be-detected power adapter.
Compared with a camera formed by other CMOS electronic elements, the CCD camera has the characteristics of high light sensitivity, clear and non-smear imaging content and high imaging quality, so that the CCD camera is used for shooting the surface of the power adapter to be detected to obtain a surface image of the power adapter to be detected, and corresponding data support is provided for subsequent analysis of the surface quality of the power adapter to be detected. Meanwhile, in order to facilitate detection and analysis of the surface quality of the power adapter to be detected, the standard power adapter with a defect-free surface is selected, and the surface image of the standard power adapter is acquired by using the CCD camera.
According to the process, the surface image of the power adapter to be detected and the surface image of the standard power adapter in the RGB color space are obtained, in order to improve the detection precision of the surface quality of the power adapter to be detected, the collected surface image of the power adapter to be detected and the collected surface image of the standard power adapter in the RGB color space are converted through a weighted average method, meanwhile, in order to reduce the influence of random natural noise in the image collection process on the appearance quality detection of the subsequent power adapter, the Gaussian filter function is used for carrying out filtering processing on the obtained surface images of the two power adapters, the interference and the influence of the random natural noise on the appearance quality detection of the subsequent power adapter are weakened or even eliminated as much as possible, and the two images obtained after the filtering processing are respectively recorded as the gray level image of the power adapter to be detected and the gray level image of the standard power adapter.
Therefore, the gray level image of the power adapter to be detected and the gray level image of the standard power adapter are obtained and used for detecting the surface quality of the subsequent power adapter.
S2, acquiring a spectrogram of the power adapter to be detected based on the gray image of the power adapter to be detected; acquiring the frequency corresponding to each pixel point in the spectrogram, constructing a frequency histogram corresponding to the power adapter to be detected based on the frequency, acquiring an initial cut-off frequency according to the frequency histogram, and acquiring a target cut-off frequency according to the gradient values of pixel points in a circle corresponding to the initial cut-off frequency in the spectrogram and pixel points in a gray level image of the power adapter to be detected; and obtaining high-frequency information and low-frequency information corresponding to each pixel point in the gray-scale image of the power adapter to be detected according to the target cut-off frequency.
When the surface of the power adapter to be detected has no quality problem, the arrangement of pixel points in the gray image and corresponding gray values all present a certain rule, when a scratch or abrasion defect occurs in a certain area on the power adapter to be detected, the gray values of the pixel points in the corresponding area can be changed correspondingly, but if the scratch or abrasion is slight, the change on the gray image of the power adapter to be detected is not easy to perceive, in addition, part of noise points in the gray image of the power adapter to be detected are difficult to remove by adopting a conventional filtering algorithm, and the existence of the noise points can also have a certain influence on the detection precision of the surface quality of the power adapter to be detected. In order to eliminate the above effects, in this embodiment, discrete fourier transform is performed on the grayscale image of the to-be-detected power adapter and the grayscale image of the standard power adapter, respectively, and the grayscale image of the to-be-detected power adapter and the grayscale image of the standard power adapter in the space domain are converted into the spectrogram of the corresponding power adapter surface in the frequency domain. The two-dimensional discrete fourier transform of an image is a well-known technique, and is often used for converting a spatial domain image into a frequency domain for corresponding analysis and calculation, and will not be described in detail herein. By adopting the method, the frequency spectrum diagram of the power adapter to be detected and the frequency spectrum diagram of the standard power adapter are obtained.
The low frequency region of the spectrogram of the power adapter typically represents a region of uniform transformation of the surface of the power adapter, located in the center of the spectrogram, while the high frequency region typically represents a region of non-uniform transformation of the surface of the power adapter, located in four different quadrant regions of the spectrogram, which typically contain cosmetic defects of the power adapter. Based on this, it is necessary to design a corresponding filter to respectively extract the high frequency region and the low frequency region in the spectrogram of the power adapter to be detected, and to perform calculation analysis respectively.
Cut-off frequency needs the manual setting in traditional butterworth wave filter, and too high or too low setting of cut-off frequency can direct influence subsequent analysis result, and this embodiment combines power adapter surface defect characteristic and the distribution characteristic self-adaptation of power adapter spectrogram to obtain optimal cut-off frequency to the effectual dependence relevant technical staff of avoiding excessively setting up cut-off frequency improves holistic intelligent effect. In general, in an airspace, the proportion of defective pixel points in a gray image of a power adapter to be detected is small, the proportion of normal pixel points is large, and the normal pixel points in the gray image of the power adapter to be detected belong to low-frequency information after being transformed, so that the normal pixel points are mostly concentrated in the central area of a spectrogram after being subjected to Fourier transform, namely the low-frequency area; the defect pixel points in the gray level image of the power adapter to be detected belong to high-frequency information after being transformed, and are relatively far away from the center position of the spectrogram, and the embodiment obtains the high-frequency and low-frequency partition boundary based on the characteristic, namely, obtains the cut-off frequency.
Firstly, obtaining the gradient value of each pixel point in the gray level image of the power adapter to be detected, wherein the method for obtaining the gradient value of the pixel point is a known technology and is not described in too much detail here; when some pixel points are located in the defect area, the gray values of the pixel points will fluctuate, and the gradient values of the pixel points will be large, so this embodiment sets a gradient threshold, marks the pixel points with the gradient value larger than the gradient threshold in the gray image of the power adapter to be detected as target pixel points, counts the number of the target pixel points, and calculates the ratio of the number of the target pixel points to the total number of the pixel points in the gray image of the power adapter to be detected
Figure DEST_PATH_IMAGE017
And as the defective pixel point proportion coefficient, the more serious the surface defect of the power adapter to be detected is, the larger the defective pixel point proportion coefficient is. The gradient threshold is set to 0.65 in this embodiment, and in a specific application, the implementer can set the threshold according to specific situations. Then, counting the frequency of each pixel point in the frequency spectrogram of the power adapter to be detected, and constructing a corresponding frequency histogram based on the frequency of each pixel point in the frequency spectrogram of the power adapter to be detected, wherein the abscissa of the frequency histogram is the frequency, and the ordinate is the probability of the occurrence of the corresponding frequency; taking the frequency corresponding to the first trough position in the frequency histogram as the initial cut-off frequency, then performing adaptive adjustment on the initial cut-off frequency to obtain the optimal cut-off frequency, which is recorded as the target cut-off frequency, and then obtaining the high-frequency information and the low-frequency information in the grayscale image of the power adapter to be detected based on the target cut-off frequency. In particular, the initial cut-off frequency is determined for the testThe method comprises the following steps of representing a circle with a radius of R in a gray level image of a source adapter, recording the circle as a first target circle, calculating the sum of gray levels corresponding to all pixel points in the first target circle, recording the sum as a first characteristic index, calculating the sum of gray levels of all pixel points in the gray level image of the power adapter to be detected, recording the sum as a second characteristic index, calculating the ratio of the first characteristic index to the second characteristic index, recording the ratio as a first ratio, taking the difference value of a constant 1 and the first ratio as a high-frequency ratio corresponding to an initial cut-off frequency, wherein the specific expression of the high-frequency ratio corresponding to the initial cut-off frequency is as follows:
Figure DEST_PATH_IMAGE018
wherein the content of the first and second substances,
Figure DEST_PATH_IMAGE019
is the high frequency ratio corresponding to the initial cut-off frequency,
Figure DEST_PATH_IMAGE020
is the first target circle
Figure DEST_PATH_IMAGE021
The gray value corresponding to each pixel point,
Figure DEST_PATH_IMAGE022
is the number of pixel points in the first target circle,
Figure DEST_PATH_IMAGE023
is the frequency spectrum diagram of the power adapter to be detected
Figure DEST_PATH_IMAGE024
The gray value corresponding to each pixel point,
Figure DEST_PATH_IMAGE025
the number of pixel points in the frequency spectrogram of the power adapter to be detected,
Figure DEST_PATH_IMAGE026
is a first characteristicThe sign of the index is carried out,
Figure DEST_PATH_IMAGE027
as the second characteristic index, the index of the first characteristic,
Figure DEST_PATH_IMAGE028
is a first ratio.
When the sum of the gray values of the pixels in the first target circle is smaller, it is indicated that the ratio of the low-frequency components in the spectrogram of the power adapter to be detected is smaller, and the ratio of the high-frequency components in the spectrogram of the power adapter to be detected is larger, namely the ratio of the high frequency corresponding to the initial cut-off frequency is larger; when the sum of the gray values of the pixels in the first target circle is larger, it is described that the ratio of the low-frequency components in the spectrogram of the power adapter to be detected is larger, and the ratio of the high-frequency components in the spectrogram of the power adapter to be detected is smaller, that is, the ratio of the high frequency corresponding to the initial cut-off frequency is smaller. Setting a difference threshold value, and calculating high-frequency ratio corresponding to the initial cut-off frequency and ratio coefficient of defective pixel points
Figure 492728DEST_PATH_IMAGE017
Recording the absolute value of the difference as a first absolute value, judging whether the first absolute value is smaller than a difference threshold, if so, indicating that the initial cut-off frequency can better divide a high-frequency region and a low-frequency region in a spectrogram of the power adapter to be detected, and taking the initial cut-off frequency as a target cut-off frequency; if the absolute value of the difference between the high-frequency ratio corresponding to the first cut-off frequency and the defect pixel point ratio coefficient is smaller than the difference threshold, the first cut-off frequency is taken as the target cut-off frequency; if the first cut-off frequency is larger than or equal to the difference threshold, reducing the first cut-off frequency to a preset frequency, and repeating the steps until the obtained absolute value is smaller than the difference threshold, and recording the finally obtained frequency as a target cut-off frequency; the true bookThe embodiment sets the difference threshold to be 0.1 and the preset frequency to be 0.2, and in a specific application, an implementer can set the difference threshold according to specific situations.
In order to ensure that the cut-off frequency can better divide the high-frequency information component and the low-frequency information component of the power adapter to be detected, the embodiment adopts the above steps to perform small adaptive adjustment on the initial cut-off frequency, and sequentially shrinks inwards based on the adjustment step length, so as to ensure that the high-frequency information in the spectrogram of the power adapter to be detected is retained to the greatest extent. In the embodiment, a butterworth high-pass filter is used for filtering out low-frequency parts in a spectrogram of a power adapter to be detected, so as to obtain a high-frequency area in the spectrogram of the power adapter to be detected; subtracting a high-frequency region in the spectrogram of the power adapter to be detected from the spectrogram of the power adapter to be detected to obtain a low-frequency region in the spectrogram of the power adapter to be detected; as other embodiments, other types of high pass filters may be used; based on the frequency corresponding to each pixel point in the spectrogram of the power adapter to be detected, obtaining high-frequency information corresponding to each pixel point, wherein the calculation formula of the high-frequency information is as follows:
Figure DEST_PATH_IMAGE029
wherein, the first and the second end of the pipe are connected with each other,
Figure DEST_PATH_IMAGE030
in order to target the cut-off frequency,
Figure DEST_PATH_IMAGE031
for the frequency at which the pixel points correspond,
Figure DEST_PATH_IMAGE032
is a frequency of
Figure 328835DEST_PATH_IMAGE031
The high frequency information corresponding to the pixel point of (2). The above calculation formula is an existing formula, and is not described herein in detail.
According to the above formula, high-frequency information corresponding to each pixel point in the spectrogram of the power adapter to be detected can be obtained, and then, in this embodiment, low-frequency information corresponding to each pixel point in the spectrogram of the power adapter to be detected is obtained, where the method for obtaining low-frequency information corresponding to any pixel point in the spectrogram of the power adapter to be detected is as follows: subtracting the high-frequency information corresponding to the pixel point from the frequency information of the pixel point to obtain a difference value, and taking the difference value as the low-frequency information corresponding to the pixel point; by adopting the method, the high-frequency information and the low-frequency information corresponding to each pixel point in the spectrogram of the power adapter to be detected can be obtained, namely the high-frequency information and the low-frequency information corresponding to each pixel point in the gray-scale image of the power adapter to be detected are obtained. Similarly, based on the spectrogram of the standard power adapter, the high-frequency information and the low-frequency information corresponding to each pixel point in the grayscale image of the standard power adapter are obtained.
S3, obtaining a frequency domain difference coefficient corresponding to the power adapter to be detected based on high-frequency information and low-frequency information corresponding to each pixel point in the gray-scale image of the power adapter to be detected and high-frequency information and low-frequency information corresponding to each pixel point in the gray-scale image of the standard power adapter; and obtaining the airspace difference coefficient corresponding to the power adapter to be detected based on the texture corresponding to the gray-scale image of the power adapter to be detected and the texture corresponding to the gray-scale image of the standard power adapter.
If the difference between the high-frequency information of a certain pixel point in the gray-scale image of the power adapter to be detected and the high-frequency information of the corresponding position in the gray-scale image of the standard power adapter is not large, and the difference between the low-frequency information of a certain pixel point in the gray-scale image of the power adapter to be detected and the low-frequency information of the corresponding position in the gray-scale image of the standard power adapter is also not large, it is indicated that the probability that the pixel point in the gray-scale image of the power adapter to be detected is a defective pixel point is low. Based on this, in this embodiment, the difference index corresponding to each pixel point in the grayscale image of the power adapter to be detected is calculated according to the low-frequency information and the high-frequency information corresponding to each pixel point in the grayscale image of the power adapter to be detected and the low-frequency information and the high-frequency information corresponding to each pixel point in the grayscale image of the standard power adapter to be detected, specifically, for the second pixel point in the grayscale image of the power adapter to be detected
Figure 270115DEST_PATH_IMAGE001
Each pixel point is used for calculating the high-frequency information corresponding to the pixel point and the gray level image of the standard power adapter
Figure 944810DEST_PATH_IMAGE001
The absolute value of the difference value of the high-frequency information corresponding to each pixel point is used as a first difference; calculating the low frequency information corresponding to the pixel point and the gray scale image of the standard power adapter
Figure 655146DEST_PATH_IMAGE001
The absolute value of the difference value of the low-frequency information corresponding to each pixel point is used as a second difference; taking the product of the first difference and the high-frequency weight as a high-frequency difference, and taking the product of the second difference and the low-frequency weight as a low-frequency difference; taking the sum of the high-frequency difference and the low-frequency difference as a difference index corresponding to the pixel point; the specific expression of the difference index corresponding to the pixel point is as follows:
Figure DEST_PATH_IMAGE033
wherein, the first and the second end of the pipe are connected with each other,
Figure DEST_PATH_IMAGE034
in the gray scale image of the power adapter to be tested
Figure 678465DEST_PATH_IMAGE001
The difference index corresponding to each pixel point,
Figure DEST_PATH_IMAGE035
in order to be a high-frequency weight,
Figure DEST_PATH_IMAGE036
in order to be a low-frequency weight,
Figure DEST_PATH_IMAGE037
in the gray scale image of the power adapter to be tested
Figure 825151DEST_PATH_IMAGE001
High-frequency information corresponding to each pixel point,
Figure DEST_PATH_IMAGE038
in grayscale images for standard power adapters
Figure 756066DEST_PATH_IMAGE001
High-frequency information corresponding to each pixel point,
Figure DEST_PATH_IMAGE039
in the gray scale image of the power adapter to be tested
Figure 930696DEST_PATH_IMAGE001
Low-frequency information corresponding to each pixel point,
Figure DEST_PATH_IMAGE040
in grayscale images for standard power adapters
Figure 390496DEST_PATH_IMAGE001
The low frequency information corresponding to each pixel point,
Figure DEST_PATH_IMAGE041
in order to take the absolute value of the value,
Figure DEST_PATH_IMAGE042
in order to be the first difference,
Figure DEST_PATH_IMAGE043
in order to be the second difference, the first difference,
Figure DEST_PATH_IMAGE044
in order to be a high-frequency difference,
Figure DEST_PATH_IMAGE045
is a low frequency difference. Since the defect generally has a high-frequency region, high-frequency information is taken as the right when the gray image of the power adapter to be detected is analyzedThe weight should be greater than the weight of the vehicle,
Figure DEST_PATH_IMAGE046
the present embodiment is arranged
Figure DEST_PATH_IMAGE047
Figure DEST_PATH_IMAGE048
In a specific application, the implementer can set the setting according to specific situations.
Figure 8166DEST_PATH_IMAGE042
In the gray scale image for representing the power adapter to be detected
Figure 539510DEST_PATH_IMAGE001
The high-frequency information corresponding to each pixel point is compared with the gray scale image of the standard power adapter
Figure 975171DEST_PATH_IMAGE001
The difference in high frequency information corresponding to an individual pixel point,
Figure 933768DEST_PATH_IMAGE044
in gray scale image for representing power adapter to be detected
Figure 822090DEST_PATH_IMAGE001
Difference indexes of high-frequency information of the pixel points;
Figure 891546DEST_PATH_IMAGE043
in the gray scale image for representing the power adapter to be detected
Figure 181713DEST_PATH_IMAGE001
The low-frequency information corresponding to each pixel point is compared with the gray level image of the standard power adapter
Figure 452157DEST_PATH_IMAGE001
Difference of low frequency information corresponding to each pixel pointIn the case of an abnormal situation,
Figure 77042DEST_PATH_IMAGE045
in gray scale image for representing power adapter to be detected
Figure 435343DEST_PATH_IMAGE001
Difference indexes of low-frequency information of the pixel points; when the power adapter to be detected is in the gray scale image
Figure 94863DEST_PATH_IMAGE001
The high and low frequency information corresponding to each pixel point is equal to the gray level image of the standard power adapter
Figure 411575DEST_PATH_IMAGE001
When the difference of each pixel point is larger and the difference of the high-frequency information is larger, the gray image of the power adapter to be detected is shown as the second image
Figure 523756DEST_PATH_IMAGE001
The more likely each pixel is to be a defective pixel; when the gray image of the power adapter to be detected is the first
Figure 685747DEST_PATH_IMAGE001
The high and low frequency information corresponding to each pixel point is equal to the gray level image of the standard power adapter
Figure 934195DEST_PATH_IMAGE001
When the difference of each pixel point does not exist or is smaller, the gray level image of the power adapter to be detected is described
Figure 421808DEST_PATH_IMAGE001
The more likely it is that a pixel is a normal pixel.
By adopting the method, the difference index corresponding to each pixel point in the gray-scale image of the power adapter to be detected can be obtained.
Considering the high and low frequency information of each pixel point in the gray scale image of the power adapter to be detected and each gray scale image of the standard power adapterThe cosine distance of the high-frequency and low-frequency information of the pixel points can also represent the difference degree of the frequency spectrum characteristics of the power adapter to be detected and the standard power adapter, and if the cosine distance is larger, the larger the frequency spectrum characteristic difference of the power adapter to be detected and the standard power adapter is, the larger the possibility that the appearance of the power adapter to be detected is defective is. Therefore, in the following embodiment, based on the low frequency information and the high frequency information corresponding to each pixel point in the grayscale image of the power adapter to be detected and the low frequency information and the high frequency information corresponding to each pixel point in the grayscale image of the standard power adapter, the cosine distance corresponding to each pixel point in the grayscale image of the power adapter to be detected is calculated, specifically, for the cosine distance corresponding to the first pixel point in the grayscale image of the power adapter to be detected
Figure 44723DEST_PATH_IMAGE001
Each pixel point, according to the high-frequency information and the low-frequency information corresponding to the pixel point, constructing a frequency domain vector corresponding to the pixel point, namely
Figure DEST_PATH_IMAGE049
(ii) a In grayscale images from standard power adapters
Figure 197356DEST_PATH_IMAGE001
Constructing high-frequency information and low-frequency information corresponding to each pixel point in gray scale image of standard power adapter
Figure 316621DEST_PATH_IMAGE001
Frequency-domain vectors corresponding to individual pixel points, i.e.
Figure DEST_PATH_IMAGE050
(ii) a Calculating the frequency domain vector corresponding to the pixel point and the first in the gray level image of the standard power adapter
Figure 896507DEST_PATH_IMAGE001
And the cosine distance of the frequency domain vector corresponding to each pixel point is used as the cosine distance corresponding to the pixel point. The specific expression of the cosine distance corresponding to the pixel point is as follows:
Figure DEST_PATH_IMAGE051
wherein, the first and the second end of the pipe are connected with each other,
Figure DEST_PATH_IMAGE052
in the gray scale image of the power adapter to be tested
Figure 248860DEST_PATH_IMAGE001
The cosine distance of the point corresponding to each pixel.
The cosine distance calculated by the formula represents the difference degree of the frequency spectrum characteristics of the power adapter to be detected and the standard power adapter, if the difference degree is the first in the gray level image of the power adapter to be detected
Figure 1921DEST_PATH_IMAGE001
The larger the cosine distance corresponding to each pixel point is, the larger the cosine distance is, the power adapter to be detected
Figure 506852DEST_PATH_IMAGE001
Pixel point and standard power supply adapting
Figure 54377DEST_PATH_IMAGE001
The larger the difference of the frequency spectrum characteristics of each pixel point is, the larger the gray level image of the power adapter to be detected is
Figure 644758DEST_PATH_IMAGE001
The more likely an individual pixel is a defective pixel; if the gray scale image of the power adapter to be detected is the first
Figure 201510DEST_PATH_IMAGE001
The smaller the cosine distance corresponding to each pixel point is, the smaller the cosine distance is, the power adapter to be detected
Figure 29789DEST_PATH_IMAGE001
Pixel point and standard power supply adapting
Figure 13794DEST_PATH_IMAGE001
The more similar the frequency spectrum characteristics of each pixel point, the first in the gray level image of the power adapter to be detected
Figure 825893DEST_PATH_IMAGE001
The more likely an individual pixel is a normal pixel.
By adopting the method, the cosine distance corresponding to each pixel point in the gray image of the power adapter to be detected can be obtained. The difference index and the cosine distance corresponding to each pixel point in the gray-scale image of the power adapter to be detected can reflect the frequency spectrum difference condition of the power adapter to be detected and the standard power adapter, so that for any pixel point in the gray-scale image of the power adapter to be detected: taking the product of the difference index corresponding to the pixel point and the cosine distance corresponding to the pixel point as the frequency spectrum difference corresponding to the pixel point; by adopting the method, the frequency spectrum difference corresponding to each pixel point in the gray-scale image of the power adapter to be detected can be obtained, the sum of the frequency spectrum differences corresponding to all the pixel points in the gray-scale image of the power adapter to be detected is calculated and is used as the frequency domain difference coefficient corresponding to the power adapter to be detected, and the larger the frequency spectrum difference corresponding to the gray-scale image of the power adapter to be detected is, the more serious the defect of the power adapter to be detected is.
In order to further improve the analysis accuracy of the appearance quality of the power adapter to be detected, the grayscale image of the power adapter in the null domain is further analyzed. When the surface of the power adapter to be detected has defects such as scratches and abrasion, the inherent texture characteristics of the surface of the power adapter to be detected can be changed, so that the embodiment analyzes the surface by extracting corresponding texture characteristics, that is, a gray level co-occurrence matrix corresponding to a gray level image of the power adapter to be detected is obtained and recorded as a gray level co-occurrence matrix to be analyzed, and simultaneously, a gray level co-occurrence matrix corresponding to a gray level image of a standard power adapter is obtained and recorded as a standard gray level co-occurrence matrix, which is used for representing the texture distribution condition of the corresponding image, the gray level co-occurrence matrix is a common texture extraction algorithm, the calculation process of the gray level co-occurrence matrix is a known technology, and redundant description is not repeated here. The larger the difference between the gray level co-occurrence matrix to be analyzed and the standard gray level co-occurrence matrix is, the larger the difference between the airspace information of the power adapter to be detected and the airspace information of the standard power adapter is. Therefore, in this embodiment, based on the gray level co-occurrence matrix to be analyzed and the standard gray level co-occurrence matrix, the airspace difference coefficient corresponding to the power adapter to be detected is calculated, that is:
Figure 920756DEST_PATH_IMAGE002
wherein the content of the first and second substances,
Figure 134700DEST_PATH_IMAGE003
the spatial domain difference coefficient corresponding to the power adapter to be detected,
Figure DEST_PATH_IMAGE053
for the number of rows of the gray level co-occurrence matrix to be analyzed,
Figure 617503DEST_PATH_IMAGE005
for the number of columns of the gray level co-occurrence matrix to be analyzed,
Figure 651318DEST_PATH_IMAGE006
for the first in the gray level co-occurrence matrix to be analyzed
Figure 549873DEST_PATH_IMAGE007
Go to the first
Figure 352744DEST_PATH_IMAGE008
The values of the columns are such that,
Figure 678552DEST_PATH_IMAGE009
is the mean value of the elements in the gray level co-occurrence matrix to be analyzed,
Figure 199663DEST_PATH_IMAGE010
is the first in the standard gray level co-occurrence matrix
Figure 636329DEST_PATH_IMAGE007
Go to the first
Figure 559286DEST_PATH_IMAGE008
The values of the columns are such that,
Figure 321574DEST_PATH_IMAGE011
is the mean value of the elements in the normal gray level co-occurrence matrix,
Figure 329982DEST_PATH_IMAGE012
for the gray level co-occurrence matrix to be analyzed,
Figure 835918DEST_PATH_IMAGE013
is a standard gray-level co-occurrence matrix,
Figure DEST_PATH_IMAGE054
in the form of a function of the variance,
Figure 800332DEST_PATH_IMAGE015
for the variance of the elements in the gray level co-occurrence matrix to be analyzed,
Figure 484254DEST_PATH_IMAGE016
is the variance of the elements in the normal gray level co-occurrence matrix.
When the difference between the gray level co-occurrence matrix to be analyzed and the standard gray level co-occurrence matrix is larger, the larger the difference between the appearance of the power adapter to be detected and the appearance of the standard power adapter is, the higher the possibility that the surface of the power adapter to be detected has defects is, namely, the larger the airspace difference coefficient corresponding to the power adapter to be detected is; when the difference between the gray level co-occurrence matrix to be analyzed and the standard gray level co-occurrence matrix is smaller, it is indicated that the difference between the appearance of the power adapter to be detected and the appearance of the standard power adapter is smaller, the possibility that the surface of the power adapter to be detected has defects is smaller, and namely the airspace difference coefficient corresponding to the power adapter to be detected is smaller.
By analyzing the frequency domain information and the spatial domain information of the power adapter to be detected, the frequency domain difference coefficient and the spatial domain difference coefficient corresponding to the power adapter to be detected are obtained.
And S4, judging the appearance quality grade of the power adapter to be detected based on the frequency domain difference coefficient and the space domain difference coefficient.
In the embodiment, the frequency domain information and the spatial domain information of the power adapter to be detected are analyzed to obtain a frequency domain difference coefficient and a spatial domain difference coefficient corresponding to the power adapter to be detected, the frequency domain difference coefficient reflects the difference condition of the frequency domain information of the power adapter to be detected and a standard power adapter, and the spatial domain difference coefficient reflects the difference condition of the spatial domain information of the power adapter to be detected and the standard power adapter; taking the sum of the constant 1 and the overall difference coefficient as a third characteristic index; taking the ratio of the overall difference coefficient to the third characteristic index as a defect index of the power adapter to be detected; the specific calculation formula of the defect index of the power adapter to be detected is as follows:
Figure DEST_PATH_IMAGE055
wherein, the first and the second end of the pipe are connected with each other,
Figure DEST_PATH_IMAGE056
is a defect index of the power adapter to be detected,
Figure 494804DEST_PATH_IMAGE003
is the airspace difference coefficient corresponding to the power adapter to be detected,
Figure DEST_PATH_IMAGE057
the frequency domain difference coefficient corresponding to the power adapter to be detected,
Figure DEST_PATH_IMAGE058
as a result of the overall difference coefficient,
Figure 929066DEST_PATH_IMAGE059
is the third characteristic index.
Calculating to obtain the defect index of the power adapter to be detected through the formula, wherein the value of the defect index of the power adapter to be detected is in the interval [0,1 ]]If the frequency domain difference coefficient and the airspace difference coefficient corresponding to the power adapter to be detected are both large, the value of the defect index of the power adapter to be detected approaches to 1, and the surface defect degree of the power adapter to be detected is more serious at the moment; setting a first defect threshold
Figure DEST_PATH_IMAGE060
And a second defect threshold
Figure DEST_PATH_IMAGE061
Figure DEST_PATH_IMAGE062
When the defect index of the power adapter to be detected
Figure DEST_PATH_IMAGE063
When the detection result is positive, the surface of the power adapter to be detected has slight defects, and the appearance quality grade of the power adapter to be detected is three grades; when the defect index of the power adapter to be detected
Figure DEST_PATH_IMAGE064
When the detection result is positive, the surface of the power adapter to be detected has a medium defect, and the appearance quality grade of the power adapter to be detected is two-grade; when the defect index of the power adapter to be detected
Figure DEST_PATH_IMAGE065
And then, the surface of the power adapter to be detected has serious defects, and the appearance quality grade of the power adapter to be detected is first grade. In this embodiment
Figure 793991DEST_PATH_IMAGE060
The value of (a) is 0.2,
Figure 632503DEST_PATH_IMAGE061
the value of (b) is 0.5, which can be set by the practitioner as the case may be in a particular application. Therefore, the method provided by the embodiment is adopted to complete the detection of the appearance quality of the power adapter to be detected.
The embodiment analyzes the power adapter to be detected from two angles of a frequency domain and an airspace, and when analyzing the frequency domain information of the power adapter to be detected, in consideration of the common condition, a high-frequency region in a gray scale image of the power adapter to be detected is a region with unevenly transformed surface of the power adapter, and the possibility of defects existing in the regions is higher, so that the embodiment distinguishes the high-frequency information and the low-frequency information based on cut-off frequency, and in consideration of the fact that the high or low set cut-off frequency directly affects the extraction precision of the high-frequency information and the low-frequency information, the embodiment firstly converts the gray scale image of the power adapter to be detected in the airspace into the frequency domain to obtain a corresponding spectrogram; the method comprises the steps of obtaining the frequency of each pixel point based on a frequency spectrogram, constructing a corresponding frequency histogram, wherein the frequency histogram can visually reflect the frequency distribution condition of the surface of the power adapter to be detected, analyzing the frequency histogram to obtain an initial cut-off frequency, obtaining high-frequency information and low-frequency information corresponding to each pixel point in a gray image of the power adapter to be detected based on the optimal cut-off frequency according to the pixel points in a circle corresponding to the initial cut-off frequency in the frequency spectrogram and the gradient values of the pixel points in the gray image of the power adapter to be detected to obtain a target cut-off frequency, namely the optimal cut-off frequency, obtaining the high-frequency information and the low-frequency information corresponding to each pixel point in the gray image of the power adapter to be detected based on the optimal cut-off frequency, and further effectively ensuring the detection accuracy of the appearance quality of the subsequent power adapter to be detected; in the embodiment, a frequency domain difference coefficient corresponding to the power adapter to be detected is calculated according to high-frequency information and low-frequency information corresponding to each pixel point in a gray-scale image of the power adapter to be detected, the frequency domain difference coefficient reflects the difference condition of the frequency domain information of the power adapter to be detected and a standard power adapter, and the larger the frequency domain difference coefficient is, the higher the possibility that the surface of the power adapter to be detected has defects is; when the airspace information of the power adapter to be detected is analyzed, the airspace difference coefficient corresponding to the power adapter to be detected is obtained based on the texture corresponding to the grayscale image of the power adapter to be detected and the texture corresponding to the grayscale image of the standard power adapter, the airspace difference coefficient reflects the difference condition of the airspace information of the power adapter to be detected and the standard power adapter, and the larger the airspace difference coefficient is, the higher the possibility that the surface of the power adapter to be detected has defects is; the method provided by the embodiment can accurately extract the high-frequency information and the low-frequency information of the power adapter to be detected, so that the analysis result is more accurate, and the detection precision of the appearance quality of the power adapter to be detected is improved.

Claims (6)

1. A power adapter appearance quality detection method based on computer vision is characterized by comprising the following steps:
acquiring a gray level image of a power adapter to be detected and a gray level image of a standard power adapter;
obtaining a spectrogram of the power adapter to be detected based on the gray level image of the power adapter to be detected; acquiring frequencies corresponding to all pixel points in the spectrogram, constructing a frequency histogram corresponding to the power adapter to be detected based on the frequencies, acquiring an initial cut-off frequency according to the frequency histogram, and acquiring a target cut-off frequency according to gradient values of pixel points in a circle corresponding to the initial cut-off frequency in the spectrogram and pixel points in a gray image of the power adapter to be detected; obtaining high-frequency information and low-frequency information corresponding to each pixel point in the gray-scale image of the power adapter to be detected according to the target cut-off frequency;
obtaining a frequency domain difference coefficient corresponding to the power adapter to be detected based on high-frequency information and low-frequency information corresponding to each pixel point in the gray-scale image of the power adapter to be detected and high-frequency information and low-frequency information corresponding to each pixel point in the gray-scale image of the standard power adapter; obtaining a space domain difference coefficient corresponding to the power adapter to be detected based on the texture corresponding to the gray level image of the power adapter to be detected and the texture corresponding to the gray level image of the standard power adapter;
judging the appearance quality grade of the power adapter to be detected based on the frequency domain difference coefficient and the space domain difference coefficient;
the obtaining of the initial cut-off frequency according to the frequency histogram includes: taking the frequency corresponding to the first trough position in the frequency histogram as an initial cut-off frequency;
the obtaining of the target cut-off frequency according to the gradient values of the pixel points in the circle corresponding to the initial cut-off frequency in the spectrogram and the pixel points in the gray scale image of the power adapter to be detected comprises:
recording pixel points with gradient values larger than a gradient threshold value in a gray level image of the power adapter to be detected as target pixel points, and counting the number of the target pixel points; calculating the ratio of the number of target pixel points to the total number of pixel points in the gray image of the power adapter to be detected, and taking the ratio as a defective pixel point ratio coefficient;
recording a circle corresponding to the initial cut-off frequency in the spectrogram as a first target circle, and obtaining a high-frequency ratio corresponding to the initial cut-off frequency according to a gray value of each pixel point in the first target circle and a gray value of each pixel point in a gray image of the power adapter to be detected;
calculating the absolute value of the difference value between the high-frequency ratio corresponding to the initial cut-off frequency and the defective pixel point ratio coefficient, recording the absolute value as a first absolute value, judging whether the first absolute value is smaller than a difference threshold value, and if so, taking the initial cut-off frequency as a target cut-off frequency; if the difference value is larger than or equal to the target cut-off frequency, taking a difference value obtained by subtracting the preset frequency from the initial cut-off frequency as the first cut-off frequency, calculating a high-frequency ratio corresponding to the first cut-off frequency, judging whether the absolute value of the difference value between the high-frequency ratio corresponding to the first cut-off frequency and the ratio coefficient of the defective pixel points is smaller than a difference threshold value, and if the absolute value of the difference value is smaller than the difference threshold value, taking the first cut-off frequency as the target cut-off frequency; if the absolute value is larger than or equal to the difference threshold, reducing the first cut-off frequency by a preset frequency, and repeating the steps until the obtained absolute value is smaller than the difference threshold, and recording the finally obtained frequency as a target cut-off frequency;
obtaining a high-frequency ratio corresponding to the initial cut-off frequency according to the gray value of each pixel point in the first target circle and the gray value of each pixel point in the gray image of the power adapter to be detected, and the method comprises the following steps:
calculating the sum of gray values corresponding to all pixel points in the first target circle, recording the sum as a first characteristic index, calculating the sum of gray values of all pixel points in a gray image of the power adapter to be detected, recording the sum as a second characteristic index, calculating the ratio of the first characteristic index to the second characteristic index, recording the ratio as a first ratio, and taking the difference value of a constant 1 and the first ratio as a high-frequency ratio corresponding to the initial cut-off frequency.
2. The method for detecting the appearance quality of the power adapter based on the computer vision of claim 1, wherein the obtaining of the frequency domain difference coefficient corresponding to the power adapter to be detected based on the high frequency information and the low frequency information corresponding to each pixel point in the grayscale image of the power adapter to be detected and the high frequency information and the low frequency information corresponding to each pixel point in the grayscale image of the standard power adapter comprises:
calculating difference indexes and cosine distances corresponding to all pixel points in the gray-scale image of the power adapter to be detected based on high-frequency information and low-frequency information corresponding to all pixel points in the gray-scale image of the power adapter to be detected and high-frequency information and low-frequency information corresponding to all pixel points in the gray-scale image of the standard power adapter;
taking the product of the difference index corresponding to each pixel point in the gray level image of the power adapter to be detected and the corresponding cosine distance as the frequency spectrum difference corresponding to each pixel point;
and calculating the sum of the frequency spectrum differences corresponding to all the pixel points in the gray level image of the power adapter to be detected, and taking the sum as the frequency domain difference coefficient corresponding to the power adapter to be detected.
3. The method for detecting the appearance quality of the power adapter based on the computer vision according to claim 2, wherein calculating the difference index corresponding to each pixel point in the gray image of the power adapter to be detected comprises:
for the gray scale image of the power adapter to be detected
Figure QLYQS_1
Each pixel point:
calculating the high frequency information corresponding to the pixel point and the gray scale image of the standard power adapter
Figure QLYQS_2
The absolute value of the difference value of the high-frequency information corresponding to each pixel point is used as a first difference; calculating the low frequency information corresponding to the pixel point and the gray scale image of the standard power adapter
Figure QLYQS_3
The absolute value of the difference value of the low-frequency information corresponding to each pixel point is used as a second difference; taking the product of the first difference and the high-frequency weight as a high-frequency difference, and taking the product of the second difference and the low-frequency weight as a low-frequency difference; and taking the sum of the high-frequency difference and the low-frequency difference as a difference index corresponding to the pixel point.
4. The method for detecting the appearance quality of the power adapter based on the computer vision according to claim 2, wherein the step of calculating the cosine distance corresponding to each pixel point in the gray-scale image of the power adapter to be detected comprises the following steps:
in gray scale image of power adapter to be detected
Figure QLYQS_4
Each pixel point is:
constructing a frequency domain vector corresponding to the pixel point according to the high-frequency information and the low-frequency information corresponding to the pixel point; in grayscale images according to standard power adapter
Figure QLYQS_5
Constructing high-frequency information and low-frequency information corresponding to each pixel point in gray scale image of standard power adapter
Figure QLYQS_6
Frequency domain vectors corresponding to the pixel points; calculating gray scale image of power adapter to be detected
Figure QLYQS_7
Frequency domain vector corresponding to each pixel point and the first in gray level image of standard power adapter
Figure QLYQS_8
And the cosine distance of the frequency domain vector corresponding to each pixel point is used as the cosine distance corresponding to the pixel point.
5. The method for detecting the appearance quality of the power adapter based on the computer vision according to claim 1, wherein obtaining the spatial domain difference coefficient corresponding to the power adapter to be detected based on the texture corresponding to the gray-scale image of the power adapter to be detected and the texture corresponding to the gray-scale image of the standard power adapter comprises:
recording a gray level co-occurrence matrix corresponding to a gray level image of a power adapter to be detected as a gray level co-occurrence matrix to be analyzed, and recording a gray level co-occurrence matrix corresponding to a gray level image of a standard power adapter as a standard gray level co-occurrence matrix; according to the gray level co-occurrence matrix to be analyzed and the standard gray level co-occurrence matrix, calculating a spatial domain difference coefficient corresponding to the power adapter to be detected by adopting the following formula:
Figure QLYQS_9
wherein, the first and the second end of the pipe are connected with each other,
Figure QLYQS_17
the spatial domain difference coefficient corresponding to the power adapter to be detected,
Figure QLYQS_12
for the number of rows of the gray level co-occurrence matrix to be analyzed,
Figure QLYQS_23
for the number of columns of the gray level co-occurrence matrix to be analyzed,
Figure QLYQS_16
for the first in the gray level co-occurrence matrix to be analyzed
Figure QLYQS_21
Go to the first
Figure QLYQS_13
The values of the columns are such that,
Figure QLYQS_22
is the mean value of the elements in the gray level co-occurrence matrix to be analyzed,
Figure QLYQS_11
is the first in the standard gray level co-occurrence matrix
Figure QLYQS_25
Go to the first
Figure QLYQS_10
The values of the columns are such that,
Figure QLYQS_19
is the mean of the elements in the standard gray level co-occurrence matrix,
Figure QLYQS_15
for the gray level co-occurrence matrix to be analyzed,
Figure QLYQS_20
is a standard gray level co-occurrence matrix,
Figure QLYQS_18
in the form of a function of the variance,
Figure QLYQS_24
for the variance of the elements in the gray level co-occurrence matrix to be analyzed,
Figure QLYQS_14
is the variance of the elements in the normal gray level co-occurrence matrix.
6. The method for detecting the appearance quality of the power adapter based on the computer vision according to claim 1, wherein the step of judging the appearance quality grade of the power adapter to be detected based on the frequency domain difference coefficient and the spatial domain difference coefficient comprises the steps of:
calculating the sum of the frequency domain difference coefficient and the space domain difference coefficient to be used as an integral difference coefficient; taking the sum of the constant 1 and the overall difference coefficient as a third characteristic index; taking the ratio of the overall difference coefficient to the third characteristic index as a defect index of the power adapter to be detected;
judging whether the defect index is less than or equal to a first defect threshold value, and if the defect index is less than or equal to the first defect threshold value, judging that the appearance quality grade of the power adapter to be detected is three grades; if the defect index is larger than the second defect threshold value, judging whether the defect index is smaller than or equal to the second defect threshold value, if so, judging that the appearance quality grade of the power adapter to be detected is of a second grade, and if so, judging that the appearance quality grade of the power adapter to be detected is of a first grade; the first defect threshold is less than the second defect threshold.
CN202211644898.7A 2022-12-21 2022-12-21 Power adapter appearance quality detection method based on computer vision Active CN115619793B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211644898.7A CN115619793B (en) 2022-12-21 2022-12-21 Power adapter appearance quality detection method based on computer vision

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211644898.7A CN115619793B (en) 2022-12-21 2022-12-21 Power adapter appearance quality detection method based on computer vision

Publications (2)

Publication Number Publication Date
CN115619793A CN115619793A (en) 2023-01-17
CN115619793B true CN115619793B (en) 2023-03-10

Family

ID=84880161

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211644898.7A Active CN115619793B (en) 2022-12-21 2022-12-21 Power adapter appearance quality detection method based on computer vision

Country Status (1)

Country Link
CN (1) CN115619793B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116237205B (en) * 2023-01-30 2023-11-24 南通市金月亮新材料科技发展有限公司 Door and window spraying adjustment method and system
CN116228764B (en) * 2023-05-08 2023-07-18 聊城市东昌府区妇幼保健院 Neonate disease screening blood sheet acquisition quality detection method and system
CN117152143B (en) * 2023-10-30 2023-12-26 南通睿智超临界科技发展有限公司 Reverse osmosis membrane surface quality detection method and system
CN117169639B (en) * 2023-11-02 2023-12-29 启东市航新实用技术研究所 Product detection method and system for power adapter production
CN117173186B (en) * 2023-11-03 2024-03-05 南通苏禾车灯配件有限公司 Train door gap parameter detection method and system
CN117408995A (en) * 2023-12-11 2024-01-16 东莞市时实电子有限公司 Power adapter appearance quality detection method based on multi-feature fusion

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114842027A (en) * 2022-04-24 2022-08-02 南通真馨家纺有限公司 Fabric defect segmentation method and system based on gray level co-occurrence matrix

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101299268B (en) * 2008-07-01 2010-08-11 上海大学 Semantic object dividing method suitable for low depth image
CN103729368B (en) * 2012-10-13 2016-12-21 复旦大学 A kind of robust audio recognition methods based on local spectrum iamge description

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114842027A (en) * 2022-04-24 2022-08-02 南通真馨家纺有限公司 Fabric defect segmentation method and system based on gray level co-occurrence matrix

Also Published As

Publication number Publication date
CN115619793A (en) 2023-01-17

Similar Documents

Publication Publication Date Title
CN115619793B (en) Power adapter appearance quality detection method based on computer vision
CN108921176B (en) Pointer instrument positioning and identifying method based on machine vision
CN116168026B (en) Water quality detection method and system based on computer vision
CN116309537B (en) Defect detection method for oil stain on surface of tab die
CN113808138B (en) Artificial intelligence-based wire and cable surface defect detection method
CN115018844B (en) Plastic film quality evaluation method based on artificial intelligence
CN115082451B (en) Stainless steel soup ladle defect detection method based on image processing
CN115063430B (en) Electric pipeline crack detection method based on image processing
CN114782329A (en) Bearing defect damage degree evaluation method and system based on image processing
CN116542982B (en) Departure judgment device defect detection method and device based on machine vision
CN115511907B (en) Scratch detection method for LED screen
CN117557820B (en) Quantum dot optical film damage detection method and system based on machine vision
CN115272303B (en) Textile fabric defect degree evaluation method, device and system based on Gaussian blur
CN115082477B (en) Semiconductor wafer processing quality detection method based on light reflection removing effect
CN115018835B (en) Automobile starter gear detection method
CN111738931B (en) Shadow removal algorithm for aerial image of photovoltaic array unmanned aerial vehicle
CN115290663A (en) Mini LED wafer appearance defect detection method based on optical detection
CN114881960A (en) Feature enhancement-based cloth linear defect detection method and system
CN114998311A (en) Part precision detection method based on homomorphic filtering
CN115601379A (en) Surface crack accurate detection technology based on digital image processing
CN116883408B (en) Integrating instrument shell defect detection method based on artificial intelligence
CN114066862A (en) Indicator identification method and system based on color gamut and contour characteristics
CN116958127B (en) Silicon wafer quality assessment method based on image features
CN117011291A (en) Watch shell quality visual detection method
CN114565563B (en) Color steel plate surface abnormity detection method based on artificial intelligence

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