CN115147409B - Mobile phone shell production quality detection method based on machine vision - Google Patents
Mobile phone shell production quality detection method based on machine vision Download PDFInfo
- Publication number
- CN115147409B CN115147409B CN202211043713.7A CN202211043713A CN115147409B CN 115147409 B CN115147409 B CN 115147409B CN 202211043713 A CN202211043713 A CN 202211043713A CN 115147409 B CN115147409 B CN 115147409B
- Authority
- CN
- China
- Prior art keywords
- pixel
- pixel block
- pixel blocks
- block
- gray
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/0002—Inspection of images, e.g. flaw detection
- G06T7/0004—Industrial image inspection
-
- G—PHYSICS
- G01—MEASURING; TESTING
- G01N—INVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
- G01N21/00—Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
- G01N21/84—Systems specially adapted for particular applications
- G01N21/88—Investigating the presence of flaws or contamination
- G01N21/8851—Scan or image signal processing specially adapted therefor, e.g. for scan signal adjustment, for detecting different kinds of defects, for compensating for structures, markings, edges
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/11—Region-based segmentation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/20—Image preprocessing
- G06V10/26—Segmentation of patterns in the image field; Cutting or merging of image elements to establish the pattern region, e.g. clustering-based techniques; Detection of occlusion
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/40—Extraction of image or video features
- G06V10/46—Descriptors for shape, contour or point-related descriptors, e.g. scale invariant feature transform [SIFT] or bags of words [BoW]; Salient regional features
- G06V10/462—Salient features, e.g. scale invariant feature transforms [SIFT]
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/70—Arrangements for image or video recognition or understanding using pattern recognition or machine learning
- G06V10/764—Arrangements for image or video recognition or understanding using pattern recognition or machine learning using classification, e.g. of video objects
-
- G—PHYSICS
- G01—MEASURING; TESTING
- G01N—INVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
- G01N21/00—Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
- G01N21/84—Systems specially adapted for particular applications
- G01N21/88—Investigating the presence of flaws or contamination
- G01N21/8851—Scan or image signal processing specially adapted therefor, e.g. for scan signal adjustment, for detecting different kinds of defects, for compensating for structures, markings, edges
- G01N2021/8887—Scan or image signal processing specially adapted therefor, e.g. for scan signal adjustment, for detecting different kinds of defects, for compensating for structures, markings, edges based on image processing techniques
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/30—Subject of image; Context of image processing
- G06T2207/30108—Industrial image inspection
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Multimedia (AREA)
- Health & Medical Sciences (AREA)
- General Health & Medical Sciences (AREA)
- Biochemistry (AREA)
- Pathology (AREA)
- Chemical & Material Sciences (AREA)
- Analytical Chemistry (AREA)
- Signal Processing (AREA)
- Quality & Reliability (AREA)
- Immunology (AREA)
- Life Sciences & Earth Sciences (AREA)
- Artificial Intelligence (AREA)
- Computing Systems (AREA)
- Databases & Information Systems (AREA)
- Evolutionary Computation (AREA)
- Medical Informatics (AREA)
- Software Systems (AREA)
- Image Analysis (AREA)
- Image Processing (AREA)
Abstract
The invention relates to the technical field of image processing, in particular to a method for detecting the production quality of a mobile phone shell based on machine vision. The method comprises the following steps: obtaining a gray scale image of the surface image of the mobile phone shell; dividing the gray scale image into pixel blocks with preset sizes, and acquiring the significance of the target pixel block based on the first and second significances of the target pixel block; obtaining the significance of all pixel blocks, wherein the significance of the pixel blocks is the significance of each pixel point in the pixel blocks; obtaining the final significance of each pixel point in the gray-scale image by utilizing the significance of each pixel point under different preset sizes; and performing linear enhancement on the gray level image based on the final saliency of each pixel point, and detecting the gray level image subjected to linear enhancement to obtain the defect of the mobile phone shell. The method and the device perform linear enhancement on the gray-scale image based on the final significance of each pixel point, so that the defect part of the gray-scale image is more significant, the difficulty in the defect detection of the mobile phone shell is further reduced, and the accuracy in the defect detection of the mobile phone shell is improved.
Description
Technical Field
The invention relates to the technical field of image processing, in particular to a method for detecting the production quality of a mobile phone shell based on machine vision.
Background
Along with the rapid development of the smart phone industry, the smart phone is widely popularized in thousands of households, the smart phone becomes an increasingly indispensable part of the daily life of people, the smart phone is not used for entertainment and work, the use of the smart phone becomes more and more frequent, and the requirements on the mobile phone shell become higher and higher along with the continuous updating of the smart phone. The mobile phone shell is characterized in that the mobile phone shell with defects of scratches and pits cannot be avoided due to the problems of production process and environmental factors in the production process, the defects can bring great influence to the overall attractiveness of the mobile phone, and therefore the mobile phone shell with the defects cannot be used on the market, and great economic loss can be brought to manufacturers.
The traditional method for detecting the defects on the surface of the mobile phone shell mainly depends on manual detection, but the detection method has low efficiency, is easy to fatigue and difficult to detect continuously for a long time, and simultaneously causes the problem of detection accuracy due to the subjective reason of manual work; with the development of image processing technology and machine vision technology, technology for detecting defects based on surface images of mobile phone shells also appears, for example, a method for detecting defects of mobile phone shells based on deep learning is used, the defects of the mobile phone shells are detected based on the surface images of the mobile phone shells through the method for deep learning, however, a large amount of training samples are needed for building a deep learning network, time consumption is long, more importantly, the characteristics of slight scratches and unobvious pits are not obviously and easily detected, and therefore the detection accuracy is also affected.
Disclosure of Invention
In order to solve the technical problems, the invention aims to provide a mobile phone shell production quality detection method based on machine vision, and the adopted technical scheme is as follows:
one embodiment of the invention provides a mobile phone shell production quality detection method based on machine vision, which comprises the following steps: preprocessing an image on the surface of the mobile phone shell to obtain a gray scale image, wherein the mobile phone shell comprises a camera hole; dividing the gray scale image into pixel blocks with preset sizes, and obtaining the contrast, entropy, energy and average value, variance, maximum value and minimum value of gray values of each pixel block; obtaining the comprehensive difference of every two pixel blocks by using the contrast, entropy and energy of every two pixel blocks and the average value, variance, maximum value and minimum value of the gray values;
classifying based on the comprehensive difference of every two pixel blocks to obtain pixel blocks of different classes; acquiring the number of pixel blocks contained in a camera hole area in a gray scale image; taking any pixel block as a target pixel block, wherein the category of the target pixel block is a first category of the target pixel block; obtaining a second category of the target pixel block according to the average value of the comprehensive differences of the pixel blocks in each category except the first category and the target pixel block; obtaining the suppression factor of the target pixel block according to the number of the pixel blocks in the first category, the number of the pixel blocks contained in the camera hole area and the number of all the pixel blocks; acquiring the first significance of the target pixel block by utilizing the comprehensive difference between the target pixel block and the pixel blocks in the first and second categories, and the suppression factor and the category number of the target pixel block;
the target pixel block and the pixel block in the neighborhood form a combined pixel block, and the second significance of the target pixel block is obtained according to the contrast, entropy and energy of the combined pixel block and the pixel block in the neighborhood; obtaining the significance of the target pixel block based on the first and second significances of the target pixel block; obtaining the significance of all pixel blocks, wherein the significance of the pixel blocks is the significance of each pixel point in the pixel blocks; obtaining the final significance of each pixel point in the gray-scale image by utilizing the significance of each pixel point under different preset sizes; and performing linear enhancement on the gray level image based on the final saliency of each pixel point, and detecting the gray level image subjected to linear enhancement to obtain the defect of the mobile phone shell.
Preferably, the obtaining of the comprehensive difference of each two pixel blocks by using the average, variance, maximum and minimum values of the contrast, entropy, energy and gray value of each two pixel blocks comprises: calculating the Euclidean distance of the contrast, entropy and energy of every two pixel blocks to obtain the texture difference of every two pixel blocks; calculating the difference value of the maximum value and the minimum value of the gray values of every two pixel blocks as the range of every two pixel blocks; calculating the mean value of the gray values of every two pixel blocks, the variance of the gray values and the Euclidean distance of the extreme difference to obtain the gray difference of every two pixel blocks; the average value of the sum of the gray difference and the texture difference of every two pixel blocks is the comprehensive difference of every two pixel blocks.
Preferably, obtaining the number of pixel blocks contained in the camera hole area in the grayscale map includes: carrying out edge detection on the gray-scale image by using a canny operator to obtain a closed edge in the gray-scale image, wherein the area included by the closed edge is a closed edge area, and the closed edge area with the largest area is a camera hole area; the number of pixel blocks contained within the camera hole area includes the number of pixel blocks entirely within the camera hole area and the number of pixel blocks of partial area within the camera hole area.
Preferably, the second category of the target pixel block is obtained according to an average value of the comprehensive differences of the pixel blocks in each category except the first category and the target pixel block; and obtaining the minimum value of the average value of the comprehensive differences between the pixel blocks in each category except the first category and the target pixel block, wherein the pixel block category in each category except the first category corresponding to the minimum value of the average value of the comprehensive differences is the second category of the target pixel block.
Preferably, obtaining the suppression factor of the target pixel block according to the number of pixel blocks in the first category, the number of pixel blocks contained in the camera hole area and the number of all pixel blocks comprises: obtaining a difference value between the number of pixel blocks in the first category and the number of pixel blocks contained in the camera hole area; and the ratio of the difference value to the number of all pixel blocks is a suppression factor of the target pixel block.
Preferably, the first significance is:
wherein,representing a first saliency of a target block of pixels;a number of classes representing a classification of the pixel block;representing the number of pixel blocks in a first category of the target pixel block,representing the integrated difference of the ith pixel block and the target pixel block in the first category;representing the number of pixel blocks in the second category of the target pixel block,representing the integrated difference of the jth pixel block and the target pixel block in the second category;a suppression factor representing a target pixel block;represents an adjustment coefficient;an exponential function with a natural constant e as the base is shown.
Preferably, the step of obtaining the second significance of the target pixel block according to the contrast, entropy and energy of the combined pixel block and the pixel block in the neighborhood comprises: respectively combining the target pixel block and pixel blocks in four neighborhoods to obtain four combined pixel blocks, and obtaining the contrast, entropy and energy of each combined pixel block based on the gray level co-occurrence matrix; the second significance of the target pixel block is:
wherein,representing a second saliency of the target block of pixels;representing a target pixelThe entropy of the corresponding a-th block of combined pixels of the block,expressing the entropy of the a-th pixel block in the four neighborhoods corresponding to the target pixel block;representing the contrast of the a-th combined pixel block corresponding to the target pixel block,representing the contrast of the a-th pixel block in the four neighborhoods corresponding to the target pixel block;representing the energy of the a-th combined pixel block corresponding to the target pixel block,and the energy of the a-th pixel block in the four neighborhoods corresponding to the target pixel block is represented.
Preferably, the saliency of the target pixel block is:
wherein,representing the saliency of a target block of pixels;representing a first saliency of a target block of pixels;representing a second saliency of the target block of pixels;is expressed with a natural constant e as the baseIs used as the exponential function of (1).
Preferably, the final saliency of each pixel point is as follows:
wherein N represents the final significance of the pixel points;indicating the number of preset size changes, i.e. in commonEach preset size;and representing the significance of the pixel point under the mth preset size.
Preferably, the linear enhancement of the gray scale image based on the final saliency of each pixel point, and the detection of the gray scale image after the linear enhancement to obtain the defect of the mobile phone shell comprises: for a pixel point in the gray-scale image, adding the final significance of the pixel point and a first preset value and multiplying the result by the gray value of the pixel point to obtain the gray value of the pixel point after linear enhancement; obtaining gray values of all pixel points in the gray image after linear enhancement, thereby obtaining a gray image after linear enhancement; and analyzing the linearly enhanced gray level image by utilizing edge detection and Hough circle detection, wherein the detected edge line which is not the edge of the mobile phone shell is a scratch defect, and the detected circle is a pit defect.
The embodiment of the invention at least has the following beneficial effects: obtaining a gray scale image of the surface image of the mobile phone shell, dividing the gray scale image into a plurality of pixel blocks, and obtaining the comprehensive difference of every two pixel blocks based on the texture information of each pixel block and the gray scale information; the information of the pixel blocks is comprehensively considered, so that the obtained comprehensive difference is more accurate; the improved CA significance analysis model is further utilized to combine the texture change condition of the combined pixel block after the target pixel block is combined with the surrounding pixel blocks to obtain the significance of the target pixel block, so that the obtained significance is more accurate; and finally, the final significance of each pixel point of the gray scale image is obtained according to the significance of each pixel point of the gray scale image under different preset sizes, and the gray scale image is linearly enhanced based on the final significance of each pixel point, so that the defect part of the gray scale image is more significant, the difficulty in defect detection of the opponent shell is reduced, and the accuracy in defect detection of the opponent shell is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions and advantages of the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a flowchart of a method for detecting the production quality of a mobile phone shell based on machine vision according to an embodiment of the present invention.
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 production quality of the mobile phone shell based on the machine vision, the specific implementation manner, the structure, the features and the effects thereof according to the present invention are provided with the accompanying drawings and the preferred embodiments. 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 following describes a specific scheme of the mobile phone shell production quality detection method based on machine vision in detail with reference to the accompanying drawings.
Example (b):
the main application scenarios of the invention are as follows: in order to prevent the defects of scratches and pits of the produced mobile phone shells, the mobile phone shells produced on the production line are detected, the mobile phone shells are arranged on a conveyor belt, a camera is arranged right above the conveyor belt, meanwhile, the shooting frequency is related to the speed of the conveyor belt, each mobile phone shell is required to be arranged in the middle of an image, and it needs to be noted that the mobile phone shells do not have textures and colors.
Referring to fig. 1, a flowchart of a method for detecting a production quality of a mobile phone case based on machine vision according to an embodiment of the present invention is shown, where the method includes the following steps:
s1, preprocessing an image of the surface of a mobile phone shell to obtain a gray scale image, wherein the mobile phone shell comprises a camera hole; dividing the gray scale image into pixel blocks with preset sizes, and obtaining the contrast, entropy, energy and average value, variance, maximum value and minimum value of gray values of each pixel block; and obtaining the comprehensive difference of every two pixel blocks by using the contrast, entropy and energy of every two pixel blocks and the average value, variance, maximum value and minimum value of the gray values.
Firstly, it can be known a priori that some defects on the surface of the mobile phone shell have obvious characteristics, while some defects with small scratches and pits have unobvious characteristics, and the defects with unobvious characteristics are not easy to detect, so that the problem of missed detection can occur, and therefore, when the defects of the mobile phone shell are identified, the image on the surface of the mobile phone shell needs to be optimized and enhanced; in the embodiment, a saliency analysis algorithm is utilized to highlight the defect area in the surface image of the mobile phone shell so as to more accurately identify the defect.
In a plurality of significance detection models, the CA significance model considers low-level factors such as gray values, contrast and the like, also considers occurrence frequency and spatial distribution of pixel blocks, and is very consistent with the scene aimed by the invention.
Further, a surface image of the mobile phone shell is obtained, wherein the mobile phone shell is located in the middle of the surface image of the mobile phone shell, the surface image of the mobile phone shell is preprocessed by a Gaussian denoising method, the preprocessed surface image of the mobile phone shell is grayed, and a gray level image is obtained, wherein the graying uses a weighted average value method.
For more convenient analysis and better extraction of local information, the grayscale image needs to be subjected to blocking processing, wherein the image blocking method uses a superpixel segmentation method to divide the grayscale image into pixel blocks of a preset size, wherein the preset size of the first division of the grayscale image is M × M, preferably, the value of M in this embodiment is 20, and it needs to be noted that the value of M needs to be determined by an implementer according to an actual situation; it should be further explained that when the saliency of the pixel point is obtained, the gray level map needs to be divided under different preset sizes, the saliency of each pixel point under each preset size is obtained, and then the saliency of the pixel point is comprehensively obtained.
Then, the main role of the saliency analysis is to highlight the most salient regions in the image, i.e. the regions that are least similar to other regions, so that the similarity between the acquired pixel blocks and other pixel blocks needs to be found.
Obtaining a gray level co-occurrence matrix of each pixel block under a preset size, and obtaining the contrast of each pixel block according to the gray level co-occurrence matrix of each pixel blockEntropy ofAnd energyWherein the contrast ratioGroove depth and entropy reflecting definition and texture of pixel blockReflects the complexity of the pixel blockMeasurement ofThe uniformity degree of the gray distribution of the pixel blocks is reflected; calculating Euclidean distances of contrast, entropy and energy of every two pixel blocks to obtain texture difference of every two pixel blocks:
wherein,、、and、、the contrast, entropy and energy of two pixel blocks are respectively, when the contrast, entropy and energy of two pixel blocks are more close, namely the texture differenceSmaller values of (a) indicate more similarity of two pixel blocks, whereas the difference is larger.
Secondly, the difference degree of the two pixel blocks is judged according to the information reflected by the gray values of the pixel blocks, and the average value, the variance, the maximum value and the minimum value of the gray values of each pixel block are obtained, wherein the difference value of the maximum value and the minimum value of the gray values of the pixel blocks is the extreme difference of the pixel blocks; calculating the mean value of the gray values of every two pixel blocks, the variance of the gray values and the Euclidean distance of the range difference to obtain the gray difference of every two pixel blocks:
wherein,representing the difference in gray levels for every two blocks of pixels,、、and、、the mean value of the gray values of the two pixel blocks, the variance of the gray values and the range are respectively. The smaller the gray difference w of the two pixel blocks is, the more similar the two pixel blocks are, otherwise, the larger the difference of the two pixel blocks is.
And finally, comprehensively analyzing the texture difference and the gray difference of every two pixel blocks to obtain the comprehensive difference of every two pixel blocks:
the larger the comprehensive difference is, the larger the difference between the two pixel blocks is, and here, the difference between the pixel blocks is analyzed from the texture information and the gray information of the pixel blocks to obtain the comprehensive difference between the two pixel blocks, so that the accuracy of the two pixel blocks can be more accurately obtained. Whereby an integrated difference of every two pixel blocks can be obtained.
S2, classifying based on the comprehensive difference of every two pixel blocks to obtain pixel blocks of different categories; acquiring the number of pixel blocks contained in a camera hole area in a gray scale image; taking any pixel block as a target pixel block, wherein the category of the target pixel block is a first category of the target pixel block; obtaining a second category of the target pixel block according to the average value of the comprehensive differences of the pixel blocks in each category except the first category and the target pixel block; obtaining the suppression factor of the target pixel block according to the number of the pixel blocks in the first category, the number of the pixel blocks contained in the camera hole area and the number of all the pixel blocks; and acquiring the first significance of the target pixel block by utilizing the comprehensive difference between the target pixel block and the pixel blocks in the first and second categories, the suppression factor of the target pixel block and the number of the categories.
Firstly, the pixel blocks are classified according to the comprehensive difference between every two pixel blocks, in this embodiment, the DBSCAN clustering algorithm is used for classifying, pixel blocks of different categories are obtained, the number of the classified categories is obtained, and when the number of the categories is more, the significance of the pixel blocks in the gray map is more.
Meanwhile, a camera hole area in the gray-scale image is required to be obtained, edge detection is carried out on the gray-scale image by using a canny operator to obtain a closed edge in the gray-scale image, the area included by the closed edge is a closed edge area, and the closed edge area with the largest area is the camera hole area; the method comprises the steps of obtaining the number of pixel blocks contained in a camera hole area, wherein the number of the pixel blocks contained in the camera hole area comprises the number of the pixel blocks completely in the camera hole area and the number of the pixel blocks in a partial area in the camera hole area, the camera hole is more prominent than the mobile phone shell, and when significance analysis is carried out, the camera hole may acquire larger significance.
Further, any pixel block is selected as a target pixel block, when the difference between the target pixel block and the most similar pixel block is larger, the significance of the target pixel block is very large, the category to which the target pixel block belongs is obtained, and the category is marked as the first category of the target pixel block; the method comprises the steps of obtaining the minimum value of the average value of the comprehensive difference between a pixel block in each category except the first category and a target pixel block, wherein the pixel block category in each category except the first category corresponding to the minimum value of the average value of the comprehensive difference is the second category of the target pixel block, selecting the target pixel blocks of two categories with larger similarity degree with the target pixel block to analyze the significance of the target pixel block, and an implementer can select different numbers of categories to analyze according to actual conditions during implementation.
Obtaining the suppression factor of the target pixel block according to the number of the pixel blocks in the first category, the number of pixel blocks contained in the camera hole area and the number of all the pixel blocks:
wherein,the suppression factors of the target pixel blocks are represented, when different pixel blocks are used as the target pixel blocks, the suppression factors are different, but when the pixel blocks belonging to the same class are used as the suppression factors, the values of the pixel blocks are the same;representing the number of pixel blocks contained in the camera aperture region;representing a number of pixel blocks within a first category of the target pixel block;representing the number of pixel blocks in the grayscale map.
And finally, acquiring the first significance of the target pixel block by utilizing the comprehensive difference between the target pixel block and the pixel blocks in the first and second categories, the suppression factor of the target pixel block and the number of the categories:
wherein,representing a first saliency of a target block of pixels;a number of classes representing a classification of the pixel block;representing the number of pixel blocks in a first category of the target pixel block,representing the integrated difference of the ith pixel block and the target pixel block in the first category;representing the number of pixel blocks in the second category of the target pixel block,representing the integrated difference of the jth pixel block and the target pixel block in the second category;when the target pixel block is a pixel block in the camera hole area, the majority of the pixel blocks in the first category to which the target pixel block belongs are the pixel blocks in the camera hole area, and the suppression factor is a number which is wireless and close to 0, so that the saliency of the target pixel block is reduced, the effect of suppressing the saliency of the camera hole area is achieved, and otherwise, the saliency of the pixel block is not suppressed, for example, the target pixel block is a pixel block in the camera hole areaWhen the target pixel block is a normal pixel block without defects, the number of the pixel blocks in the first category to which the target pixel block belongs is relatively large, and the significance of the target pixel block is also inhibited when the suppression factor is a negative value;represents an adjustment coefficient whose value is a value infinitely close to 0 but not 0;representing an exponential function with a natural constant e as the base.
Indicating that the target pixel block is more significant when the pixel blocks in the first and second categories of the target pixel block have greater comprehensive difference with the target pixel block; meanwhile, a larger value of the first saliency indicates a larger saliency of the target pixel block. The first saliency of each block of pixels can be obtained so far.
S3, forming a combined pixel block by the target pixel block and the pixel block in the neighborhood, and obtaining the second significance of the target pixel block according to the contrast, entropy and energy of the combined pixel block and the pixel block in the neighborhood; obtaining the significance of the target pixel block based on the first and second significances of the target pixel block; obtaining the significance of all pixel blocks, wherein the significance of the pixel blocks is the significance of each pixel point in the pixel blocks; obtaining the final significance of each pixel point in the gray-scale image by utilizing the significance of each pixel point under different preset sizes; and performing linear enhancement on the gray level image based on the final saliency of each pixel point, and detecting the gray level image subjected to linear enhancement to obtain the defect of the mobile phone shell.
First, in step S2, the saliency of the pixel block is analyzed in combination with the texture information and the grayscale information of the pixel block, and the saliency of the target pixel block needs to be analyzed by the pixel blocks in the neighborhood of the target pixel block. Obtaining pixel blocks in the four neighborhoods of the target pixel block, combining the pixel blocks with the target pixel block to form a combined pixel block, obtaining the significance of the target pixel block according to the combined pixel block corresponding to the four neighborhoods of the target pixel block and the corresponding pixel block, and marking as the second significance of the target pixel block:
wherein,representing a second saliency of the target block of pixels;representing the entropy of the a-th combined pixel block corresponding to the target pixel block,expressing the entropy of the a-th pixel block in the four neighborhoods corresponding to the target pixel block;representing the contrast of the a-th combined pixel block corresponding to the target pixel block,representing the contrast of the a-th pixel block in the four neighborhoods corresponding to the target pixel block;representing the energy of the a-th combined pixel block corresponding to the target pixel block,and the energy of the a-th pixel block in the four neighborhoods corresponding to the target pixel block is represented.
The significance of the target pixel block is relatively large when the contrast, entropy and energy of the combined pixel block in the four-neighborhood of the target pixel block and the pixel blocks in the four-neighborhood are obviously changed.
Further, the saliency of the target pixel block is obtained:
the significance of the target pixel block is:
wherein,representing the saliency of a target block of pixels;representing a first saliency of a target block of pixels;representing a second saliency of the target block of pixels;an exponential function with a natural constant e as the base is shown.
Therefore, the significance of each pixel block with the preset size of M × M can be obtained, wherein it needs to be described that the significance of each pixel block is also the significance of a pixel point in the pixel block, in order to more accurately obtain the significance of each pixel point in the gray-scale map, the significance of the pixel point in the gray-scale map needs to be comprehensively analyzed by using a plurality of pixel blocks with the preset size, in this embodiment, the gray-scale map is divided five times in total, that is, five different preset sizes are provided, the size of the pixel block obtained by dividing each time is M/M, wherein M represents the number of dividing times, therefore, the preset size of the pixel block obtained by dividing the first time is 20 × 20, the preset size of the pixel block obtained by dividing the second time is 10 × 10, and by analogy, the preset size of the pixel block obtained by dividing the fifth time is 4*4. Obtaining the final significance of the gray image pixel points according to the significance of the pixel points under each preset size:
wherein N represents the final significance of the pixel points;the number of times of the preset size conversion is shown, in the embodiment, the value is 5, and in the specific implementation process, the implementer adjusts according to the actual situation;and representing the significance of the pixel point under the mth preset size.
Therefore, the final significance of each pixel point in the gray-scale image can be obtained.
Finally, after the final saliency of each pixel point in the gray-scale image is obtained, the gray-scale image is subjected to linear enhancement based on the final saliency of the pixel point so that the defect part can be more prominently displayed, and the detection is facilitated; the linear enhancement is formulated as:
wherein g represents the gray value of the pixel point before linear enhancement, XX represents the gray value of the pixel point after linear enhancement, and N represents the final significance of the pixel point.
And analyzing the linearly enhanced gray level image by utilizing edge detection and Hough circle detection, wherein the detected edge line which is not the edge of the mobile phone shell is a scratch defect, and the detected circle is a pit defect.
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. 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.
Claims (9)
1. A mobile phone shell production quality detection method based on machine vision is characterized by comprising the following steps: preprocessing an image on the surface of the mobile phone shell to obtain a gray scale image, wherein the mobile phone shell comprises a camera hole; dividing the gray scale image into pixel blocks with preset sizes, and obtaining the contrast, entropy, energy and average value, variance, maximum value and minimum value of gray values of each pixel block; obtaining the comprehensive difference of every two pixel blocks by using the contrast, entropy and energy of every two pixel blocks and the average value, variance, maximum value and minimum value of the gray values;
classifying based on the comprehensive difference of every two pixel blocks to obtain pixel blocks of different classes; obtaining the number of pixel blocks contained in a camera hole area in a gray-scale image; taking any pixel block as a target pixel block, wherein the category of the target pixel block is a first category of the target pixel block; obtaining a second category of the target pixel block according to the average value of the comprehensive differences of the pixel blocks in each category except the first category and the target pixel block; obtaining the suppression factor of the target pixel block according to the number of the pixel blocks in the first category, the number of the pixel blocks contained in the camera hole area and the number of all the pixel blocks; acquiring the first significance of the target pixel block by utilizing the comprehensive difference between the target pixel block and the pixel blocks in the first and second categories, and the suppression factor and the category number of the target pixel block;
the target pixel block and the pixel blocks in the neighborhood form a combined pixel block, and the second significance of the target pixel block is obtained according to the contrast, entropy and energy of the combined pixel block and the pixel blocks in the neighborhood; obtaining the significance of the target pixel block based on the first and second significances of the target pixel block; obtaining the significance of all pixel blocks, wherein the significance of the pixel blocks is the significance of each pixel point in the pixel blocks; obtaining the final significance of each pixel point in the gray-scale image by utilizing the significance of each pixel point under different preset sizes; carrying out linear enhancement on the gray level image based on the final saliency of each pixel point, and detecting the gray level image subjected to linear enhancement to obtain the defect of the mobile phone shell;
the obtaining of the suppression factors of the target pixel blocks according to the number of the pixel blocks in the first category, the number of the pixel blocks contained in the camera hole area and the number of all the pixel blocks comprises: obtaining a difference value between the number of pixel blocks in the first category and the number of pixel blocks contained in the camera hole area; and the ratio of the difference value to the number of all pixel blocks is the inhibiting factor of the target pixel block.
2. The method of claim 1, wherein the obtaining the integrated difference of each two pixel blocks by using the contrast, entropy, energy and the mean, variance, maximum and minimum of the gray values of each two pixel blocks comprises: calculating the Euclidean distance of the contrast, entropy and energy of every two pixel blocks to obtain the texture difference of every two pixel blocks; calculating the difference value of the maximum value and the minimum value of the gray values of every two pixel blocks as the range of every two pixel blocks; calculating the mean value of the gray values of every two pixel blocks, the variance of the gray values and the Euclidean distance of the extreme difference to obtain the gray difference of every two pixel blocks; the average value of the sum of the gray difference and the texture difference of every two pixel blocks is the comprehensive difference of every two pixel blocks.
3. The method of claim 1, wherein the obtaining the number of pixel blocks contained in the camera hole area in the grayscale map comprises: carrying out edge detection on the gray-scale image by using a canny operator to obtain a closed edge in the gray-scale image, wherein the area included by the closed edge is a closed edge area, and the closed edge area with the largest area is a camera hole area; the number of pixel blocks contained within the camera hole area includes the number of pixel blocks entirely within the camera hole area and the number of pixel blocks of partial area within the camera hole area.
4. The method of claim 1, wherein said obtaining a second class of target pixel blocks based on an average of the combined differences of the target pixel blocks and pixel blocks within each of the other classes except the first class comprises; and obtaining the minimum value of the average value of the comprehensive differences between the pixel blocks in each category except the first category and the target pixel block, wherein the pixel block category in each category except the first category corresponding to the minimum value of the average value of the comprehensive differences is the second category of the target pixel block.
5. The method for detecting the production quality of the mobile phone shell based on the machine vision is characterized in that the first saliency is as follows:
wherein,representing a first saliency of a target block of pixels;a number of classes representing a classification of the pixel block;representing the number of pixel blocks in a first category of the target pixel block,representing the integrated difference of the ith pixel block and the target pixel block in the first category;representing the number of pixel blocks in the second category of the target pixel block,representing the integrated difference of the jth pixel block and the target pixel block in the second category;a suppression factor representing a target pixel block;represents an adjustment coefficient;an exponential function with a natural constant e as the base is shown.
6. The method of claim 1, wherein the target pixel block and the intra-neighborhood pixel block form a combined pixel block, and the obtaining the second significance of the target pixel block according to the contrast, entropy and energy of the combined pixel block and the intra-neighborhood pixel block comprises: respectively combining the target pixel block and pixel blocks in four neighborhoods to obtain four combined pixel blocks, and obtaining the contrast, entropy and energy of each combined pixel block based on the gray level co-occurrence matrix; the second significance of the target pixel block is:
wherein,representing a second saliency of the target block of pixels;representing the target pixel blocka combining the entropy of the pixel blocks,expressing the entropy of the a-th pixel block in the four neighborhoods corresponding to the target pixel block;representing the contrast of the a-th combined pixel block corresponding to the target pixel block,representing the contrast of the a-th pixel block in the four neighborhoods corresponding to the target pixel block;representing the energy of the a-th combined pixel block corresponding to the target pixel block,and the energy of the a-th pixel block in the four neighborhoods corresponding to the target pixel block is represented.
7. The method for detecting the production quality of the mobile phone shell based on the machine vision as claimed in claim 1, wherein the saliency of the target pixel block is as follows:
8. The method for detecting the production quality of the mobile phone shell based on the machine vision as claimed in claim 1, wherein the final saliency of each pixel point is as follows:
9. The method for detecting the production quality of the mobile phone shell based on the machine vision as claimed in claim 1, wherein the step of performing linear enhancement on the gray scale image based on the final saliency of each pixel point and detecting the gray scale image after the linear enhancement to obtain the defect of the mobile phone shell comprises the steps of: for a pixel point in the gray-scale image, adding the final significance of the pixel point and a first preset value and multiplying the result by the gray value of the pixel point to obtain the gray value of the pixel point after linear enhancement; obtaining gray values of all pixel points in the gray image after linear enhancement, thereby obtaining a gray image after linear enhancement; and analyzing the linearly enhanced gray scale image by utilizing edge detection and Hough circle detection, wherein the detected edge line which is not the edge of the mobile phone shell is a scratch defect, and the detected circle is a pit defect.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211043713.7A CN115147409B (en) | 2022-08-30 | 2022-08-30 | Mobile phone shell production quality detection method based on machine vision |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211043713.7A CN115147409B (en) | 2022-08-30 | 2022-08-30 | Mobile phone shell production quality detection method based on machine vision |
Publications (2)
Publication Number | Publication Date |
---|---|
CN115147409A CN115147409A (en) | 2022-10-04 |
CN115147409B true CN115147409B (en) | 2022-11-29 |
Family
ID=83416439
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211043713.7A Active CN115147409B (en) | 2022-08-30 | 2022-08-30 | Mobile phone shell production quality detection method based on machine vision |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115147409B (en) |
Families Citing this family (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115797299B (en) * | 2022-12-05 | 2023-09-01 | 常宝新材料(苏州)有限公司 | Defect detection method of optical composite film |
CN115695621B (en) * | 2022-12-29 | 2023-05-23 | 昆山市恒达精密机械工业有限公司 | Quality detection and evaluation method and system for mobile phone shell processing |
CN115797225B (en) * | 2023-01-06 | 2023-04-21 | 山东环宇地理信息工程有限公司 | Unmanned ship acquired image enhancement method for underwater topography measurement |
CN116503426B (en) * | 2023-06-26 | 2023-08-25 | 天津大学 | Ultrasound Image Segmentation Method Based on Image Processing |
CN116703899B (en) * | 2023-08-03 | 2023-10-24 | 青岛义龙包装机械有限公司 | Bag type packaging machine product quality detection method based on image data |
CN116912254B (en) * | 2023-09-14 | 2023-12-08 | 山东博诚电气有限公司 | Cable defect identification method based on data enhancement preprocessing |
CN116993724B (en) * | 2023-09-26 | 2023-12-08 | 卡松科技股份有限公司 | Visual detection method for coal mine industrial gear oil based on image filtering |
Family Cites Families (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103729842B (en) * | 2013-12-20 | 2016-04-27 | 中原工学院 | Based on the fabric defect detection method of partial statistics characteristic and overall significance analysis |
CN105160652A (en) * | 2015-07-10 | 2015-12-16 | 天津大学 | Handset casing testing apparatus and method based on computer vision |
CN106875381B (en) * | 2017-01-17 | 2020-04-28 | 同济大学 | Mobile phone shell defect detection method based on deep learning |
CN109543701A (en) * | 2018-11-30 | 2019-03-29 | 长沙理工大学 | Vision significance method for detecting area and device |
CN109872304B (en) * | 2019-01-17 | 2022-12-02 | 京东方科技集团股份有限公司 | Image defect detection method and device, electronic device and storage medium |
CN111080574A (en) * | 2019-11-19 | 2020-04-28 | 天津工业大学 | A fabric defect detection method based on information entropy and visual attention mechanism |
CN111896556B (en) * | 2020-08-04 | 2021-05-28 | 湖南大学 | A method and system for detecting glass bottle bottom defects based on machine vision |
CN113888461A (en) * | 2021-08-26 | 2022-01-04 | 华能大理风力发电有限公司 | Method, system and equipment for detecting defects of hardware parts based on deep learning |
CN114494179A (en) * | 2022-01-24 | 2022-05-13 | 深圳闪回科技有限公司 | Mobile phone back damage point detection method and system based on image recognition |
-
2022
- 2022-08-30 CN CN202211043713.7A patent/CN115147409B/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN115147409A (en) | 2022-10-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN115147409B (en) | Mobile phone shell production quality detection method based on machine vision | |
CN114937055B (en) | Image self-adaptive segmentation method and system based on artificial intelligence | |
CN116309537B (en) | Defect detection method for oil stain on surface of tab die | |
CN115082419A (en) | Blow-molded luggage production defect detection method | |
CN116152242B (en) | Visual detection system of natural leather defect for basketball | |
CN117218122B (en) | Watch shell quality detection method based on image data | |
CN116883408B (en) | Integrating instrument shell defect detection method based on artificial intelligence | |
CN115063409A (en) | Method and system for detecting surface material of mechanical cutter | |
CN109726649B (en) | Remote sensing image cloud detection method, system and electronic equipment | |
WO2021118463A1 (en) | Defect detection in image space | |
CN115619775B (en) | Material counting method and device based on image recognition | |
CN114782329A (en) | Bearing defect damage degree evaluation method and system based on image processing | |
CN113256624A (en) | Continuous casting round billet defect detection method and device, electronic equipment and readable storage medium | |
CN110866915A (en) | Circular inkstone quality detection method based on metric learning | |
CN118279304B (en) | Abnormal recognition method, device and medium for special-shaped metal piece based on image processing | |
CN108573254B (en) | License plate character gray scale image generation method | |
CN114820625A (en) | Automobile top block defect detection method | |
CN115131356A (en) | Steel plate defect classification method based on richness | |
CN117392066A (en) | Defect detection method, device, equipment and storage medium | |
CN117974671A (en) | Watch dial defect intelligent detection method based on artificial intelligence | |
CN109726660A (en) | A method of remote sensing image ship recognition | |
CN115033721A (en) | Image retrieval method based on big data | |
CN115082449A (en) | Electronic component defect detection method | |
CN119090879A (en) | Printing material surface quality detection method based on image enhancement | |
CN116703930B (en) | Automobile rearview mirror mold forming detection method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |