IP Library › Granted Patent US 12,118,714
Granted Patent B2
US 12,118,714 · App. 17/566,159 · Granted Oct 15, 2024

Method of detecting and classifying defects and electronic device using the same

Inventors: Tung-Tso Tsai (New Taipei, TW); Tzu-Chen Lin (New Taipei, TW); Chin-Pin Kuo (New Taipei, TW); Shih-Chao Chien (New Taipei, TW)
Assignee: HON HAI PRECISION INDUSTRY CO., LTD.
G06T7/001G06T2207/20081G06T2207/30108
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,118,714
App. No.
17/566,159
Granted
Oct 15, 2024
Kind
B2
Abstract

A method applied in an electronic device for detecting and classifying apparent defects in images of products inputs an image to a trained autoencoder to obtain a reconstructed image, determines whether the image reveals defects based on a defect criterion for filtering out small noise reconstruction errors. If so revealed, the electronic device calculates a plurality of structural similarity values between the image and a plurality of template images with marked defect categories, determines a target defect category corresponding to the highest structural similarity value, and classifies the defect revealed in the image into the target defect category.

Claims (382)

1. A method for detecting and classifying defects comprising:

inputting an image to be detected to a trained autoencoder, and obtaining a reconstructed image corresponding to the image to be detected;

determining whether the image to be detected has defects based on a defect criteria for filtering out small noise reconstruction errors;

in response that the image to be detected has defects, calculating a plurality of structural similarity values between the image to be detected and a plurality of template images marking defect categories respectively;

determining a target defect category corresponding to the template image with the highest structural similarity value, and classifying the image to be detected into the target defect category, wherein a mathematical expression of the defect criteria is

∑

i

,

j

⁢

Δ

⁢

⁢

X

i

,

j

*

δ

⁢

⁢

X

i

,

j

∑

i

,

j

⁢

δ

⁢

⁢

X

i

,

j

>

τ

,

wherein ΔX i,j is a reconstruction error image between the image to be detected and the reconstructed image, δX i,j is a binary image of the reconstruction error image, i and j represent pixel positions, τ is a preset reconstruction error measurement threshold.

2. The method for detecting and classifying defects as recited in claim 1 , wherein τ is a statistical value of a reconstruction error corresponding to a reconstructed error image between the image and the reconstructed image, and the τ is adjusted based on a recall rate of a preset defect detection and an accuracy rate of the preset defect detection, the accuracy rate is a number of the images correctly detected as defective as a proportion of a number of all images detected as defective, and the recall rate is the number of the images correctly detected as defective as a proportion of the number of all images showing real defects.

3. The method for detecting and classifying defects as recited in claim 1 , wherein a binary image calculation formula of the binary image is

δ

⁢

⁢

X

i

,

j

=

