# US 2023/0401691 A1 · Image defect detection method, electronic device and readable storage medium

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2023/0401691 A1
- Document ID: US20230401691A1
- Status: Published application
- Kind: A1
- Application number: 17/896,663
- Filed: 2022-08-26
- Published: 2023-12-14
- Earliest claimed: 2022-06-09
- Assignees: Hon Hai Precision Industry Co., Ltd.
- Applicants: Hon Hai Precision Industry Co., Ltd.
- Inventors: CHIH-TE LU; WAN-JHEN LEE; CHIN-PIN KUO
- Web page: https://patentgrep.com/patent/US20230401691A1

## CPC

- G06T 7/0008: {checking presence/absence}
- G06V 10/52: Scale-space analysis, e.g. wavelet analysis (multi-scale boundary representations G06V10/42)
- G06T 5/50: using two or more images, e.g. averaging or subtraction
- G06T 7/0002: {Inspection of images, e.g. flaw detection}
- G06T 7/11: Region-based segmentation
- G06V 10/28: Quantising the image, e.g. histogram thresholding for discrimination between background and foreground patterns
- G06V 10/761: {Proximity, similarity or dissimilarity measures}
- G06V 10/82: using neural networks
- G06V 10/98: Detection or correction of errors, e.g. by rescanning the pattern or by human intervention; Evaluation of the quality of the acquired patterns
- G06T 2207/20016: Hierarchical, coarse-to-fine, multiscale or multiresolution image processing; Pyramid transform
- G06T 2207/20021: Dividing image into blocks, subimages or windows
- G06T 2207/20076: Probabilistic image processing
- G06T 2207/20081: Training; Learning
- G06T 2207/20084: Artificial neural networks [ANN]
- G06T 2207/20224: Image subtraction
- G06V 2201/07: Target detection
- Y02P 90/30: Computing systems specially adapted for manufacturing
- G06T: IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06V: IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- Y02P: CLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS

## Abstract

An image defect detection method applied to an electronic device is provided. The method includes dividing a detecting image into a plurality of detecting areas, generating a detection accuracy value for each detecting area based on a defective image and a non-defective image, and obtaining a plurality of detection accuracy values. An autoencoder is selected for each detection accuracy value. A model corresponding to each detecting area is obtained by training the autoencoder based on the non-defective image. A plurality of reconstructed image blocks is obtained by inputting each of a plurality of detecting blocks into the corresponding model, and a reconstruction error value between each reconstructed image block and the corresponding detecting block is obtained. A detection result of a product contained in the image to be detected is obtained based on the reconstruction error value corresponding to each detecting block.

## Claims

### Claim 1

An image defect detection method applied to an electronic device, the method comprising:
acquiring an image to be detected, a defective image, and a non-defective image;
dividing the image to be detected into a plurality of detecting areas, generating a detection accuracy value for each of the plurality of detecting areas based on the defective image and the non-defective image, and obtaining a plurality of detection accuracy values;
constructing a plurality of learners;
selecting an autoencoder for each of the plurality of detection accuracy values from the plurality of learners;
obtaining a multi-scale autoencoder model corresponding to each of the plurality of detecting areas by training the corresponding autoencoder based on the non-defective image;
dividing each of the plurality of detecting areas into a plurality of detecting blocks, and obtaining a plurality of reconstructed image blocks by inputting each of the plurality of detecting blocks into the corresponding multi-scale autoencoder model;
calculating a reconstruction error value between each of the plurality of reconstructed image blocks and the corresponding detecting block;
generating a detection result of a product contained in the image to be detected based on the reconstruction error value corresponding to each detecting block.

### Claim 2 (depends on 1)

The image defect detection method according to claim 1, wherein generating the detection accuracy value for each of the plurality of areas based on the defective image and the non-defective image comprises:
dividing the defective image into a plurality of defective areas, and dividing the non-defective image into a plurality of non-defective areas;
dividing each of the plurality of defective areas into a plurality of defective blocks; and dividing each of the plurality of non-defective areas into a plurality of non-defective blocks;
for each of the plurality of defective areas, calculating a similarity value between each of the plurality of defective blocks and a corresponding non-defective block and obtaining a plurality of similarity values;
calculating an average value of the plurality of similarity values, and determining the calculated average value as being a target average value corresponding to each defective area, therefore obtaining a plurality of target average values each of which is corresponding to one of the plurality of defective areas;
generating a parameter range of each defective area based on the target average value corresponding to each defective area; and
determining the parameter range of each defective area as the detection accuracy value of a corresponding detecting area.

