TW202127371A - Image-based defect detection method and computer readable medium thereof - Google Patents
Image-based defect detection method and computer readable medium thereof Download PDFInfo
- Publication number
- TW202127371A TW202127371A TW109141935A TW109141935A TW202127371A TW 202127371 A TW202127371 A TW 202127371A TW 109141935 A TW109141935 A TW 109141935A TW 109141935 A TW109141935 A TW 109141935A TW 202127371 A TW202127371 A TW 202127371A
- Authority
- TW
- Taiwan
- Prior art keywords
- defect
- image
- target
- area
- level
- Prior art date
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
- 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
Landscapes
- Engineering & Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Quality & Reliability (AREA)
- Image Analysis (AREA)
- Investigating Materials By The Use Of Optical Means Adapted For Particular Applications (AREA)
- Image Processing (AREA)
Abstract
Description
本發明涉及一種基於圖像的瑕疵檢測方法及電腦可讀存儲介質。The invention relates to an image-based defect detection method and a computer-readable storage medium.
當前產品製造業朝向高精度、高品質發展,使得精密零部件於加工後容易產生碰撞、壓傷、擦傷等多種瑕疵,且瑕疵尺寸達到微米級,目前均需投入大量的檢測人力檢測上述瑕疵。然而,檢測人員需進行長時間培養,才可精確判別瑕疵類別及等級,且檢測人員易受主觀意識、情緒、視力與疲勞所影響,造成判別精度不穩定。雖然,利用自動光學檢測設備(Automated Optical Inspection, AOI)拍攝圖像並基於影像處理技術進行瑕疵的檢測可減少大量的人力投入,然而基於影像處理技術的傳統機器視覺外觀檢測對微小及多變的瑕疵,無法給出精確的類別與等級判斷。The current product manufacturing industry is developing towards high precision and high quality, making precision parts prone to collisions, crushing, scratches and other defects after processing, and the size of the defects reaches the micron level. At present, a large amount of inspection manpower is required to detect the above defects. However, the inspectors need to train for a long time to accurately distinguish the defect types and grades, and the inspectors are susceptible to subjective consciousness, emotions, eyesight, and fatigue, resulting in unstable judgment accuracy. Although the use of automatic optical inspection equipment (Automated Optical Inspection, AOI) to take images and detect defects based on image processing technology can reduce a lot of labor input, traditional machine vision appearance inspection based on image processing technology is very Defects, it is impossible to give an accurate classification and grade judgment.
鑒於以上內容,有必要提出一種基於圖像的瑕疵檢測方法及電腦可讀存儲介質以精確地確定產品的外觀瑕疵。In view of the above, it is necessary to propose an image-based defect detection method and computer-readable storage medium to accurately determine the appearance of the product.
本申請的第一方面提供一種基於圖像的瑕疵檢測方法,適用於檢測一待測物體的外觀瑕疵,所述圖像瑕疵檢測方法包括: 獲取待測物體的至少一張圖像; 從所述圖像中提取多個目標瑕疵子區域; 利用第一處理方法判斷所述多個目標瑕疵子區域的瑕疵類型; 利用第二處理方法從所述多個目標瑕疵子區域產生至少一個目標瑕疵區域; 根據第一準則判斷所述目標瑕疵區域的第一瑕疵等級; 儲存所述第一瑕疵等級。The first aspect of the present application provides an image-based defect detection method, which is suitable for detecting the appearance defect of an object to be tested, and the image defect detection method includes: Acquire at least one image of the object to be measured; Extracting multiple target defect sub-regions from the image; Judging the defect types of the multiple target defect sub-regions by using the first processing method; Generating at least one target defect area from the plurality of target defect sub-areas by using the second processing method; Judging the first defect level of the target defect area according to the first criterion; The first defect level is stored.
優選地,所述方法還包括: 判斷所述第一瑕疵等級是否滿足預設條件; 當所述第一瑕疵等級不滿足預設條件時,根據第二準則判斷所述目標瑕疵區域的第二瑕疵等級; 儲存所述第二瑕疵等級。Preferably, the method further includes: Judging whether the first defect level meets a preset condition; When the first defect level does not meet a preset condition, judging the second defect level of the target defect area according to a second criterion; The second defect level is stored.
優選地,所述方法還包括:根據所述第一瑕疵等級和/或所述第二瑕疵等級判斷所述目標瑕疵區域是否具有瑕疵。Preferably, the method further comprises: judging whether the target defect area has a defect according to the first defect level and/or the second defect level.
優選地,所述預設條件為所述第一瑕疵等級屬於預設等級。Preferably, the preset condition is that the first defect level belongs to a preset level.
優選地,所述根據第二準則判斷所述目標瑕疵區域的第二瑕疵等級的步驟還包括: 提取所述目標瑕疵區域的多個第一特徵值; 將所述多個第一特徵值轉換為預設格式的第二特徵值; 利用第三處理方法處理所述第二特徵值以得到所述第二瑕疵等級。Preferably, the step of judging the second flaw level of the target flaw area according to the second criterion further includes: Extracting a plurality of first feature values of the target defect area; Converting the plurality of first characteristic values into second characteristic values in a preset format; A third processing method is used to process the second characteristic value to obtain the second defect level.
優選地,所述第一特徵值可以是尺寸、灰度、紋理、位置、方向的任意組合,所述預設格式為圖像格式,所述第二特徵值是由所述第一特徵值轉換組成的特徵圖。Preferably, the first feature value can be any combination of size, grayscale, texture, position, and direction, the preset format is an image format, and the second feature value is converted from the first feature value. Composition feature map.
優選地,所述第三處理方法是深度學習演算法。Preferably, the third processing method is a deep learning algorithm.
優選地,所述根據第一準則判斷所述目標瑕疵區域的第一瑕疵等級的步驟包括: 計算所述目標瑕疵區域的區域大小; 根據所述目標瑕疵區域的區域大小給定所述第一瑕疵等級。Preferably, the step of judging the first flaw level of the target flaw area according to the first criterion includes: Calculating the area size of the target defect area; The first flaw level is given according to the area size of the target flaw area.
優選地,所述根據第一準則判斷所述目標瑕疵區域的第一瑕疵等級的步驟包括: 根據所述目標瑕疵區域的瑕疵類型,判斷所述目標瑕疵區域的關注等級; 根據所述關注等級計算所述目標瑕疵區域的瑕疵數值; 根據所述瑕疵數值和至少一個預設閾值以得到所述目標瑕疵區域的第一瑕疵等級。Preferably, the step of judging the first flaw level of the target flaw area according to the first criterion includes: Judging the attention level of the target flaw area according to the flaw type of the target flaw area; Calculating the defect value of the target defect area according to the attention level; The first defect level of the target defect area is obtained according to the defect value and at least one preset threshold value.
優選地,所述從所述圖像中提取多個目標瑕疵子區域的步驟還包括: 對所述圖像做前處理以提取多個預測瑕疵位置; 根據所述多個預測瑕疵位置框選多個瑕疵子區域; 根據尺寸大小從所述多個瑕疵子區域中選取多個目標瑕疵子區域。Preferably, the step of extracting multiple target defect sub-regions from the image further includes: Pre-processing the image to extract multiple predicted defect positions; Frame selection of multiple defect sub-regions according to the multiple predicted defect positions; Selecting multiple target defect sub-areas from the multiple defect sub-areas according to the size.
優選地,所述對所述圖像做前處理以提取多個預測瑕疵位置的步驟還包括: 從所述圖像中提取多個興趣區域; 利用第四處理方法從所述多個興趣區域中提取所述多個預測瑕疵位置; 聚合所述多個預測瑕疵位置中相鄰的至少二個。Preferably, the step of pre-processing the image to extract multiple predicted defect positions further includes: Extracting multiple regions of interest from the image; Extracting the plurality of predicted defect positions from the plurality of regions of interest by using a fourth processing method; At least two adjacent ones of the plurality of predicted defect positions are aggregated.
優選地,所述第四處理方法是語意分割演算法。Preferably, the fourth processing method is a semantic segmentation algorithm.
優選地,所述利用第一處理方法判斷所述多個目標瑕疵子區域的瑕疵類型的步驟還包括: 利用卷積神經網路模型判斷所述多個目標瑕疵子區域的瑕疵類型。Preferably, the step of judging the defect types of the plurality of target defect sub-regions by using the first processing method further includes: The convolutional neural network model is used to determine the defect types of the multiple target defect sub-regions.
優選地,所述利用第二處理方法從所述多個目標瑕疵子區域產生至少一個目標瑕疵區域的步驟還包括: 根據所述多個目標瑕疵子區域的瑕疵類型和位置,聚合類型相同且位置相鄰的一或數個所述目標瑕疵子區域產生所述目標瑕疵區域。Preferably, the step of generating at least one target defect area from the plurality of target defect sub-areas by using the second processing method further includes: According to the defect types and positions of the multiple target defect sub-areas, the target defect area is generated by grouping one or more of the target defect sub-areas with the same type and adjacent positions.
本申請的第二方面提供一種電腦可讀存儲介質,其上存儲有電腦程式,其特徵在於:所述電腦程式被處理器執行時實現所述基於圖像的瑕疵檢測方法。A second aspect of the present application provides a computer-readable storage medium on which a computer program is stored, wherein the computer program is characterized in that the image-based defect detection method is implemented when the computer program is executed by a processor.
本發明利用第一處理方法判斷待測物體的圖像中提取出的多所述多個目標瑕疵子區域的瑕疵類型,利用第二處理方法從所述多個目標瑕疵子區域產生至少一個目標瑕疵區域,及根據第一準則判斷所述目標瑕疵區域的第一瑕疵等級,實現了對待測物體的瑕疵的精確判定。The present invention uses the first processing method to determine the defect types of the multiple target defect sub-regions extracted from the image of the object to be measured, and uses the second processing method to generate at least one target defect from the multiple target defect sub-regions Area, and judging the first defect level of the target defect area according to the first criterion, so as to realize the accurate judgment of the defect of the object to be measured.
為了能夠更清楚地理解本發明的上述目的、特徵和優點,下面結合附圖和具體實施例對本發明進行詳細描述。需要說明的是,在不衝突的情況下,本申請的實施例及實施例中的特徵可以相互組合。In order to be able to understand the above objectives, features and advantages of the present invention more clearly, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that the embodiments of the application and the features in the embodiments can be combined with each other if there is no conflict.
在下面的描述中闡述了很多具體細節以便於充分理解本發明,所描述的實施例僅僅是本發明一部分實施例,而不是全部的實施例。基於本發明中的實施例,本領域普通技術人員在沒有做出創造性勞動前提下所獲得的所有其他實施例,都屬於本發明保護的範圍。In the following description, many specific details are explained in order to fully understand the present invention. The described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of the present invention.
除非另有定義,本文所使用的所有的技術和科學術語與屬於本發明的技術領域的技術人員通常理解的含義相同。本文中在本發明的說明書中所使用的術語只是為了描述具體的實施例的目的,不是旨在於限制本發明。Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field of the present invention. The terms used in the specification of the present invention herein are only for the purpose of describing specific embodiments, and are not intended to limit the present invention.
優選地,本發明基於深度學習的外觀瑕疵檢測方法應用在一個或者多個電子設備中。所述電子設備是一種能夠按照事先設定或存儲的指令,自動進行數值計算和/或資訊處理的設備,其硬體包括但不限於微處理器、專用積體電路(Application Specific Integrated Circuit,ASIC)、可程式設計閘陣列(Field-Programmable Gate Array,FPGA)、數位信號處理器(Digital Signal Processor,DSP)、嵌入式設備等。Preferably, the appearance defect detection method based on deep learning of the present invention is applied to one or more electronic devices. The electronic device is a device that can automatically perform numerical calculation and/or information processing in accordance with pre-set or stored instructions. Its hardware includes, but is not limited to, a microprocessor and a dedicated integrated circuit (ASIC) , Field-Programmable Gate Array (FPGA), Digital Signal Processor (DSP), embedded devices, etc.
所述電子設備可以是桌上型電腦、筆記型電腦、平板電腦及雲端伺服器等計算設備。所述設備可以與使用者通過鍵盤、滑鼠、遙控器、觸控板或聲控設備等方式進行人機交互。The electronic device may be a computing device such as a desktop computer, a notebook computer, a tablet computer, and a cloud server. The device can interact with the user through a keyboard, a mouse, a remote control, a touch pad, or a voice control device.
圖1A和圖1B說明待測物體的圖像可能包含多個瑕疵,可利用現有影像處理方法結合智慧化演算法提取瑕疵的相關資訊並作出更加精確的判斷。通過瑕疵的相關資訊可依照不同的瑕疵類型給出相對應的瑕疵等級。由於待測物體的瑕疵類別和形態可能有多樣,每種瑕疵在圖像中的特徵也不盡相同。利用單一方法無法精確判斷所有可能存在或關切的瑕疵。本發明先將先將圖像做小區域處理找出瑕疵的可能位置,對具有瑕疵的小區域做分類,分類後再將位置相鄰可能實際屬於同一瑕疵的小瑕疵聚合為一大瑕疵,針對各類型的大瑕疵進行分級。如果該類瑕疵較為複雜,無法簡單判斷,則可以對瑕疵等級有疑慮的大瑕疵利用其它判斷準則再進行二次判斷。Figures 1A and 1B illustrate that the image of the object to be tested may contain multiple flaws. The existing image processing method combined with the intelligent algorithm can be used to extract the relevant information of the flaw and make a more accurate judgment. Through the related information of the defect, the corresponding defect level can be given according to different defect types. Since there may be various types and shapes of defects in the object to be tested, the characteristics of each type of defect in the image are not the same. A single method cannot accurately determine all possible defects or concerns. The present invention first processes the image in small areas to find the possible positions of the flaws, classifies the small areas with flaws, and then aggregates the small flaws that may actually belong to the same flaw into a large flaw after the classification. All types of large defects are classified. If this type of defect is more complicated and cannot be simply judged, you can use other judgment criteria to make a second judgment for the large defect with doubts about the defect level.
請參考圖2,所示為本發明一實施方式中基於圖像的瑕疵檢測方法的流程圖。本實施方式中,在提取出圖像中的瑕疵區域後先對瑕疵區域作分類得到瑕疵類型,再依瑕疵類型利用第一準則做初步判斷瑕疵區域的等級,其中,所述第一準則僅利用圖像已知的特徵值判斷出瑕疵區域的等級。Please refer to FIG. 2, which shows a flowchart of an image-based defect detection method in an embodiment of the present invention. In this embodiment, after the defect area in the image is extracted, the defect area is first classified to obtain the defect type, and then the first criterion is used to initially judge the level of the defect area according to the defect type, wherein the first criterion only uses The known feature value of the image determines the level of the defect area.
參考圖2所示,所述基於圖像的瑕疵檢測方法具體包括以下步驟。Referring to FIG. 2, the image-based defect detection method specifically includes the following steps.
步驟S21,獲取待測物體的至少一張圖像。Step S21: Acquire at least one image of the object to be measured.
本實施方式中,獲取待測物體的至少一張圖像包括:獲取相機拍攝的待測物體的至少一張圖像,其中,相機可以為線陣相機或面陣相機。本實施方式中,待測物體為手機或平板電腦等裝置。在另一實施方式中,獲取待測物體的至少一張圖像包括:接收伺服器傳送的待測物體的至少一張圖像。在其他實施方式中,可以從本地資料庫中獲取待測物體的至少一張圖像。本實施方式中,圖像可包括待測物體的完整或局部圖像。圖像可以是任意解析度,也可以經過高採樣或低採樣,依實際需求而定。In this embodiment, acquiring at least one image of the object to be measured includes: acquiring at least one image of the object to be measured taken by a camera, where the camera may be a line scan camera or an area scan camera. In this embodiment, the object to be measured is a device such as a mobile phone or a tablet computer. In another embodiment, acquiring at least one image of the object to be measured includes: receiving at least one image of the object to be measured transmitted by the server. In other embodiments, at least one image of the object to be measured can be obtained from a local database. In this embodiment, the image may include a complete or partial image of the object to be measured. The image can be of any resolution, or it can be high-sampled or low-sampled, depending on actual needs.
步驟S22,從圖像中提取多個目標瑕疵子區域。Step S22: Extract multiple target defect sub-regions from the image.
在一實施方式中,從圖像中提取多個目標瑕疵子區域的步驟還包括:對圖像做前處理以提取多個預測瑕疵位置,根據多個預測瑕疵位置框選多個瑕疵子區域,根據尺寸大小從多個瑕疵子區域中選取多個目標瑕疵子區域。在一實施方式中,對圖像做前處理以提取多個預測瑕疵位置還包括:從圖像中提取多個興趣區域,利用第四處理方法從多個興趣區域中提取多個預測瑕疵位置,聚合多個預測瑕疵位置中相鄰的至少二個得到多個目標瑕疵子區域。本實施方式中,第四處理演算法是語意分割演算法。In one embodiment, the step of extracting multiple target defect sub-regions from the image further includes: pre-processing the image to extract multiple predicted defect locations, and frame selection of multiple defect sub-regions according to the multiple predicted defect locations, Select multiple target defect sub-areas from multiple defect sub-areas according to the size. In an embodiment, pre-processing the image to extract multiple predicted defect locations further includes: extracting multiple regions of interest from the image, and extracting multiple predicted defect locations from the multiple regions of interest using the fourth processing method, Aggregating at least two adjacent ones of the multiple predicted defect positions to obtain multiple target defect sub-regions. In this embodiment, the fourth processing algorithm is a semantic segmentation algorithm.
在一實施方式中,可根據興趣區域(Region of Interest, ROI)演算法從圖像中提取多個興趣區域。利用語意分割演算法對多個興趣區域進行預測處理並輸出多個興趣區域中的背景圖元點及瑕疵圖元點,對背景圖元點及瑕疵圖元點進行二值化並根據二值化的圖元點分離出多個興趣區域中的瑕疵圖元點,根據分離出的多個興趣區域中的瑕疵圖元點得到多個預測瑕疵位置,及聚合多個預測瑕疵位置中相鄰的至少二個得到多個目標瑕疵子區域。In an embodiment, multiple regions of interest can be extracted from the image according to a Region of Interest (ROI) algorithm. Use semantic segmentation algorithm to predict and process multiple regions of interest and output background primitive points and flawed primitive points in multiple regions of interest, and binarize the background primitive points and flawed primitive points according to the binarization Separate the defect image element points in the multiple regions of interest, obtain multiple predicted defect locations according to the separated defect image element points in the multiple interest areas, and aggregate at least adjacent ones of the multiple predicted defect locations Two get multiple target defect sub-regions.
在一實施方式中,對背景圖元點及瑕疵圖元點進行二值化並根據二值化的圖元點分離出多個興趣區域中的瑕疵圖元點包括:將多個興趣區域中的圖元點的灰度設置為0或255以對多個興趣區域的圖元點的灰度進行二值化。將灰度值為255的圖元點作為瑕疵圖元點,並將灰度值為0的圖元點作為背景圖元點。在一具體實施方式中,可通過k-means聚類方法將多個興趣區域中的圖元點的灰度進行分組得到兩個分組,再將兩個分組中的圖元點的灰度二值化,且每一分組中二值化後的圖元點的灰度值相同。接著將多個興趣區域中的圖元點的灰度值與預設閾值進行比較,將圖元點中大於預設閾值的灰度值設置為255,及將圖元點中不大於預設閾值的灰度值設置為0。其中,預設閾值可以根據使用者的需要進行設置。In one embodiment, binarizing the background image element point and the defect image element point and separating the defect image element points in the multiple interest regions according to the binarized image element points includes: The gray level of the image element point is set to 0 or 255 to binarize the gray level of the image element points in the multiple regions of interest. A pixel point with a gray value of 255 is used as a defective pixel point, and a pixel point with a gray value of 0 is used as a background pixel point. In a specific embodiment, the gray levels of the pixel points in multiple regions of interest can be grouped by the k-means clustering method to obtain two groups, and then the gray level binary values of the pixel points in the two groups can be obtained. And the gray values of the binarized pixel points in each group are the same. Then compare the gray values of the pixel points in the multiple regions of interest with the preset threshold, set the gray value of the pixel points greater than the preset threshold to 255, and set the pixel points not to be greater than the preset threshold The gray value of is set to 0. Among them, the preset threshold can be set according to the needs of the user.
在一實施方式中,根據分離出的多個興趣區域中的瑕疵圖元點得到多個預測瑕疵位置包括:濾除多個興趣區域中的非瑕疵圖元點,對多個興趣區域中的瑕疵圖元點進行群聚得到多個瑕疵塊,通過每一瑕疵塊的邊界框選出一個矩形區域作為瑕疵塊的瑕疵區域並確定每一瑕疵塊的瑕疵區域的座標,其中每一瑕疵塊由瑕疵圖元點群聚得到,及根據每一瑕疵塊的瑕疵區域的座標得到多個預測瑕疵位置,其中每一預測瑕疵位置對應一個瑕疵塊的瑕疵區域。In one embodiment, obtaining multiple predicted defect locations according to the separated defect image element points in the multiple interest regions includes: filtering out non-defect image element points in the multiple interest areas, and correcting the defects in the multiple interest areas. The pixel points are clustered to obtain multiple defect blocks, a rectangular area is selected as the defect area of each defect block through the boundary box of each defect block, and the coordinates of the defect area of each defect block are determined, and each defect block is represented by the defect map The element points are clustered, and a plurality of predicted defect locations are obtained according to the coordinates of the defect area of each defect block, wherein each predicted defect location corresponds to the defect area of a defect block.
在一實施方式中,根據多個預測瑕疵位置框選出多個瑕疵子區域包括:根據瑕疵區域的座標框選出多個瑕疵子區域。本實施方式中,根據每一瑕疵區域的座標框選出多個瑕疵子區域包括:在圖像中以圖像左上角的點為原點建立笛卡爾座標系,其中笛卡爾座標系的X方向表示圖像的寬度,笛卡爾座標系的Y方向表示圖像的高度。在笛卡爾座標系中將每一瑕疵塊的最左邊的圖元點所對應的x座標作為瑕疵塊的左邊邊界,將每一瑕疵塊的最右邊的圖元點所對應的x座標作為瑕疵塊的右邊邊界,將每一瑕疵塊的最上邊的圖元點所對應的y座標作為瑕疵塊的上邊邊界,及將每一瑕疵塊的最下邊的圖元點所對應的y座標作為瑕疵塊的下邊邊界。根據左邊邊界、右邊邊界、上邊邊界、下邊邊界框選出矩形區域作為瑕疵塊的瑕疵區域的座標,並根據瑕疵區域的座標框選出多個瑕疵子區域。In one embodiment, selecting multiple defect sub-regions based on multiple predicted defect position frames includes: selecting multiple defect sub-regions based on coordinate boxes of the defect area. In this embodiment, selecting multiple defect sub-areas according to the coordinate frame of each defect area includes: establishing a Cartesian coordinate system in the image with the point on the upper left corner of the image as the origin, where the X direction of the Cartesian coordinate system represents The width of the image, the Y direction of the Cartesian coordinate system represents the height of the image. In the Cartesian coordinate system, the x coordinate corresponding to the leftmost primitive point of each defective block is regarded as the left boundary of the defective block, and the x coordinate corresponding to the rightmost primitive point of each defective block is regarded as the defective block The y coordinate corresponding to the uppermost primitive point of each defective block is regarded as the upper boundary of the defective block, and the y coordinate corresponding to the lowermost primitive point of each defective block is regarded as the y coordinate of the defective block Lower border. According to the left boundary, right boundary, upper boundary, and lower boundary box, a rectangular area is selected as the coordinates of the flaw area of the flaw block, and multiple flaw sub-areas are selected according to the coordinate box of the flaw area.
在一實施方式中,根據尺寸大小從多個瑕疵子區域中選取多個目標瑕疵子區域包括:根據尺寸大小將多個瑕疵子區域進行排序,選取排序靠前的第一預設數量個瑕疵子區域作為目標瑕疵子區域。將多個瑕疵子區域中除去排序靠前的第一預設數量個瑕疵子區域以外的瑕疵區域按照寬度與高度之和的大小進行排序,並選取寬度與高度之和在預設範圍內且排序靠前的第二預設數量個瑕疵區域作為目標瑕疵區域。本實施方式中,第一預設數量、第二預設數量及預設範圍可以根據使用者需要進行設置。In one embodiment, selecting multiple target defect sub-areas from the multiple defect sub-areas according to the size includes: sorting the multiple defect sub-areas according to the size, and selecting the first preset number of defect sub-areas with the highest ranking. The area serves as the target defect sub-area. Sort the defect areas except the first preset number of defect sub-areas from the multiple defect sub-areas according to the sum of width and height, and select the sum of width and height to be within the preset range and sort The first second preset number of defect areas are used as target defect areas. In this embodiment, the first preset quantity, the second preset quantity, and the preset range can be set according to the needs of the user.
步驟S23,利用第一處理方法判斷多個目標瑕疵子區域的瑕疵類型。In step S23, the first processing method is used to determine the defect types of the multiple target defect sub-regions.
在一實施方式中,利用第一處理方法判斷多個目標瑕疵子區域的瑕疵類型是利用卷積神經網路模型判斷多個目標瑕疵子區域的瑕疵類型。In one embodiment, using the first processing method to determine the defect types of multiple target defect sub-regions is to use a convolutional neural network model to determine the defect types of multiple target defect sub-regions.
在一實施方式中,目標瑕疵子區域的瑕疵類型包括:擦傷類型、刮傷類型、碰傷類型及污漬類型。在一實施方式中,卷積神經網路模型包括,但不限於:支援向量機(Support Vector Machine,SVM)模型。將多個目標瑕疵子區域作為卷積神經網路模型的輸入,經過卷積神經網路模型計算後,輸出瑕疵類型。In an embodiment, the defect type of the target defect sub-region includes: a scratch type, a scratch type, a bruise type, and a stain type. In an embodiment, the convolutional neural network model includes, but is not limited to: a support vector machine (Support Vector Machine, SVM) model. The multiple target defect sub-regions are used as the input of the convolutional neural network model, and the defect type is output after the convolutional neural network model is calculated.
在一實施方式中,卷積神經網路模型的訓練過程包括:In one embodiment, the training process of the convolutional neural network model includes:
1)獲取正樣本的圖像的瑕疵資料及負樣本的圖像的瑕疵資料,並將正樣本的圖像的瑕疵資料標注瑕疵類型,以使正樣本的圖像的瑕疵資料攜帶瑕疵類型標籤。1) Obtain the defect data of the image of the positive sample and the defect data of the image of the negative sample, and mark the defect type of the image of the positive sample so that the defect data of the image of the positive sample carries the defect type label.
例如,分別選取1000個擦傷類型、刮傷類型、碰傷類型、污漬類型對應的瑕疵資料,並對每個瑕疵資料標注類型,可以以“1”作為擦傷類型的資料標籤,以“2”作為刮傷類型的資料標籤,以“3”作為碰傷類型的資料標籤,以“4”作為污漬類型的資料標籤。For example, select 1000 defect data corresponding to the scratch type, scratch type, bruise type, and stain type, and mark the type of each defect data. You can use "1" as the data label of the scratch type and "2" as the label For the data label of the scratch type, use "3" as the data label of the scratch type, and use "4" as the data label of the stain type.
2)將正樣本的瑕疵資料及負樣本的瑕疵資料隨機分成第一預設比例的訓練集和第二預設比例的驗證集,利用訓練集訓練卷積神經網路模型,並利用驗證集驗證訓練後的卷積神經網路模型的準確率。2) Randomly divide the defect data of the positive sample and the defect data of the negative sample into a training set with a first preset ratio and a validation set with a second preset ratio, use the training set to train the convolutional neural network model, and use the verification set to verify The accuracy of the trained convolutional neural network model.
先將不同瑕疵類型的訓練集中的訓練樣本分發到不同的資料夾裡。例如,將擦傷類型的訓練樣本分發到第一資料夾裡、刮傷類型的訓練樣本分發到第二資料夾裡、碰傷類型的訓練樣本分發到第三資料夾裡、污漬類型的訓練樣本分發到第四資料夾裡。然後從不同的資料夾裡分別提取第一預設比例(例如,70%)的訓練樣本作為總的訓練樣本進行卷積神經網路模型的訓練,從不同的資料夾裡分別取剩餘第二預設比例(例如,30%)的訓練樣本作為總的測試樣本對訓練完成的卷積神經網路模型進行準確性驗證。First distribute the training samples in the training set of different defect types to different folders. For example, distribute the training samples of the scratch type to the first folder, distribute the training samples of the scratch type to the second folder, distribute the training samples of the bruise type to the third folder, and distribute the training samples of the stain type Go to the fourth folder. Then extract the training samples of the first preset ratio (for example, 70%) from different folders as the total training samples for training the convolutional neural network model, and take the remaining second presets from different folders. Set a proportion (for example, 30%) of the training samples as the total test samples to verify the accuracy of the trained convolutional neural network model.
3)若準確率大於或者等於預設準確率時,則結束訓練,以訓練後的卷積神經網路模型作為分類器識別目標瑕疵子區域的瑕疵類型。若準確率小於預設準確率時,則增加正樣本數量及負樣本數量以重新訓練卷積神經網路模型直至準確率大於或者等於預設準確率。3) If the accuracy rate is greater than or equal to the preset accuracy rate, the training ends, and the trained convolutional neural network model is used as the classifier to identify the defect type of the target defect sub-region. If the accuracy rate is less than the preset accuracy rate, increase the number of positive samples and the number of negative samples to retrain the convolutional neural network model until the accuracy rate is greater than or equal to the preset accuracy rate.
步驟S24,利用第二處理方法從多個目標瑕疵子區域產生至少一個目標瑕疵區域。Step S24, using a second processing method to generate at least one target defect area from a plurality of target defect sub-areas.
本實施方式中,利用第二處理方法從多個目標瑕疵子區域產生至少一個目標瑕疵區域包括:根據多個目標瑕疵子區域的類型和位置,聚合類型相同且位置相鄰的一或數個目標瑕疵子區域產生目標瑕疵區域。In this embodiment, using the second processing method to generate at least one target defect area from a plurality of target defect sub-areas includes: according to the types and positions of the multiple target defect sub-areas, aggregating one or more targets with the same type and adjacent positions. The defect sub-area produces the target defect area.
例如,當圖像中的瑕疵類型為擦傷類型時,一個擦傷有可能包括多個連續且緊鄰的小擦傷。請參考圖3A,所示為本發明一實施方式中擦傷的示意圖。如圖3A所示,第一擦傷30包括第一區域301,第二區域302,第三區域303和第四區域304。第二擦傷31包括第五區域311和第六區域312。為了避免將所述第一區域301,第二區域302,第三區域303,第四區域304,第五區域311和第六區域312誤認為是六個擦傷,需要將所述第一區域301,第二區域302,第三區域303和第四區域304進行群聚得到目標瑕疵區域,即所述第一擦傷30。將所述第五區域311和第六區域312進行群聚得到目標瑕疵區域,成為第二擦傷31。For example, when the type of blemish in the image is a scratch type, one scratch may include a plurality of consecutive and adjacent small scratches. Please refer to FIG. 3A, which is a schematic diagram of abrasion in an embodiment of the present invention. As shown in FIG. 3A, the
又如,當圖像中的瑕疵類型為刮傷類型時,一個刮傷有可能包括多個連續且緊鄰的小刮傷。請參考圖3B,所示為本發明一實施方式中刮傷的示意圖。如圖3B所示,刮傷20包括第一長條21,第二長條22,第三長條23和第四長條24。為了避免將所述第一長條21,第二長條22,第三長條23和第四長條24誤認為是四個刮傷,需要將所述第一長條21,第二長條22,第三長條23和第四長條24進行擬合得到目標瑕疵區域,成為刮傷20。For another example, when the type of blemish in the image is a scratch type, one scratch may include multiple consecutive and adjacent small scratches. Please refer to FIG. 3B, which is a schematic diagram of scratches in an embodiment of the present invention. As shown in FIG. 3B, the
步驟S25,根據第一準則判斷目標瑕疵區域的第一瑕疵等級。Step S25, judging the first defect level of the target defect area according to the first criterion.
在一實施方式中,根據第一準則判斷目標瑕疵區域的第一瑕疵等級包括:計算目標瑕疵區域的區域大小,及根據目標瑕疵區域的區域大小確定第一瑕疵等級。在具體實施方式中,在計算出目標瑕疵區域的區域大小後根據目標瑕疵區域的區域大小查找瑕疵等級關係表確定與區域大小相對應的第一瑕疵等級,其中,瑕疵等級關係表中包括多個目標瑕疵區域的區域大小與多個第一瑕疵等級,並定義了多個目標瑕疵區域的區域大小與多個第一瑕疵等級的對應關係。In one embodiment, judging the first flaw level of the target flaw area according to the first criterion includes: calculating the area size of the target flaw area, and determining the first flaw level according to the area size of the target flaw area. In a specific embodiment, after the area size of the target defect area is calculated, the defect level relationship table is searched according to the area size of the target defect area to determine the first defect level corresponding to the area size, wherein the defect level relationship table includes multiple The area size of the target defect area and multiple first defect levels, and the corresponding relationship between the area size of the multiple target defect areas and the multiple first defect levels is defined.
在另一實施方式中,根據第一準則判斷目標瑕疵區域的第一瑕疵等級包括:根據目標瑕疵區域的瑕疵類型,判斷目標瑕疵區域的關注等級,根據關注等級計算目標瑕疵區域的瑕疵數值,及根據瑕疵數值和至少一個預設閾值以得到目標瑕疵區域的第一瑕疵等級。在具體實施方式中,判斷目標瑕疵區域的關注等級包括:根據目標瑕疵區域的瑕疵類型查找關注等級關係表確定與瑕疵類型相對應的目標瑕疵區域的關注等級,其中,關注等級關係表中包括多個目標瑕疵區域的瑕疵類型與多個關注等級,並定義了多個瑕疵類型與關注等級的對應關係。在具體實施方式中,根據關注等級計算目標瑕疵區域的瑕疵數值包括:根據關注等級查找計算規則關係表確定與關注等級相對應的瑕疵數值的計算規則,按照計算規則計算與目標瑕疵區域的關注等級對應的瑕疵數值。其中,計算規則關係表中定義了目標瑕疵區域的多個關注等級與多個計算規則的對應關係。本實施方式中,計算規則包括根據目標瑕疵區域的面積計算瑕疵數值、根據目標瑕疵區域的長寬之和計算瑕疵數值。In another embodiment, judging the first flaw level of the target flaw area according to the first criterion includes: determining the attention level of the target flaw area according to the flaw type of the target flaw area, and calculating the flaw value of the target flaw area according to the attention level, and According to the defect value and at least one preset threshold value, the first defect level of the target defect area is obtained. In a specific embodiment, judging the attention level of the target defect area includes: searching the attention level relation table according to the defect type of the target defect area to determine the attention level of the target defect area corresponding to the defect type, where the attention level relation table includes multiple The defect type and multiple attention levels of a target defect area are defined, and the corresponding relationship between multiple defect types and attention levels is defined. In a specific embodiment, calculating the defect value of the target defect area according to the attention level includes: searching the calculation rule relationship table according to the attention level to determine the calculation rule of the defect value corresponding to the attention level, and calculating the attention level of the target defect area according to the calculation rule The corresponding defect value. Among them, the calculation rule relationship table defines the correspondence between multiple attention levels of the target defect area and multiple calculation rules. In this embodiment, the calculation rule includes calculating the defect value according to the area of the target defect area, and calculating the defect value according to the sum of the length and width of the target defect area.
步驟S26,儲存第一瑕疵等級。In step S26, the first defect level is stored.
請參考圖4,所示為本發明另一實施方式中基於圖像的瑕疵檢測方法的流程圖。本實施方式中,在提取出瑕疵區域後先對瑕疵區域作分類得到瑕疵類型,再依瑕疵類型利用第一準則做初步判斷後,如果初步判斷的結果不精確,則對該些瑕疵區域利用第二準則做二次判斷。本實施方式中,第一準則僅利用圖像已知的特徵值,而第二準則將已知特徵值做進一步處理後再使用,而且第一準則運算量小於第二準則,從而提高運算效率和判斷準確度。Please refer to FIG. 4, which shows a flowchart of an image-based defect detection method in another embodiment of the present invention. In this embodiment, after the defect area is extracted, the defect area is first classified to obtain the defect type, and then the first criterion is used to make a preliminary judgment according to the defect type. If the preliminary judgment result is not accurate, the first criterion is used for the defect area. The second criterion is to make a second judgment. In this embodiment, the first criterion only uses the known feature values of the image, while the second criterion uses the known feature values for further processing, and the calculation amount of the first criterion is smaller than the second criterion, thereby improving the computational efficiency and Judgment accuracy.
參考圖4所示,基於圖像的瑕疵檢測方法具體包括以下步驟。Referring to FIG. 4, the image-based defect detection method specifically includes the following steps.
步驟S31,獲取待測物體的至少一張圖像。Step S31: Acquire at least one image of the object to be measured.
步驟S32,從圖像中提取多個目標瑕疵子區域。Step S32: Extract multiple target defect sub-regions from the image.
在一實施方式中,從圖像中提取多個目標瑕疵子區域的步驟還包括:對圖像做前處理以提取多個預測瑕疵位置,根據多個預測瑕疵位置框選多個瑕疵子區域,根據尺寸大小從多個瑕疵子區域中選取多個目標瑕疵子區域。在一實施方式中,對圖像做前處理以提取多個預測瑕疵位置還包括:從圖像中提取多個興趣區域,利用第四處理方法從多個興趣區域中提取多個預測瑕疵位置,聚合多個預測瑕疵位置中相鄰的至少二個得到多個目標瑕疵子區域。在一實施方式中,第四處理演算法是語意分割演算法。In one embodiment, the step of extracting multiple target defect sub-regions from the image further includes: pre-processing the image to extract multiple predicted defect locations, and frame selection of multiple defect sub-regions according to the multiple predicted defect locations, Select multiple target defect sub-areas from multiple defect sub-areas according to the size. In an embodiment, pre-processing the image to extract multiple predicted defect locations further includes: extracting multiple regions of interest from the image, and extracting multiple predicted defect locations from the multiple regions of interest using the fourth processing method, Aggregating at least two adjacent ones of the multiple predicted defect positions to obtain multiple target defect sub-regions. In one embodiment, the fourth processing algorithm is a semantic segmentation algorithm.
在具體實施方式中,可根據興趣區域演算法從圖像中提取多個興趣區域。利用語意分割演算法對多個興趣區域進行預測處理並輸出多個興趣區域中的背景圖元點及瑕疵圖元點,對背景圖元點及瑕疵圖元點進行二值化並根據二值化的圖元點分離出多個興趣區域中的瑕疵圖元點,根據分離出的多個興趣區域中的瑕疵圖元點得到多個預測瑕疵位置,及聚合多個預測瑕疵位置中相鄰的至少二個得到多個目標瑕疵子區域。In a specific implementation, multiple regions of interest can be extracted from the image according to the region of interest algorithm. Use semantic segmentation algorithm to predict and process multiple regions of interest and output background primitive points and flawed primitive points in multiple regions of interest, and binarize the background primitive points and flawed primitive points according to the binarization Separate the defect image element points in the multiple regions of interest, obtain multiple predicted defect locations according to the separated defect image element points in the multiple interest areas, and aggregate at least adjacent ones of the multiple predicted defect locations Two get multiple target defect sub-regions.
在一實施方式中,對背景圖元點及瑕疵圖元點進行二值化並根據二值化的圖元點分離出多個興趣區域中的瑕疵圖元點包括:將多個興趣區域中的圖元點的灰度設置為0或255以對多個興趣區域的圖元點的灰度進行二值化,將灰度值為255的圖元點作為瑕疵圖元點,及將灰度值為0的圖元點作為背景圖元點。在一具體實施方式中,通過k-means聚類方法將多個興趣區域中的圖元點的灰度進行分組得到兩個分組。將兩個分組中的圖元點的灰度二值化,且每一分組中二值化後的圖元點的灰度值相同,接著將多個興趣區域中的圖元點的灰度值與預設閾值進行比較,將圖元點中大於預設閾值的灰度值設置為255,及將圖元點中不大於預設閾值的灰度值設置為0。其中,預設閾值可以根據使用者的需要進行設置。In one embodiment, binarizing the background image element point and the defect image element point and separating the defect image element points in the multiple interest regions according to the binarized image element points includes: Set the gray level of the pixel point to 0 or 255 to binarize the gray level of the pixel points in multiple regions of interest. Use the pixel point with a gray value of 255 as the defective pixel point, and set the gray value The primitive point that is 0 is used as the background primitive point. In a specific embodiment, the gray levels of the primitive points in the multiple regions of interest are grouped by the k-means clustering method to obtain two groups. Binarize the gray values of the pixel points in the two groups, and the gray values of the binarized pixel points in each group are the same, and then convert the gray values of the pixel points in multiple regions of interest Comparing with the preset threshold, the gray value of the image element point greater than the preset threshold is set to 255, and the gray value of the image element point not greater than the preset threshold is set to 0. Among them, the preset threshold can be set according to the needs of the user.
在一實施方式中,根據分離出的多個興趣區域中的瑕疵圖元點得到多個預測瑕疵位置包括:濾除多個興趣區域中的非瑕疵圖元點,對多個興趣區域中的瑕疵圖元點進行群聚得到多個瑕疵塊,通過每一瑕疵塊的邊界框選出一個矩形區域作為瑕疵塊的瑕疵區域並確定每一瑕疵塊的瑕疵區域的座標,其中每一瑕疵塊由瑕疵圖元點群聚得到,及根據每一瑕疵塊的瑕疵區域的座標得到多個預測瑕疵位置,其中每一預測瑕疵位置對應一個瑕疵塊的瑕疵區域。In one embodiment, obtaining multiple predicted defect locations according to the separated defect image element points in the multiple interest regions includes: filtering out non-defect image element points in the multiple interest areas, and correcting the defects in the multiple interest areas. The pixel points are clustered to obtain multiple defect blocks, a rectangular area is selected as the defect area of each defect block through the boundary box of each defect block, and the coordinates of the defect area of each defect block are determined, and each defect block is represented by the defect map The element points are clustered, and a plurality of predicted defect locations are obtained according to the coordinates of the defect area of each defect block, wherein each predicted defect location corresponds to the defect area of a defect block.
在一實施方式中,根據多個預測瑕疵位置框選出多個瑕疵子區域包括:根據瑕疵區域的座標框選出多個瑕疵子區域。本實施方式中,根據每一瑕疵區域的座標框選出多個瑕疵子區域包括:在圖像中以圖像左上角的點為原點建立笛卡爾座標系,其中笛卡爾座標系的X方向表示圖像的寬度,笛卡爾座標系的Y方向表示圖像的高度。在笛卡爾座標系中將每一瑕疵塊的最左邊的圖元點所對應的x座標作為瑕疵塊的左邊邊界,將每一瑕疵塊的最右邊的圖元點所對應的x座標作為瑕疵塊的右邊邊界,將每一瑕疵塊的最上邊的圖元點所對應的y座標作為瑕疵塊的上邊邊界,及將每一瑕疵塊的最下邊的圖元點所對應的y座標作為瑕疵塊的下邊邊界。根據左邊邊界、右邊邊界、上邊邊界、下邊邊界框選出矩形區域作為瑕疵塊的瑕疵區域的座標,並根據瑕疵區域的座標框選出多個瑕疵子區域。In one embodiment, selecting multiple defect sub-regions based on multiple predicted defect position frames includes: selecting multiple defect sub-regions based on coordinate boxes of the defect area. In this embodiment, selecting multiple defect sub-areas according to the coordinate frame of each defect area includes: establishing a Cartesian coordinate system in the image with the point on the upper left corner of the image as the origin, where the X direction of the Cartesian coordinate system represents The width of the image, the Y direction of the Cartesian coordinate system represents the height of the image. In the Cartesian coordinate system, the x coordinate corresponding to the leftmost primitive point of each defective block is regarded as the left boundary of the defective block, and the x coordinate corresponding to the rightmost primitive point of each defective block is regarded as the defective block The y coordinate corresponding to the uppermost primitive point of each defective block is regarded as the upper boundary of the defective block, and the y coordinate corresponding to the lowermost primitive point of each defective block is regarded as the y coordinate of the defective block Lower border. According to the left boundary, right boundary, upper boundary, and lower boundary box, a rectangular area is selected as the coordinates of the flaw area of the flaw block, and multiple flaw sub-areas are selected according to the coordinate box of the flaw area.
在一實施方式中,根據尺寸大小從多個瑕疵子區域中選取多個目標瑕疵子區域包括:根據尺寸大小將多個瑕疵子區域進行排序,選取排序靠前的第一預設數量個瑕疵子區域作為目標瑕疵子區域。接著將多個瑕疵子區域中除去排序靠前的第一預設數量個瑕疵子區域以外的瑕疵區域按照寬度與高度之和的大小進行排序,並選取寬度與高度之和在預設範圍內且排序靠前的第二預設數量個瑕疵區域作為目標瑕疵區域。本實施方式中,第一預設數量、第二預設數量及預設範圍可以根據使用者需要進行設置。In one embodiment, selecting multiple target defect sub-areas from the multiple defect sub-areas according to the size includes: sorting the multiple defect sub-areas according to the size, and selecting the first preset number of defect sub-areas with the highest ranking. The area serves as the target defect sub-area. Then sort the defect areas except the first preset number of defect sub-areas in the multiple defect sub-areas according to the size of the sum of width and height, and select the sum of width and height to be within the preset range and The second preset number of defect areas ranked at the top are used as the target defect areas. In this embodiment, the first preset quantity, the second preset quantity, and the preset range can be set according to the needs of the user.
步驟S33,利用第一處理方法判斷多個目標瑕疵子區域的瑕疵類型。In step S33, the first processing method is used to determine the defect types of the multiple target defect sub-regions.
在一實施方式中,利用第一處理方法判斷多個目標瑕疵子區域的瑕疵類型是利用卷積神經網路模型判斷多個目標瑕疵子區域的類型。In one embodiment, using the first processing method to determine the defect types of multiple target defect sub-regions is to use a convolutional neural network model to determine the types of multiple target defect sub-regions.
步驟S34,利用第二處理方法從多個目標瑕疵子區域產生至少一個目標瑕疵區域。Step S34, using a second processing method to generate at least one target defect area from a plurality of target defect sub-areas.
在一實施方式中,利用第二處理方法從多個目標瑕疵子區域產生至少一個目標瑕疵區域包括:根據多個目標瑕疵子區域的類型和位置,聚合類型相同且位置相鄰的一或數個目標瑕疵子區域產生目標瑕疵區域。In one embodiment, using the second processing method to generate at least one target defect area from a plurality of target defect sub-areas includes: according to the types and positions of the multiple target defect sub-areas, one or more of the same type and adjacent positions are aggregated The target defect sub-area generates a target defect area.
步驟S35,根據第一準則判斷目標瑕疵區域的第一瑕疵等級。Step S35: Determine the first defect level of the target defect area according to the first criterion.
在一實施方式中,根據第一準則判斷目標瑕疵區域的第一瑕疵等級包括:計算目標瑕疵區域的區域大小,及根據目標瑕疵區域的區域大小確定第一瑕疵等級。在具體實施方式中,在計算出目標瑕疵區域的區域大小後根據目標瑕疵區域的區域大小查找瑕疵等級關係表確定與區域大小相對應的第一瑕疵等級。其中,瑕疵等級關係表中包括多個目標瑕疵區域的區域大小與多個第一瑕疵等級,並定義了多個目標瑕疵區域的區域大小與多個第一瑕疵等級的對應關係。In one embodiment, judging the first flaw level of the target flaw area according to the first criterion includes: calculating the area size of the target flaw area, and determining the first flaw level according to the area size of the target flaw area. In a specific embodiment, after calculating the area size of the target defect area, the defect level relationship table is searched according to the area size of the target defect area to determine the first defect level corresponding to the area size. Wherein, the defect level relationship table includes the area sizes of multiple target defect areas and multiple first defect levels, and defines the correspondence between the area sizes of multiple target defect areas and the multiple first defect levels.
步驟S36,儲存第一瑕疵等級。In step S36, the first defect level is stored.
步驟S37,判斷第一瑕疵等級是否滿足預設條件,及當第一瑕疵等級不滿足預設條件時,根據第二準則判斷目標瑕疵區域的第二瑕疵等級,並存儲第二瑕疵等級。Step S37: Determine whether the first flaw level meets the preset condition, and when the first flaw level does not meet the preset condition, determine the second flaw level of the target flaw area according to the second criterion, and store the second flaw level.
在一實施方式中,預設條件為第一瑕疵等級屬於預設等級。即,當第一瑕疵等級不屬於預設等級時,根據第二準則判斷目標瑕疵區域的第二瑕疵等級。In one embodiment, the preset condition is that the first defect level belongs to the preset level. That is, when the first defect level does not belong to the preset level, the second defect level of the target defect area is determined according to the second criterion.
在一實施方式中,根據第二準則判斷目標瑕疵區域的第二瑕疵等級包括:提取目標瑕疵區域的多個第一特徵值,將多個第一特徵值轉換為預設格式的第二特徵值,及利用第三處理方法處理第二特徵值以得到第二瑕疵等級。在一實施方式中,第一特徵值是尺寸、灰度、紋理、位置、方向的任意組合,預設格式為圖像格式,第二特徵值是由第一特徵值轉換組成的特徵圖。本實施方式中,第三處理方法是深度學習演算法。In one embodiment, judging the second flaw level of the target flaw area according to the second criterion includes: extracting a plurality of first characteristic values of the target flaw area, and converting the plurality of first characteristic values into second characteristic values in a preset format , And use the third processing method to process the second feature value to obtain the second defect level. In one embodiment, the first feature value is any combination of size, grayscale, texture, position, and direction, the preset format is an image format, and the second feature value is a feature map formed by the conversion of the first feature value. In this embodiment, the third processing method is a deep learning algorithm.
在一實施方式中,瑕疵檢測方法還包括:根據第一瑕疵等級和/或第二瑕疵等級判斷目標瑕疵區域是否具有瑕疵。In one embodiment, the flaw detection method further includes: judging whether the target flaw area has a flaw according to the first flaw level and/or the second flaw level.
請參考圖5,所示為本發明另一實施方式中基於圖像的瑕疵檢測方法的流程圖。方法包括如下步驟。Please refer to FIG. 5, which shows a flowchart of an image-based defect detection method in another embodiment of the present invention. The method includes the following steps.
步驟S41,獲取待測物體的至少一張圖像。Step S41: Acquire at least one image of the object to be measured.
在一實施方式中,獲取待測物體的至少一張圖像的方式是獲取相機拍攝的待測物體的至少一張圖像,其中,相機可以為線陣相機或面陣相機。本實施方式中,待測物體為手機或平板電腦等裝置。在另一實施方式中,獲取待測物體的至少一張圖像的方式是接收伺服器傳送的待測物體的至少一張圖像。在其他實施方式中,可以從本地資料庫中獲取待測物體的至少一張圖像。本實施方式中,圖像可包括待測物體的完整或局部圖像。圖像可以是任意解析度,也可以經過高採樣或低採樣,依實際需求而定。In one embodiment, the method of acquiring at least one image of the object to be measured is to acquire at least one image of the object to be measured taken by a camera, where the camera may be a line scan camera or an area scan camera. In this embodiment, the object to be measured is a device such as a mobile phone or a tablet computer. In another embodiment, the method of acquiring at least one image of the object to be measured is to receive at least one image of the object to be measured sent by the server. In other embodiments, at least one image of the object to be measured can be obtained from a local database. In this embodiment, the image may include a complete or partial image of the object to be measured. The image can be of any resolution, or it can be high-sampled or low-sampled, depending on actual needs.
步驟S42,對圖像做前處理。Step S42, pre-processing the image.
在一實施方式中,對圖像做前處理包括:根據興趣區域演算法從圖像中提取多個興趣區域,利用語意分割演算法對多個興趣區域進行預測處理並輸出多個興趣區域中的背景圖元點及瑕疵圖元點,對背景圖元點及瑕疵圖元點進行二值化並根據二值化的圖元點分離出多個興趣區域中的瑕疵圖元點。In one embodiment, pre-processing the image includes: extracting multiple regions of interest from the image according to the region of interest algorithm, using the semantic segmentation algorithm to predict and process the multiple regions of interest, and outputting information in the multiple regions of interest. The background image element point and the defect image element point are binarized, and the defect image element points in the multiple regions of interest are separated according to the binarized image element point.
在其他實施方式中,對圖像做前處理還包括:對圖像進行濾波、去噪點處理。In other embodiments, pre-processing the image further includes: filtering and denoising the image.
步驟S43,從圖像中提取多個瑕疵子區域。Step S43: Extract multiple defect sub-regions from the image.
在一實施方式中,從圖像中提取多個瑕疵子區域包括:對多個興趣區域中的瑕疵圖元點進行群聚得到多個瑕疵塊,通過每一瑕疵塊的邊界框選出一個矩形區域作為瑕疵塊的瑕疵區域,並確定每一瑕疵塊的瑕疵區域的座標。其中每一瑕疵塊由瑕疵圖元點群聚得到,及根據每一瑕疵塊的瑕疵區域的座標得到多個瑕疵子區域。In one embodiment, extracting multiple defect sub-regions from the image includes: clustering defect primitive points in multiple regions of interest to obtain multiple defect blocks, and selecting a rectangular area through the bounding box of each defect block As the defect area of the defect block, and determine the coordinates of the defect area of each defect block. Each of the defect blocks is obtained by clustering the defect image element points, and multiple defect sub-areas are obtained according to the coordinates of the defect area of each defect block.
步驟S44,從多個瑕疵子區域提取出目標瑕疵子區域。Step S44, extracting the target defect sub-areas from the multiple defect sub-areas.
在一實施方式中,從多個瑕疵子區域提取出目標瑕疵子區域包括:根據尺寸大小將多個瑕疵子區域進行排序,選取排序靠前的第一預設數量個瑕疵子區域作為目標瑕疵子區域。將多個瑕疵子區域中除去排序靠前的第一預設數量個瑕疵子區域以外的瑕疵區域按照寬度與高度之和的大小進行排序,並選取寬度與高度之和在預設範圍內且排序靠前的第二預設數量個瑕疵區域作為目標瑕疵區域。本實施方式中,第一預設數量、第二預設數量及預設範圍可以根據使用者需要進行設置。In one embodiment, extracting the target flaw sub-regions from the multiple flaw sub-regions includes: sorting the multiple flaw sub-regions according to the size, and selecting the first preset number of flaw sub-regions with the highest ranking as the target flaw sub-regions area. Sort the defect areas except the first preset number of defect sub-areas from the multiple defect sub-areas according to the sum of width and height, and select the sum of width and height to be within the preset range and sort The first second preset number of defect areas are used as target defect areas. In this embodiment, the first preset quantity, the second preset quantity, and the preset range can be set according to the needs of the user.
步驟S45,利用第一處理方法判斷多個目標瑕疵子區域的瑕疵類型。In step S45, the first processing method is used to determine the defect types of the multiple target defect sub-regions.
在一實施方式中,利用第一處理方法判斷多個目標瑕疵子區域的瑕疵類型包括:將圖像進行等分處理得到預設尺寸的多個圖像塊及每個圖像塊的座標,並將每一圖像塊與一待預測的目標瑕疵子區域關聯,並將與目標瑕疵子區域關聯的圖像塊利用卷積神經網路模型判斷多個目標瑕疵子區域的瑕疵類型。In one embodiment, using the first processing method to determine the defect type of the multiple target defect sub-regions includes: dividing the image into equal parts to obtain multiple image blocks of a preset size and the coordinates of each image block, and Each image block is associated with a target flaw sub-region to be predicted, and the image block associated with the target flaw sub-region is used to determine the flaw type of the multiple target flaw sub-regions using a convolutional neural network model.
在一實施方式中,目標瑕疵子區域的瑕疵類型包括:擦傷類型、刮傷類型、碰傷類型及污漬類型。本實施方式中,卷積神經網路模型包括,但不限於:支援向量機模型。將多個目標瑕疵子區域作為卷積神經網路模型的輸入,經過卷積神經網路模型計算後,輸出瑕疵類型。In an embodiment, the defect type of the target defect sub-region includes: a scratch type, a scratch type, a bruise type, and a stain type. In this embodiment, the convolutional neural network model includes, but is not limited to: a support vector machine model. The multiple target defect sub-regions are used as the input of the convolutional neural network model, and the defect type is output after the convolutional neural network model is calculated.
步驟S46,依據第二處理方法從目標瑕疵子區域產生至少一個目標瑕疵區域。Step S46, generating at least one target defect area from the target defect sub-area according to the second processing method.
在一實施方式中,依據第二處理方法從目標瑕疵子區域產生至少一個目標瑕疵區域包括:根據多個目標瑕疵子區域的類型和位置,聚合類型相同且位置相鄰的一個或多個目標瑕疵子區域產生目標瑕疵區域。In an embodiment, generating at least one target defect area from the target defect sub-area according to the second processing method includes: according to the types and positions of the multiple target defect sub-areas, aggregating one or more target defects of the same type and adjacent in position. The sub-area produces the target defect area.
步驟S47,根據瑕疵區域的類型判斷目標瑕疵區域的關注等級。Step S47, judging the attention level of the target flaw area according to the type of the flaw area.
在一實施方式中,根據瑕疵區域的類型判斷目標瑕疵區域的關注等級包括:利用目標瑕疵區域的類型及座標判斷目標瑕疵區域的長寬比,並根據目標瑕疵區域的長寬比確定目標瑕疵區域的關注等級。不同類型的瑕疵可能具有不同的分佈傾向,可以根據目標瑕疵區域的類型和所在位置,判斷其關注等級,例如關注等級越高,表示目標瑕疵區域的位置與類型的符合程度越高。In one embodiment, judging the attention level of the target flaw area according to the type of the flaw area includes: using the type and coordinates of the target flaw area to determine the aspect ratio of the target flaw area, and determining the target flaw area according to the aspect ratio of the target flaw area Level of attention. Different types of defects may have different distribution tendencies. The attention level can be determined according to the type and location of the target defect area. For example, the higher the attention level, the higher the degree of conformity between the location of the target defect area and the type.
步驟S48,根據目標瑕疵區域的關注等級,按照第一準則判斷目標瑕疵區域的第一瑕疵等級。Step S48, according to the attention level of the target flaw area, determine the first flaw level of the target flaw area according to the first criterion.
在一實施方式中,根據目標瑕疵區域的關注等級按照第一準則判斷目標瑕疵區域的第一瑕疵等級包括:計算目標瑕疵區域的區域大小,及根據目標瑕疵區域的區域大小確定第一瑕疵等級。In one embodiment, judging the first flaw level of the target flaw area according to the first criterion according to the attention level of the target flaw area includes: calculating the area size of the target flaw area, and determining the first flaw level according to the area size of the target flaw area.
步驟S49,判斷目標瑕疵區域的第一瑕疵等級是否滿足預設條件,及當第一瑕疵等級不滿足預設條件是,根據第二準則判斷目的地區域的第二瑕疵等級。In step S49, it is judged whether the first defect level of the target defect area meets the preset condition, and when the first defect level does not meet the preset condition, the second defect level of the destination area is judged according to the second criterion.
在一實施方式中,預設條件為第一瑕疵等級屬於預設等級。在一實施方式中,根據第二準則判斷目標瑕疵區域的第二瑕疵等級包括:提取目標瑕疵區域的多個第一特徵值,將多個第一特徵值轉換為預設格式的第二特徵值,及利用第三處理方法處理第二特徵值以得到第二瑕疵等級。在一具體實施方式中,第一特徵值是尺寸、灰度、紋理、位置、方向的任意組合,預設格式為圖像格式,第二特徵值是由第一特徵值轉換組成的特徵圖。在一實施方式中,第三處理方法是深度學習演算法。In one embodiment, the preset condition is that the first defect level belongs to the preset level. In one embodiment, judging the second flaw level of the target flaw area according to the second criterion includes: extracting a plurality of first characteristic values of the target flaw area, and converting the plurality of first characteristic values into second characteristic values in a preset format , And use the third processing method to process the second feature value to obtain the second defect level. In a specific embodiment, the first feature value is any combination of size, grayscale, texture, position, and direction, the preset format is an image format, and the second feature value is a feature map formed by the conversion of the first feature value. In one embodiment, the third processing method is a deep learning algorithm.
步驟S50,根據第一瑕疵等級和/或第二瑕疵等級判斷目標瑕疵區域是否存在瑕疵。Step S50, judging whether there is a defect in the target defect area according to the first defect level and/or the second defect level.
在一實施方式中,如果第一瑕疵等級屬於預設等級,則依據第一瑕疵等級來判斷目標瑕疵區域是否存在瑕疵,如果第一瑕疵等級不屬於預設等級,則依據第二瑕疵等級來判斷目標瑕疵區域是否存在瑕疵。在其他實施方式中,如果第一瑕疵等級不屬於預設等級,也可以綜合依據第一瑕疵等級和第二瑕疵等級來判斷目標瑕疵區域是否存在瑕疵。In one embodiment, if the first defect level belongs to the preset level, determine whether there is a defect in the target defect area according to the first defect level, and if the first defect level does not belong to the preset level, then judge according to the second defect level Whether there are defects in the target defect area. In other implementation manners, if the first defect level does not belong to the preset level, it can also be comprehensively judged whether there is a defect in the target defect area based on the first defect level and the second defect level.
步驟S51,存儲第一瑕疵等級及第二瑕疵等級。Step S51, storing the first defect level and the second defect level.
請參考圖6,所示為本發明一實施方式中瑕疵檢測系統1的示意圖。瑕疵檢測系統1包括計算單元11和存儲單元12。計算單元11可以執行存儲單元12內的檢測程式121。計算單元11可以從瑕疵檢測系統1或是遠端的存儲單元取得待測物體的圖像,或是利用設置在瑕疵檢測系統1或是遠端的拍攝單元,或是從遠端的伺服器或資料庫取得。本實施方式中,計算單元11可以包括多個計算子單元,不同檢測程式121區段可以被不同的計算子單元執行。本實施方式中,計算單元11也可以協同遠端的遠端計算單元分別執行部分檢測程式121區段。檢測結果可以儲存在瑕疵檢測系統1或是遠端的存儲單元,或是輸出到遠端的伺服器或資料庫。Please refer to FIG. 6, which is a schematic diagram of the
請參考圖7,所示為本發明一實施方式中瑕疵檢測系統1的功能模組圖。瑕疵檢測系統1包括一個或多個模組,一個或者多個模組運行在計算單元11中。本實施方式中,瑕疵檢測系統1包括圖像獲取模組101、瑕疵提取模組102、第一處理模組103、第二處理模組104、第一判斷模組105及存儲模組106。本實施方式中,像獲取模組101、瑕疵提取模組102、第一處理模組103、第二處理模組104、第一判斷模組105及存儲模組106存儲在存儲單元12中,並被計算單元11調用執行。本發明所稱的模組是指能夠完成特定功能的一系列電腦程式指令段,比程式更適合於描述軟體在瑕疵檢測系統1中的執行過程。在其他實施方式中,圖像獲取模組101、瑕疵提取模組102、第一處理模組103、第二處理模組104、第一判斷模組105及存儲模組106為內嵌或固化在計算單元11中的程式段或代碼。Please refer to FIG. 7, which shows a functional module diagram of the
本實施方式中,圖像獲取模組101是用於獲取待測物體的至少一張圖像。圖像獲取模組101可以例如獲取相機拍攝的待測物體的至少一張圖像,其中,相機可以為線陣相機或面陣相機。本實施方式中,待測物體為手機或平板電腦等裝置。在另一實施方式中,圖像獲取模組101是接收伺服器傳送的待測物體的至少一張圖像。在其他實施方式中,可以從本地資料庫中獲取待測物體的至少一張圖像。本實施方式中,圖像可包括待測物體的完整或局部圖像。圖像可以是任意解析度,也可以經過高採樣或低採樣,依實際需求而定。In this embodiment, the
本實施方式中,瑕疵提取模組102是用於從圖像中提取多個目標瑕疵子區域。在一實施方式中,瑕疵提取模組102還可以對圖像做前處理以提取多個預測瑕疵位置,根據多個預測瑕疵位置框選多個瑕疵子區域,並根據尺寸大小從多個瑕疵子區域中選取多個目標瑕疵子區域。在一實施方式中,瑕疵提取模組102還可以從圖像中提取多個興趣區域,利用第四處理方法從多個興趣區域中提取多個預測瑕疵位置,聚合多個預測瑕疵位置中相鄰的至少二個得到多個目標瑕疵子區域。在一實施方式中,第四處理演算法是語意分割演算法。In this embodiment, the
在具體實施方式中,瑕疵提取模組102可以根據興趣區域(Region of Interest, ROI)演算法從圖像中提取多個興趣區域。瑕疵提取模組102利用語意分割演算法對多個興趣區域進行預測處理並輸出多個興趣區域中的背景圖元點及瑕疵圖元點,對背景圖元點及瑕疵圖元點進行二值化並根據二值化的圖元點分離出多個興趣區域中的瑕疵圖元點,根據分離出的多個興趣區域中的瑕疵圖元點得到多個預測瑕疵位置,及聚合多個預測瑕疵位置中相鄰的至少二個得到多個目標瑕疵子區域。In a specific implementation, the
在一實施方式中,瑕疵提取模組102可以將多個興趣區域中的圖元點的灰度設置為0或255以對多個興趣區域的圖元點的灰度進行二值化,將灰度值為255的圖元點作為瑕疵圖元點,及將灰度值為0的圖元點作為背景圖元點。在一具體實施方式中,瑕疵提取模組102可以通過k-means聚類方法將多個興趣區域中的圖元點的灰度進行分組得到兩個分組,將兩個分組中的圖元點的灰度二值化,且每一分組中二值化後的圖元點的灰度值相同,接著將多個興趣區域中的圖元點的灰度值與預設閾值進行比較,將圖元點中大於預設閾值的灰度值設置為255,及將圖元點中不大於預設閾值的灰度值設置為0。其中,預設閾值可以根據使用者的需要進行設置。In an embodiment, the
在一實施方式中,瑕疵提取模組102可以濾除多個興趣區域中的非瑕疵圖元點,對多個興趣區域中的瑕疵圖元點進行群聚得到多個瑕疵塊。通過每一瑕疵塊的邊界框選出一個矩形區域作為瑕疵塊的瑕疵區域並確定每一瑕疵塊的瑕疵區域的座標,其中每一瑕疵塊由瑕疵圖元點群聚得到。再根據每一瑕疵塊的瑕疵區域的座標得到多個預測瑕疵位置,其中每一預測瑕疵位置對應一個瑕疵塊的瑕疵區域。In one embodiment, the
在一實施方式中,瑕疵提取模組102可以根據瑕疵區域的座標框選出多個瑕疵子區域。在一實施方式中,瑕疵提取模組102可以在圖像中以圖像左上角的點為原點建立笛卡爾座標系,其中笛卡爾座標系的X方向表示圖像的寬度,笛卡爾座標系的Y方向表示圖像的高度。在笛卡爾座標系中將每一瑕疵塊的最左邊的圖元點所對應的x座標作為瑕疵塊的左邊邊界,將每一瑕疵塊的最右邊的圖元點所對應的x座標作為瑕疵塊的右邊邊界,將每一瑕疵塊的最上邊的圖元點所對應的y座標作為瑕疵塊的上邊邊界,及將每一瑕疵塊的最下邊的圖元點所對應的y座標作為瑕疵塊的下邊邊界。根據左邊邊界、右邊邊界、上邊邊界、下邊邊界框選出矩形區域作為瑕疵塊的瑕疵區域的座標,並根據瑕疵區域的座標框選出多個瑕疵子區域。In one embodiment, the
在一實施方式中,瑕疵提取模組102可以根據尺寸大小將多個瑕疵子區域進行排序,選取排序靠前的第一預設數量個瑕疵子區域作為目標瑕疵子區域。再將多個瑕疵子區域中除去排序靠前的第一預設數量個瑕疵子區域以外的瑕疵區域按照寬度與高度之和的大小進行排序,並選取寬度與高度之和在預設範圍內且排序靠前的第二預設數量個瑕疵區域作為目標瑕疵區域。本實施方式中,第一預設數量、第二預設數量及預設範圍可以根據使用者需要進行設置。In an embodiment, the
第一處理模組103是用於利用第一處理方法判斷多個目標瑕疵子區域的瑕疵類型。在一實施方式中,第一處理方法是利用卷積神經網路模型判斷多個目標瑕疵子區域的瑕疵類型。在一實施方式中,目標瑕疵子區域的瑕疵類型包括:擦傷類型、刮傷類型、碰傷類型及污漬類型。The
第二處理模組104是用於利用第二處理方法從多個目標瑕疵子區域產生至少一個目標瑕疵區域。在一實施方式中,第二處理模組104根據多個目標瑕疵子區域的類型和位置,聚合類型相同且位置相鄰的一或數個目標瑕疵子區域產生目標瑕疵區域。The
第一判斷模組105是用於根據第一準則判斷目標瑕疵區域的第一瑕疵等級。在一實施方式中,第一判斷模組105可計算目標瑕疵區域的區域大小,並根據目標瑕疵區域的區域大小確定第一瑕疵等級。在具體實施方式中,在計算出目標瑕疵區域的區域大小後根據目標瑕疵區域的區域大小查找瑕疵等級關係表確定與區域大小相對應的第一瑕疵等級,其中,瑕疵等級關係表中包括多個目標瑕疵區域的區域大小與多個第一瑕疵等級,並定義了多個目標瑕疵區域的區域大小與多個第一瑕疵等級的對應關係。The
在另一實施方式中,第一判斷模組105是根據目標瑕疵區域的瑕疵類型,判斷目標瑕疵區域的關注等級,根據關注等級計算目標瑕疵區域的瑕疵數值,再根據瑕疵數值和至少一個預設閾值以得到目標瑕疵區域的第一瑕疵等級。在一個具體實施方式中,第一判斷模組105是根據目標瑕疵區域的瑕疵類型查找關注等級關係表確定與瑕疵類型相對應的目標瑕疵區域的關注等級,其中,關注等級關係表中包括多個目標瑕疵區域的瑕疵類型與多個關注等級,並定義了多個瑕疵類型與關注等級的對應關係。在一個具體實施方式中,第一判斷模組105是根據關注等級查找計算規則關係表確定與關注等級相對應的瑕疵數值的計算規則,按照計算規則計算與目標瑕疵區域的關注等級對應的瑕疵數值。其中,計算規則關係表中定義了目標瑕疵區域的多個關注等級與多個計算規則的對應關係。本實施方式中,計算規則包括根據目標瑕疵區域的面積計算瑕疵數值、根據目標瑕疵區域的長寬之和計算瑕疵數值。In another embodiment, the
存儲模組106用於儲存第一瑕疵等級。The
請參考圖8,所示為本發明另一實施方式中瑕疵檢測系統1的功能模組圖。瑕疵檢測系統1包括一個或多個模組,一個或者多個模組運行在計算單元11中。本實施方式中,瑕疵檢測系統1包括圖像獲取模組201、瑕疵提取模組202、第一處理模組203、第二處理模組204、第一判斷模組205、存儲模組206、第二判斷模組207及第三判斷模組208。Please refer to FIG. 8, which shows a functional module diagram of the
圖像獲取模組201用於獲取待測物體的至少一張圖像。The
瑕疵提取模組202用於從圖像中提取多個目標瑕疵子區域。The
在一實施方式中,瑕疵提取模組202可對圖像做前處理以提取多個預測瑕疵位置,根據多個預測瑕疵位置框選多個瑕疵子區域,根據尺寸大小從多個瑕疵子區域中選取多個目標瑕疵子區域。在一實施方式中,瑕疵提取模組202可從圖像中提取多個興趣區域,利用第四處理方法從多個興趣區域中提取多個預測瑕疵位置,聚合多個預測瑕疵位置中相鄰的至少二個得到多個目標瑕疵子區域。在一實施方式中,第四處理演算法是語意分割演算法。In one embodiment, the
在一實施方式中,瑕疵提取模組202可用於根據興趣區域演算法從圖像中提取多個興趣區域,利用語意分割演算法對多個興趣區域進行預測處理並輸出多個興趣區域中的背景圖元點及瑕疵圖元點,對背景圖元點及瑕疵圖元點進行二值化並根據二值化的圖元點分離出多個興趣區域中的瑕疵圖元點,根據分離出的多個興趣區域中的瑕疵圖元點得到多個預測瑕疵位置,及聚合多個預測瑕疵位置中相鄰的至少二個得到多個目標瑕疵子區域。In one embodiment, the
在一實施方式中,瑕疵提取模組202可用於濾除多個興趣區域中的非瑕疵圖元點,對多個興趣區域中的瑕疵圖元點進行群聚得到多個瑕疵塊,通過每一瑕疵塊的邊界框選出一個矩形區域作為瑕疵塊的瑕疵區域並確定每一瑕疵塊的瑕疵區域的座標,其中每一瑕疵塊由瑕疵圖元點群聚得到。以及根據每一瑕疵塊的瑕疵區域的座標得到多個預測瑕疵位置,其中每一預測瑕疵位置對應一個瑕疵塊的瑕疵區域。In one embodiment, the
在一實施方式中,瑕疵提取模組202可用於根據瑕疵區域的座標框選出多個瑕疵子區域。本實施方式中,瑕疵提取模組202可用於在圖像中以圖像左上角的點為原點建立笛卡爾座標系,其中笛卡爾座標系的X方向表示圖像的寬度,笛卡爾座標系的Y方向表示圖像的高度;笛卡爾座標系中將每一瑕疵塊的最左邊的圖元點所對應的x座標作為瑕疵塊的左邊邊界,將每一瑕疵塊的最右邊的圖元點所對應的x座標作為瑕疵塊的右邊邊界,將每一瑕疵塊的最上邊的圖元點所對應的y座標作為瑕疵塊的上邊邊界,及將每一瑕疵塊的最下邊的圖元點所對應的y座標作為瑕疵塊的下邊邊界。根據左邊邊界、右邊邊界、上邊邊界、下邊邊界框選出矩形區域作為瑕疵塊的瑕疵區域的座標,並根據瑕疵區域的座標框選出多個瑕疵子區域。In one embodiment, the
在一實施方式中,瑕疵提取模組202可用於根據尺寸大小將多個瑕疵子區域進行排序,選取排序靠前的第一預設數量個瑕疵子區域作為目標瑕疵子區域。再將多個瑕疵子區域中除去排序靠前的第一預設數量個瑕疵子區域以外的瑕疵區域按照寬度與高度之和的大小進行排序,並選取寬度與高度之和在預設範圍內且排序靠前的第二預設數量個瑕疵區域作為目標瑕疵區域。本實施方式中,第一預設數量、第二預設數量及預設範圍可以根據使用者需要進行設置。In one embodiment, the
第一處理模組203是用於利用第一處理方法判斷多個目標瑕疵子區域的瑕疵類型。在一實施方式中,第一處理模組203是利用卷積神經網路模型判斷多個目標瑕疵子區域的類型。The
第二處理模組20是用於利用第二處理方法從多個目標瑕疵子區域產生至少一個目標瑕疵區域。在一實施方式中,第二處理模組204可根據多個目標瑕疵子區域的類型和位置,聚合類型相同且位置相鄰的一或數個目標瑕疵子區域產生目標瑕疵區域。The
第一判斷模組205是用於根據第一準則判斷目標瑕疵區域的第一瑕疵等級。在一實施方式中,第一判斷模組205可計算目標瑕疵區域的區域大小,及根據目標瑕疵區域的區域大小確定第一瑕疵等級。在具體實施方式中,在計算出目標瑕疵區域的區域大小後根據目標瑕疵區域的區域大小查找瑕疵等級關係表確定與區域大小相對應的第一瑕疵等級,其中,瑕疵等級關係表中包括多個目標瑕疵區域的區域大小與多個第一瑕疵等級,並定義了多個目標瑕疵區域的區域大小與多個第一瑕疵等級的對應關係。The
存儲模組206是用以儲存第一瑕疵等級。The
第二判斷模組207是用以判斷第一瑕疵等級是否滿足預設條件,及當第一瑕疵等級不滿足預設條件時,根據第二準則判斷目標瑕疵區域的第二瑕疵等級。在一實施方式中,預設條件為第一瑕疵等級屬於預設等級。即,當第一瑕疵等級不屬於預設等級時,第二判斷模組207根據第二準則判斷目標瑕疵區域的第二瑕疵等級。The
存儲模組206還用於存儲第二瑕疵等級。The
在一實施方式中,第二判斷模組207可提取目標瑕疵區域的多個第一特徵值,將多個第一特徵值轉換為預設格式的第二特徵值,及利用第三處理方法處理第二特徵值以得到第二瑕疵等級。在一實施方式中,第一特徵值是尺寸、灰度、紋理、位置、方向的任意組合,預設格式為圖像格式,第二特徵值是由第一特徵值轉換組成的特徵圖。在一實施方式中,第三處理方法是深度學習演算法。In one embodiment, the
在一實施方式中,第三判斷模組208用於根據第一瑕疵等級和/或第二瑕疵等級判斷目標瑕疵區域是否具有瑕疵。In one embodiment, the
在本發明所提供的幾個實施例中,應該理解到,所揭露的電子設備和方法,可以通過其它的方式實現。例如,以上所描述的電子設備實施例僅僅是示意性的,例如,模組的劃分,僅僅為一種邏輯功能劃分,實際實現時可以有另外的劃分方式。In the several embodiments provided by the present invention, it should be understood that the disclosed electronic device and method may be implemented in other ways. For example, the electronic device embodiments described above are merely illustrative. For example, the division of modules is only a logical function division, and there may be other division methods in actual implementation.
另外,在本發明各個實施例中的各功能模組可以集成在相同處理模組中,也可以是各個模組單獨物理存在,也可以兩個或兩個以上模組集成在相同模組中。上述集成的模組既可以採用硬體的形式實現,也可以採用硬體加軟體功能模組的形式實現。In addition, the functional modules in the various embodiments of the present invention may be integrated in the same processing module, or each module may exist alone physically, or two or more modules may be integrated in the same module. The above-mentioned integrated modules can be implemented either in the form of hardware or in the form of hardware plus software functional modules.
對於本領域技術人員而言,顯然本發明不限於上述示範性實施例的細節,而且在不背離本發明的精神或基本特徵的情況下,能夠以其他的具體形式實現本發明。因此,無論從哪一點來看,均應將實施例看作是示範性的,而且是非限制性的,本發明的範圍由所附發明申請專利範圍而不是上述說明限定,因此旨在將落在發明申請專利範圍的等同要件的含義和範圍內的所有變化涵括在本發明內。不應將發明申請專利範圍中的任何附圖標記視為限制所涉及的發明申請專利範圍。此外,顯然“包括”一詞不排除其他模組或步驟,單數不排除複數。電子設備發明申請專利範圍中陳述的多個模組或電子設備也可以由同一個模組或電子設備通過軟體或者硬體來實現。第一,第二等詞語用來表示名稱,而並不表示任何特定的順序。For those skilled in the art, it is obvious that the present invention is not limited to the details of the above exemplary embodiments, and the present invention can be implemented in other specific forms without departing from the spirit or basic characteristics of the present invention. Therefore, no matter from which point of view, the embodiments should be regarded as exemplary and non-restrictive. The scope of the present invention is defined by the scope of the appended invention patent application rather than the above description, so it is intended to fall within The meaning of the equivalent elements and all changes within the scope of the patent application for invention are included in the present invention. Any reference signs in the scope of the patent application for invention shall not be regarded as limiting the scope of the patent application for the invention involved. In addition, it is obvious that the word "include" does not exclude other modules or steps, and the singular does not exclude the plural. Multiple modules or electronic devices stated in the scope of an electronic device invention patent application can also be implemented by the same module or electronic device through software or hardware. Words such as first and second are used to denote names, but do not denote any specific order.
最後應說明的是,以上實施例僅用以說明本發明的技術方案而非限制,儘管參照較佳實施例對本發明進行了詳細說明,本領域的普通技術人員應當理解,可以對本發明的技術方案進行修改或等同替換,而不脫離本發明技術方案的精神和範圍。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present invention can be Modifications or equivalent replacements are made without departing from the spirit and scope of the technical solution of the present invention.
S21~S26:步驟 20:刮傷 21:第一長條 22:第二長條 23:第三長條 24:第四長條 30:第一擦傷 301:第一區域 302:第二區域 303:第三區域 304:第四區域 31:第二擦傷 311:第五區域 312:第六區域 S31~S37:步驟 S41~S49,S50~S51:步驟 1:瑕疵檢測系統 11:計算單元 12:存儲單元 121:檢測程式 101:圖像獲取模組 102:瑕疵提取模組 103:第一處理模組 104:第二處理模組 105:第一判斷模組 106:存儲模組 201:圖像獲取模組 202:瑕疵提取模組 203:第一處理模組 204:第二處理模組 205:第一判斷模組 206:存儲模組 207:第二判斷模組 208:第三判斷模組S21~S26: steps 20: scratch 21: The first strip 22: The second long strip 23: The third bar 24: The fourth bar 30: first scratch 301: The first area 302: The second area 303: The third area 304: The fourth area 31: The second scrape 311: Fifth Region 312: The sixth area S31~S37: steps S41~S49, S50~S51: steps 1: Defect detection system 11: Computing unit 12: storage unit 121: detection program 101: Image acquisition module 102: Defect Extraction Module 103: The first processing module 104: The second processing module 105: The first judgment module 106: storage module 201: Image acquisition module 202: Defect Extraction Module 203: The first processing module 204: The second processing module 205: The first judgment module 206: Storage Module 207: Second Judgment Module 208: Third Judgment Module
圖1A及圖1B為本發明一實施方式中待測物體的圖像包含多個瑕疵的示意圖。 圖2為本發明一實施方式中基於圖像的瑕疵檢測方法的流程圖。 圖3A為本發明一實施方式中擦傷的示意圖,圖3B為本發明一實施方式中刮傷的示意圖。 圖4為本發明另一實施方式中基於圖像的瑕疵檢測方法的流程圖。 圖5為本發明另一實施方式中基於圖像的瑕疵檢測方法的流程圖。 圖6為本發明一實施方式中瑕疵檢測系統的示意圖。 圖7為本發明一實施方式中瑕疵檢測系統的功能模組圖。 圖8為本發明另一實施方式中瑕疵檢測系統的功能模組圖。FIG. 1A and FIG. 1B are schematic diagrams of the image of the object to be measured including multiple defects in an embodiment of the present invention. Fig. 2 is a flowchart of an image-based defect detection method in an embodiment of the present invention. FIG. 3A is a schematic diagram of a scratch in an embodiment of the present invention, and FIG. 3B is a schematic diagram of a scratch in an embodiment of the present invention. FIG. 4 is a flowchart of an image-based defect detection method in another embodiment of the present invention. Fig. 5 is a flowchart of an image-based defect detection method in another embodiment of the present invention. Fig. 6 is a schematic diagram of a defect detection system in an embodiment of the present invention. FIG. 7 is a functional module diagram of a defect detection system in an embodiment of the present invention. FIG. 8 is a functional module diagram of a defect detection system in another embodiment of the present invention.
S21~S26:步驟 S21~S26: steps
Claims (15)
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911421961.9A CN111242899B (en) | 2019-12-31 | 2019-12-31 | Image-based flaw detection method and computer-readable storage medium |
CN201911421961.9 | 2019-12-31 |
Publications (1)
Publication Number | Publication Date |
---|---|
TW202127371A true TW202127371A (en) | 2021-07-16 |
Family
ID=70870746
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
TW109141935A TW202127371A (en) | 2019-12-31 | 2020-11-27 | Image-based defect detection method and computer readable medium thereof |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN111242899B (en) |
TW (1) | TW202127371A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TWI808019B (en) * | 2022-10-03 | 2023-07-01 | 漢通科技股份有限公司 | Method for filtering surface type of object based on artificial neural network and system |
TWI807854B (en) * | 2022-06-09 | 2023-07-01 | 鴻海精密工業股份有限公司 | Method for detecting defects, computer device and storage medium |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US11657279B2 (en) | 2020-06-16 | 2023-05-23 | National Taiwan University Of Science And Technology | Electronic device and method for document segmentation |
CN113989279B (en) * | 2021-12-24 | 2022-03-22 | 武汉华康龙兴工贸有限公司 | Plastic film quality detection method based on artificial intelligence and image processing |
CN116593486B (en) * | 2023-07-18 | 2023-12-08 | 佛山市南海德耀纺织实业有限公司 | Intelligent detection method for cloth flaws and related equipment thereof |
Family Cites Families (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP5658873B2 (en) * | 2009-11-13 | 2015-01-28 | オリンパス株式会社 | Image processing apparatus, electronic apparatus, endoscope system, and program |
CN106097371A (en) * | 2016-06-23 | 2016-11-09 | 凌云光技术集团有限责任公司 | A kind of flaw detection method and system |
CN107301637B (en) * | 2017-05-22 | 2020-08-11 | 南京理工大学 | Method for detecting surface flaws of approximately rectangular planar industrial product |
CN109509172A (en) * | 2018-09-25 | 2019-03-22 | 无锡动视宫原科技有限公司 | A kind of liquid crystal display flaw detection method and system based on deep learning |
CN110047073B (en) * | 2019-05-05 | 2021-07-06 | 北京大学 | X-ray weld image defect grading method and system |
CN110596116B (en) * | 2019-07-23 | 2022-06-07 | 浙江科技学院 | Vehicle surface flaw detection method and system |
-
2019
- 2019-12-31 CN CN201911421961.9A patent/CN111242899B/en active Active
-
2020
- 2020-11-27 TW TW109141935A patent/TW202127371A/en unknown
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TWI807854B (en) * | 2022-06-09 | 2023-07-01 | 鴻海精密工業股份有限公司 | Method for detecting defects, computer device and storage medium |
TWI808019B (en) * | 2022-10-03 | 2023-07-01 | 漢通科技股份有限公司 | Method for filtering surface type of object based on artificial neural network and system |
Also Published As
Publication number | Publication date |
---|---|
CN111242899A (en) | 2020-06-05 |
CN111242899B (en) | 2023-09-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
TW202127371A (en) | Image-based defect detection method and computer readable medium thereof | |
CN109118482B (en) | Panel defect analysis method and device and storage medium | |
CN101996405B (en) | Method and device for rapidly detecting and classifying defects of glass image | |
CN116188475B (en) | Intelligent control method, system and medium for automatic optical detection of appearance defects | |
JP2024509411A (en) | Defect detection method, device and system | |
CN112669275B (en) | YOLOv3 algorithm-based PCB surface defect detection method and device | |
WO2022036919A1 (en) | Defect detection method and apparatus, and electronic device and computer storage medium | |
WO2021168733A1 (en) | Defect detection method and apparatus for defect image, and computer-readable storage medium | |
WO2020156409A1 (en) | Data processing method, defect detection method, computing apparatus, and storage medium | |
TW202013248A (en) | Method and apparatus for vehicle damage identification | |
CN111612784A (en) | Steel plate surface defect detection method based on classification-first YOLO network | |
CN113724231A (en) | Industrial defect detection method based on semantic segmentation and target detection fusion model | |
CN108520278A (en) | A kind of road surface crack detection method and its evaluation method based on random forest | |
CN109462999B (en) | Visual inspection method based on learning through data balance and visual inspection device using same | |
Azad et al. | A novel and robust method for automatic license plate recognition system based on pattern recognition | |
CN115272652A (en) | Dense object image detection method based on multiple regression and adaptive focus loss | |
CN113240623A (en) | Pavement disease detection method and device | |
CN116245882A (en) | Circuit board electronic element detection method and device and computer equipment | |
KR101782364B1 (en) | Vision inspection method based on learning data | |
CN111415330A (en) | Copper foil appearance defect detection method based on deep learning | |
CN115082776A (en) | Electric energy meter automatic detection system and method based on image recognition | |
CN113781483B (en) | Industrial product appearance defect detection method and device | |
Ibragimov et al. | Automated Pavement Condition Index Assessment with Deep Learning and Image Analysis: An End-to-End Approach | |
Xu et al. | The steel surface multiple defect detection and size measurement system based on improved yolov5 | |
CN111340000A (en) | Method and system for extracting and optimizing PDF document table |