Search

US-12626501-B2 - Method for detecting defect in image and device for detecting defect in image

US12626501B2US 12626501 B2US12626501 B2US 12626501B2US-12626501-B2

Abstract

A method for detecting defect in image is provided. The method obtains a number of original images, determines a first reference image from the original images, and performs a histogram matching on the original images excluding the first reference image according to the first reference image, to obtain a plurality of matched images. The method further generates a synthesized image according to pixel intensities of the matched images and pixel intensities of the first reference image; and uses the synthesized image as a second reference image to perform an image comparison with a test image, to generate a result of defect detection. A related device and a related non-transitory storage medium are also provided.

Inventors

  • LI-CHE LIN
  • Yen-Yi Lin
  • Cheng-Feng Wang

Assignees

  • HON HAI PRECISION INDUSTRY CO., LTD.

Dates

Publication Date
20260512
Application Date
20230719
Priority Date
20220721

Claims (17)

  1. 1 . A method of detecting defect in image comprising: obtaining a plurality of original images; selecting one of the plurality of original images as a first reference image, and serving the plurality of original images without the first reference image as the other images; matching a histogram of each of the other images with a histogram of the first reference image according to the first reference image, to obtain a plurality of matched images; overlapping the plurality of matched images and the first reference image to generate a plurality of overlapping images, each of the plurality of overlapping images comprising a plurality of pixel points; generating a synthesized image according to pixel intensities of the plurality of overlapping image; and using the synthesized image as a second reference image to perform an image comparison with a test image, to generate a result of defect detection; wherein the generating the synthesized image according to pixel intensities of the plurality of overlapping images comprises: for each of the plurality of pixel points in an overlapping image of the plurality of overlapping images, determining a median pixel intensity of a plurality of pixel intensities at a same pixel point of the plurality of overlapping images; and generating the synthesized image according to the median pixel intensity corresponding to each of the plurality of pixel points; wherein the histogram of each of the plurality of matched images is adjusted based on a degree of similarity between the histogram of each of the other images and the histogram of the first reference image.
  2. 2 . The method according to claim 1 , wherein: before the determining the first reference image from the plurality of original images, the method further comprises: obtaining pixel distribution information of each of the plurality of original images, where the pixel distribution information comprising a distribution of pixel points and a plurality of pixel intensities corresponding to the pixel points; the determining the first reference image from the plurality of original images comprises: dividing averagely the plurality of image intensities of each of the plurality of original images into a plurality of ranges of intensity; counting a quantity of pixel points fell in each of the plurality of ranges of intensity; determining a plurality of pixel distribution maps corresponding to the original images according to the plurality of ranges of intensity of the original images and the quantity of the pixel points fell in each of the plurality of ranges of intensity; each of the plurality of pixel distribution maps corresponding to one of the plurality of original images; determining the first reference image to be an image corresponding to one of the plurality of pixel distribution maps which is a most standard normal distribution among the plurality of pixel distribution maps.
  3. 3 . The method according to claim 1 , wherein: the overlapping the plurality of matched images and the first reference image to generate the plurality of overlapping images comprises: aligning each of the plurality of matched images with the first reference image; and generating the plurality of overlapping images, which are overlapped areas among the aligned plurality of matched images and first reference image.
  4. 4 . The method according to claim 1 , wherein: before using the synthesized image as the second reference image to perform the image comparison with the test image, to generate the result of defect detection, the method further comprises: performing a gaussian blur processing on the test image; the using the synthesized image as the second reference image to perform the image comparison with the test image, to generate the result of defect detection comprises: using the synthesized image as the second reference image to perform the image comparison with the test image after the Gaussian blur processing is performed, to generate the result of the defect detection.
  5. 5 . The method according to claim 1 , wherein: the using the synthesized image as the second reference image to perform the image comparison with the test image, to generate the result of defect detection comprises: generating the result of the defect detection according to a result of a luminance comparison, a result of a contrast comparison, and a result of a structure comparison between the synthesized image and the test image.
  6. 6 . The method according to claim 1 , wherein: the using the synthesized image as the second reference image to perform the image comparison with the test image, to generate the result of defect detection comprises: using the synthesized image as the second reference image; partitioning the second reference image and the test image to generate a plurality of image blocks; performing the image comparison between each of the plurality of image blocks of the test image and a corresponding of the plurality of image blocks of the second reference image; determining one of the plurality of image blocks of the test image to be a defect block and remark the defect in the defect block if a result of the image comparison between the one of the plurality of image blocks of the test image and one corresponding of the plurality of image blocks of the second reference image is greater than a preset threshold.
  7. 7 . A device configured for detecting defects in an image, the 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: obtain a plurality of original images; select one of the plurality of original images as a first reference image, and serve the plurality of original images without the first reference image as the other images; match a histogram of each of the other images with a histogram of the first reference image according to the first reference image, to obtain a plurality of matched images; overlap the plurality of matched images and the first reference image to generate a plurality of overlapping images, each of the plurality of overlapping images comprising a plurality of pixel points; generate a synthesized image according to pixel intensities of the plurality of overlapping image; and use the synthesized image as a second reference image to perform an image comparison with a test image, to generate a result of defect detection; wherein further causing the at least one processor to: for each of the plurality of pixel points in an overlapping image of the plurality of overlapping images, determine a median pixel intensity of a plurality of pixel intensities at a same pixel point of the plurality of overlapping images; and generate the synthesized image according to the median pixel intensity corresponding to each of the plurality of pixel points; wherein the histogram of each of the plurality of matched images is adjusted based on a degree of similarity between the histogram of each of the other images and the histogram of the first reference image.
  8. 8 . The device according to claim 7 , further causing the at least one processor to: obtain pixel distribution information of each of the plurality of original images, where the pixel distribution information comprising a distribution of pixel points and a plurality of pixel intensities corresponding to the pixel points; divide averagely the plurality of image intensities of each of the plurality of original images into a plurality of ranges of intensity; count a quantity of pixel points fell in each of the plurality of ranges of intensity; determine a plurality of pixel distribution maps corresponding to the original images according to the plurality of ranges of intensity of the original images and the quantity of the pixel points fell in each of the plurality of ranges of intensity; each of the plurality of pixel distribution maps corresponding to one of the plurality of original images; and determine the first reference image to be an image corresponding to one of the plurality of pixel distribution maps which is a most standard normal distribution among the plurality of pixel distribution maps.
  9. 9 . The device according to claim 8 , further causing the at least one processor to: align each of the plurality of matched images with the first reference image; and generate the plurality of overlapping images which are overlapped areas among the aligned plurality of matched images and first reference image.
  10. 10 . The device according to claim 7 , further causing the at least one processor to: perform a gaussian blur processing on the test image; and use the synthesized image as the second reference image to perform the image comparison with the test image after the Gaussian blur processing is performed, to generate the result of the defect detection.
  11. 11 . The device according to claim 7 , further causing the at least one processor to: generate the result of the defect detection according to a result of a luminance comparison, a result of a contrast comparison, and a result of a structure comparison between the synthesized image and the test image.
  12. 12 . The device according to claim 7 , further causing the at least one processor to: use the synthesized image as the second reference image; partition the second reference image and the test image to generate a plurality of image blocks; perform the image comparison between each of the plurality of image blocks of the test image and a corresponding of the plurality of image blocks of the second reference image; determine one of the plurality of image blocks of the test image to be a defect block and remark the defect in the defect block if a result of the image comparison between the one of the plurality of image blocks of the test image and one corresponding of the plurality of image blocks of the second reference image is greater than a preset threshold.
  13. 13 . A non-transitory storage medium storing a set of commands, when the commands being executed by at least one processor of a device for detecting defect in image, causing the at least one processor to: obtain a plurality of original images; select one of the plurality of original images as a first reference image, and serve the plurality of original images without the first reference image as the other images; match a histogram of each of the other images with a histogram of the first reference image according to the first reference image, to obtain a plurality of matched images; overlap the plurality of matched images and the first reference image to generate a plurality of overlapping images, each of the plurality of overlapping images comprising a plurality of pixel points; generate a synthesized image according to pixel intensities of the plurality of overlapping image; and use the synthesized image as a second reference image to perform an image comparison with a test image, to generate a result of defect detection; wherein further causing the at least one processor to: for each of the plurality of pixel points in an overlapping image of the plurality of overlapping images, determine a median pixel intensity of a plurality of pixel intensities at a same pixel point of the plurality of overlapping images; and generate the synthesized image according to the median pixel intensity corresponding to each of the plurality of pixel points; wherein the histogram of each of the plurality of matched images is adjusted based on a degree of similarity between the histogram of each of the other images and the histogram of the first reference image.
  14. 14 . The non-transitory storage medium according to claim 13 , further causing the at least one processor to: obtain pixel distribution information of each of the plurality of original images, where the pixel distribution information comprising a distribution of pixel points and a plurality of pixel intensities corresponding to the pixel points; divide averagely the plurality of image intensities of each of the plurality of original images into a plurality of ranges of intensity; count a quantity of pixel points fell in each of the plurality of ranges of intensity; determine a plurality of pixel distribution maps corresponding to the original images according to the plurality of ranges of intensity of the original images and the quantity of the pixel points fell in each of the plurality of ranges of intensity; each of the plurality of pixel distribution maps corresponding to one of the plurality of original images; and determine the first reference image to be an image corresponding to one of the plurality of pixel distribution maps which is a most standard normal distribution among the plurality of pixel distribution maps.
  15. 15 . The non-transitory storage medium according to claim 13 , further causing the at least one processor to: align each of the plurality of matched images with the first reference image; and generate the plurality of overlapping images which are overlapped areas among the aligned plurality of matched images and first reference image.
  16. 16 . The non-transitory storage medium according to claim 13 , further causing the at least one processor to: perform a gaussian blur processing on the test image; and use the synthesized image as the second reference image to perform the image comparison with the test image after the Gaussian blur processing is performed, to generate the result of the defect detection.
  17. 17 . The non-transitory storage medium according to claim 13 , further causing the at least one processor to: generate the result of the defect detection according to a result of a luminance comparison, a result of a contrast comparison, and a result of a structure comparison between the synthesized image and the test image.

