Disclosure of Invention
In order to solve the technical problems, the invention aims to provide a machine vision-based method for detecting the speckles of the rubber and plastic part, which adopts the following technical scheme:
collecting a rubber and plastic part image, wherein the rubber and plastic part image contains periodic patterns; dividing the rubber and plastic part image by using different threshold values to obtain a plurality of target threshold value division graphs and corresponding division effectiveness;
performing Fourier transform on each target threshold segmentation graph to obtain a spectrogram; selecting a maximum value point and target frequency points around the maximum value point from a plurality of initial frequency points of each spectrogram, and acquiring Gaussian distribution of each target frequency point by using the maximum value point to obtain a theoretical amplitude of the target frequency point; calculating the reliability of each target frequency point according to the difference value between the real amplitude value obtained by the spectrogram and the theoretical amplitude value; selecting target frequency points which are symmetrically distributed on a preset angle in a frequency spectrogram as initial frequency point groups, wherein the product of the reliability mean value and the real amplitude mean value of each target frequency point in the initial frequency point groups is a probability to be selected, and selecting two secondary frequency point groups in each frequency spectrogram according to the probability to be selected; obtaining two target points of the multiple target threshold segmentation graphs according to the segmentation effectiveness, the probability to be selected and the secondary frequency point group of the multiple target threshold segmentation graphs; obtaining a minimum periodic area of the rubber and plastic part image from the target point, and dividing the rubber and plastic part image into a plurality of periodic areas according to the minimum periodic area;
acquiring a gray level histogram of each period region, and constructing a gray level frequency sequence according to the gray level histogram; and calculating the illumination offset groups of each period area and the adjacent period area by using the gray frequency sequence, and obtaining the spot area according to the density of the illumination offset groups.
Preferably, the segmenting the rubber and plastic part image by using different threshold values to obtain a plurality of target threshold segmentation maps and corresponding segmentation effectiveness comprises:
performing threshold segmentation on the rubber and plastic part image by using a plurality of thresholds to obtain a plurality of initial threshold segmentation images;
obtaining the connected domain area range of each initial threshold segmentation graph, wherein the reciprocal of the connected domain area range is the segmentation effectiveness;
the initial threshold segmentation map corresponding to the segmentation effectiveness greater than the preset segmentation effectiveness threshold is a target threshold segmentation map.
Preferably, the selecting of the maximum value point and the target frequency points around the maximum value point from the plurality of initial frequency points of each spectrogram includes:
each spectrogram has a plurality of initial frequency points; acquiring maximum value points in the initial frequency points based on a plurality of initial frequency points in each spectrogram;
constructing Gaussian distribution corresponding to each maximum point according to the maximum points and the amplitudes of the initial frequency points around the maximum points; obtaining the variance and the mean of Gaussian distribution corresponding to each maximum value point by using an EM (effective-energy-efficient) algorithm, and obtaining a variance range by using the variance; and taking the maximum value point as a center, and acquiring initial frequency points positioned in a variance range as target frequency points, wherein the target frequency points comprise the maximum value point.
Preferably, the calculating the reliability of each target frequency point according to the difference between the real amplitude obtained from the spectrogram and the theoretical amplitude includes:
the reliability calculation formula is as follows:
wherein,
is as follows
The reliability of individual target frequency points;
is as follows
The real amplitude of each target frequency point;
is as follows
Theoretical amplitude of each target frequency point.
Preferably, the selecting, as the initial frequency point group, target frequency points symmetrically distributed at a preset angle in the spectrogram includes:
constructing a rectangular coordinate system by taking the central point of each spectrogram as an origin, a horizontal line passing through the origin as a horizontal axis and a vertical line passing through the origin as a longitudinal axis; and selecting target frequency points which are symmetrical in a preset angle in a rectangular coordinate system as an initial frequency point group, wherein the initial frequency point group comprises a first initial frequency point group and a second initial frequency point group.
Preferably, the selecting two secondary frequency point groups in each spectrogram according to the candidate probability includes:
the secondary frequency point groups comprise a first secondary frequency point group and a second secondary frequency point group;
based on the plurality of first initial frequency point groups and the plurality of second initial frequency point groups, selecting the first initial frequency point group with the maximum probability of candidate as a first secondary frequency point group, and selecting the second initial frequency point group with the maximum probability of candidate as a second secondary frequency point group.
Preferably, the obtaining two target points of the multiple target threshold segmentation maps according to the segmentation effectiveness, the candidate probability and the secondary frequency point groups of the multiple target threshold segmentation maps includes:
the target points include a first target point and a second target point;
acquiring a first product of the segmentation effectiveness corresponding to each target threshold segmentation graph, the candidate probability corresponding to the first frequency point group and the frequency point coordinate corresponding to the first frequency point group, and summing the first products corresponding to the multiple target threshold segmentation graphs to obtain a first product sum; obtaining a second product of the segmentation effectiveness corresponding to each target threshold segmentation graph and the probability to be selected corresponding to the first frequency point group, and summing the second products corresponding to the multiple target threshold segmentation graphs to obtain a second product sum; the ratio of the first product sum to the second product sum is the absolute value of the abscissa of the first target point, and the ordinate of the first target point is 0;
obtaining a third product of the segmentation effectiveness corresponding to each target threshold segmentation graph, the candidate probability corresponding to the second secondary frequency point group and the frequency point coordinates corresponding to the second secondary frequency point group, and summing the third products corresponding to the multiple target threshold segmentation graphs to obtain a third product; obtaining a fourth product of the segmentation effectiveness corresponding to each target threshold segmentation graph and the probability to be selected corresponding to the first frequency point group, and summing the fourth products corresponding to the multiple target threshold segmentation graphs to obtain a fourth product sum; the ratio of the third product sum to the fourth product sum is an absolute value of a vertical coordinate of a second target point, and a horizontal coordinate of the second target point is 0.
Preferably, the obtaining a minimum periodic area of the rubber-plastic image from the target point, and dividing the rubber-plastic image into a plurality of periodic areas according to the minimum periodic area includes:
the reciprocal of the absolute value of the abscissa of the first target point is the length of the minimum period region; the reciprocal of the absolute value of the ordinate of the second target point is the width of the minimum period region;
and dividing the rubber and plastic part image into a plurality of periodic areas according to the minimum periodic area by taking the first pixel point at the upper left of the rubber and plastic part image as a starting point.
Preferably, the calculating, by using the gray frequency sequence, the set of illumination offsets of each period region and the adjacent period region includes:
the gray frequency sequence is circularly shifted for multiple times to obtain a shift sequence;
calculating sequence similarity of a plurality of shift sequences of each period region and gray frequency sequences of four adjacent period regions, and acquiring minimum sequence similarity corresponding to each period region and each adjacent period region, wherein each period region corresponds to four minimum sequence similarities; and constructing an illumination offset group corresponding to each period region according to the minimum sequence similarity.
Preferably, the obtaining the speckle region according to the density of the illumination offset group includes:
clustering the illumination offset group to obtain a plurality of clustering categories, wherein the clustering categories comprise a plurality of discrete points and a plurality of clusters;
acquiring a cluster group with the most illumination offset groups as a target cluster group; calculating the Manhattan distance from the discrete point to the central point of the target cluster group, and calculating the probability of the speckles according to the Manhattan distance; and the periodic region corresponding to the discrete point of the spot probability which is greater than the preset spot probability threshold is a spot region.
The embodiment of the invention at least has the following beneficial effects:
the embodiment of the invention utilizes a machine vision technology to collect the rubber and plastic part image and carry out threshold segmentation on the rubber and plastic part image to obtain a plurality of target threshold segmentation graphs and corresponding segmentation effectiveness. Carrying out Fourier transform on each target threshold segmentation graph to obtain a frequency spectrogram, acquiring a plurality of target frequency points in each frequency spectrogram, and screening secondary frequency point groups from the target frequency points; and the secondary frequency point groups are obtained by screening the target frequency points in each spectrogram, removing unreliable non-periodic or low-reliability frequency points, and finally obtaining two secondary frequency point groups in each spectrogram, wherein the two secondary frequency point groups respectively reflect the longitudinal periodicity and the transverse periodicity. Fusing the secondary frequency point groups corresponding to each spectrogram to obtain target points, obtaining the minimum period region of the rubber and plastic part image from the target points, and dividing the rubber and plastic part image into a plurality of period regions according to the minimum period region; the resulting minimum periodic areas are periodic areas such that each minimum periodic area contains a periodic pattern in the image of the rubber-plastic element. Acquiring a gray level histogram of each period region, calculating an illumination offset group corresponding to each period region according to the gray level histogram, obtaining a mottled region according to the intensity of the illumination offset group, and evaluating the quality of the rubber and plastic part according to the occupied area of the mottled region. The method comprises the steps of obtaining a minimum period area of a rubber and plastic part image by using a spectrogram, accurately segmenting a threshold value of the rubber and plastic part image under the condition that the surface brightness of the rubber and plastic part is not uniform, and determining a mottled area in the rubber and plastic part image through an illumination offset set of each period area. The purpose that the spot area cannot be accurately determined due to inaccurate threshold segmentation is achieved.
Detailed Description
In order to further illustrate the technical means and effects of the present invention adopted to achieve the predetermined objects, the following detailed description of the method for detecting the mottling of the rubber-plastic part based on machine vision, the specific implementation manner, structure, features and effects thereof according to the present invention, with reference to the accompanying drawings and the preferred embodiments, is provided. In the following description, different "one embodiment" or "another embodiment" refers to not necessarily the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any suitable manner in one or more 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 embodiment of the invention provides a specific implementation method of a rubber and plastic part mottling detection method based on machine vision, which is suitable for a rubber and plastic part mottling detection scene. The surface of the rubber and plastic part comprises a plurality of patterns, and the patterns in the transverse and longitudinal directions are periodic. A gray camera is arranged above the rubber and plastic part and used for collecting images of the rubber and plastic part, and the optical axis of the gray camera is perpendicular to the surface of the rubber and plastic part. Meanwhile, an irradiation light source is also arranged above the rubber and plastic part, the irradiation light source can be randomly arranged at the left upper part, the right upper part and the like of the rubber and plastic part, and the irradiation intensity of the irradiation light source is uniform. The method aims to solve the problem that a proper threshold value is difficult to find for segmentation when the rubber and plastic image is segmented due to the fact that the surface brightness of the rubber and plastic image is not uniform. According to the embodiment of the invention, Fourier transform is carried out on a plurality of threshold segmentation maps to convert the threshold segmentation maps into the frequency spectrograms, frequency points of the frequency spectrograms are screened to obtain the minimum period region of the rubber part image, accurate threshold segmentation is carried out on the rubber part image under the condition that the surface brightness of the rubber part is not uniform, and then the mottled region in the rubber part image is determined through the illumination offset group of each period region. The purpose that the spot area cannot be accurately determined due to inaccurate threshold segmentation is achieved.
The specific scheme of the machine vision-based rubber and plastic piece mottling detection method provided by the invention is specifically described below with reference to the accompanying drawings.
Referring to fig. 1, a flow chart of steps of a method for detecting speckles in a rubber-plastic member based on machine vision according to an embodiment of the present invention is shown, where the method includes the following steps:
step S100, collecting a rubber and plastic part image, wherein the rubber and plastic part image comprises periodic patterns; and dividing the rubber and plastic part image by using different threshold values to obtain a plurality of target threshold value division graphs and corresponding division effectiveness.
And acquiring a rubber part image by using a gray-scale camera, wherein the rubber part image comprises periodic patterns. The gray scale camera is used for collecting the image of the plastic part because the gray scale camera has more comprehensive response to photons with different wavelengths, and the detailed representation of the light flux and the image is better than that of a color camera.
When the mottling detection is carried out, the irradiation light source generally adopts a lateral light source for illumination, the image illumination intensity of the rubber and plastic image is not uniform for the whole rubber and plastic image, but because the proportion of a periodic pattern in the rubber and plastic image is very small, the illumination belonging to the same period area can be considered to be approximately uniform.
When the irradiation light source uniformly irradiates each area of the image of the rubber and plastic part, the illumination intensity of each periodic area is the same for the periodic patterns on the rubber and plastic part; for the lateral light source, the lateral light source is unevenly irradiated on the rubber and plastic part, wherein the illumination belonging to the same period area is considered to be approximately even, and the illumination intensity difference between each period area and the adjacent period area in the whole rubber and plastic part image is also similar, because the light source emitted by the illumination light source is even if the lateral light source is used for illumination, and the illumination intensity difference corresponding to each period is very small; when the illumination difference between any periodic region and the adjacent periodic region is large, or the illumination intensity difference corresponding to other periodic regions is large, the probability that the periodic region is a speckle region is considered to be large. It should be noted that the periodic region refers to an imaging region of a single pattern which is tightly arranged when the light is uniformly illuminated on the image of the rubber-plastic member, and referring to fig. 5, the selected portion of each white frame is a periodic region.
Since the patterns of the rubber parts are various in actual production and the distances between the camera and the rubber parts are also various, the situation that if only the artificially given periodic area is used, the pattern cannot be adapted to all detection conditions can be caused, and when the pattern or the distance between the camera and the rubber part is changed, the pattern with a complete period can not be obtained by using the artificially given periodic area. The embodiment of the invention aims to automatically obtain a proper periodic area according to the actual condition of each rubber and plastic part image, and the proper periodic area contains a complete pattern. Obtaining a proper periodic area, and firstly, finding a proper threshold segmented rubber and plastic part image to analyze the rubber and plastic part image. Referring to fig. 2, the step of obtaining the target threshold segmentation image specifically includes:
step S110, performing threshold segmentation on the rubber and plastic part image by using a plurality of thresholds to obtain a plurality of initial threshold segmentation maps.
And performing threshold segmentation on the acquired rubber and plastic part image by using a plurality of different thresholds to obtain a plurality of initial threshold segmentation maps. The plurality of different threshold values are arbitrary values from the gradation value 0 to 255 in the embodiment of the present invention. The threshold segmentation refers to setting the pixel values of all the pixel points larger than the threshold to be 1, and setting the pixel values of all the pixel points smaller than the threshold to be 0. Each threshold corresponds to an initial threshold segmentation map. Referring to fig. 6, the image corresponding to a in fig. 6 is an original rubber and plastic image, and the images corresponding to b, c, d, and e are four segmentation result diagrams obtained by respectively performing threshold segmentation on the original rubber and plastic image by using four different thresholds.
For a plurality of initial threshold segmentation maps, a plurality of target threshold segmentation maps need to be screened out from the initial threshold segmentation maps, the target threshold segmentation maps can reflect patterns on the rubber and plastic part more clearly, the screened initial threshold segmentation maps often segment the rubber and plastic part image into too large or too small areas, the threshold segmentation maps are less helpful for determining proper periodic areas, and therefore the threshold segmentation maps are firstly screened out.
And step S120, acquiring the connected domain area range of each initial threshold segmentation graph, wherein the reciprocal of the connected domain area range is the segmentation effectiveness.
And analyzing the connected domains of each initial threshold segmentation graph to obtain a plurality of connected domains, and calculating the area of each connected domain, wherein the area of each connected domain is the number of pixel points in each connected domain in the embodiment of the invention. And acquiring the maximum connected domain area and the minimum connected domain area of each initial threshold segmentation graph to obtain the connected domain area range corresponding to each initial threshold segmentation graph.
When the connected domain area range is too large, the threshold corresponding to the initial threshold segmentation graph after threshold segmentation is reflected to be not suitable, and because the patterns on the rubber and plastic image are periodic patterns, the threshold segmentation area in the threshold segmentation graph which is desired to be obtained by the embodiment of the invention is uniform, so the connected domain area range is as small as possible. The smaller the area difference of the connected domain is, the stronger the corresponding segmentation effectiveness is, namely, the periodic patterns of the images of the rubber and plastic parts can be reflected. That is, for an initial threshold segmentation map with strong segmentation effectiveness, the area difference of different connected domains in the initial threshold segmentation map is not too large, if the area difference is too large, the information contained in the threshold segmentation result map is invalid, so the area difference of the connected domains and the segmentation effectiveness of the initial threshold segmentation map are reflected by the area difference of the connected domains.
The reciprocal of the connected domain area range is the segmentation effectiveness.
First, the
Segmentation effectiveness of a sheet-initial threshold segmentation map
The calculation formula of (2) is as follows:
wherein,
is as follows
Expanding the maximum connected domain area of the initial threshold segmentation graph;
is as follows
Opening the minimum connected domain area of the initial threshold segmentation graph;
is as follows
The connected domain area of the tensor initial threshold segmentation map is extremely poor.
Each initial threshold segmentation map has a respective segmentation validity.
In step S130, the initial threshold segmentation map corresponding to the segmentation effectiveness greater than the preset segmentation effectiveness threshold is the target threshold segmentation map.
Obtaining the segmentation effectiveness of each initial threshold segmentation graph, and presetting a segmentation effectiveness threshold
. Comparing the segmentation effectiveness corresponding to each initial threshold segmentation graph with a preset segmentation effectiveness threshold value:
when in use
When the initial threshold segmentation maps are invalid, removing the threshold segmentation maps;
when in use
When the corresponding initial threshold segmentation maps are valid, these threshold segmentation maps are retained, wherein,
is as follows
Segmentation effectiveness of a sheet-initial threshold segmentation map
(ii) a These retained initial threshold segmentation maps serve as target threshold segmentation maps. In the embodiment of the invention, the preset segmentation effectiveness threshold is the reciprocal of half of the total area of the rubber and plastic image, and in other embodiments, the implementer can adjust the threshold according to the actual situation.
Step S200, carrying out Fourier transform on each target threshold segmentation graph to obtain a spectrogram; selecting a maximum value point and target frequency points around the maximum value point from a plurality of initial frequency points of each spectrogram, and acquiring Gaussian distribution of each target frequency point by using the maximum value point to obtain a theoretical amplitude of the target frequency point; calculating the reliability of each target frequency point according to the difference value of the real amplitude and the theoretical amplitude obtained by the spectrogram; selecting target frequency points which are symmetrically distributed on a preset angle in a frequency spectrogram as an initial frequency point group, taking the product of the reliability mean value and the real amplitude mean value of each target frequency point in the initial frequency point group as a probability to be selected, and selecting two secondary frequency point groups in each frequency spectrogram according to the probability to be selected; obtaining two target points of the multiple target threshold segmentation graphs according to the segmentation effectiveness, the candidate probability and the secondary frequency point group of the multiple target threshold segmentation graphs; and obtaining the minimum period area of the rubber and plastic part image from the target point, and dividing the rubber and plastic part image into a plurality of period areas according to the minimum period area.
And carrying out Fourier transform on each reserved target threshold segmentation graph to obtain a spectrogram, wherein each target threshold segmentation graph corresponds to one spectrogram. Referring to fig. 7, a left graph in fig. 7 is an image of a rubber and plastic part without fourier transform, and a right graph in fig. 7 is a frequency spectrum graph of the left graph after fourier transform, wherein each frequency spectrum graph has a plurality of initial frequency points. It should be noted that the distance from each initial frequency point in the spectrogram to the center point of the spectrogram is the frequency corresponding to the initial frequency point; the direction from the center point of the spectrogram to the initial frequency point is the direction of the plane wave; the gray value of the initial frequency point is the amplitude of the initial frequency point.
And screening a plurality of target frequency points from the plurality of initial frequency points, and acquiring the theoretical amplitude corresponding to each target frequency point. The purpose of screening out the target frequency point is to further obtain the frequency point capable of reflecting the minimum period of the image of the rubber and plastic part.
According to the priori knowledge, if the rubber and plastic part image is formed by vertical periodic black and white stripes, the black and white stripes of the rubber and plastic part image can be imagined as waves, the pixel point value is used as the fluctuation height, and then a horizontal left or right black wave can be obtained; if the rubber and plastic part image is formed by horizontal periodic black and white stripes, the black and white stripes of the rubber and plastic part image can be imagined as waves, and the pixel point value is taken as the fluctuation height, so that a vertically upward or downward black wave can be obtained; the black wave curve may be a superposition of a number of sine waves of different frequencies, or may be a sine wave.
If the pixel point value of the image of the plastic part is a sine wave in the horizontal direction, two horizontal and symmetrical frequency points are arranged on a spectrogram corresponding to the image of the plastic part; if the rubber and plastic image is composed of horizontal periodic black and white stripes, the pixel point value of the rubber and plastic image can be considered to be a vertical sine wave, and two vertical and symmetrical frequency points are arranged on a spectrogram corresponding to the rubber and plastic image. In the embodiment of the invention, the rubber and plastic part image has periodicity in the horizontal direction and also has periodicity in the vertical direction, so that the periodic region in the embodiment of the invention corresponds to two frequency points which are symmetrical in the horizontal direction and two frequency points which are symmetrical in the vertical direction in a frequency spectrogram.
Referring to fig. 3, two target points capable of reflecting the minimum period area of the image of the rubber part are obtained, and the image of the rubber part is divided into a plurality of period areas according to the target points, specifically:
step S210, a plurality of initial frequency points and target frequency points in each spectrogram are obtained, the theoretical amplitude of each target frequency point is obtained by using the maximum value point in the initial frequency points, and the reliability of each target frequency point is calculated according to the difference value between the real amplitude and the theoretical amplitude obtained by the spectrograms.
Each spectrogram has a plurality of initial frequency points, which are caused by that the target threshold segmentation map may have a certain periodicity in other directions besides the horizontal and vertical directions, or the pixel values at the pattern boundary of the periodic pattern of the target threshold segmentation map have a certain regularity deviation, so that the pixel values at the pattern boundary exhibit another periodicity regularity.
Based on a plurality of initial frequency points in each spectrogram, maximum value points in the initial frequency points are obtained, and a plurality of maximum value points exist in each spectrogram.
And for the maximum value points in each spectrogram, constructing Gaussian distribution corresponding to each maximum value point by using the amplitude values of the maximum value points and the initial frequency points around the maximum value points. And obtaining the variance and the mean of Gaussian distribution corresponding to each maximum point by using an EM (effective velocity) algorithm, wherein each maximum point corresponds to one Gaussian distribution. Variance of Gaussian distribution corresponding to each maximum point
Obtaining variance range, in the embodiment of the present invention, setting the variance range to
In other embodiments, the range may be adjusted by the implementer according to the actual situation.
For each spectrogram, the position of each maximum value point is taken as the center to obtain the position of each maximum value pointRange of difference
The initial frequency points in the frequency domain are target frequency points, wherein the target frequency points comprise maximum value points.
And obtaining the theoretical amplitude of each target frequency point according to the Gaussian distribution corresponding to each maximum value point. And after the Gaussian distribution corresponding to each maximum point is obtained, substituting the distance between each target frequency point and the corresponding maximum point into the Gaussian distribution corresponding to the maximum point to obtain the theoretical amplitude of the target frequency point.
And calculating the reliability of each target frequency point according to the difference value between the real amplitude and the theoretical amplitude obtained by the spectrogram, wherein the real amplitude is obtained from the gray value corresponding to the frequency point in the spectrogram.
The first part is
The reliability calculation formula of each target frequency point is as follows:
wherein,
is as follows
The real amplitude of each target frequency point;
is as follows
Theoretical amplitude of each target frequency point.
The smaller the difference between the real amplitude and the theoretical amplitude corresponding to the target frequency point is, the greater the corresponding reliability is, and the greater the probability that the target frequency point belongs to the frequency point in the initial frequency point group is.
Step S220, selecting target frequency points which are symmetrically distributed on a preset angle in the frequency spectrogram as an initial frequency point group, taking the product of the reliability mean value and the real amplitude mean value of each target frequency point in the initial frequency point group as a candidate probability, and selecting two secondary frequency point groups in each frequency spectrogram according to the candidate probability.
And for each spectrogram, constructing a rectangular coordinate system by taking the central point of each spectrogram as an origin, a horizontal line passing through the origin as a horizontal axis and a vertical line passing through the origin as a vertical axis.
The position coordinates of each target frequency point in the spectrogram are acquired, and because the rubber and plastic part image is required to be acquired in the embodiment of the invention in a longitudinal and transverse periodicity mode, only two symmetrical points of the target frequency points which are on the transverse axis and the longitudinal axis of the rectangular coordinate system and are symmetrical about the original point are required to be selected from the target frequency points as the initial frequency point group to be selected in the embodiment of the invention.
Target frequency points symmetrical in a preset angle in a rectangular coordinate system are selected as initial frequency point groups, and the preset angles are 0 degree, 90 degrees, 180 degrees and 270 degrees in the embodiment of the invention. Namely, selecting target frequency points which are symmetrical on a horizontal axis and a vertical axis in a rectangular coordinate as initial frequency point groups, wherein the initial frequency point groups comprise a first initial frequency point group and a second initial frequency point group, and the first initial frequency point group is the target frequency points which are symmetrical on the horizontal axis; the second initial frequency point group is a target frequency point which is symmetrical on the longitudinal axis, and because the target frequency point coordinates in each initial frequency point group are symmetrical, each initial frequency point group comprises two target frequency points.
And the product of the reliability mean value and the real amplitude mean value of each target frequency point in the initial frequency point group is the probability to be selected.
The first part is
Probability of candidate of initial frequency point group
The calculation formula of (2) is as follows:
wherein,
is as follows
In the initial frequency point group
Reliability of each target frequency point;
is as follows
In the initial frequency point group
Reliability of each target frequency point;
is as follows
And the real amplitude mean value of the target frequency points in the initial frequency point group.
And acquiring the candidate probabilities corresponding to the plurality of first initial frequency point groups and the candidate probabilities corresponding to the plurality of second initial frequency point groups. And screening two secondary frequency point groups from the plurality of first initial frequency point groups and the plurality of second initial frequency point groups according to the probability to be selected. The secondary frequency point groups comprise a first secondary frequency point group and a second secondary frequency point group.
Specifically, for each spectrogram, based on a plurality of first initial frequency point groups and a plurality of second initial frequency point groups, the first initial frequency point group with the highest probability to be selected serves as a first secondary frequency point group; and the second initial frequency point group with the maximum candidate probability is used as a second secondary frequency point group.
And step S230, obtaining two target points of the multiple target threshold segmentation maps according to the segmentation effectiveness, the candidate probability and the secondary frequency point groups of the multiple target threshold segmentation maps.
The frequency spectrogram corresponding to each target threshold segmentation graph has a first secondary frequency point group and a second secondary frequency point group. And fusing the two secondary frequency point groups in each spectrogram to obtain a target point which can reflect the minimum positive period and is required by the embodiment of the invention. The target points comprise a first target point and a second target point, the first target point reflects the longitudinal periodicity of the rubber and plastic image, and the second target point reflects the transverse periodicity of the rubber and plastic image.
And acquiring a first product of the segmentation effectiveness corresponding to each target threshold segmentation graph, the candidate probability corresponding to the first frequency point group and the frequency point coordinate corresponding to the first frequency point group, and summing the first products corresponding to the multiple target threshold segmentation graphs to obtain a first product sum.
And obtaining a second product of the segmentation effectiveness corresponding to each target threshold segmentation graph and the candidate probability corresponding to the first frequency point group, and summing the second products corresponding to the multiple target threshold segmentation graphs to obtain a second product sum.
The ratio of the first product sum to the second product sum is the absolute value of the abscissa of the first target point, the ordinate of the first target point is 0, and the absolute value of the abscissa fused with the first target point is obtained by fusing the coordinates of the first frequency point groups of the multiple target threshold segmentation maps.
Absolute value of abscissa of the first target point
Comprises the following steps:
wherein,
is as follows
Opening the segmentation effectiveness of the target threshold segmentation map;
is as follows
Opening the candidate probability of the first frequency point group of the target threshold segmentation graph;
is as follows
Opening absolute values of abscissas of a first time frequency point group of the target threshold segmentation graph;
the number of graphs to segment for the target threshold.
And acquiring a third product of the segmentation effectiveness corresponding to each target threshold segmentation graph, the candidate probability corresponding to the second secondary frequency point group and the frequency point coordinates corresponding to the second secondary frequency point group, and summing the third products corresponding to the multiple target threshold segmentation graphs to obtain a third product.
And obtaining a fourth product of the segmentation effectiveness corresponding to each target threshold segmentation graph and the candidate probability corresponding to the second frequency point group, and summing the fourth products corresponding to the multiple target threshold segmentation graphs to obtain a fourth product sum.
The ratio of the third product sum to the fourth product sum is the absolute value of the ordinate of the second target point, the abscissa of the second target point is 0, and the absolute value of the ordinate fused with the second target point is obtained by fusing the second secondary frequency point group coordinates of the multiple target threshold segmentation maps.
Absolute value of ordinate of the second target point
Comprises the following steps:
wherein, among others,
is as follows
Opening the segmentation effectiveness of the target threshold segmentation map;
is as follows
Opening the candidate probability of the second frequency point group of the target threshold segmentation graph;
is as follows
Opening absolute values of vertical coordinates of a second secondary frequency point group of the target threshold segmentation graph;
the number of graphs to segment for the target threshold.
The first time frequency point groups of the multiple target threshold segmentation graphs are fused to obtain a first target point, and the coordinate of the first target point is
Obtaining a second target point after the second frequency point groups of the multiple target threshold segmentation graphs are fused, wherein the coordinate of the second target point is
。
In all secondary frequency point groups, the target threshold segmentation graph with high effectiveness and the secondary frequency point group with higher candidate probability are more worthy of being trusted, so that the target point is determined by weighting the effectiveness and the candidate probability together.
Step S240, obtaining a minimum period area of the rubber and plastic image from the target point, and dividing the rubber and plastic image into a plurality of period areas according to the minimum period area.
Because the distance from the frequency point to the center point of the spectrogram in the spectrogram is the frequency corresponding to the frequency point. The first target point obtained by final calculation is only the abscissa, and the ordinate is 0; the second target point is only ordinate, with 0 on the abscissa. Therefore, the absolute value of the abscissa of the first target point and the absolute value of the ordinate of the second target point are distances corresponding to the two target points, i.e., frequencies corresponding to the two target points.
The first target point can reflect the transverse minimum period in the rubber and plastic part image, and the second target point can reflect the longitudinal minimum period in the rubber and plastic part image.
Since the frequency and the period are inversely related, the period can be represented by the inverse of the frequency.
The reciprocal of the absolute value of the abscissa of the first target point is the length of the minimum period region, and the reciprocal of the absolute value of the ordinate of the second target point is the width of the minimum period region, that is, the minimum period region is obtained.
And dividing the rubber and plastic part image into a plurality of periodic regions according to the obtained minimum periodic region by taking the first pixel point at the upper left of the rubber and plastic part image as a starting point.
Step S300, acquiring a gray level histogram of each period region, and constructing a gray level frequency sequence according to the gray level histogram; and calculating the illumination offset groups of each period area and the adjacent period areas by utilizing the gray frequency sequence, and obtaining the spot areas according to the density degree of the illumination offset groups.
After the rubber and plastic part is divided into a plurality of periodic areas, the illumination offset of each area is calculated according to the divided periodic areas, and the mottled areas are obtained. The illumination offset refers to a condition that illumination of each periodic region changes relative to four periodic regions adjacent to the periodic region in the vertical and horizontal directions. Because the patterns of the rubber-plastic parts in each periodic area are the same, under the condition of uniform illumination, the illumination offset of each periodic area corresponding to the adjacent area of each periodic area is the same or similar, and it should be noted that even if the illumination light source adopts a side light source for illumination, the illumination can be considered to be approximately uniform.
Referring to fig. 4, the step of obtaining the mottle area specifically includes:
step S310, acquiring a gray level histogram of each period area, and constructing a gray level frequency sequence according to the gray level histogram.
And acquiring a gray level histogram of each period region in the image of the rubber and plastic part, and constructing a gray level frequency sequence corresponding to each period region by taking the gray level as a serial number and the frequency of the occurrence of the gray level as a value. Each period region corresponds to a gray frequency sequence.
In step S320, the gray frequency sequence is used to calculate the set of illumination offsets for each period region and the adjacent period regions.
Obtaining gray scale of rubber and plastic part image
Generating a shift step interval
Each integer in the shift step interval is extracted as a shift step, i.e. the step of each shift is increased by 1. The grayscale frequency sequence is cyclically shifted, for example, the grayscale frequency sequence is shifted by 1 step in the first shift, the grayscale frequency sequence is shifted by 2 steps in the second shift (2 nd shift), … …, and the grayscale frequency sequence is shifted by n steps in the nth shift. And taking the shifted gray frequency sequence as a shift sequence. And circularly shifting the gray frequency sequence for multiple times to obtain multiple shift sequences.
Calculating sequence similarity of a plurality of shift sequences of each period region and gray frequency sequences of four adjacent period regions, and acquiring minimum sequence similarity corresponding to each period region and each adjacent period region, wherein each period region corresponds to four minimum sequence similarities; and constructing an illumination offset group corresponding to each period region according to the minimum sequence similarity.
If each periodic area is taken as a coordinate point and placed in a rectangular coordinate system, the abscissa of the rectangular coordinate system is the number of rows of the periodic area from the lower left corner in the rubber-plastic image, and the ordinate of the rectangular coordinate system is the number of columns of the periodic area from the lower left corner in the rubber-plastic image, namely the periodic area pair of the lowest layer in the rubber-plastic imageThe corresponding abscissa is 1, the ordinate corresponding to the periodic region of the leftmost layer is 1, the row and column positions of the periodic region in the image of the rubber and plastic part are corresponding coordinate positions, the periodic region of the lower left corner of the image is taken as a starting point, the coordinate of the periodic region of the lower left corner is (1, 1), and each periodic region corresponds to a rectangular coordinate. Taking the periodic region w as an example, let the rectangular coordinate of the periodic region w be
![Figure DEST_PATH_IMAGE080](https://patentimages.storage.***apis.com/68/f1/b0/851384f454505a/DEST_PATH_IMAGE080.png)
The rectangular coordinates corresponding to four adjacent periodic regions, i.e. the upper, the lower, the left and the right, of the periodic region w are respectively
。
Acquiring gray frequency sequences of four adjacent periodic regions of a periodic region w, namely an upper periodic region, a lower periodic region, a left periodic region and a right periodic region and a plurality of shift sequences of the periodic region w.
Sequence similarity of a plurality of shift sequences of the period region w and gray frequency sequences of four adjacent period regions is calculated.
Current cycle region number
The shift sequence obtained by the secondary shift and the periodic region
Sequence similarity of gray frequency sequences of adjacent periodic regions
The calculation formula of (2) is as follows:
wherein,
for the current cycle region
The shift sequence obtained by the secondary shift and the periodic region
The regular distance between the two sequences of the gray frequency sequences of the adjacent periodic regions after the gray frequency sequences are processed by a dynamic time regular algorithm;
for the current cycle region
The shift sequence obtained by the secondary shift and the periodic region
L2 distance of the gray frequency sequence of adjacent periodic regions.
And acquiring the minimum sequence similarity corresponding to each period region w and each adjacent period region, and acquiring the shift step corresponding to the minimum sequence similarity, wherein the shift step is the illumination offset of the adjacent period region.
For coordinates above the periodic region w of
The corresponding minimum sequence similarity of the adjacent periodic regions is obtained, and the step length corresponding to the minimum sequence similarity is set as follows:
then the corresponding coordinate
The illumination offset of the adjacent periodic region is
;
For the coordinates below the periodic region w of
The corresponding minimum sequence similarity of the adjacent periodic regions is obtained, and the step length corresponding to the minimum sequence similarity is set as follows:
then the corresponding coordinate
The illumination offset of the adjacent periodic region is
;
To the left of the periodic region w
The corresponding minimum sequence similarity of the adjacent periodic regions is obtained, and the step length corresponding to the minimum sequence similarity is set as follows:
then the corresponding coordinate
The illumination offset of the adjacent periodic region is
;
To the right of the periodic region w
The corresponding minimum sequence similarity of the adjacent periodic regions is obtained, and the step length corresponding to the minimum sequence similarity is set as follows:
then the corresponding coordinate
The illumination offset of the adjacent periodic region is
;
Then the final corresponding illumination offset group of the periodic region w is:
。
and acquiring an illumination offset group corresponding to each period area, wherein each period area has the illumination offset group corresponding to each period area.
And step S330, obtaining a mottled area according to the density of the illumination offset group.
In the embodiment of the present invention, a single fixed light source is used, and if there is no mottle on the image of the rubber member, the set of illumination offsets of the regions on each image of the rubber member should be similar. The spot area is determined according to the density of the illumination offset group, or the spot area is determined according to the dissimilarity of the illumination offset groups of the current area and other areas.
And for the illumination offset groups corresponding to the plurality of periodic regions, clustering the illumination offset groups by using a density clustering algorithm (DBSCAN) to obtain a plurality of clustering categories, wherein the clustering categories comprise a plurality of discrete points and a plurality of clusters.
The rough probability of the periodic area corresponding to the discrete points is the flower spot area, and the flower spot probability that the periodic area corresponding to each discrete point is the flower spot area is calculated. Specifically, the cluster with the largest illumination offset group is obtained as the target cluster. And calculating the Manhattan distance (L1 distance) from each discrete point to the central point of the target cluster, and calculating the probability of the speckles according to the Manhattan distance. The farther the discrete point is from the cluster center point, the lower the similarity between the discrete point and the cluster is reflected, and the greater the speckle probability that the periodic region corresponding to the discrete point is the speckle region.
The first part is
Mottle probability of discrete points
The calculation formula of (2) is as follows:
wherein,
is as follows
The corresponding manhattan distances of the discrete points.
Presetting the probability threshold of mottle
When is coming into contact with
And when the pattern is printed, the periodic area corresponding to the discrete point is not the mottled area.
When in use
And when the pattern is printed, the periodic area corresponding to the discrete point is not the mottled area. In the embodiment of the present invention, the preset mottle probability threshold is 0.73, and in other embodiments, the threshold may be adjusted by an implementer according to actual situations.
And comparing the plaque probability of each discrete point with a preset plaque probability to obtain a plaque area.
And acquiring the spot area of the spot area, and calculating the ratio of the spot area to obtain the spot degree.
And when the mottling degree is larger than the preset mottling degree threshold value, the quality of the rubber and plastic part is considered to be not in accordance with the requirement, and the re-melting and re-manufacturing are required. In the embodiment of the present invention, the threshold of the mottle degree is preset to be 0.3, and in other embodiments, the threshold may be adjusted by an implementer according to actual situations.
And when the mottling degree is less than or equal to the preset mottling degree threshold value, the quality of the rubber and plastic part is considered to meet the requirement, and the rubber and plastic part can be delivered from a factory.
In summary, the embodiment of the present invention utilizes the machine vision technology to acquire the rubber-plastic image and perform threshold segmentation on the rubber-plastic image to obtain a plurality of target threshold segmentation maps and corresponding segmentation effectiveness. Carrying out Fourier transform on each target threshold segmentation graph to obtain a spectrogram, acquiring a plurality of initial frequency points and target frequency points in each spectrogram, screening initial frequency point groups and secondary frequency point groups from the target frequency points, fusing the secondary frequency point groups corresponding to each spectrogram to obtain target points, obtaining a minimum period region of the rubber and plastic part image from the target points, and dividing the rubber and plastic part image into a plurality of period regions according to the minimum period region. Acquiring a gray level histogram of each period region, calculating an illumination offset group corresponding to each period region according to the gray level histogram, obtaining a mottled region according to the intensity of the illumination offset group, and evaluating the quality of the rubber and plastic part according to the occupied area of the mottled region. The method comprises the steps of obtaining a minimum period area of a rubber and plastic part image by using a spectrogram, accurately segmenting a threshold value of the rubber and plastic part image under the condition that the surface brightness of the rubber and plastic part is not uniform, and determining a mottled area in the rubber and plastic part image through an illumination offset set of each period area. The purpose that the spot area cannot be accurately determined due to inaccurate threshold segmentation is achieved.
It should be noted that: the precedence order of the above embodiments of the present invention is only for description, and does not represent the merits of the embodiments. And specific embodiments thereof have been described above. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.