TWI779948B - Lens dirt detection method for camera module - Google Patents
Lens dirt detection method for camera module Download PDFInfo
- Publication number
- TWI779948B TWI779948B TW110145118A TW110145118A TWI779948B TW I779948 B TWI779948 B TW I779948B TW 110145118 A TW110145118 A TW 110145118A TW 110145118 A TW110145118 A TW 110145118A TW I779948 B TWI779948 B TW I779948B
- Authority
- TW
- Taiwan
- Prior art keywords
- image
- block
- tested
- brightness
- camera module
- Prior art date
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N5/00—Details of television systems
- H04N5/14—Picture signal circuitry for video frequency region
- H04N5/21—Circuitry for suppressing or minimising disturbance, e.g. moiré or halo
-
- G—PHYSICS
- G01—MEASURING; TESTING
- G01B—MEASURING LENGTH, THICKNESS OR SIMILAR LINEAR DIMENSIONS; MEASURING ANGLES; MEASURING AREAS; MEASURING IRREGULARITIES OF SURFACES OR CONTOURS
- G01B11/00—Measuring arrangements characterised by the use of optical techniques
-
- G—PHYSICS
- G01—MEASURING; TESTING
- G01M—TESTING STATIC OR DYNAMIC BALANCE OF MACHINES OR STRUCTURES; TESTING OF STRUCTURES OR APPARATUS, NOT OTHERWISE PROVIDED FOR
- G01M11/00—Testing of optical apparatus; Testing structures by optical methods not otherwise provided for
-
- G—PHYSICS
- G01—MEASURING; TESTING
- G01N—INVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
- G01N21/00—Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
- G01N21/84—Systems specially adapted for particular applications
- G01N21/88—Investigating the presence of flaws or contamination
- G01N21/8851—Scan or image signal processing specially adapted therefor, e.g. for scan signal adjustment, for detecting different kinds of defects, for compensating for structures, markings, edges
-
- G—PHYSICS
- G01—MEASURING; TESTING
- G01N—INVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
- G01N21/00—Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
- G01N21/84—Systems specially adapted for particular applications
- G01N21/88—Investigating the presence of flaws or contamination
- G01N21/94—Investigating contamination, e.g. dust
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N25/00—Circuitry of solid-state image sensors [SSIS]; Control thereof
- H04N25/60—Noise processing, e.g. detecting, correcting, reducing or removing noise
- H04N25/63—Noise processing, e.g. detecting, correcting, reducing or removing noise applied to dark current
Landscapes
- General Physics & Mathematics (AREA)
- Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Signal Processing (AREA)
- Chemical & Material Sciences (AREA)
- Analytical Chemistry (AREA)
- Life Sciences & Earth Sciences (AREA)
- Health & Medical Sciences (AREA)
- Multimedia (AREA)
- Biochemistry (AREA)
- General Health & Medical Sciences (AREA)
- Immunology (AREA)
- Pathology (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Studio Devices (AREA)
- Encapsulation Of And Coatings For Semiconductor Or Solid State Devices (AREA)
Abstract
Description
本發明是有關於一種影像處理技術,尤其是一種相機模組的鏡頭髒污偵測方法。The invention relates to an image processing technology, in particular to a lens dirty detection method of a camera module.
相機模組的鏡頭一般是由透鏡組成的用於在底片或投影布上形成影像的光學裝置,可廣泛的應用於攝影機、數位相機、或具有攝影或拍攝功能的手機、電腦等電子設備。The lens of a camera module is generally an optical device composed of a lens and used to form an image on a film or projection cloth. It can be widely used in video cameras, digital cameras, or electronic devices such as mobile phones and computers with photography or filming functions.
由於鏡頭廣泛的被應用,因此對於鏡頭的量產以及其質量的需求也相對提升。然而,在鏡頭的生產及裝配的過程中,難免會有灰塵、皮屑、污垢、水漬、刮痕、壞點等異物或髒污情形出現在鏡頭上,導致相機模組最後的成像會出現不需要的陰影,而影響成像的質量,並造成鏡頭生產的良率下降。因此,對鏡頭進行精準的髒污檢測變成極為重要。Due to the widespread use of lenses, the demand for mass production and quality of lenses has also increased relatively. However, in the process of lens production and assembly, it is inevitable that dust, dander, dirt, water stains, scratches, dead pixels and other foreign objects or dirt will appear on the lens, resulting in the final imaging of the camera module will appear Unnecessary shadows affect the quality of imaging and cause a decrease in the yield of lens production. Therefore, it is extremely important to perform accurate dirt detection on the lens.
然而,由於鏡頭的髒污的位置與形狀是微小且不易偵測的。因而,一般在進行鏡頭的髒污檢測時,會對相機模組之經由鏡頭所拍攝的影像進行影像處理而突顯出髒污以方便判斷。然而,此影像處理方式會將影像的干擾波紋(例如自然波紋)也同時突顯出來,而會影響對髒污的偵測(例如會致使髒污檢測發生錯誤判斷的情形)。However, the location and shape of the dirt on the lens are tiny and difficult to detect. Therefore, generally, when detecting the dirt of the lens, image processing is performed on the image captured by the camera module through the lens to highlight the dirt so as to facilitate judgment. However, this image processing method will also highlight the interference ripples (such as natural ripples) of the image at the same time, which will affect the detection of dirt (for example, it will cause wrong judgments in the dirt detection).
鑑於上述,本發明提供一種相機模組的鏡頭髒污偵測方法,可在對鏡頭進行髒污偵測時,消除相機模組經由鏡頭所拍攝的影像的干擾波紋,並精準的偵測出鏡頭的髒污。In view of the above, the present invention provides a lens dirt detection method of a camera module, which can eliminate the interference ripples of the image captured by the camera module through the lens when the lens is dirty detected, and accurately detect the lens dirty.
依據一些實施例,相機模組的鏡頭髒污偵測方法包含取得相機模組拍攝的一影像;對影像執行一灰階處理以取得一灰階影像;對灰階影像執行一高通濾波處理及一對比處理以取得一待測影像;將待測影像區分為多個區塊;對每一區塊中的複數像素的亮度值計算一亮度平均值;對於每個區塊計算其與相鄰的多個區塊的一亮度梯度;以及當亮度梯度大於一亮度門檻值時,判斷對應的區塊為一髒污。According to some embodiments, the lens contamination detection method of the camera module includes obtaining an image captured by the camera module; performing a grayscale processing on the image to obtain a grayscale image; performing a high-pass filtering process and a grayscale image on the grayscale image. Compare and process to obtain an image to be tested; divide the image to be tested into multiple blocks; calculate a brightness average value for the brightness values of the complex pixels in each block; a brightness gradient of a block; and when the brightness gradient is greater than a brightness threshold value, it is determined that the corresponding block is dirty.
綜上所述,依據本發明之實施例,藉由對影像進行灰階處理以及高通濾波處理以消除干擾波紋而降低髒污偵測的誤判。由於影像中每個像素之間並不一定是連續的,因此藉由對影像中的多個像素組合成的區塊進行亮度比對,以準確的判斷出鏡頭的髒污及鏡頭的髒污位置(例如判斷出髒污的邊緣以界定出髒污的位置及大小),而提升相機模組生產良率。To sum up, according to the embodiment of the present invention, by performing grayscale processing and high-pass filtering processing on the image to eliminate interference ripples and reduce misjudgment of dirt detection. Since each pixel in the image is not necessarily continuous, the brightness of the block composed of multiple pixels in the image is compared to accurately determine the dirt of the lens and the dirty position of the lens (For example, determine the edge of the dirt to define the location and size of the dirt), so as to improve the production yield of the camera module.
在本文中使用了某些詞彙來指稱特定的元件。所屬領域中具有通常知識者應可理解,硬體製造商可能會用不同的名詞來稱呼同一個元件。應以元件在功能上的差異來作為區分的準則,並不以名稱的差異來作為區分元件的方式。在本文中所提及的「包含」係為一開放式的用語,故應解釋成「包含但不限定於」。此外,「耦接」一詞在此係包含任何直接及間接的電氣連接手段,因此,若文中描述一第一裝置耦接於一第二裝置,則代表第一裝置可直接電氣連接於第二裝置,或者透過其他裝置或連接手段間接地電氣連接至第二裝置。Certain terms are used herein to refer to particular elements. It should be understood by those skilled in the art that hardware manufacturers may use different terms to refer to the same component. The difference in function of the components should be used as the criterion for distinguishing the components, and the difference in the name should not be used as the way to distinguish the components. The "comprising" mentioned in this article is an open-ended term, so it should be interpreted as "including but not limited to". In addition, the term "coupled" here includes any direct and indirect means of electrical connection. Therefore, if it is described in the text that a first device is coupled to a second device, it means that the first device can be directly electrically connected to the second device. device, or indirectly electrically connected to a second device through other devices or connection means.
參照圖1,圖1係為本發明一實施例之鏡頭髒污偵測的系統的方塊示意圖。鏡頭髒污偵測的系統包含待測的一相機模組100以及影像處理裝置200。相機模組100耦接影像處理裝置200。所述相機模組100可為設置於攝影裝置、數位相機、智慧型手機、電腦等具有攝影或取像功能的電子設備。相機模組100可包含鏡頭(鏡頭模組)以及影像感測器,以對物體進行攝影或取像,而產生物體的影像。若鏡頭具有髒污時,則會產生具有髒污陰影的影像。所述鏡頭可為由一或多個光學玻璃組成的透鏡組。所述影像感測器可為將光訊號轉換為類比電訊號的感光裝置,例如感光耦合裝置(Charge Coupled Device,CCD)、互補性氧化金屬半導體感光裝置(Complementary Metal-Oxide Semiconductor,CMOS)。影像處理裝置200自相機模組100取得其產生的影像,並對影像進行對應的處理,以產生處理後的結果。具體來說,影像處理裝置200執行本發明之相機模組100的鏡頭髒污偵測方法,以判斷相機模組100的鏡頭是否有髒污而產生一結果。所述影像處理裝置200可為桌上型電腦、筆記型電腦、嵌入式運算系統等具有影像處理功能的運算裝置。Referring to FIG. 1 , FIG. 1 is a schematic block diagram of a lens dirt detection system according to an embodiment of the present invention. The lens contamination detection system includes a
參照圖2,圖2係為本發明一實施例之相機模組100的鏡頭髒污偵測方法的流程圖。合併參照圖3,圖3係為本發明一實施例之相機模組100拍攝白色背景模板所產生的影像的示意圖。首先,取得相機模組100拍攝的一影像(步驟S201)。具體來說,影像處理裝置200取得相機模組100經由鏡頭所拍攝的影像。例如,取得相機模組100透過拍攝白色背景模板所產生的影像。所述白色背景模板可以為白板、白紙、白布、白牆等。在一些實施例中,相機模組100的鏡頭可以緊貼於一目標光屏以進行拍攝而產生影像。所述目標光屏可為一表面光滑的穩定平行光源。透過拍攝目標光屏能夠排除背景模板本身紋理對於後續髒污偵測造成的影響,並能進一步提高拍攝亮度,從而使髒污更加準確且清晰地呈現於影像中,以利後續的髒污偵測。Referring to FIG. 2 , FIG. 2 is a flowchart of a method for detecting lens contamination of the
合併參照圖4,圖4係為本發明一實施例之灰階影像的示意圖。接著,對影像執行一灰階處理以取得一灰階影像(步驟S203)。具體來說,影像處理裝置200將影像的三原色光模式(RGB color model)的三個圖像通道轉換為單一圖像通道以產生灰階影像。例如,將影像中的每個像素的RGB值根據式1或式2來計算明亮度(Luminance 或 Luma)而轉換成灰階影像。其中式1與式2的Y表示明亮度,R代表單位像素的紅色通道亮度,G代表單位像素的綠色通道亮度,B代表單位像素的藍色通道亮度。Referring to FIG. 4 together, FIG. 4 is a schematic diagram of a grayscale image according to an embodiment of the present invention. Next, a grayscale process is performed on the image to obtain a grayscale image (step S203 ). Specifically, the
……(式1) ……(Formula 1)
……(式2) ... (Formula 2)
在取得灰階影像後,對灰階影像執行一高通濾波處理及一對比處理以取得一待測影像(步驟S205)。具體來說,影像處理裝置200將灰階影像透過高通濾波器提取其中的高頻分量,並將提取的高頻分量與灰階影像疊加,以產生強化影像中高頻細節的一高通濾波影像。在一些實施例中,高通濾波處理可為高斯濾波、中值濾波、最大值濾波、最小值濾波、反銳化遮掩(Unsharp Masking)或雙邊濾波(Bilateral Filter)等高通濾波的影像處理方式。藉由將影像轉換為適當的灰階影像,並將灰階影像透過適當的高通濾波處理,能夠消除影像中的干擾波紋(例如由影像中心所產生的同心圓波紋),以降低對於後續髒污偵測造成的影響(例如降低髒污偵測誤判的機會)。After the grayscale image is obtained, a high-pass filtering process and a comparison process are performed on the grayscale image to obtain an image to be tested (step S205 ). Specifically, the
合併參照圖5,圖5係為本發明一實施例之待測影像的示意圖。續,在影像處理裝置200取得高通濾波影像後,對高通濾波影像執行對比處理以取得待測影像。具體來說,影像處理裝置200對高通濾波影像進一步執行對比度的調節而產生待測影像。例如強化影像明暗對比,以使高通濾波影像中具有亮度值(Intensity)較小的像素其亮度值變得更小,而具有亮度值較大的像素其亮度值變得更大,以進一步強化高通濾波影像的細節(例如突顯出高通濾波影像中的髒污陰影)。在一些實施例中,影像處理裝置200可以對高通濾波影像進行對比平衡的調節,以重新分布高通濾波影像中的亮部與陰影,而使亮部與陰影之間達到平衡。所述對比處理例如但不限於全域型對比增強(Global Enhancement Methods)、直方圖均衡對比增強(Histogram Equalization)、自適應直方圖均衡對比增強(Adaptive Histogram Equalization)、限制對比度自適應直方圖均衡化(Contrast Limited Adaptive Histogram Equalization)等。Combined with reference to FIG. 5 , FIG. 5 is a schematic diagram of an image to be tested according to an embodiment of the present invention. Next, after the
合併參照圖6,圖6係為本發明一實施例之區分為多個區塊61的待測影像的示意圖。在取得待測影像後,將待測影像區分為多個區塊61(步驟S207)。具體來說,影像處理裝置200將待測影像以多個邊界63區分為分別包含多個像素的多個區塊61,每一區塊61所包含的像素數量可為一致的,且每一區塊61定義在待測影像中的不同的位置並且互相不重疊。換言之,相鄰的複數個像素組合成為一區塊61。在一些實施例中,每一區塊61包含由複數個像素組成的一像素矩陣(例如3*3的像素矩陣,亦即9個像素組合成的像素矩陣)。Referring to FIG. 6 together, FIG. 6 is a schematic diagram of an image to be tested divided into a plurality of
接著,對每一區塊61中的複數像素的亮度值計算一亮度平均值(步驟S209)。具體來說,待測影像中的每一像素具有一亮度值,亮度值的範圍可以依據影像處理裝置200所設定的色彩解析度來調整,其中色彩解析度為影像處理裝置200是使用幾個位元來記錄色彩。例如若影像處理裝置200使用八位元來記錄色彩,則亮度值的範圍為0~255。影像處理裝置200將每一區塊61中的每一像素的亮度值相加後除以每一區塊61中的像素數量,以計算得每一區塊61的亮度平均值,如式3所示,其中I
B為每一區塊61的亮度平均值,n為每一區塊61中像素的數量,I
i為每一區塊61中每一像素的亮度值。
Next, a brightness average value is calculated for the brightness values of the plurality of pixels in each block 61 (step S209 ). Specifically, each pixel in the image to be tested has a brightness value, and the range of the brightness value can be adjusted according to the color resolution set by the
……(式3) ... (Formula 3)
在計算得每一區塊61的亮度平均值後,對於每一區塊61計算其與相鄰的多個區塊61的一亮度梯度(步驟S211)。具體來說,影像處理裝置200對每一區塊61與其相鄰的多個區塊61分別進行偏微分以計算得亮度梯度(例如,若與當前欲計算的區塊61相鄰的多個區塊61的數量是8個,則將當前區塊61分別一對一計算其與相鄰的區塊61的亮度梯度,亦即計算得分別對應每一相鄰區塊61的8個亮度梯度),亦即計算得每一區塊61其與相鄰的多個區塊61之間的亮度值差異,(例如,計算得每一區塊61其與相鄰的多個區塊61之間的亮度值的變化率),換言之,影像處理裝置200是根據每一區塊61的亮度平均值其與相鄰的多個區塊61的亮度平均值之間的變化程度來計算亮度梯度。After calculating the average brightness of each
合併參照圖7,圖7係為本發明一實施例之髒污偵測結果。在計算得每一區塊61的亮度梯度後,影像處理裝置200判斷區塊61的亮度梯度是否大於一亮度門檻值(步驟S213)。在區塊61的亮度梯度大於亮度門檻值時,影像處理裝置200判斷亮度梯度大於亮度門檻值的區塊61為一髒污10(步驟S215)。換言之,當區塊61的亮度梯度大於亮度門檻值時,表示當前區塊61其與相鄰的多個區塊61之間的亮度值差異過大,此時當前區塊61可能為鏡頭髒污的邊緣,因而影像處理裝置200判斷當前的區塊61為髒污。在區塊61的亮度梯度不大於亮度門檻值時,影像處理裝置200判斷亮度梯度不大於亮度門檻值的區塊為一非髒污(步驟S217)。影像處理裝置200藉由組合判斷為髒污的區塊61,以獲得鏡頭的每個髒污10的位置及大小,並產生一髒污結果,並於髒污結果中標記出髒污10的位置及大小。例如,如圖7所示,影像處理裝置200於影像中標記出判斷為髒污10的區塊61,並將判斷為髒污10的相鄰的區塊61以一標示線串連而形成一髒污標記60,以產生具有髒污10的位置與髒污10的大小的髒污標記60的一髒污偵測結果。藉此,可精準的判斷出鏡頭是否有髒污10、髒污10的位置及大小,以快速判斷相機模組100是否有瑕疵。Combined with reference to FIG. 7 , FIG. 7 is a dirt detection result according to an embodiment of the present invention. After calculating the brightness gradient of each
參照圖8,圖8係為本發明一實施例之另一待測影像的示意圖。區塊A5與區塊A1~A4、A6~A9相鄰,區塊A5位於髒污10的邊緣。在此實施例中,可見區塊A5的亮度平均值小於與其相鄰的區塊A1、A4、A7、A8,亦即區塊A5與其相鄰的區塊A1、A4、A7、A8之間的亮度差異是較大的,換言之計算得的區塊A5的亮度梯度大於亮度門檻值,而影像處理裝置200將會判斷區塊A5為髒污10。另一方面,區塊B5與區塊B1~B4、B6~B9相鄰,區塊B5未位於髒污10的邊緣,且區塊B5的亮度平均值與其相鄰的區塊B1~B4、B6~B9相同,因而計算得的區塊B5的亮度梯度小於亮度門檻值,此時影像處理裝置200將判斷區塊B5為非髒污。Referring to FIG. 8 , FIG. 8 is a schematic diagram of another image to be tested according to an embodiment of the present invention. Block A5 is adjacent to blocks A1~A4, A6~A9, and block A5 is located at the edge of
在一些實施例中,在步驟S207中,影像處理裝置200根據待測影像的一影像解析度決定待測影像被區分成區塊61的數量。例如,若待測影像的影像解析度較高時(亦即相機模組100所使用的鏡頭的解析度較高時),則每一區塊61所包含的像素數量可以大於在較低影像解析度區分出的每一區塊61所包含的像素數量,以使對於解析度高的鏡頭及解析度低的鏡頭皆可以快速的偵測髒污10。在一些實施例中,亮度門檻值可以根據待測影像的影像解析度而作調整。例如,若待測影像的影像解析度較高時,此時每一區塊61包含較大的像素數量,而致使每一區塊61其與相鄰的多個區塊61的亮度梯度值可能較小(亦即,二區塊61之間的亮度值差異可能較小),因此,為了精準的判斷區塊61是否為髒污10,影像處理裝置200可調降亮度門檻值。In some embodiments, in step S207 , the
參照圖9,圖9係為本發明一實施例之相機模組100的鏡頭髒污偵測方法的流程圖。在一些實施例中,在步驟S205中,選用反銳化遮掩處理作為高通濾波處理。反銳化遮掩處理為使用模糊(blurred)、非銳化(unsharp)或負影像(negative)來對原影像進行遮罩(mask),以產生較原影像清晰(銳化或不模糊)的新影像。在一些實施例中,反銳化遮掩處理可為以線性高頻濾波器或非線性高頻率波器來放大影像中高頻的分量。Referring to FIG. 9 , FIG. 9 is a flowchart of a method for detecting lens contamination of the
於此說明反銳化遮掩處理的程序。在取得灰階影像後,對灰階影像執行模糊處理而取得一模糊影像(步驟S2051)。具體來說,影像處理裝置200以一低通濾波器提取灰階影像中的低頻分量,以產生模糊影像。所述低通濾波器可為框濾波器(box filter)、高斯模糊濾波器(Gaussian blur filter)、中值濾波器(median filter)、雙邊濾波器(bilateral filter)等。舉例來說,以高斯模糊濾波器為例,影像處理裝置200將灰階影像與灰階影像的常態分佈進行卷積(Convolution),而產生降低雜訊與影像細節層次的模糊影像。在一些實施例中,低通濾波器在進行卷積以提取灰階影像中的低頻分量時,所使用的卷積核(kernel)的尺寸可以根據灰階影像的影像解析度(或鏡頭的解析度)來設定,例如若灰階影像的影像解析度較高時,可以將卷積核設定為較大的尺寸。The procedure of unsharp masking is described here. After the grayscale image is obtained, a blurring process is performed on the grayscale image to obtain a blurred image (step S2051 ). Specifically, the
在取得模糊影像後,對模糊影像執行一亮度反向處理而取得一負影像(步驟S2053)。具體來說,影像處理裝置200將模糊影像中的每個像素的亮度值反轉(inverse),而產生負影像。亦即,影像處理裝置200將模糊影像中的原明亮處變暗,並將原暗處變亮。舉例來說,以影像處理裝置200使用八位元來記錄色彩,而每個像素的亮度值的範圍為0~255為例,當影像處理裝置200執行亮度反向處理時,以亮度值範圍的最大值(例如255)減去每一像素的原亮度值而計算出每一像素的新亮度值,以產生具有新的亮度值的負影像。After the blurred image is obtained, a brightness inversion process is performed on the blurred image to obtain a negative image (step S2053 ). Specifically, the
在取得灰階影像及負影像後,依據負影像及灰階影像,執行一線性光處理(Linear light)而取得一線性光影像(步驟S2055)。具體來說,影像處理裝置200將灰階影像及負影像進行透明合成(Alpha blending)後產生線性光影像。更具體地來說,影像處理裝置200將灰階影像中的每一像素的原亮度值根據式4計算出新的亮度值而產生具有新的亮度值的線性光影像。在一些實施例中,線性光處理可為結合線性加深處理(Linear Burn)與線性減淡處理(Linear Dodge),且線性光處理的效果可為類似於亮光處理(Vivid light)的效果。其中,線性加深處理為根據式5進行影像處理,線性減淡處理為根據式6進行影像處理,亮光處理為根據式7進行影像處理。其中式4的L表示線性光影像中每一像素的亮度值,式5的L表示經線性加深處理後產生的影像中每一像素的亮度值,式6的L表示經線性減淡處理後產生的影像中每一像素的亮度值,式7的L表示經亮光處理後的影像中每一像素的亮度值。其中,式4~式7的O表示灰階影像中每一像素的亮度值,N表示負影像中每一像素的亮度值,Max表示亮度值範圍的最大值。After the grayscale image and the negative image are obtained, a linear light processing (Linear light) is performed according to the negative image and the grayscale image to obtain a linear light image (step S2055 ). Specifically, the
……(式4) ... (Formula 4)
……(式5) ... (Formula 5)
……(式6) ... (Formula 6)
……(式7) ... (Formula 7)
在取得灰階影像及線性光影像後,合併灰階影像與線性光影像以產生一高通濾波影像(步驟S2057)。具體來說,影像處理裝置200將灰階影像及線性光影像進行透明合成後產生放大了灰階影像中的高頻分量的高通濾波影像。更具體地來說,影像處理裝置200將灰階影像中的每一像素的原亮度值根據式8計算出新的亮度值而產生具有新的亮度值的高通濾波影像。其中式8的L表示線性光影像中每一像素的亮度值,O表示灰階影像中每一像素的亮度值,H表示高通濾波影像中每一像素的亮度值。After the grayscale image and the linear light image are obtained, the grayscale image and the linear light image are combined to generate a high-pass filtered image (step S2057 ). Specifically, the
……(式8) ... (Formula 8)
在取得高通濾波影像後,可選用自適應直方圖均衡化處理作為對比處理,以取得待測影像(步驟S2059)。舉例來說,影像處理裝置200可以設定一直方圖亮度閾值,並將高通濾波影像根據直方圖亮度閾值而區分為像素的亮度值小於直方圖亮度閾值的一區域及像素的亮度值大於直方圖亮度閾值的另一區域。影像處理裝置200分別對該二區域進行直方圖均衡化處理,以重新分布高通濾波影像的像素的亮度值,而改進高通濾波影像的局部對比度和增強高通濾波影像中的邊緣來獲得更多細節。例如影像處理裝置200可以根據式9與式10來分別對該二區域進行直方圖均衡化處理。其中,式9與式10的
表示為待測影像的像素的亮度值,
表示為待測影像的該些像素中所具有的最小亮度值,
表示為直方圖亮度閾值,
表示為待測影像的該些像素中所具有的最大亮度值。在式9中,
表示為高通濾波影像的小於直方圖亮度閾值的像素的累積分布函數,
表示為高通濾波影像的小於直方圖亮度閾值的該些像素中所具有的最小累積分布函數,
表示為高通濾波影像的小於直方圖亮度閾值的該些像素中所具有的最大累積分布函數。在式10中,
表示為高通濾波影像的大於直方圖亮度閾值的像素的累積分布函數,
表示為高通濾波影像的大於直方圖亮度閾值的該些像素中所具有的最小累積分布函數,
表示為高通濾波影像的大於直方圖亮度閾值的該些像素中所具有的最大累積分布函數。
After obtaining the high-pass filtered image, an adaptive histogram equalization process can be selected as a comparison process to obtain the image to be tested (step S2059 ). For example, the
……(式9) ... (Formula 9)
……(式10) ... (Formula 10)
在一些實施例中,影像處理裝置200還可以決定待測影像的暗邊區(步驟S219),以協助判斷區塊61是否為髒污10。具體來說,影像處理裝置200判斷區塊61是否位於暗邊區(步驟S221),若區塊61位於暗邊區中,則影像處理裝置200判斷區塊61是非髒污(步驟S217);若區塊61位於暗邊區之外,則影像處理裝置200判斷該區塊61可能為髒污10(步驟S215),或是進一步執行其他協助判斷區塊61是否為髒污10的步驟。由於相機模組100的設計及結構因素,一般所拍攝出的影像四周會具有暗邊區,而暗邊區中的像素其亮度值為小的,而若髒污10為位於拍攝出的影像的暗邊區時,並不會影響影像的成像結果。因此,影像處理裝置200在對鏡頭進行髒污偵測時,可以排除位於暗邊區中的區塊61而僅對位於暗邊區以外的區塊61進行髒污偵測。In some embodiments, the
參照圖10,圖10係為本發明一實施例之決定出暗邊區20的待測影像的示意圖。在一些實施例中,暗邊區20是待測影像的一影像邊緣21向內位移一距離23所界定的一暗邊邊緣25和影像邊緣21之間的區域。例如,影像邊緣21往待測影像的中心軸C位移一距離23以界定暗邊邊緣25。在一些實施例中,影像邊緣21向內位移的距離23可以根據暗邊邊緣25對應至中心軸C的間距27與影像邊緣21對應至中心軸C的間距29之間的比例關係來設定。例如,暗邊邊緣25對應至中心軸C的間距27可為影像邊緣21對應至中心軸C的間距29之98.5%,因此距離23可為影像邊緣21對應至中心軸C的間距29之1.5%。Referring to FIG. 10 , FIG. 10 is a schematic diagram of an image to be tested for determining a
在一些實施例中,影像處理裝置200還可以決定待測影像的暗角區(步驟S223),以協助判斷區塊61是否為髒污10。具體來說,影像處理裝置200判斷區塊61是否位於暗角區(步驟S225),若區塊61位於暗角區中,則影像處理裝置200判斷區塊61是非髒污(步驟S217);若區塊61位於暗角區之外,則影像處理裝置200判斷該區塊61可能為髒污10(步驟S215),或是進一步執行其他協助判斷區塊61是否為髒污10的步驟。由於相機模組100的設計及結構因素,一般所拍攝出的影像四角落會具有暗角區,而暗角區中的像素其亮度值為小的,而若髒污10為位於拍攝出的影像的暗角區時,並不會影響影像的成像結果。因此,影像處理裝置200在對鏡頭進行髒污偵測時,可以排除位於暗角區中的區塊61而僅對位於暗角區以外的區塊61進行髒污偵測。In some embodiments, the
參照圖11,圖11係為本發明一實施例之決定出暗角區30的待測影像的示意圖。在一些實施例中,暗角區30是待測影像的一影像邊角31向內位移一距離35所界定的一暗邊邊角33和影像邊角31之間的區域。例如,影像邊角31往待測影像的中心點cp位移一距離35以界定暗邊邊角33。在一些實施例中,影像邊角31向內位移的距離35可以根據暗邊邊角33對應至中心點cp的間距37與影像邊角31對應至中心點cp的間距39之間的比例關係來設定。例如,暗邊邊角33對應至中心點cp的間距37可為影像邊角31對應至中心點cp間距39之85%,因此距離35可為影像邊角31對應至中心點cp間距39之15%。Referring to FIG. 11 , FIG. 11 is a schematic diagram of an image to be tested for determining the
在一些實施例中,步驟S213、步驟S221及步驟S225的順序可以相互對調,換言之,可以先判斷區塊61是否位於暗邊區20或暗角區30後,始判斷區塊61的亮度梯度是否大於亮度門檻值;或是先判斷區塊61的亮度梯度是否大於亮度門檻值後,始判斷區塊61是否位於暗邊區20或暗角區30。在一些實施例中,步驟S219及步驟S223可以在步驟S201~S213之間執行,需注意的是步驟S221需在步驟S219之後執行,步驟S225需在步驟S223之後執行。In some embodiments, the order of step S213, step S221 and step S225 can be reversed. In other words, it is possible to judge whether the
參照圖12,圖12係為本發明一實施例之相機模組100的鏡頭髒污偵測方法的流程圖。在一些實施例中,在某些情形下,由於以包含複數個像素的多個區塊61進行髒污偵測可能會漏偵測髒污10。例如,當前欲偵測的區塊61與其相鄰的區塊61皆位於髒污10的邊緣時,可能會導致判斷當前的區塊61為非髒污而漏偵測到此區塊61,亦即發生髒污偵測誤判。因此為了提升髒污偵測的精準度,在判斷完每一區塊61是否為髒污10後(步驟S215及S217),影像處理裝置200將區分為多個區塊61(於後稱為第一區塊)的多個邊界63(於後稱為第一邊界)沿一方向移動一步幅(stride)而根據移動後的多個邊界63(於後稱為第二邊界)界定另一多個區塊61(於後稱為第二區塊)(步驟S227)。Referring to FIG. 12 , FIG. 12 is a flowchart of a method for detecting lens contamination of the
參照圖13,圖13係為本發明一實施例之將區分的第一區塊40移動第一邊界41後,形成的第二邊界51所界定的第二區塊50的待測影像的示意圖。在一些實施例中,影像處理裝置200可以將第一區塊40的第一邊界41沿著待測影像的一維度方向(例如水平維度或垂直維度)移動一步輻後,形成第二邊界51而以第二邊界51界定第二區塊50。在一些實施例中,步輻的大小可以根據第一區塊40的像素所組合成的像素矩陣來設定,例如步輻的大小可設定成一半的像素矩陣。舉例來說,若第一區塊40的像素矩陣為3*3的矩陣(亦即第一區塊40包含9個像素),則影像處理裝置200可以將第一區塊40的第一邊界41由左至右移動1.5個像素距離後,形成第二邊界51以界定第二區塊50。Referring to FIG. 13 , FIG. 13 is a schematic diagram of an image to be tested of the second block 50 defined by the
在界定出第二區塊50後,對每一第二區塊50中的多個像素計算亮度平均值,亦即執行步驟S209。在計算得每一第二區塊50的亮度平均值後,計算每一第二區塊50其與相鄰的多個第二區塊50的亮度梯度,亦即執行步驟S211,並接續後續步驟(步驟S213~步驟S225),以判斷第二區塊50是否為髒污10。藉此,可提升髒污偵測的準確率。在判斷完每一第二區塊50是否為髒污後(步驟S215及S217),可再回去執行步驟S227而將第二區塊50的第二邊界51沿著前一次移動的方向(亦即第一邊界41所移動的方向)或沿著另一方向(例如前一次為沿著水平維度移動,此次為沿著垂直維度移動;例如前一次為由左至右移動,此次為由上至下移動),而形成新的邊界以界定新的區塊61,並重複後續判斷髒污10的步驟,以完善的偵測相機模組100經由鏡頭所拍攝的影像是否具有髒污10。After the second block 50 is defined, the average brightness of the pixels in each second block 50 is calculated, that is, step S209 is executed. After calculating the average brightness of each second block 50, calculate the brightness gradient between each second block 50 and a plurality of adjacent second blocks 50, that is, execute step S211, and continue with subsequent steps (step S213 ~ step S225 ), to determine whether the second block 50 is dirty 10 . In this way, the accuracy of dirt detection can be improved. After judging whether each second block 50 is dirty (steps S215 and S217), step S227 can be executed again to move the
在一些實施例中,髒污偵測也可以由物體偵測(Object Detection)來實現。例如使用YOLOv3的神經網路分析方式來實現。In some embodiments, dirt detection can also be implemented by object detection. For example, use YOLOv3's neural network analysis method to achieve.
綜上所述,依據本發明之實施例,藉由對影像進行灰階處理以及高通濾波處理以消除干擾波紋而降低髒污偵測的誤判。由於影像中每個像素之間並不一定是連續的,因此藉由對影像中的多個像素組合成的區塊進行亮度比對,以準確的判斷出鏡頭的髒污及鏡頭的髒污位置(例如判斷出髒污的邊緣以界定出髒污的位置及大小),而提升相機模組生產良率。To sum up, according to the embodiment of the present invention, by performing grayscale processing and high-pass filtering processing on the image to eliminate interference ripples and reduce misjudgment of dirt detection. Since each pixel in the image is not necessarily continuous, the brightness of the block composed of multiple pixels in the image is compared to accurately determine the dirt of the lens and the dirty position of the lens (For example, determine the edge of the dirt to define the location and size of the dirt), so as to improve the production yield of the camera module.
100:相機模組
200:影像處理裝置
S201~S227:步驟
10:髒污
60:髒污標記
61,A1~A9,B1~B9:區塊
63:邊界
20:暗邊區
21:影像邊緣
23:距離
25:暗邊邊緣
27:間距
29:間距
C:中心軸
30:暗角區
31:影像邊角
33:暗邊邊角
35:距離
37:間距
39:間距
cp:中心點
40:第一區塊
41:第一邊界
50:第二區塊
51:第二邊界
100: Camera module
200: image processing device
S201~S227: steps
10: Dirty
60:
[圖1]係為本發明一實施例之鏡頭髒污偵測的系統的方塊示意圖。 [圖2]係為本發明一實施例之相機模組的鏡頭髒污偵測方法的流程圖。 [圖3]係為本發明一實施例之相機模組拍攝白色背景模板所產生的影像的示意圖。 [圖4]係為本發明一實施例之灰階影像的示意圖。 [圖5]係為本發明一實施例之待測影像的示意圖。 [圖6]係為本發明一實施例之區分為多個區塊的待測影像的示意圖。 [圖7]係為本發明一實施例之髒污偵測結果的示意圖。 [圖8]係為本發明一實施例之另一待測影像的示意圖。 [圖9]係為本發明一實施例之相機模組的鏡頭髒污偵測方法的流程圖。 [圖10]係為本發明一實施例之決定出暗邊區的待測影像的示意圖。 [圖11]係為本發明一實施例之決定出暗角區的待測影像的示意圖。 [圖12]係為本發明一實施例之相機模組的鏡頭髒污偵測方法的流程圖。 [圖13]係為本發明一實施例之將區分的第一區塊移動第一邊界後,形成的第二邊界所界定的第二區塊的待測影像的示意圖。 [ FIG. 1 ] is a schematic block diagram of a system for detecting lens contamination according to an embodiment of the present invention. [ FIG. 2 ] is a flow chart of a method for detecting lens contamination of a camera module according to an embodiment of the present invention. [ FIG. 3 ] is a schematic diagram of an image generated by a camera module shooting a white background template according to an embodiment of the present invention. [FIG. 4] is a schematic diagram of a grayscale image according to an embodiment of the present invention. [ FIG. 5 ] is a schematic diagram of an image to be tested according to an embodiment of the present invention. [ FIG. 6 ] is a schematic diagram of an image to be tested divided into multiple blocks according to an embodiment of the present invention. [ FIG. 7 ] is a schematic diagram of the dirt detection result of an embodiment of the present invention. [ FIG. 8 ] is a schematic diagram of another image to be tested according to an embodiment of the present invention. [ FIG. 9 ] is a flow chart of a method for detecting lens contamination of a camera module according to an embodiment of the present invention. [ FIG. 10 ] is a schematic diagram of an image to be tested with a dark border area determined according to an embodiment of the present invention. [ FIG. 11 ] is a schematic diagram of an image to be tested for determining a vignetting area according to an embodiment of the present invention. [ FIG. 12 ] is a flowchart of a method for detecting lens contamination of a camera module according to an embodiment of the present invention. [ FIG. 13 ] is a schematic diagram of the image to be tested of the second block defined by the second boundary formed after the first distinguished first block is moved to the first boundary according to an embodiment of the present invention.
S201~S217:步驟 S201~S217: steps
Claims (9)
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011393221.1 | 2020-12-02 | ||
CN202011393221.1A CN112583999B (en) | 2020-12-02 | 2020-12-02 | Method for detecting lens dirt of camera module |
Publications (2)
Publication Number | Publication Date |
---|---|
TW202224404A TW202224404A (en) | 2022-06-16 |
TWI779948B true TWI779948B (en) | 2022-10-01 |
Family
ID=75127063
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
TW110145118A TWI779948B (en) | 2020-12-02 | 2021-12-02 | Lens dirt detection method for camera module |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN112583999B (en) |
TW (1) | TWI779948B (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113532801A (en) * | 2021-06-24 | 2021-10-22 | 四川九洲电器集团有限责任公司 | High/multispectral camera dead pixel detection method and system based on distribution quantile |
CN113570582B (en) * | 2021-07-30 | 2022-07-29 | 上海集成电路制造创新中心有限公司 | Camera cover plate cleanliness detection method and detection device |
CN113834823B (en) * | 2021-11-29 | 2022-04-08 | 浙江华诺康科技有限公司 | Endoscope contamination detection device and contamination detection method |
CN114390225A (en) * | 2022-01-20 | 2022-04-22 | 上海安翰医疗技术有限公司 | Method and device for detecting dirt of capsule endoscope |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109767428A (en) * | 2018-12-26 | 2019-05-17 | 中国科学院西安光学精密机械研究所 | A kind of dirty detection method of camera module |
CN110992327A (en) * | 2019-11-27 | 2020-04-10 | 北京达佳互联信息技术有限公司 | Lens contamination state detection method and device, terminal and storage medium |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2007172397A (en) * | 2005-12-22 | 2007-07-05 | Seiko Epson Corp | Edge gradient detection method, stain defect detection method, edge gradient detection device and stain defect detection device |
-
2020
- 2020-12-02 CN CN202011393221.1A patent/CN112583999B/en active Active
-
2021
- 2021-12-02 TW TW110145118A patent/TWI779948B/en active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109767428A (en) * | 2018-12-26 | 2019-05-17 | 中国科学院西安光学精密机械研究所 | A kind of dirty detection method of camera module |
CN110992327A (en) * | 2019-11-27 | 2020-04-10 | 北京达佳互联信息技术有限公司 | Lens contamination state detection method and device, terminal and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN112583999A (en) | 2021-03-30 |
CN112583999B (en) | 2024-03-15 |
TW202224404A (en) | 2022-06-16 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
TWI779948B (en) | Lens dirt detection method for camera module | |
US7999867B2 (en) | Image edge detection apparatus and method, image sharpness emphasizing apparatus and method, recorded meduim recorded the program performing it | |
CN111028189A (en) | Image processing method, image processing device, storage medium and electronic equipment | |
KR101662846B1 (en) | Apparatus and method for generating bokeh in out-of-focus shooting | |
TWI425831B (en) | System and method for detecting and correcting defective pixels in an image sensor | |
CN102404495B (en) | Method for adjusting shooting parameters of digital camera | |
CN110519485B (en) | Image processing method, image processing device, storage medium and electronic equipment | |
CN110766621A (en) | Image processing method, image processing device, storage medium and electronic equipment | |
Várkonyi-Kóczy et al. | Gradient-based synthesized multiple exposure time color HDR image | |
JP4539432B2 (en) | Image processing apparatus and imaging apparatus | |
CN107395991A (en) | Image combining method, device, computer-readable recording medium and computer equipment | |
TW201346835A (en) | Image blur level estimation method and image quality evaluation method | |
CN110728705B (en) | Image processing method, image processing device, storage medium and electronic equipment | |
TW201947536A (en) | Image processing method and image processing device | |
CN110717871A (en) | Image processing method, image processing device, storage medium and electronic equipment | |
CN110740266B (en) | Image frame selection method and device, storage medium and electronic equipment | |
CN114584700A (en) | Focusing marking method, marking device and electronic equipment | |
US9860456B1 (en) | Bayer-clear image fusion for dual camera | |
Chen et al. | Hybrid saliency detection for images | |
Lasang et al. | CFA-based motion blur removal using long/short exposure pairs | |
Nagalakshmi et al. | Image acquisition, noise removal, edge detection methods in image processing using Matlab for prawn species identification | |
CN110706168A (en) | Image brightness adjusting method | |
TWI733286B (en) | Method for determining moire pattern, method for suppressing moire pattern and circuit system thereof | |
JP4089780B2 (en) | Color image processing method | |
CN107517367A (en) | Baeyer area image interpolation method, device, picture processing chip and storage device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
GD4A | Issue of patent certificate for granted invention patent |