### Claim 3 (depends on 2)

The image defect detection method according to claim 2, wherein selecting the autoencoder for each detection accuracy value from the plurality of learners comprises:
determining each defective block in each defective area and the corresponding non-defective block in the non-defective area as being test image blocks;
obtaining a marking result of each of the test image blocks;
obtaining a plurality of first reconstructed image blocks by inputting each of the test image blocks in each of the plurality of learners;
calculating an error value between each of the first reconstructed image blocks and the corresponding test image block;
generating a verification result according to the error value and a first preset value; obtaining a comparison result by comparing the verification result with the marking result;
calculating a correct rate of each learner according to the comparison result;
selecting the learner corresponding to a highest correct rate as the autoencoder corresponding to each defective area; and
determining the autoencoder corresponding to each defective area as the autoencoder of the detection accuracy value corresponding each defective area.

### Claim 4 (depends on 3)

The image defect detection method according to claim 3, wherein calculating the correct rate of each learner according to the comparison result comprises:
for each learner, determining the verification result that is the same as the marking result as a target result;
counting a first quantity of the target results, and counting a second quantity of the verification results;
calculating a ratio of the target results in the verification results according to the first quantity and the second quantity; and
determining the calculated ratio as the correct rate of each learner.

### Claim 5 (depends on 1)

The image defect detection method according to claim 1, wherein constructing the plurality of learners comprises:
constructing latent spaces with a plurality of sizes;
obtaining a plurality of operation results by performing operations according to each of the plurality of sizes and an image size of each detecting block;
for each of the plurality of sizes, constructing a corresponding number of hidden layers as an encoder according to the plurality of operation results, and constructing a corresponding number of operation layers as a decoder according to the plurality of operation results; and
generating a learner according to the encoder, the latent space and the decoder corresponding to each of the plurality of size, and obtaining the plurality of learners.

### Claim 6 (depends on 5)

The image defect detection method according to claim 5, wherein obtaining the plurality of reconstructed image blocks by inputting each of the plurality of detecting blocks into the corresponding multi-scale autoencoder model comprises:
obtaining a feature vector by inputting each detecting block into the hidden layer of the corresponding multi-scale self-encoder model for feature extraction;
determining the obtained feature vector as an input vector of a next hidden layer;
determining a feature vector output by a last hidden layer as a potential vector corresponding to the image to be detected;
obtaining a reconstructed vector output by each operation layer by inputting the potential vector into the operation layer of the corresponding multi-scale autoencoder model, determining the reconstruction vector output by each operation layer as being the input vector of a next operation layer; and
obtaining the plurality of reconstructed image blocks by performing conversion on the reconstruction vector output by the last operation layer.

### Claim 7 (depends on 1)

The image defect detection method according to claim 1, wherein calculating the reconstruction error value between each reconstructed image block and the corresponding detecting block comprises:
obtaining a difference image by performing a subtraction operation between a pixel value of each pixel point in each reconstructed image block and a pixel value of the corresponding pixel point in the detecting block;
obtaining a binarized image by binarizing the difference image;
extracting the pixel points whose pixel value equals a configuration value from the binarized image as a target area; and
obtaining the reconstruction error value by calculating an area of the target area.

### Claim 8 (depends on 1)

The image defect detection method according to claim 1, wherein generating the detection result of the product contained in the image to be detected based on the reconstruction error value corresponding to each detecting block comprises:
comparing the reconstruction error value corresponding to each detecting block with a second preset value;
if the reconstruction error value corresponding to a certain detecting block is greater than the second preset value, determining the certain detecting block as a target image block;
locating a position of the target image block in the image to be detected as a position of a defect; and
determining that the product to be detected is defective and outputting the position of the defect.

### Claim 9

An electronic device comprising:
a storage device;
at least one processor; and
the storage device storing one or more programs, which when executed by the at least one processor, cause the at least one processor to:
acquire an image to be detected, a defective image, and a non-defective image;
divide the image to be detected into a plurality of detecting areas, generate a detection accuracy value for each of the plurality of detecting areas based on the defective image and the non-defective image, and obtain a plurality of detection accuracy values;
construct a plurality of learners;
select an autoencoder for each of the plurality of detection accuracy values from the plurality of learners;
obtain a multi-scale autoencoder model corresponding to each of the plurality of detecting areas by training the corresponding autoencoder based on the non-defective image;
divide each of the plurality of detecting areas into a plurality of detecting blocks, and obtain a plurality of reconstructed image blocks by inputting each of the plurality of detecting blocks into the corresponding multi-scale autoencoder model;
calculate a reconstruction error value between each of the plurality of reconstructed image blocks and the corresponding detecting block; and
generate a detection result of a product contained in the image to be detected based on the reconstruction error value corresponding to each detecting block.

### Claim 10 (depends on 9)

The electronic device according to claim 9, wherein the at least one processor generates the detection accuracy value for each of the plurality of areas based on the defective image and the non-defective image by:
dividing the defective image into a plurality of defective areas, and dividing the non-defective image into a plurality of non-defective areas;
dividing each of the plurality of defective areas into a plurality of defective blocks; and dividing each of the plurality of non-defective areas into a plurality of non-defective blocks;
for each of the plurality of defective areas, calculating a similarity value between each of the plurality of defective blocks and a corresponding non-defective block and obtaining a plurality of similarity values;
calculating an average value of the plurality of similarity values, and determining the calculated average value as being a target average value corresponding to each defective area, therefore obtaining a plurality of target average values each of which is corresponding to one of the plurality of defective areas;
generating a parameter range of each defective area based on the target average value corresponding to each defective area; and
determining the parameter range of each defective area as the detection accuracy value of a corresponding detecting area.

### Claim 11 (depends on 10)

The electronic device according to claim 10, wherein the at least one processor selects the autoencoder for each detection accuracy value from the plurality of learners by:
determining each defective block in each defective area and the corresponding non-defective block in the non-defective area as being test image blocks;
obtaining a marking result of each of the test image blocks;
obtaining a plurality of first reconstructed image blocks by inputting each of the test image blocks in each of the plurality of learners;
calculating an error value between each of the first reconstructed image blocks and the corresponding test image block;
generating a verification result according to the error value and a first preset value; obtaining a comparison result by comparing the verification result with the marking result;
calculating a correct rate of each learner according to the comparison result;
selecting the learner corresponding to a highest correct rate as the autoencoder corresponding to each defective area; and
determining the autoencoder corresponding to each defective area as the autoencoder of the detection accuracy value corresponding each defective area.

### Claim 12 (depends on 11)

The electronic device according to claim 11, wherein the at least one processor calculates the correct rate of each learner according to the comparison result by:
for each learner, determining the verification result that is the same as the marking result as a target result;
counting a first quantity of the target results, and counting a second quantity of the verification results;
calculating a ratio of the target results in the verification results according to the first quantity and the second quantity; and
determining the calculated ratio as the correct rate of each learner.

### Claim 13 (depends on 9)

The electronic device according to claim 9, wherein the at least one processor constructs the plurality of learners by:
constructing latent spaces with a plurality of sizes;
obtaining a plurality of operation results by performing operations according to each of the plurality of sizes and an image size of each detecting block;
for each of the plurality of sizes, constructing a corresponding number of hidden layers as an encoder according to the plurality of operation results, and constructing a corresponding number of operation layers as a decoder according to the plurality of operation results; and
generating a learner according to the encoder, the latent space and the decoder corresponding to each of the plurality of size, and obtaining the plurality of learners.

### Claim 14 (depends on 13)

The electronic device according to claim 13, wherein the at least one processor obtains the plurality of reconstructed image blocks by inputting each of the plurality of detecting blocks into the corresponding multi-scale autoencoder model by:
obtaining a feature vector by inputting each detecting block into the hidden layer of the corresponding multi-scale self-encoder model for feature extraction;
determining the obtained feature vector as an input vector of a next hidden layer;
determining a feature vector output by a last hidden layer as a potential vector corresponding to the image to be detected;
obtaining a reconstructed vector output by each operation layer by inputting the potential vector into the operation layer of the corresponding multi-scale autoencoder model, determining the reconstruction vector output by each operation layer as being the input vector of a next operation layer; and
obtaining the plurality of reconstructed image blocks by performing conversion on the reconstruction vector output by the last operation layer.

### Claim 15 (depends on 9)