Description

FIELD The subject matter herein generally relates to defect detection technology, and particularly to a method for detecting defect in image and a device for detecting defect in image. BACKGROUND To detect defect in an image, a histogram equalization method is employed to reduce a gray level difference among a number of original images, and then a median filter is employed to generate a synthesized image. A following detection processing for defect can be then performed. If sources for the original images are different, a problem of variations in the light source, the contrast, and the color among the original images may appear, where different sources, for example, can be different capturing environments, different cameras, and different parameters of the camera. Thus, pixel distributions among the processed original images cannot be guaranteed to be similar and the pixel distributions at a single position may not meet the assumption of normality. When the median filter generates the synthesized image, defects in some original images may be doped into the synthesized image, thus a reference value of the synthesized image is lower and an efficiency of an image comparison is lower. SUMMARY An embodiment of the present application provides a method for detecting defect in image and a device for detecting defect in image which can improve an image comparison efficiency. In a first aspect, an embodiment of the present application provides a method for detecting defect in image. The method includes obtaining a number of original images, and determining a first reference image from the original images. The method further includes performing a histogram matching on the original images excluding the first reference image according to the first reference image, to obtain a number of matched images. The method includes generating a synthesized image according to pixel intensities of the matched images and pixel intensities of the first reference image. The method further includes using the synthesized image as a second reference image to perform an image comparison with a test image, to generate a result of defect detection. According to some embodiments of the present application, after obtaining a number of original images, the method further includes obtaining pixel distribution information of each original image. Where the pixel distribution information including a distribution of pixel points and a number of pixel intensities corresponding to the pixel points. Each pixel intensity corresponds to one pixel point. According to some embodiments of the present application, determining a first reference image from the original images includes dividing averagely the image intensities of each original image into a number of ranges of intensity; counting a quantity of pixel points fell in each range of intensity; determining a number of pixel distribution maps corresponding to the original images according to the ranges of intensity of the original images and the quantity of the pixel points fell in each range of intensity; each pixel distribution map corresponding to one original image; and determining the first reference image to be an image corresponding to one pixel distribution map which is a most standard normal distribution among the pixel distribution maps. According to some embodiments of the present application, before generating the synthesized image according to image intensities of the matched images, the method further includes overlapping the matched images and the first reference image to generate a number of overlapping images. Each overlapping image includes a number of pixel points. According to some embodiments of the present application, the overlapping the matched images and the first reference image to generate a number of overlapping images includes aligning each matched image with the first reference image, and generating the overlapping images which are overlapped areas among the aligned matched images and first reference image. According to some embodiments of the present application, generating a synthesized image according to image intensities of the matched images includes, for each of the pixel points in one overlapping image, determining a median in a number of pixel intensities at a same pixel point of the overlapping images, and generating the synthesized image according to the median corresponding to each of the pixel points. According to some embodiments of the present application, after generating the synthesized image according to image intensities of the matched images, the method further includes performing a gaussian blur processing on the test image, and using the synthesized image as the second reference image to perform the image comparison with the test image after the Gaussian blur processing to generate the result of the defect detection. According to some embodiments of the present application, using the synthesized image as a second reference image to perform the image co