{

1

Δ

⁢

⁢

X

i

,

j

>

ɛ

0

otherwise

,

ε is a filtering threshold of small noise reconstruction error.

4. The method for detecting and classifying defects as recited in claim 1 , further comprising:

training the autoencoder by an optimization objective function, wherein the optimization objective function is |X−X′| 1 +λ|X−X′| 2 , wherein X is the image to be detected, X′ is the reconstructed image, λ is a weight with a value range of 0.1-10, |X−X′| 1 is an L1 norm of a reconstructed error image between the image and the reconstructed image, and |X−X′ 2 is L2 norm of the reconstruction error image.

5. The method for detecting and classifying defects as recited in claim 1 , further comprising:

calculating the structural similarity values between the image to be detected and the number of template images marking defect categories respectively according to SSIM(x,y)=[l(x,y)] α [c(x,y)] β [s(x,y)] γ , wherein,

l

⁡

(

x

,

y

)

=

2

⁢

μ

x

⁢

μ

y

+

C

1

μ

x

2

+

μ

y

2

+

C

1

,

c

⁡

(

x

,

y

)

=

2

⁢

σ

x

⁢

σ

y

+

C

2

σ

x

2

+

σ

y

2

+

C

2

,

s

⁡

(

x

,

y

)

=

2

⁢

σ

xy

+

C

3

σ

x

⁢

σ

y

+

C

3

,

x is the image to be detected, y is the template image, and SSIM(x,y) is the structural similarity values between the image to be detected and the template image, l(x,y) is used to compare a brightness of x with a brightness of y, μ x , μ y represent an image mean of x and an image mean of y, and c(x,y) is used to compare an image contrast of x with an image contrast of y, σ x , σ y represent an image standard deviation of x and an image standard deviation of y, σ xy is an image covariance between x and y, C 1 , C 2 , C 3 are constants.

6. The method for detecting and classifying defects as recited in claim 1 , wherein the structural similarity value of the image to be detected and the template image is positively correlated with the similarity between the image to be detected and the template image.

7. The method for detecting and classifying defects as recited in claim 1 , further comprising:

in response that the image to be detected complies with a defect criterion of filtering out small noise reconstruction error, determining that the image to be detected has defects;

in response that the image to be detected does not comply with the defect judgment criterion, determining that the image to be detected to be determined to have no defect.

8. An electronic device comprising:

a processor; and

a non-transitory storage medium coupled to the processor and configured to store a plurality of instructions, which cause the processor to:

input an image to be detected to a trained autoencoder to obtain a reconstructed image corresponding to the image to be detected;

determine whether the image to be detected has defects based on a defect criteria for filtering out small noise reconstruction errors;

in response that the image to be detected has defects, calculate a plurality of structural similarity values between the image to be detected and a plurality of template images marking defect categories respectively;

determine a target defect category corresponding to the template image with the highest structural similarity value, and classifying the image to be detected into the target defect category, wherein a mathematical expression of the defect criteria is

∑

i

,

j

⁢

Δ

⁢

⁢

X

i

,

j

*

δ

⁢

⁢

X

i

,

j

∑

i

,

j

⁢

δ

⁢

⁢

X

i

,

j

>

τ

,

wherein ΔX i,j is a reconstruction error image between the image to be detected and the reconstructed image, δX i,j is a binary image of the reconstruction error image, i and j represent pixel positions, τ is a preset reconstruction error measurement threshold.

9. The electronic device as recited in claim 8 , wherein τ is a statistical value of a reconstruction error corresponding to a reconstructed error image between the image and the reconstructed image, and the t is adjusted based on a recall rate of a preset defect detection and an accuracy rate of the preset defect detection, the accuracy rate is a number of the images correctly detected as defective as a proportion of the number of all images detected as defective, and the recall rate is the number of the images correctly detected as defective as a proportion of the number of all images showing real defects.

10. The electronic device as recited in claim 8 , wherein a binary image calculation formula of the binary image is

δ

⁢

⁢

X

i

,

j

=

{

1

Δ

⁢

⁢

X

i

,

j

>

ɛ

0

otherwise

,

ε is a filtering threshold of small noise reconstruction error.

11. The electronic device as recited in claim 8 , wherein the plurality of instructions are further configured to cause the processor to:

train the autoencoder by an optimization objective function, wherein the optimization objective function is |X−X′| 1 +λ|X−X′| 2 , wherein X is the image to be detected, X′ is the reconstructed image, λ is a weight with a value range of 0.1-10, |X−X′| 1 is an L1 norm of a reconstructed error image between the image and the reconstructed image, and |X−X′ 2 is L2 norm of the reconstruction error image.

12. The electronic device as recited in claim 8 , wherein the plurality of instructions are further configured to cause the processor to:

calculate the structural similarity values between the image to be detected and the number of template images marking defect categories respectively according to SSIM (x,y)=[l(x,y)] α [c(x,y)] β [s(x,y)] γ , wherein,

l

⁡

(

x

,

y

)

=

2

⁢

μ

x

⁢

μ

y

+

C

1

μ

x

2

+

μ

y

2

+

C

1

,

c

⁡

(

x

,

y

)

=

2

⁢

σ

x

⁢

σ

y

+

C

2

σ

x

2

+

σ

y

2

+

C

2

,

s

⁡

(

x

,

y

)

=

2

⁢

σ

xy

+

C

3

σ

x

⁢

σ

y

+

C

3

,

x is the image to be detected, y is the template image, and SSIM(x,y) is the structural similarity values between the image to be detected and the template image, l(x,y) is used to compare a brightness of x with a brightness of y, μ x , μ y represent an image mean of x and an image mean of y, and c(x,y) is used to compare an image contrast of x with an image contrast of y, σ x , σ y represent an image standard deviation of x and an image standard deviation of y, σ xy is an image covariance between x and y, C 1 , C 2 , C 3 are constants.

13. The electronic device as recited in claim 8 , wherein the structural similarity value of the image to be detected and the template image is positively correlated with the similarity between the image to be detected and the template image.

14. The electronic device as recited in claim 8 , wherein the plurality of instructions are further configured to cause the processor to:

in response that the image to be detected complies with a defect criterion of filtering out small noise reconstruction error, determine that the image to be detected has defects;

in response that the image to be detected doesn't comply with the defect judgment criterion, determine that the image to be detected to be determined to have no defect.

15. A non-transitory storage medium having stored thereon instructions that, when executed by at least one processor of an electronic device, causes the least one processor to execute instructions of a method for detecting and classifying defects, the method comprising:

inputting an image to be detected to a trained autoencoder to obtain a reconstructed image corresponding to the image to be detected;

determining whether the image to be detected has defects based on a defect criteria for filtering out small noise reconstruction errors;

in response that the image to be detected has defects, calculating a plurality of structural similarity values between the image to be detected and a plurality of template images marking defect categories respectively;

determining a target defect category corresponding to the template image with the highest structural similarity value, and classifying the image to be detected into the target defect category, wherein a mathematical expression of the defect criteria is

∑

i

,

j

⁢

Δ

⁢

⁢

X

i

,

j

*

δ

⁢

⁢

X

i

,

j

∑

i

,

j

⁢

δ

⁢

⁢

X

i

,

j

>

τ

,

wherein ΔX i,j is a reconstruction error image between the image to be detected and the reconstructed image, δX i,j is a binary image of the reconstruction error image, i and j represent pixel positions, τ is a preset reconstruction error measurement threshold.

16. The non-transitory storage medium as recited in claim 15 , wherein τ is a statistical value of a reconstruction error corresponding to a reconstructed error image between the image and the reconstructed image, and the t is adjusted based on a recall rate of a preset defect detection and an accuracy rate of the preset defect detection, the accuracy rate is a number of the images correctly detected as defective as a proportion of the number of all images detected as defective, and the recall rate is the number of the images correctly detected as defective as a proportion of the number of all images showing real defects.

17. The non-transitory storage medium as recited in claim 15 , wherein a binary image calculation formula of the binary image is

δ

⁢

⁢

X

i

,

j

=

{

1

Δ

⁢

⁢

X

i

,

j

>

ɛ

0

otherwise

,

ε is a filtering threshold of small noise reconstruction error.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Dec 30, 2021
From: TSAI, TUNG-TSO; LIN, TZU-CHEN; KUO, CHIN-PIN; CHIEN, SHIH-CHAO
To: HON HAI PRECISION INDUSTRY CO., LTD.
Reel/Frame 058510/0753 →
Priority Claims (1)
CN 202011633792.8 · Dec 31, 2020 · national
Continuity (1)
Related Publication 20220207687A1 · Jun 30, 2022