The electronic device according to claim 9, wherein the at least one processor calculates the reconstruction error value between each reconstructed image block and the corresponding detecting block by:
obtaining a difference image by performing a subtraction operation between a pixel value of each pixel point in each reconstructed image block and a pixel value of the corresponding pixel point in the detecting block;
obtaining a binarized image by binarizing the difference image;
extracting the pixel points whose pixel value equals a configuration value from the binarized image as a target area; and
obtaining the reconstruction error value by calculating an area of the target area.

### Claim 16 (depends on 9)

The electronic device according to claim 9, wherein the at least one processor generates the detection result of the product contained in the image to be detected based on the reconstruction error value corresponding to each detecting block by:
comparing the reconstruction error value corresponding to each detecting block with a second preset value;
if the reconstruction error value corresponding to a certain detecting block is greater than the second preset value, determining the certain detecting block as a target image block;
locating a position of the target image block in the image to be detected as a position of a defect; and
determining that the product to be detected is defective and outputting the position of the defect.

### Claim 17

A non-transitory storage medium having instructions stored thereon, when the instructions are executed by a processor of an electronic device, the processor is caused to perform an image defect detection method, wherein the method comprises:
acquiring an image to be detected, a defective image, and a non-defective image;
dividing the image to be detected into a plurality of detecting areas, generating a detection accuracy value for each of the plurality of detecting areas based on the defective image and the non-defective image, and obtaining a plurality of detection accuracy values;
constructing a plurality of learners;
selecting an autoencoder for each of the plurality of detection accuracy values from the plurality of learners;
obtaining a multi-scale autoencoder model corresponding to each of the plurality of detecting areas by training the corresponding autoencoder based on the non-defective image;
dividing each of the plurality of detecting areas into a plurality of detecting blocks, and obtaining a plurality of reconstructed image blocks by inputting each of the plurality of detecting blocks into the corresponding multi-scale autoencoder model;
calculating a reconstruction error value between each of the plurality of reconstructed image blocks and the corresponding detecting block;
generating a detection result of a product contained in the image to be detected based on the reconstruction error value corresponding to each detecting block.

### Claim 18 (depends on 17)

The non-transitory storage medium according to claim 17, wherein generating the detection accuracy value for each of the plurality of areas based on the defective image and the non-defective image comprises:
dividing the defective image into a plurality of defective areas, and dividing the non-defective image into a plurality of non-defective areas;
dividing each of the plurality of defective areas into a plurality of defective blocks; and dividing each of the plurality of non-defective areas into a plurality of non-defective blocks;
for each of the plurality of defective areas, calculating a similarity value between each of the plurality of defective blocks and a corresponding non-defective block and obtaining a plurality of similarity values;
calculating an average value of the plurality of similarity values, and determining the calculated average value as being a target average value corresponding to each defective area, therefore obtaining a plurality of target average values each of which is corresponding to one of the plurality of defective areas;
generating a parameter range of each defective area based on the target average value corresponding to each defective area; and
determining the parameter range of each defective area as the detection accuracy value of a corresponding detecting area.

### Claim 19 (depends on 18)

The non-transitory storage medium according to claim 18, wherein selecting the autoencoder for each detection accuracy value from the plurality of learners comprises:
determining each defective block in each defective area and the corresponding non-defective block in the non-defective area as being test image blocks;
obtaining a marking result of each of the test image blocks;
obtaining a plurality of first reconstructed image blocks by inputting each of the test image blocks in each of the plurality of learners;
calculating an error value between each of the first reconstructed image blocks and the corresponding test image block;
generating a verification result according to the error value and a first preset value; obtaining a comparison result by comparing the verification result with the marking result;
calculating a correct rate of each learner according to the comparison result;
selecting the learner corresponding to a highest correct rate as the autoencoder corresponding to each defective area; and
determining the autoencoder corresponding to each defective area as the autoencoder of the detection accuracy value corresponding each defective area.

### Claim 20 (depends on 17)

The non-transitory storage medium according to claim 17, wherein calculating the correct rate of each learner according to the comparison result comprises:
for each learner, determining the verification result that is the same as the marking result as a target result;
counting a first quantity of the target results, and counting a second quantity of the verification results;
calculating a ratio of the target results in the verification results according to the first quantity and the second quantity; and
determining the calculated ratio as the correct rate of each learner.
