Image quality defect detection system based on machine vision
Through the machine vision-based image quality defect detection system, the degree of smoothness of motion blur in the advertising image and the edge of the blur defect is solved, and the problem of difficulty in detecting and positioning of blurred parts in the advertising image in the prior art is solved, and higher detection accuracy and image quality are achieved.
Patent Information
- Application Number
- CN202510300864.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-14
- Publication Date
- 2025-06-27
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The prior art is difficult to effectively detect and locate the blurred parts in the advertising image, and it is impossible to specifically assist the detector in finding the blurred parts and making judgments.
Using an image quality defect detection system based on machine vision, the initial edge acquisition module, suspected fuzzy edge acquisition module, fitted line acquisition module, fuzzy defect degree calculation module and fuzzy defect edge acquisition module are used to calculate the smoothness of motion blur in the image, obtain the suspected fuzzy edge, calculate its degree of blurry defect and existence, and finally obtain the fuzzy defect edge.
Improve the detection accuracy of blurred edges in advertising images, assisting staff to find blurred parts and make judgments, and improve the quality of advertising images.
Smart Images

Figure CN120219332A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image detection, and particularly to an image quality defect detection system based on machine vision. Background Art
[0002] With the rapid development of the advertising industry, advertising images play a crucial role in brand promotion and product marketing. However, when the object being photographed moves or makes a movement during the shooting process, partial blurring is likely to occur in the captured image. The slight blurring caused by slight movement is not easily detectable by the human eye. Therefore, it is necessary to infer the image quality based on machine vision.
[0003] When traditionally analyzing whether there is blurring in an image through image processing, the canny edge detection algorithm is generally used to find the edges in the image, and then the blurring degree of the image is measured by the gradient of the image edges. This method determines whether there is blurring by the gradient values of the edge pixel points, so it will identify some edges with relatively small gradient values as blurring. Moreover, this method can only evaluate the blurring degree of the overall image and cannot specifically locate the blurring part, making it unable to well assist the detection personnel in finding the blurring part and making a judgment. Summary of the Invention
[0004] In order to solve the above technical problems, the purpose of the present invention is to provide an image quality defect detection system based on machine vision, and the specific technical solution adopted is as follows:
[0005] An embodiment of the present invention provides an image quality defect detection system based on machine vision, mainly including:
[0006] An initial edge acquisition module, configured to acquire an advertising grayscale image and obtain all the edges in the image, denoted as the initial edges;
[0007] A suspected blurring edge acquisition module, configured to calculate the motion blurring smoothness degree of an initial edge based on the coordinates, quantity, and gradient direction entropy of the edge pixel points of the initial edge, and acquire the suspected blurring edges;
[0008] A fitting straight line acquisition module, configured to use the coordinates of the edge pixel points of the suspected blurring edges to perform fitting to obtain a coordinate fitting straight line; acquire the adjacent pixel points of an edge pixel point of the suspected blurring edges; and obtain the fitting straight line of the edge pixel point according to the actual coordinates and the fitting coordinates of the adjacent pixel points;
[0009] The fuzzy defect degree calculation module is used to draw a straight line perpendicular to an edge pixel point through the edge pixel point, which is denoted as the gradient straight line; starting from the edge pixel point, a preset number of pixel points are sequentially taken in two directions of the gradient straight line to form two gradient pixel point groups; the fuzzy defect degree of the suspected fuzzy edge is calculated according to the two gradient pixel point groups corresponding to each edge pixel point.
[0010] The fuzzy defect edge acquisition module is used to obtain similar edges of the suspected fuzzy edge; calculate the fuzzy defect existence degree of the suspected fuzzy edge according to the fuzzy defect degree and slope of the similar edge; multiply the fuzzy defect existence degree and the fuzzy defect degree of the suspected fuzzy edge and normalize to obtain the comprehensive defect degree, and then obtain the fuzzy defect edge.
[0011] Preferably, all edges in the image are obtained, denoted as the initial edges, including:
[0012] Use the canny edge detection algorithm to obtain all edges in the advertisement grayscale image. For the edges with nodes, starting from the nodes, the edges are sequentially divided into independent edges, and the edges without nodes are not processed to obtain the initial edges, where the nodes are the nodes at the intersections of the edges.
[0013] Preferably, based on the coordinates, quantity, and gradient direction entropy of the edge pixel points of an initial edge, calculate the motion blur smoothness degree of the initial edge and obtain the suspected fuzzy edge, including:
[0014] Sort the coordinates of the edge pixel points of the initial edge in the order from left to right and from top to bottom to obtain a coordinate sequence; obtain the ratio of the difference in abscissa and the difference in ordinate of every two adjacent coordinates in the coordinate sequence corresponding to an initial edge, which is denoted as the change rate of the edge pixel point corresponding to the latter coordinate of every two adjacent coordinates; take the reciprocal of the product of the mean value, standard deviation, gradient direction entropy of the edge pixel points, and the quantity of the edge pixel points of the initial edge and normalize to obtain the motion blur smoothness degree of the initial edge.
[0015] The initial edges with a motion blur smoothness degree greater than the first threshold are the suspected fuzzy edges.
[0016] Preferably, obtain the neighboring pixel points of an edge pixel point of the suspected fuzzy edge, including:
[0017] Starting from an edge pixel point, along the direction of the suspected fuzzy edge, obtain a set number of pixel points closest to the edge pixel point in the order of taking points from left to right and from top to bottom as the neighboring pixel points of the edge pixel point.
[0018] Preferably, obtaining the fitting line of the edge pixel according to the actual coordinates and fitting coordinates of adjacent pixel points includes:
[0019] Calculating the Euclidean distance between the fitting coordinates and actual coordinates of an adjacent pixel point, normalizing the reciprocal of the sum of the Euclidean distance and the first parameter to obtain the coordinate weight of the adjacent pixel point; multiplying the weighted weight of an adjacent pixel point by the actual coordinates of the adjacent pixel point to obtain the weighted coordinates; using the actual coordinates of an edge pixel point and the weighted coordinates of the adjacent pixel points of the edge pixel point for curve fitting to obtain the fitting line of the edge pixel point.
[0020] Preferably, calculating the blurring defect degree of the suspected blurry edge according to two gradient pixel point groups corresponding to each edge pixel point includes:
[0021] Fitting the gray values of the pixel points in a gradient pixel point group of an edge pixel point by using the least squares method to obtain a linear fitting function, where the slope of the linear fitting function is the slope corresponding to the gradient pixel point group, and obtaining the fitting gray values of the pixel points in the gradient pixel point group;
[0022] Obtaining the average value of the absolute values of the slopes of the two gradient pixel point groups corresponding to the edge pixel point, denoted as the first average value; summing the absolute values of the differences between the fitting gray values and actual gray values of each pixel point in a gradient pixel point group to obtain the cumulative fitting difference of the gradient pixel point group, and obtaining the average value of the cumulative fitting differences of the two gradient pixel point groups corresponding to the edge pixel point, denoted as the second average value;
[0023] Multiplying the ratio of the first average value to the second average value, the absolute value of the Pearson correlation coefficient of the gray values in the two gradient pixel point groups, and the standard deviation of the gray values of the pixel points within the window centered on the edge pixel point to obtain the blurring feature of the edge pixel point; averaging the blurring features of all edge pixel points of the suspected blurry edge to obtain the blurring defect degree of the suspected blurry edge.
[0024] Preferably, obtaining the similar edge of the suspected blurry edge includes:
[0025] Intercepting the coordinate fitting line of the suspected blurry edge at both ends of the suspected blurry edge to obtain a fitting line segment; constructing a square with the fitting line segment as the median line, where the side length of the square is the same as the length of the fitting line segment; obtaining all suspected blurry edges within the square, denoted as adjacent edges, obtaining the coordinate fitting lines of the adjacent edges, and obtaining the slopes of the adjacent edges; calculating the difference between the slope of the coordinate fitting line of the suspected blurry edge and the slopes of the adjacent edges, and taking the two adjacent edges with the smallest difference as the similar edges of the suspected blurry edge.
[0026] Preferably, calculating the degree of existence of fuzzy defects of suspected fuzzy edges according to the degree of fuzzy defects and slopes of similar edges includes:
[0027] Obtaining the coordinate sequence of the similar edge; calculating the similarity between the gray values in the coordinate sequence of the suspected fuzzy edge and the gray values in the coordinate sequence of the similar edge by using the DTW algorithm, denoted as the gray similarity; respectively obtaining the absolute values of the differences between the slopes of the coordinate fitting lines of the two similar edges and the slope of the coordinate fitting line of the suspected fuzzy edge, and averaging the two absolute values of the differences to obtain an average value, and the reciprocal of the average value is the degree of parallelism; multiplying the average value of the degrees of fuzzy defects of the two similar edges, the average value of the gray similarities between the two similar edges and the suspected fuzzy edge, and the degree of parallelism to obtain the degree of existence of fuzzy defects of the suspected fuzzy edge.
[0028] Preferably, obtaining the fuzzy defect edge includes:
[0029] The suspected fuzzy edge with the comprehensive defect degree greater than or equal to the second threshold is the fuzzy defect edge.
[0030] The embodiments of the present invention have at least the following beneficial effects: By obtaining the initial edge in the advertisement gray image and calculating the motion blur smoothness of the initial edge, the present invention preliminarily screens the initial edge to obtain the suspected fuzzy edge, reduces the subsequent calculation amount, and improves the calculation efficiency; further, by obtaining the gradual change feature and gray distribution feature of the adjacent pixels of the edge pixels of the suspected fuzzy edge, the degree of fuzzy defects of the suspected fuzzy edge is obtained, and according to the distribution feature of the suspected fuzzy edge, the degree of existence of its fuzzy defects is further obtained. By combining the degree of existence of its fuzzy defects and the degree of fuzzy defects, the edge with fuzzy defects is obtained, thereby improving the detection accuracy of the fuzzy edge in the advertisement image, assisting the staff to find the fuzzy part and make a judgment, and improving the quality of the advertisement image. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0032] Figure 1 It is a system block diagram of an image quality defect detection system based on machine vision provided by an embodiment of the present invention;
[0033] Figure 2 It is an advertisement schematic diagram of an image quality defect detection system based on machine vision provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0034] In order to further elaborate on the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, details the specific implementation manner, structure, features and effects of an image quality defect detection system based on machine vision proposed according to the present invention. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. In addition, the specific features, structures, or characteristics in one or more embodiments can be combined in any suitable form.
[0035] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which the present invention belongs.
[0036] The following specifically describes the specific solution of an image quality defect detection system based on machine vision provided by the present invention in conjunction with the accompanying drawings.
[0037] Embodiment:
[0038] The main application scenario of the present invention is: analyzing the blurred edges in the advertisement image, and then detecting the blurred parts in the advertisement image to achieve the purpose of detecting the quality defects of the advertisement image.
[0039] Please refer to Figure 1 , which shows a system block diagram of an image quality defect detection system based on machine vision provided by an embodiment of the present invention. The system includes the following modules:
[0040] An initial edge acquisition module, configured to acquire an advertisement grayscale image and obtain all the edges in the image, denoted as initial edges.
[0041] Acquire the captured advertisement image, perform grayscale processing on the obtained advertisement image, and denote it as the advertisement grayscale image. An example of the advertisement image is as Figure 2 shown.
[0042] Furthermore, during the process of capturing the advertisement image, if the captured object moves, it will cause local blur defects in the advertisement image. Therefore, it is necessary to acquire the edges in the advertisement grayscale image.
[0043] Specifically, all edges in the grayscale advertisement image are obtained through the Canny edge detection algorithm. Since the local features of the edges need to be analyzed later, it is necessary to map the obtained edges back to the grayscale advertisement image for marking. Since the edges obtained by Canny edge detection are continuous for the entire object, while blurring generally occurs locally for the whole (such as local blurring of a human hand), when analyzing it, the edges of the entire object need to be divided into each edge for analysis to obtain the specific location of local blurring. For all the edges obtained by using the Canny edge detection algorithm, there may be intersecting edges among them, so they need to be separated to facilitate subsequent analysis.
[0044] During the process of marking the obtained edges, to avoid edge intersections that may affect subsequent analysis. For the edges with nodes, starting from the nodes, the edges are sequentially divided into independent edges, removing the nodes among them; for the edges without nodes, normal marking can be done. For example, for two intersecting cross-shaped edges, they can be divided into four independent edges. Among them, a node is the intersection of edges, and thus the initial edges are obtained.
[0045] The suspected blurred edge acquisition module is used to calculate the motion blur smoothness degree of an initial edge based on the coordinates, quantity, and gradient direction entropy of the edge pixel points of the initial edge, and acquire the suspected blurred edges.
[0046] During the process of shooting the advertisement image, if the shooting object moves, it will cause local blurring defects in the image. After obtaining the initial edges in the image through the edge detection algorithm, since the reason for the blurring defect is the movement of the shooting object, the edges corresponding to the blurring defects are the edges in the movement direction of the shooting object. Since the shutter time of the shooting image is short, the movement direction of the shooting object can be simply captured and the movement trajectory is short, that is, the change rate of the blurred edges is low and the overall change trend is relatively gentle. In summary, the motion blur smoothness degree of each initial edge can be obtained through the length, mean and standard deviation of the change rate, and the gradient direction entropy of the initial edge, and then it can be judged whether there are blurring defects.
[0047] For any initial edge, obtain the coordinates of all the edge pixel points in it, and sort the coordinates of the edge pixel points of the initial edge in the order from left to right and from top to bottom according to the distribution characteristics of the initial edge to obtain a coordinate sequence.
[0048] For the blurred edges to be found in this solution, since the shutter time of the captured image is short, the corresponding captured motion direction is simple, and the motion blur area is small, that is, the motion trajectory of the blurred edge is simple and the area is small. Therefore, for any initial edge, the smaller the change rate of each pixel point, the smaller the fluctuation degree of the change rate, and the fewer the number of edge pixel points, the higher the smoothness of the edge, and the shorter the edge length, that is, the more likely it is to be a motion blurred edge.
[0049] For a motion blurred edge, its edge smoothness is not only manifested as a position distribution feature, but there is also a gray level distribution feature between edge pixel points. The blurred edge is caused by the movement of the captured object, and the shutter is short during shooting, and the captured direction of the movement of the captured object is simple, so the gradient direction of its corresponding edge is consistent, that is, the edge gradient direction entropy is small.
[0050] Therefore, obtain the ratio of the difference in the abscissa and the difference in the ordinate of every two adjacent coordinates in the coordinate sequence corresponding to an initial edge, which is denoted as the change rate of the edge pixel point corresponding to the latter coordinate in every two adjacent coordinates; take the reciprocal of the product of the mean value, standard deviation, gradient direction entropy of the edge pixel points, and the number of edge pixel points of the initial edge and normalize it to obtain the motion blur smoothness of the initial edge.
[0051] The specific calculation formula is as follows:
[0052]
[0053] Among them, αi is the motion blur smoothness of the i-th initial edge; μ bi and θ bi respectively represent the mean value and standard deviation of the change rate of the edge pixel points of the i-th initial edge; μ bi *θ bi The smaller it is, the better the smoothness of the initial edge and the more likely it is to be a motion blurred smooth edge; -Σ ia p(ia)logp(ia) represents the gradient direction entropy of the i-th initial edge, p(ia) represents the probability that the edge gradient direction a appears among the edge pixel points of the i-th initial edge, and the smaller the gradient direction entropy, the more consistent the edge gradient direction and the greater the possibility that the edge is a motion blurred smooth edge; Gi is the number of edge pixel points of the i-th initial edge, that is, the length of the edge, and the shorter the edge, the higher the possibility that the edge is a motion blurred edge. Thus, the motion blur smoothness of each initial edge can be obtained.
[0054] The motion blur smoothness of the initial edge can be obtained as above. Since the motion blur edge has a relatively high smoothness, a first threshold f is set (the empirical value of f is taken as f = 0.6, and the implementer can adjust it according to the actual situation). The initial edges with a motion blur smoothness greater than the first threshold f are marked as suspected blurred edges, and then the next calculation is performed.
[0055] The fitting straight line acquisition module is used to obtain a coordinate fitting straight line by fitting the coordinates of the edge pixel points of the suspected blurred edge; obtain the neighboring pixel points of an edge pixel point of the suspected blurred edge; and obtain the fitting straight line of this edge pixel point according to the actual coordinates and the fitting coordinates of the neighboring pixel points.
[0056] Since the blurred defect part generates a trailing shadow starting from the part where the action occurs or the whole part generates artifacts to form a blur, the blurred defect part not only has a smoothness feature at the edge, but also has an obvious blur feature in the local gray distribution of its edge area. Since there are trailing shadows on both sides of the blurred edge due to motion, the pixel points in the motion part have a gradual change feature in the direction perpendicular to the motion direction with the blurred edge as the dividing line. Although the motion blur edge has good smoothness, some blurred edges still have irregular situations. Therefore, when determining the gradual change direction of each motion blur edge pixel point, not only the local edge change feature needs to be considered, but also the edge change feature compared with the whole needs to be considered to find the edge fitting function that best fits this pixel point, so as to obtain a more accurate gradual change direction; since the pixel points on both sides of the blurred edge have obvious blur features, it corresponds to poor uniformity of the gray distribution of the neighboring pixel points of the blurred edge. Secondly, because the photographed object is a whole and the trailing shadow is generated at the same speed, the gray distribution features on both sides of the blurred edge are similar, that is, the gray gradual change degree is similar. Based on the above neighborhood features, the motion blur degree of the suspected blurred edge can be obtained.
[0057] The motion blur edge not only shows a smoothness feature in the edge part, but also shows a gradual change feature of the neighboring pixel points of the edge in the direction perpendicular to the motion direction; the pixel points on both sides of the edge have non-uniform features due to the blur; and since the blur on both sides of the edge is generated at the same speed, the gray distribution features on both sides of the edge are similar, that is, the gray gradual change degree is similar.
[0058] For any suspected blurred edge, first obtain the blurred gradient direction of each edge pixel point. When the object being photographed moves, the direction of blur generation is the direction of motion, and the blurred gradient direction is the direction perpendicular to the direction of motion. Since the shape of the object being photographed is unknown, it is necessary to obtain the vertical edge direction of each edge pixel point as the blurred gradient direction. To obtain the vertical edge direction of each edge pixel point, first obtain the fitting line of the edge direction of each edge pixel point. Since the motion-blurred edge is only a relatively smooth curve, the motion direction of each edge pixel point is different. When obtaining the fitting direction of its edge pixel points, it is not possible to only consider the local situation of each pixel point for fitting. It is also necessary to combine the overall trend of the edge to obtain the importance of each edge pixel point during local fitting, and then perform fitting on it to obtain the edge fitting direction of each edge pixel point that conforms to both local features and the overall trend.
[0059] First, obtain the coordinates of all edge pixel points of a suspected blurred edge, then perform fitting through the least squares method to obtain the coordinate fitting line, and further obtain the fitting coordinates of each edge pixel point. Starting from an edge pixel point, along the direction of the suspected blurred edge, obtain a set number of pixel points closest to this edge pixel point in the suspected blurred edge in the order of taking points from left to right and from top to bottom as the neighboring pixel points of this edge pixel point. The set number is m is the number of edge pixel points on the upper edge of the suspected blurred edge. If is not an integer, round up. The nearest neighbor refers to the smallest Euclidean distance between pixel points.
[0060] Since the fitting coordinates represent the overall trend of the suspected blur, when fitting the suspected blurred edge, it is necessary to consider the overall trend of the suspected blurred edge, take the reciprocal of the difference between the fitting coordinates and the actual coordinates of the neighboring pixel points as the importance of each neighboring pixel point, and obtain the weight of each neighboring pixel point.
[0061] Specifically, calculate the Euclidean distance between the fitting coordinates and the actual coordinates of a neighboring pixel point, normalize the reciprocal of the sum of the Euclidean distance and the first parameter to obtain the coordinate weight of this neighboring pixel point; multiply the weighted weight of a neighboring pixel point by the actual coordinates of this neighboring pixel point to obtain the weighted coordinates; use the actual coordinates of an edge pixel point and the weighted coordinates of the neighboring pixel points of this edge pixel point for curve fitting to obtain the fitting line of this edge pixel point. The first parameter is a very small positive number to prevent the denominator from being 0.
[0062] The calculation formula for the weighted coordinates is:
[0063]
[0064] Among them, ρizq It represents the weighted coordinate of the q-th neighboring pixel of the z-th edge pixel of the i-th suspected blurred edge; It represents the reciprocal of the sum of the Euclidean distance between the fitted coordinate and the actual coordinate of the q-th neighboring pixel of the z-th edge pixel of the i-th suspected blurred edge and the first parameter; It represents the coordinate weight of the neighboring pixel. For a neighboring pixel, the greater the difference between the fitted coordinate and the actual coordinate (the greater the Euclidean distance), the less the corresponding actual coordinate conforms to the trend of the overall edge, and the smaller its weight. On the contrary, the more it conforms to the trend of the overall edge, the greater the weight should be given to ensure that the fitted line of the edge pixel conforms to the trend of the overall edge. (x, y) represents the actual coordinate of the neighboring pixel.
[0065] After obtaining the fitted line of each edge pixel on the suspected blurred edge, that is, determining the fitted line of each edge pixel that better conforms to the change of the overall edge, subsequent analysis of the pixels in the gradient direction can be carried out according to the fitted line.
[0066] The blurred defect degree calculation module is used to draw a line perpendicular to the fitted line of the edge pixel through an edge pixel, denoted as the gradient line; take a preset number of pixels in two directions of the gradient line respectively starting from the edge pixel to form two groups of gradient pixels; calculate the blurred defect degree of the suspected blurred edge according to the two groups of gradient pixels corresponding to each edge pixel.
[0067] For an edge pixel on the suspected blurred edge, drawing a perpendicular line to its fitted line through the edge pixel can obtain its gradient direction. Drawing a line perpendicular to the fitted line of the edge pixel through an edge pixel is denoted as the gradient line. Further, take a preset number of pixels in two directions of the gradient line of the gradient pixel respectively starting from an edge pixel, and then form two groups of gradient pixels respectively. One edge pixel corresponds to two groups of gradient pixels, and the number of pixels in the two groups is equal. The empirical value of the preset number is 5, and the implementer can adjust it according to the actual situation.
[0068] After obtaining the gradient direction of each edge pixel and two groups of gradient pixels from the above, since there are gradient features in both groups of gradient pixels on both sides of the suspected blurred edge, it corresponds to that the fitting function of the gray values of the pixels in the two groups of pixels has a slope and a high degree of linear fitting. That is, the larger the slope and the smaller the difference between the fitting value and the actual value of the gray value, the more obvious the gradient feature and the more in line with the local feature of the motion blurred edge. For the two groups of gradient pixel groups obtained above, the linear fitting function of the gray values of each group is obtained by the least squares method, and the absolute value of the slope of each group of gradient pixels is obtained. Among them, the larger the absolute value of the slope, the more obvious the gradient feature and the faster the change speed. Then, the difference between the gray fitting value and the actual value of each pixel is obtained. The smaller the difference, the higher the fitting degree and the more in line with the gradient feature.
[0069] Since the blurring on both sides of the edge is generated at the same speed, the gray distributions on both sides of the blurred edge are similar, which is manifested as the similarity in the degree of gradient of the two groups of gradient pixels in the gradient direction, that is, the absolute value of the Pearson correlation coefficient of the two groups of data is large.
[0070] Since there are obvious blurring features in the pixels on both sides of the blurred edge, for any edge pixel, a window with a preset size is established centered on it. Since the pixels in the window are in the blurred edge part, their uniformity is poor, that is, it is manifested as a large standard deviation of the pixels in the window. The preset size is n*n, and the empirical value of n is 5.
[0071] Finally, the blurring defect degree of the suspected blurred edge is calculated according to the two groups of gradient pixel groups corresponding to each edge pixel. Specifically, the gray values of the pixels in a group of gradient pixels of an edge pixel are fitted by the least squares method to obtain a linear fitting function. The slope of the linear fitting function is the slope corresponding to the group of gradient pixels, and the fitted gray values of the pixels in the group of gradient pixels are obtained; the average value of the absolute values of the slopes corresponding to the two groups of gradient pixel groups corresponding to the edge pixel is obtained and denoted as the first average value; the sum of the absolute values of the differences between the fitted gray value and the actual gray value of each pixel in a group of gradient pixels is obtained to obtain the cumulative fitting difference of the group of gradient pixels, and the average value of the cumulative fitting differences of the two groups of gradient pixel groups corresponding to the edge pixel is obtained and denoted as the second average value; the ratio of the first average value to the second average value, the absolute value of the Pearson correlation coefficient of the gray values in the two groups of gradient pixels, and the standard deviation of the gray values of the pixels in the window centered on the edge pixel are multiplied to obtain the blurring feature of the edge pixel; the average value of the blurring features of all edge pixels of the suspected blurred edge is obtained to obtain the blurring defect degree of the suspected blurred edge.
[0072] Specific calculation formula:
[0073]
[0074] Among them, β represents the degree of blurring defect of a suspected blurry edge; ki represents the average value of the absolute values of the slopes corresponding to the two groups of gradient pixels corresponding to the i-th edge pixel of the suspected blurry edge, that is, the first average value. The larger the first average value, the more obvious the gradient feature; H1 and H2 respectively represent the cumulative fitting differences of the two groups of gradient pixels corresponding to the i-th edge pixel of the suspected blurry edge. represents the second average value, which represents the difference between the linear fitting function of the gradient direction and the actual value. The smaller the difference, the better the fitting degree of the fitting function, and the more obvious the gradient feature of the edge pixel in the gradient direction. is the ratio of the first average value and the second average value, that is, the gradient degree of the i-th edge pixel. When the average value of the slopes corresponding to the two groups of gradient pixels in the gradient direction is larger and the difference between the gray value fitting value and the actual value is smaller, the gradient feature is more obvious and more conforms to the feature of the gradually changing gray value of the blurry edge; pi represents the absolute value of the Pearson correlation coefficient of the gray values in the two groups of gradient pixels corresponding to the i-th edge pixel. The larger this value, the more similar the gradient features on both sides of the corresponding edge, and the more similar the gray value distribution features on both sides of the edge pixel; θi is the standard deviation of the gray values within the window corresponding to the i-th edge pixel of the suspected blurry edge. The larger the standard deviation, the more uneven the gray value distribution on both sides of the i-th edge pixel, and the more conforms to the blurry feature; k is the number of pixels of the suspected blurry edge.
[0075] Thus, the degree of blurring defect of each suspected blurry edge can be obtained.
[0076] The blurring defect edge acquisition module is used to obtain similar edges of the suspected blurry edge; calculate the degree of blurring defect existence of the suspected blurry edge according to the degree of blurring defect and slope of the similar edge; multiply the degree of blurring defect existence of the suspected blurry edge and the degree of blurring defect and normalize to obtain the comprehensive defect degree, and then obtain the blurring defect edge.
[0077] After obtaining the above degree of blurring defect, since the blurry edge caused by motion is generated by an object, its blurry edge generally exists at the object nodes (such as the bone nodes of a human hand), and an object has at least two nodes, that is, both ends of the object (for an object generating motion, if its structure is single without nodes, then the blurry edges generated are the two ends of the object parallel to the motion direction).
[0078] Motion blur occurs because the object undergoes displacement or movement. Therefore, the motion blur edge does not exist alone. That is, there will be at least one other edge with a similar distribution around the blur edge. So, the degree of blur defect of the suspected blur edge can be obtained by the similarity between the adjacent edge of the suspected blur edge and it. Due to the local characteristics of the distribution of the blur edge, that is, there is at least one blur edge similar to it near the blur edge, and both are generated by the movement of the same object. Therefore, the generated blur edges are relatively parallel, that is, at least one of the blur edge and its adjacent blur edge is parallel. For the suspected blur edge, the coordinates of all edge pixels in it are fitted to obtain the general trend of the edge. Since the object generating the blur edge is a whole, the blurred part of the edge is relatively parallel in distribution and has a high local similarity.
[0079] Further, obtain the similar edges of the suspected blur edge. Specifically, intercept the coordinate fitting lines of the suspected blur edge at both ends of the suspected blur edge to obtain the fitting line segments; construct a square with the fitting line segment as the median line, and the side length of the square is the same as the length of the fitting line segment; obtain all the suspected blur edges within the square, denoted as adjacent edges, obtain the coordinate fitting line of the adjacent edges, and obtain the slope of the adjacent edges; calculate the difference between the slope of the coordinate fitting line of the suspected blur edge and the slope of the adjacent edges, and take the two adjacent edges with the smallest difference as the similar edges of the suspected blur edge. The median line is the connection line of the midpoints of two opposite waist lines of the square.
[0080] Next, calculate the degree of blur defect of the suspected blur edge according to the degree of blur defect and slope of the similar edges of the suspected blur edge. Specifically, obtain the coordinate sequence of the similar edges; use the DTW algorithm to calculate the similarity between the gray values in the coordinate sequence of the suspected blur edge and the gray values in the coordinate sequence of the similar edges, denoted as gray similarity; respectively obtain the absolute values of the differences between the slopes of the coordinate fitting lines of the two similar edges and the slope of the coordinate fitting line of the suspected blur edge, and average the two absolute values of the differences to obtain the average value, and the reciprocal of the average value is the parallel degree; multiply the average value of the degrees of blur defect of the two similar edges, the average value of the gray similarities between the two similar edges and the suspected blur edge, and the parallel degree to obtain the degree of blur defect of the suspected blur edge.
[0081] Its specific calculation formula is:
[0082]
[0083] Among them, γi represents the degree of blur defect of the i-th suspected blur edge; δi' represents the average value of the degrees of blur defect of the two similar edges of the i-th suspected blur edge; D irepresents the mean of the gray-scale similarity degrees between two similar edges of the $i$-th suspected blurred edge and the $i$-th suspected blurred edge; $B$, $B1$, and $B2$ are the slopes of the coordinate fitting lines of the $i$-th suspected blurred edge and the two similar edges of the $i$-th suspected blurred edge, respectively. Represents the degree of parallelism. The smaller the mean of the absolute values of the slope differences between the suspected blurred edge and the two similar edges, the greater the degree of parallelism. Then the target edge is more parallel to the two similar edges and more conforms to the blurred edge distribution. The greater the degree of blurred defect of the two similar edges of the suspected blurred edge, the more similar the gray-scale distribution between the suspected blurred edge and the two similar edges, and the more parallel the suspected blurred edge is to the similar edges, the higher the degree of existence of the blurred defect of the suspected blurred edge.
[0084] Since the blurred edge not only has distribution characteristics of the edge itself, but also has a strong correlation with the surrounding neighborhood distribution, the comprehensive defect degree is obtained by combining the degree of blurred defect and the degree of existence of the blurred defect of the suspected blurred edge, and the edges with higher defect degrees are marked as quality defect edges.
[0085] Multiply the degree of existence of the blurred defect and the degree of blurred defect of the suspected blurred edge and normalize them to obtain the comprehensive defect degree. The greater the degree of existence of the blurred defect and the degree of blurred defect, the higher the comprehensive defect degree, and the more likely it is to be a quality defect edge. Among them, the degree of blurred defect is the similarity degree between the edge itself and the blurred edge feature, and the degree of existence of the blurred defect is the similar feature of the suspected blurred edge and the blurred edge in the local range, that is, the blurred edge does not exist alone and there are certain characteristics in the local gray-scale distribution of the blurred edge. By combining the suspected blurred edge itself and the local features, the comprehensive defect degree of the suspected blurred edge can be obtained.
[0086] In summary, after obtaining the comprehensive defect degree of each suspected blurred edge, the suspected blurred edges with a comprehensive defect degree greater than or equal to the second threshold $g$ ($g$ is empirically taken as $g = 0.8$) are marked as quality defect edges, that is, blurred defect edges.
[0087] After obtaining the quality defect edges in the image as above, map them to the acquired image for marking. If there are no marked edges in the acquired image, it is classified as a normal quality image; if the acquired image contains marked edges, it is classified as an image with quality defects to assist the human to find the blurred edges and determine whether the blurred edges are caused by shooting effects or quality defects.
[0088] It should be noted that: the above sequence of the embodiments of the present invention is only for description and does not represent the advantages or disadvantages of the embodiments. And the above describes specific embodiments of this specification. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0089] Each embodiment in this specification is described in a progressive manner. For the same or similar parts among the embodiments, reference can be made to each other, and the differences between each embodiment and other embodiments are emphasized.
[0090] The above are only the preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.
Claims
1. An image quality defect detection system based on machine vision, characterized in that: The system includes: The initial edge acquisition module is used to acquire the grayscale image of the advertisement and obtain all the edges in the image, which are recorded as initial edges; A suspected blurred edge acquisition module is used to calculate the motion blur smoothness of an initial edge based on the coordinates, number and gradient direction entropy of edge pixel points of the initial edge, and to acquire the suspected blurred edge; A fitting straight line acquisition module is used to obtain a coordinate fitting straight line by fitting the coordinates of edge pixel points of a suspected blurred edge; obtain neighboring pixel points of an edge pixel point of a suspected blurred edge; and obtain a fitting straight line of the edge pixel point according to the actual coordinates of the neighboring pixel points and the fitting coordinates; A blur defect degree calculation module is used to make a straight line perpendicular to a fitting straight line of an edge pixel point through an edge pixel point, which is recorded as a gradient straight line; taking the edge pixel point as the starting point, sequentially taking a preset number of pixel points in two directions of the gradient straight line to form two gradient pixel point groups; and calculating the blur defect degree of the suspected blur edge according to the two gradient pixel point groups corresponding to each edge pixel point; The fuzzy defect edge acquisition module is used to obtain a similar edge of a suspected fuzzy edge; calculate the fuzzy defect existence degree of the suspected fuzzy edge according to the fuzzy defect degree and slope of the similar edge; multiply the fuzzy defect existence degree and the fuzzy defect degree of the suspected fuzzy edge and normalize them to obtain a comprehensive defect degree, and then obtain a fuzzy defect edge.
2. The image quality defect detection system based on machine vision according to claim 1, characterized in that: All edges in the image are obtained, recorded as initial edges, including: The canny edge detection algorithm is used to obtain all the edges in the grayscale image of the advertisement. For the edges where nodes appear, the nodes are used as the starting point to divide the edges into independent edges in sequence. The edges where no nodes appear are not processed to obtain the initial edges, and the nodes are the nodes at the intersection of the edges.
3. The image quality defect detection system based on machine vision according to claim 1, characterized in that: The step of calculating the motion blur smoothness of an initial edge based on the coordinates, quantity and gradient direction entropy of edge pixel points of the initial edge and obtaining a suspected blurred edge includes: The coordinates of the edge pixel points of the initial edge are sorted from left to right and from top to bottom to obtain a coordinate sequence; the ratio of the difference between the horizontal coordinate and the vertical coordinate of each two adjacent coordinates in the coordinate sequence corresponding to an initial edge is obtained, which is recorded as the change rate of the edge pixel points corresponding to the latter coordinate of each two adjacent coordinates; the mean, standard deviation, gradient directional entropy of the edge pixel points and the number of edge pixel points of the change rate of the initial edge are inverted and normalized to obtain the motion blur smoothness of the initial edge; An initial edge whose motion blur smoothing degree is greater than a first threshold is regarded as a suspected blurred edge.
4. The image quality defect detection system based on machine vision according to claim 1, characterized in that: The step of obtaining neighboring pixel points of an edge pixel point suspected to be a blurred edge comprises: Taking an edge pixel point as the starting point, a set number of pixel points closest to the edge pixel point in the suspected blurred edge are obtained in a sequence from left to right and from top to bottom along the direction of the suspected blurred edge as the neighboring pixel points of the edge pixel point.
5. The image quality defect detection system based on machine vision according to claim 1, characterized in that: The step of obtaining a fitting straight line of the edge pixel point according to the actual coordinates and the fitting coordinates of the neighboring pixel points includes: Obtain the Euclidean distance between the fitted coordinates and the actual coordinates of a neighboring pixel point, normalize the inverse of the sum of the Euclidean distance and the first parameter, and obtain the coordinate weight of the neighboring pixel point; multiply the weighted weight of a neighboring pixel point by the actual coordinates of the neighboring pixel point to obtain the weighted coordinates; use the actual coordinates of an edge pixel point and the weighted coordinates of the neighboring pixel points of the edge pixel point to perform curve fitting to obtain the fitting straight line of the edge pixel point.
6. The image quality defect detection system based on machine vision according to claim 1, characterized in that: The calculating the blur defect degree of the suspected blur edge according to the two gradient pixel groups corresponding to each edge pixel point includes: The grayscale value of a pixel in a gradient pixel group of an edge pixel is fitted by the least square method to obtain a linear fitting function, the slope of the linear fitting function is the slope corresponding to the gradient pixel group, and the fitting grayscale value of the pixel in the gradient pixel group is obtained; The mean of the absolute values of the slopes corresponding to the two gradient pixel groups corresponding to the edge pixel point is obtained, which is recorded as the first mean value; the absolute value of the difference between the fitted grayscale value and the actual grayscale value of each pixel point in a gradient pixel point group is summed to obtain the cumulative fitting difference of the gradient pixel point group, and the mean of the cumulative fitting differences of the two gradient pixel point groups corresponding to the edge pixel point is obtained, which is recorded as the second mean value; The ratio of the first mean to the second mean, the absolute value of the Pearson correlation coefficient of the grayscale values in the two gradient pixel groups, and the standard deviation of the grayscale values of the pixels in the window centered on the edge pixel are multiplied to obtain the blur feature of the edge pixel; the blur features of all edge pixels of the suspected blurred edge are averaged to obtain the blur defect degree of the suspected blurred edge.
7. The image quality defect detection system based on machine vision according to claim 1, characterized in that: The obtaining of similar edges of suspected fuzzy edges includes: The coordinate fitting straight lines of the suspected fuzzy edge are intercepted at both ends of the suspected fuzzy edge to obtain the fitting line segment; a square with the fitting line segment as the median is constructed, and the side length of the square is the same as the length of the fitting line segment; all the suspected fuzzy edges in the square are obtained, recorded as adjacent edges, the coordinate fitting straight lines of the adjacent edges are obtained, and the slopes of the adjacent edges are obtained; the difference between the slope of the coordinate fitting straight line of the suspected fuzzy edge and the slope of the adjacent edge is calculated, and the two adjacent edges with the smallest difference are taken as similar edges of the suspected fuzzy edge.
8. The image quality defect detection system based on machine vision according to claim 1, characterized in that: The calculating the existence degree of the fuzzy defect of the suspected fuzzy edge according to the fuzzy defect degree and slope of the similar edge includes: Obtain the coordinate sequence of similar edges; use the DTW algorithm to calculate the similarity of the grayscale values in the coordinate sequence of the suspected fuzzy edge and the grayscale values in the coordinate sequence of the similar edge, recorded as grayscale similarity; obtain the absolute value of the difference between the slope of the coordinate fitting line of the two similar edges and the slope of the coordinate fitting line of the suspected fuzzy edge, and average the absolute values of the two differences to obtain the average value, and the reciprocal of the average value is the degree of parallelism; multiply the mean value of the degree of fuzzy defect of the two similar edges, the mean value of the grayscale similarity between the two similar edges and the suspected fuzzy edge, and the degree of parallelism to obtain the degree of fuzzy defect of the suspected fuzzy edge.
9. The image quality defect detection system based on machine vision according to claim 1, characterized in that: The step of obtaining the blurred defect edge comprises: The suspected fuzzy edge with a comprehensive defect degree greater than or equal to the second threshold is a fuzzy defect edge.