TW200825985A - System and method for image focus synthesizing - Google Patents

System and method for image focus synthesizing Download PDF

Info

Publication number
TW200825985A
TW200825985A TW95144678A TW95144678A TW200825985A TW 200825985 A TW200825985 A TW 200825985A TW 95144678 A TW95144678 A TW 95144678A TW 95144678 A TW95144678 A TW 95144678A TW 200825985 A TW200825985 A TW 200825985A
Authority
TW
Taiwan
Prior art keywords
image
point
value
focus
gray value
Prior art date
Application number
TW95144678A
Other languages
Chinese (zh)
Inventor
Chih-Kuang Chang
Xiao-Chao Sun
Zhong-Kui Yuan
Original Assignee
Hon Hai Prec Ind Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hon Hai Prec Ind Co Ltd filed Critical Hon Hai Prec Ind Co Ltd
Priority to TW95144678A priority Critical patent/TW200825985A/en
Publication of TW200825985A publication Critical patent/TW200825985A/en

Links

Abstract

A method for image focus synthesizing is disclosed. The method includes steps of: reading an image to be synthesized as a first image; reading another image to be synthesized as a second image; obtaining gray value p and grads g value of a point from the first image; obtaining gray value p0 and grads g0 value of one point corresponding with the point from the second image; modifying the gray value p in the first image into p0 and modifying the grads value g in the first image into g0 if the grads value g less than the grads value g0; keeping the gray value p and the grads value g in the first image if the grads value g not less than the grads value g0;return the step of obtaining gray value p and grads g value of a point from the first image until all the point have been synthesized in the first image. A system for image focus synthesizing is also disclosed.

Description

200825985 九、發明說明: 【發明所屬之技術領域】 本發明涉及一種影像焦點合成的系統及方法。 【先前技術】 在精密影像量測中,標準工業電荷耦合裝置(charge200825985 IX. Description of the Invention: [Technical Field] The present invention relates to a system and method for image focus synthesis. [Prior Art] Standard industrial charge coupled device (charge) in precision image measurement

Coupled Device,CCD)搭配特殊的鏡頭可以得到高分辨 的影像也就是高清晰圖像,且精度高,重複性好,且不會 以成變形,對被罝測工件影響小,所以在工廠及實驗室得 到廣泛應用。其中,其中圖像解析度是用於衡量圖像内資 料量多少的-個參數,通常表示成ppi(每英寸圖元)。包含 的資料越多,圖敎件的長度就越大,也能表現更豐富的 細節。圖元(Pixd)是由PicturM〇 m刪nt這兩個字母所 ,成的’是用來計算影像的—種單位,影像具有連續性的 ,淡階調’若把影似大數倍,會發現這些連續色調其實 2許夕色$相近的小方點所組成,這些小方點就是構成 衫像的最小單位“圖元”。 本/ΓΙ^於物鏡本身特點,其景深很小,—般不足0·1 二1:=方便自動對焦),較大景深的物鏡也不 的量測。〜 M ’無法滿足有斷差尺寸讀或物體 工 件 :ί 1機台上要測量有斷差尺寸的』 要使模;二地;、主:邛清晰’在模糊地方取點誤差較大, 要使_的地方b晰採點, 晰的地方就會模糊,得料k樣’原“ 張不同焦點的局部清晰的影 200825985 像。雖然^實補確採點, 很好,兩個點的位置關係。㈣姊不直硯’不能 【發明内2差尺寸的量測即是量測位於不同平面的物體。 該系、= = 供:種,焦點合成系統, 點合成程包括一個焦點合成程式,該焦 ,以另-張影像作爲第二影像:二 圖元點的第二影像中的相對應 =2:像中的對應點的梯度值,則更新第一謝圖 盘梯产ί又值與梯度值爲所述第二影像中對應點的灰度值 又值’如果第一影像中圖元點的梯度值不小於所述第 一衫像中的對應點的梯度值,則不改變第一影像中圖元點 的灰度值及梯度值;繼續讀取另一張影像爲第二影像並與 該第一影像進行焦點合併,直到所有的影像都合併完爲止、。 本發明提供一種影像焦點合成方法,該方法將電腦獲 取的手動影像量測機台調焦過程所截取的同一個有斷差工 件的多張影像合成爲一張全焦點影像,該方法包括步驟: 讀取一張影像作爲第一影像;讀取另一張影像作爲第二影 像;提取該第一影像中需合併點的灰度值Ρ及梯度值g ;提 取該第二影像中與第一影像中需合併點對應的點的灰度值 200825985 p0及梯度值g〇;如果梯度值g不小於梯度值g〇,則不改變第 一影像中該需合併點的灰度值P及梯度值g;如果梯度值g 小於梯度值go,則更新第一影像中該需合併點的灰度值p 爲P〇,梯度值g爲go ;返回提取第一影像中需合併點灰度值 P及梯度值g的步驟直到該第一影像中需合併點都提取完爲 止;重複上述讀取另一張影像作爲第二影像的步驟直到所 有的影像都合併完爲止。 本發明的焦點合成系統及方法能夠將具有斷差的同 一物體的不同焦點的影像合成起來,得到—張全焦點影 像,也即是任何地方都清晰的影像,使得量測人員可以在 該全焦點影像上精確採點,解決了手動量測機台在量測有 斷差物體時只有局部清晰的缺陷;而且本發明可以把該量 /貝J到的不同焦點的影像保存下來進行離線合成及量測採 點,實現了離線量測,減少量測機台的佔用時間。 【實施方式】 參閱圖1所示,爲本發明影像焦點合成系統較佳實施 例的硬體架構圖。該影像焦點合成系統包括-電腦主機! 及二放置待測工件5的機台6。其中,機台6的Z轴上還有用 於採集連續影像的電荷耦合裝置7 ( Charged Coupled Device,CCD) ’該電荷耦合裝置7裝有工業光學鏡頭,該 電荷輕合裝置7透職卫業光學鏡頭將制卫件5的影像聚 焦。所述電腦主機1裝有影像擷取卡10及焦點合成程式U。 其中電荷#合裝置7透過影像資料線與所述影像擷取卡⑺ 相連’該1赖合裝置7透過該影像資料線將從機台6獲取 200825985 將所獲取的待;:Γ卡10上;所述焦點合成程式11用於 系統還可以包=15§的不同焦點的影像進行焦點合成。該 -腦主機1相連,用H 置(未示出)’該顯示裝置與電 ^ ^ 用於棱供互動介面,使得量測人員透過該顯 W硯看焦點合成過程及結果,並可以透過該顯示裝置 主機1發出命令,以控制影像的獲取或焦點的合成。 浐4所_述機台6上還有一個又軸手動搖桿2,一個γ轴手動搖 (^及個2軸手動搖桿3。其中X軸手動搖桿2控制機台6 右移動,Y軸手動搖桿4控制機台6前後移動,機台上的 Uj工件5隨控制機台6的移動而隨之移冑;ζ轴手動搖桿3 控制機台6在Z軸方向上下移動,且機台6在2軸方向上下移 動的同時帶動電荷輕合裝置7和工業光學鏡頭進行移動以 對待測卫件5聚焦,得到待測工件5的影像。 在待測工件5有斷差的情況下,搖動X軸手動搖桿2和Y 抽手動搖杯3移動機台6使待測工件$處於光學鏡頭下,再透 搖動夕該Z轴手動搖桿3進行調焦,在調焦過程中得到待測 =5夕張不同焦點的影像,由於待測工件$存在斷差,導 =每張#像只有在同—水平面上的部分位置清晰,參照 二圖6、圖7及圖8所示。將該多張不同焦點的影像透過 ^主機1中的焦點合成程式11,得到-張全部清晰的全焦 你:像如圖9所不。其中,在調焦時截取工件5不同焦點影 、過程中’該工件5的水平位置是固定的;如果在此過程 丄需要水平方向移動工件5,則需要記錄下該工件5 則的X、Y座標,在重新繼續對該工件進行調焦以戴取不 200825985 同焦點影像時需要將該工件恢復到原來的χ、γ座標位置。 該種調焦過程所獲取到的有斷差物體的不同焦點影 像的狀況還包括,如利用一個有手動調焦功能的相機拍攝 一個固定在某處的有斷差的物體,或拍攝遠處的景觀等, 其中該手動調焦功能的相機要用三角架或其他固定裝置固 定在一個位置,在該位置的同一個角度拍攝該有斷差的物 體或景觀。其中在調焦過程中所截取到的多張影像也可作 爲本發明中焦點合成的物件。 在本發明中,上述在調焦過程中所截取的多張不同焦 點的影像是以點陣圖的格式進行存儲的。每張影像可以單 獨存儲在一個點陣圖文件中。所述的點陣圖文件通常都包 括點陣圖文件頭及點陣圖資料。其中點陣圖文件頭保存點 陣圖文件的識別資訊,包括文件類型、文件大小。點陣圖 資料是圖像資料位元組陣列。圖像的每一掃描行由表示圖 像圖元的連續的位元組組成,每一行的位元組數取決於圖 像的顏色數目和用圖元表示的圖像寬度。掃描行是由底向 上存儲的,這就是說,陣列中的第一個位元組表示點陣圖 左下角的圖元灰度值,而最後一個位元組表示點陣圖右上 角的圖元灰度值,也即圖元的灰度值是從下到上,從左到 右保存的。 在本發明中,因爲該所截取的多張影像是在同一台量 測機台上量測的同一個工件的影像,只不過焦點不同,其 所存儲的格式都是點陣圖文件,因此該多張影像的點陣圖 文件頭是相同的,所不同的只是因爲每張影像的焦點不 11 200825985 同’所以每張影像的點陵 产值有所·。= 資料中所存儲的每個圖元的灰 :中,不但佔用存儲3張獨存儲在-個點陣圖文 較多時間在讀取上。因丄:=進行焦點合併時會花費 縮存儲在-個文件中,在4= ’將該多張影像壓 ==的點陣圖資料’其中該多張影像共用該同- ==頭’減少了在磁片上的存儲空間且在進行焦 點^併時也減少了影像的讀取時間。 —占Γ且=所截取的影像是脫離量測機台在電腦主機1中 完成焦點合併的,其亦眘祖7私a曰 的佔用時間。 實見了離線1測,減少了量測機台 f關2所爲本發明景彡像焦點合成方法較佳實施 例的流程圖。 步驟S32 ’讀取-個f彡像壓敎件,鄉像壓縮文件 包括多張不同焦點影像文件,並獲取其中的影像張數N。 在該步驟中’所述的多張不同焦點影像是同—待測工件的 影像,該多張影像是在精密影像測量—個有斷差的工件的 過程中,透過搖動Z軸手動搖桿3控制機台6、電荷柄合裝 置7和工業學光鏡頭在Z軸方向上下移動以對待測工件5聚 焦的調焦過程中所截取的不同焦點的影像。該所載取的影 像是以點陣圖格式進行存儲的。 步驟S34,判斷該所獲取的影像張數N是否小於丄,如 果N小於1,則結束該流程。 如果N不小於1,則於步驟S36從該影像壓縮文件中讀 12 200825985 取一張影像的全部圖元資料,該圖元資料包括該影像中每 個圖元點的灰度值。將該所讀取的影像作爲第一影像bmp。 步驟S40,再從上述影像壓縮文件中讀取另一張影像 的圖元資料,該圖元資料同樣包括該影像中每個圖元點的 灰度值。將該所讀取的另一張影像作爲第二影像bmp〇。 步驟S42,將該張影像bmpO與第一影像bmp進行焦點 合併,該焦點合併後的影像仍然作爲第一影像bmp。 步驟S44,判斷該所讀取的第二影像是否是最後一張 影像,如果不是最後一張影像,則返回步驟S4〇。 如果該所讀取的影像是最後一張影像,則於步驟 S46,對該合併後的第二影像1)1111)進行過濾去毛邊,在該步 驟中’所用的方法爲平均法或者中值法去毛邊。 步驟S48,最後返回合併後的第二影像bmp。 參閱圖3所不,是圖2中步驟S42進行焦點合併的較佳 實施例的流程圖。首先,步驟S42〇,提取第一影像1)1^的 一個圖兀點的灰度值p及根據其灰度值計算出來的該圖元 點的梯度值g。 步驟S422,再提取要合併的第二影像bmp〇中的要合併 點的灰度值p0及梯度值g〇。其中在第二影像1?1^〇要合併的 點與第一影像bmp中所提取的點是——對應的。提取圖元 點灰度值的順序是以其在影像巾的點陣圖資料巾的存儲順 序進行提取的。 步驟S424,判斷第-影像bmp中該點梯度值找否小於 要第二影像bmpO的要合併點梯度值g〇。 13 200825985 步驟S426,如果第一影像bmp中該點梯度值於第二 影像bmpO的要合併點梯度值g〇,則設置第一影像bmp中該 點灰度值爲p0,該點梯度值爲g〇。 步驟S430,判斷在第一影像bmp中該點是否是最後一 點,如果是則結束流程。如果不是,則進入步驟S432。 在步驟S424中,如果第一影像bmp中該點梯度值g不小 於要第二影像bmpO的要合併點梯度值g0,則不進行焦點合 併,而進入步驟S432。 在步驟S432中,提取第一影像bmp中的下一點的灰产 值P及梯度值g,然後進入步驟S422。 參閱圖4所示,是本發明影像焦點合成方法較佳實施 例的過滤去毛邊的示意圖。如圖所示,平均法和中值、去去 毛邊主要是利用圖像在較小區域灰度相關這個特性,用週 圍點的平均灰度值代替該點的灰度值(平均法),或用週圍 點的中間灰度值代替該點的灰度值(中值法)。這兩種方法 可以去掉-些孤立的圖元點,同時又很好的 々 有的輪賴性。 冢原 當處理的點在内部時,用週圍8個點和自身共9個點來 處理’圖示爲正在處理的點68。以下用平均法和、法八 別進行處理如下: '刀 平均法:68new= (57,58,59,67,68,的,7 79) /9 ; ’ 中值法則對57 ’ 58,59,67,68,69,77,78,79、古 9個點的灰度值進行排序,取排序後的第4個灰度值(從ζ 200825985 開始計數)作爲新的值68new,當處理的點爲邊界時,〇 對在内部的點參與計算。 β 參閱圖5、圖6、圖7、圖8及圖9所示,是對焦點人、 截取的四張圖片進行合成說明,該影像來自一個有5功1成 右斷差的接插件。其中,圖5、圖6、圖7及圖8是在使= 台6對該接插件進行調焦過程中截取到的四張圖片,由於、 頭原因,景深較小,導致都只有在同—水平面上的部分鏡 置清晰,透過使用本發明的焦點合成處理,得到如圖9位 的全部清晰的全焦點圖像。 不 本發明不僅適用於精密量測工業的手動量測機4 1測有斷差的同―卫件時的難過程中職取的不同焦 影像的合成,而且也適用於其他情況,如可以調焦的相、播點 固定相機的拍攝位置及所拍攝物體的位置,對該物體一 拍攝所得到不同焦點的圖片。 行 本發明雖以較佳實施例揭露如上,然其並非用以限^ 士發明。任何熟悉此項技藝者,在不脫離本發明之精神弋 範圍内’當可做更動與潤飾,因此本發明之保護範 後附之申請專利範圍所界定者為準。 田 【圖式簡單說明】 圖1爲本發明影像焦點合成系統難實施例的硬 構圖。 /' 圖。圖2爲本發明影像㈣合成方法較佳實施例的流程 θ爲圖2 _步驟S42 it行焦點合併的較佳實施例的 15 200825985 流程圖。 圖4爲本發明影像焦點合成方法較佳實施例的過濾去 毛邊的不意圖。 圖5、圖6、圖7及圖8爲本發明中同一工件的部分 位置清晰的不同焦點的影像。 圖9爲上述圖5至圖8合成的一張清晰的全焦點影像。 【主要元件符號說明】 電腦主機 1 影像擷取卡 10 焦點合成程式 11 X軸手動搖桿 2 Y軸手動搖桿 3 Z軸手動搖桿 4 待測工件 5 機台 6 電荷耦合裝置 7 16Coupled Device, CCD) with a special lens can get high-resolution images, that is, high-definition images, high precision, good repeatability, and will not be deformed, have little effect on the workpiece being tested, so in the factory and experiment The room is widely used. Among them, the image resolution is a parameter used to measure the amount of information in the image, usually expressed as ppi (pixels per inch). The more data you have, the larger the length of the image and the richer the details. The picture element (Pixd) is deleted by the two letters of PicturM〇m, which is the unit used to calculate the image. The image has continuity, and the light level tone is like a large number of times. It is found that these continuous tones are actually composed of two small square points that are similar to each other. These small square points are the smallest unit "picture elements" that make up the shirt image. This / ΓΙ ^ in the objective lens itself, its depth of field is very small, - generally less than 0 · 1 2: = convenient auto focus), the objective lens of a large depth of field is not measured. ~ M 'can not meet the difference in size reading or object workpiece: ί 1 on the machine to measure the size of the gap 』 to make the mold; two places;, the main: 邛 clear 'in the fuzzy place to take a large point error, to Let the _ place b clear point, the clear place will be blurred, get the k-like 'original' different local focus of the shadow of the 200825985 image. Although the actual compensation point, very good, the location of the two points Relationship. (4) 姊不直砚 'Can't [Invented 2 difference size measurement is to measure objects located in different planes. The system, = = supply: species, focus synthesis system, point synthesis process includes a focus synthesis program, The focal point, the other image as the second image: the corresponding image in the second image of the two pixel points = 2: the gradient value of the corresponding point in the image, then the first Xie map ladder is updated and the value is The gradient value is a value of the gray value of the corresponding point in the second image. If the gradient value of the primitive point in the first image is not smaller than the gradient value of the corresponding point in the first shirt image, the first value is not changed. Gray value and gradient value of the primitive point in the image; continue to read another image as the second image Combining with the first image until all the images are merged. The present invention provides an image focus synthesis method, which intercepts the same one of the manual image measuring machine's focusing process acquired by the computer. Combining multiple images of the difference workpiece into one all-focus image, the method includes the steps of: reading one image as the first image; reading the other image as the second image; and extracting the merged point in the first image a gray value Ρ and a gradient value g; extracting a gray value 200825985 p0 and a gradient value g〇 of a point corresponding to a point to be merged in the first image in the second image; if the gradient value g is not smaller than the gradient value g〇, The gray value P and the gradient value g of the merged point in the first image are not changed; if the gradient value g is smaller than the gradient value go, the gray value p of the merged point in the first image is updated to be P〇, the gradient value g is go; returning the step of extracting the gray value P and the gradient value g of the first image to be merged until the merged points in the first image are all extracted; repeating the reading of the other image as the second image Steps until all The image synthesizing system and method of the present invention can synthesize images of different focal points of the same object with a gap to obtain an all-in-focus image, that is, an image that is clear everywhere, so that the measurement is performed. The person can accurately take points on the all-focus image, and solve the problem that the manual measuring machine only has local clear defects when measuring the object with the gap; and the invention can save the image of the different focus of the quantity/before Downstream synthesis and measurement of the acquisition point, the offline measurement is performed, and the occupation time of the measurement machine is reduced. Embodiments Referring to FIG. 1 , a hardware architecture of a preferred embodiment of the image focus synthesis system of the present invention is shown. The image focus synthesis system includes a computer main unit and two machines 6 on which the workpiece 5 to be tested is placed. The Z-axis of the machine 6 also has a charge coupled device (CCD) for collecting continuous images. The charge-coupled device 7 is equipped with an industrial optical lens that focuses the image of the guard 5 through the occupational optical lens. The computer host 1 is equipped with an image capture card 10 and a focus synthesis program U. The charge device 100 is connected to the image capture card (7) through the image data line. The first device 7 can obtain the acquired device from the machine 6 through the image data line; The focus synthesis program 11 is used for the system to perform focus synthesis on images of different focus groups of 15=. The brain host 1 is connected, and the display device and the electric device are used for the edge interaction interface through the H (not shown), so that the measurement personnel can see the focus synthesis process and the result through the display, and can pass through the The display device host 1 issues a command to control image acquisition or focus synthesis.浐4 _ said machine 6 also has a shaft manual rocker 2, a γ axis manual rocking (^ and a 2-axis manual rocker 3. Among them X-axis manual rocker 2 control machine 6 right movement, Y The shaft manual rocker 4 controls the machine table 6 to move back and forth, and the Uj workpiece 5 on the machine table moves with the movement of the control machine table 6; the cymbal manual rocker 3 controls the machine table 6 to move up and down in the Z-axis direction, and When the machine 6 moves up and down in the 2-axis direction, the charge coupling device 7 and the industrial optical lens are moved to focus on the measuring member 5 to obtain an image of the workpiece 5 to be tested. In the case where the workpiece 5 to be tested has a gap. , shaking the X-axis manual rocker 2 and Y pumping the manual shaker 3 moving the machine table 6 so that the workpiece to be tested is under the optical lens, and then the Z-axis manual rocker 3 is used for focusing, which is obtained during the focusing process. For the image of the different focus to be measured = 5, due to the difference of the workpiece to be tested, the position of each of the # images is only clear on the same-horizontal plane, as shown in Figure 6, Figure 7, and Figure 8. The image of the plurality of different focal points is transmitted through the focus synthesis program 11 in the host 1 to obtain a full-focus full focus. No. Among them, the different focus shadows of the workpiece 5 are intercepted during the focusing, and the horizontal position of the workpiece 5 is fixed during the process; if the workpiece 5 needs to be moved horizontally in this process, the X of the workpiece 5 needs to be recorded. , Y coordinate, in the re-continuation of the focus of the workpiece to wear the same focus image of the 200825985, the workpiece needs to be restored to the original χ, γ coordinate position. The focus of the focus process obtained by the offset object The conditions of different focus images include, for example, using a camera with a manual focus function to capture a fixed object fixed somewhere, or shooting a distant landscape, etc., where the manual focus function camera uses a triangle The frame or other fixing device is fixed at a position, and the object or landscape with the gap is photographed at the same angle of the position. The plurality of images intercepted during the focusing process can also be used as the object of the focus synthesis in the present invention. In the present invention, the images of the plurality of different focal points intercepted during the focusing process are stored in a bitmap format. Each image can be stored separately. In a bitmap file, the bitmap file usually includes a bitmap file header and a bitmap image, wherein the bitmap file header stores identification information of the bitmap file, including file type and file size. The bitmap data is an array of image data bytes. Each scan line of the image is composed of consecutive bytes representing image primitives, and the number of bytes per line depends on the number of colors of the image and The width of the image represented by the primitive. The scan line is stored from the bottom up, that is, the first byte in the array represents the gray value of the primitive in the lower left corner of the bitmap, and the last byte represents the last byte. The gray value of the primitive in the upper right corner of the bitmap, that is, the gray value of the primitive is saved from bottom to top and from left to right. In the present invention, since the plurality of images captured are in the same station The image of the same workpiece measured on the measuring machine is different, but the focus is different. The format of the bitmap image file is the same, so the difference is only the same. Because the focus of each image is not 11 200825985 ‘So every image has a point production value. = Gray of each primitive stored in the data: not only takes up 3 copies of storage, but also stores it in a dot matrix.丄:= When the focus merge is performed, it will be stored in a file, and in the case of 4='the bitmap image data of the multiple images === the multiple images share the same -==head' reduction The storage space on the magnetic disk and the reading time of the image are also reduced when the focus is performed. —Occupy and = the captured image is taken out of the measurement machine in the computer host 1 to complete the focus merge, which is also the occupation time of the cautious 7 private a曰. In fact, the offline 1 measurement is reduced, and the measurement machine is reduced. The reference is a flow chart of a preferred embodiment of the focus image synthesis method of the present invention. In step S32, the image compression device is read, and the compressed image file includes a plurality of different focus image files, and the number N of images is obtained. In this step, the plurality of different focus images are the same as the image of the workpiece to be tested, and the plurality of images are in the process of measuring the workpiece with a fault in the precision image, by shaking the Z-axis manual rocker 3 The control machine 6, the charge shank device 7, and the industrial light lens are moved up and down in the Z-axis direction to image different focuss captured during the focusing process of the workpiece 5 to be measured. The captured image is stored in a bitmap format. In step S34, it is determined whether the number N of acquired images is less than 丄, and if N is less than 1, the flow is ended. If N is not less than 1, then in step S36, read from the image compression file 12 200825985 to take all the image data of one image, the primitive data includes the gray value of each primitive point in the image. The read image is taken as the first image bmp. In step S40, the image data of another image is read from the image compression file, and the primitive data also includes the gray value of each primitive point in the image. The other image read is taken as the second image bmp〇. In step S42, the image bmpO is combined with the first image bmp, and the combined image is still used as the first image bmp. In step S44, it is determined whether the read second image is the last image, and if it is not the last image, the process returns to step S4. If the image to be read is the last image, then in step S46, the merged second image 1) 1111) is filtered to remove the burrs, and in this step, the method used is the averaging method or the median method. Go to the raw edge. In step S48, the merged second image bmp is finally returned. Referring to Figure 3, there is shown a flow chart of a preferred embodiment of focus combining in step S42 of Figure 2. First, in step S42, the gradation value p of a map point of the first image 1) 1 and the gradient value g of the primitive point calculated based on the gradation value are extracted. Step S422, extracting the gray value p0 and the gradient value g〇 of the point to be merged in the second image bmp〇 to be merged. The point to be merged in the second image 1?1^ is corresponding to the point extracted in the first image bmp. The order in which the gray values of the pixels are extracted is extracted in the order in which they are stored in the bitmap of the image towel. In step S424, it is determined whether the gradient value of the point in the first image bmp is smaller than the gradient value g〇 of the point to be merged of the second image bmpO. 13 200825985 Step S426, if the gradient value of the point in the first image bmp is the gradient value g〇 of the second image bmpO to be merged, the gray value of the point in the first image bmp is set to p0, and the gradient value of the point is g Hey. In step S430, it is determined whether the point is the last point in the first image bmp, and if so, the flow is ended. If not, the process proceeds to step S432. In step S424, if the point gradient value g in the first image bmp is not smaller than the point to merge value g0 to be merged of the second image bmp0, the focus combination is not performed, and the process proceeds to step S432. In step S432, the gray production value P and the gradient value g of the next point in the first image bmp are extracted, and the flow proceeds to step S422. Referring to Fig. 4, there is shown a schematic diagram of filtering deburring of a preferred embodiment of the image focus synthesizing method of the present invention. As shown in the figure, the averaging method and the median and deburring are mainly based on the fact that the image is gray-scaled in a small area, and the gray value of the point is replaced by the average gray value of the surrounding points (average method), or The gray value of the point is replaced by the intermediate gray value of the surrounding point (median method). These two methods can remove some isolated primitive points, while at the same time being very good. When the point of processing is internal, it is treated with 9 points around it and 9 points in total. The following is handled by the averaging method and the law eight: "Knife average method: 68new = (57,58,59,67,68, of, 7 79) /9; 'The median rule is 57 ' 58,59, 67,68,69,77,78,79, the gray value of the ancient 9 points is sorted, and the 4th gray value after sorting (counting from 25200825985) is taken as the new value 68new, when the point is processed When it is a boundary, 参与 participates in the calculation at the point inside. β Referring to Fig. 5, Fig. 6, Fig. 7, Fig. 8 and Fig. 9, the focus and the four pictures taken are combined, and the image is from a connector having 5 functions and 1 right margin. Among them, FIG. 5, FIG. 6, FIG. 7 and FIG. 8 are the four pictures intercepted during the focusing process of the connector 6 by the table 6, because of the head cause, the depth of field is small, so that only the same - The partial mirrors on the horizontal plane are clear, and by using the focus synthesis processing of the present invention, all clear all-focus images as shown in Fig. 9 are obtained. The invention is not only applicable to the manual measuring machine of the precision measuring industry, but also the synthesis of different focal images taken during the difficult process of measuring the same security member, and is also applicable to other situations, such as The phase of the focus, the broadcast point fix the position of the camera and the position of the object being photographed, and the picture of the different focus is obtained by shooting the object. Although the present invention has been disclosed above in the preferred embodiments, it is not intended to limit the invention. Any person skilled in the art will be able to make changes and refinements without departing from the spirit and scope of the invention, and the scope of the invention as defined in the appended claims is intended to be limited. [Simplified illustration of the drawings] Fig. 1 is a hard view of a difficult embodiment of the image focus synthesis system of the present invention. /' Figure. 2 is a flow chart of a preferred embodiment of the image (four) synthesis method of the present invention. FIG. 2 is a flow chart of the preferred embodiment of FIG. 2 - step S42. 4 is a schematic diagram of filtering the burrs of the preferred embodiment of the image focus synthesis method of the present invention. Fig. 5, Fig. 6, Fig. 7, and Fig. 8 are images of different focal points of the same workpiece in the present invention with clear positions. Fig. 9 is a clear all-focus image synthesized by the above Figs. 5 to 8. [Main component symbol description] Computer main unit 1 Image capture card 10 Focus synthesis program 11 X-axis manual joystick 2 Y-axis manual joystick 3 Z-axis manual joystick 4 Workpiece to be tested 5 Machine 6 Charge-coupled device 7 16

Claims (1)

200825985 十、申請專利範圍 1、 一種影像焦點合成系統,該系統包括一台電腦及一台手 動影像量測機台,所述電腦獲取該手動影像量測機台調 焦過程中所截取的同一個有斷差工件的多張影像,該電 腦包括一個焦點合成程式,該焦點合成程式用於:讀取 該不同焦點的多張影像,以其中一張影像作爲第一影 像,以另一張影像作爲第二影像,判斷第一影像中圖元 點的梯度值是否小於第二影像中的相對應圖元點的梯 度值;如果第一影像中的圖元點的梯度值小於所述第二 影像中的對應點的梯度值,則更新第一影像中圖元點的 灰度值與梯度值爲所述第二影像中對應點的灰度值與 梯度值;如果第一影像中圖元點的梯度值不小於所述第 二影像中的對應點的梯度值,則不改變第一影像中圖元 點的灰度值及梯度值;繼續讀取下一張影像爲第二影像 並與該第一影像進行焦點合併,直到所有的影像都合併 完爲止。 2、 如申請專利範圍第1項所述的影像焦點合成系統,所述 電腦安裝有影像擷取卡;所述手動影像量測機台在調焦 過程中所截取的該工件的多張不同焦點影像透過影像 資料線傳送到該影像擷取卡。 3、 如申請專利範圍第1項所述的影像焦點合成系統,所述 工件在調焦過程中的水平位置是固定的。 4、 如申請專利範圍第1項所述的影像焦點合成系統,所述 每一張影像單獨存儲爲點陣圖格式的文件。 17 200825985 5 ηΓ旦申H專利範圍第1項所述的影像焦點合成系統,該多 張衫像存儲爲— ^ ^ ^场一個點陣圖格式的壓縮文件,在該壓縮文 件中,每張影你U Μ士 〜像共用一個點陣圖文件頭,且各自擁有— 個存儲圖凡^1;允& 匕點灰度值的點陣圖資料。 6、如申請專利餘 點人成ήΛ圍弟5項所述的影像焦點合成系統,該焦 ^ 王式母次讀取一張影像的全部點陣圖資料,包括 該張影像的戶斤古m ^ 有圖元點的灰度值,並根據灰度值計算出 母個圖元點的梯度值。 出 5成方法,該方法將電腦獲取的手動 量測機台調隹讲#丄 、 ^ “、、k長中所截取的同一個有斷差工件的多 象5成爲一張全焦點影像,該方法包括步驟: f取一張影像作爲第-影像; :取另:張影像作爲第二影像; ^取該第一影像中需合併點的灰度值p及梯度值g ; 提取該第二影像中與第一影像中需合併點對應的點的 灰度值p0及梯度值g〇; 如果梯度g不小於梯度g0,則不改變第一影像中該需合 併點的灰度值P及梯度值g ; 如果梯度g值小於梯度值g〇,則更新第一影像中該需合 併點的灰度值P爲p〇,梯度值g爲g〇 ; 返回提取第一影像中需合併點灰度值p及梯度值§的步 驟直到該第一影像中需合併點都提取完爲止; 重複上述讀取另-舞像作爲第二縣的步驟直到所 有的影像都合併完爲止。 18 200825985 8、 如申請專利範圍第7項所述的影像焦點合成方法,該方 法還包括步驟:對該合併之後的第一影像過濾去毛邊。 9、 如申請專利範圍第7項所述的影像焦點合成方法,所述 工件在調焦過程中的水平位置是固定的。 10、 如申請專利範圍第7項所述的影像焦點合成方法,該每 張影像單獨存儲爲點陣圖格式的文件。 11、 如申請專利範圍第7項所述的影像焦點合成方法,該多 張影像存儲爲一個點陣圖格式的壓縮文件,在該壓縮文 件中,每一張影像共用一個點陣圖文件頭,且各自擁有 一個存儲圖元點灰度值的點陣圖資料。 12、 如申請專利範圍第11項所述的影像焦點合成方法,所 述讀取一張影像是指一次讀取一張影像的全部點陣圖 資料,包括該張影像的所有圖元點的灰度值,並根據灰 度值計算出每個圖元點的梯度值。 19200825985 X. Patent application scope 1. An image focus synthesis system, the system includes a computer and a manual image measuring machine, and the computer acquires the same one taken during the focusing process of the manual image measuring machine There are multiple images of the workpiece with a difference, the computer includes a focus synthesis program, and the focus synthesis program is used to: read multiple images of the different focus, one image as the first image and the other image as the other image a second image, determining whether a gradient value of a primitive point in the first image is smaller than a gradient value of a corresponding primitive point in the second image; if a gradient value of the primitive point in the first image is smaller than the second image The gradient value of the corresponding point is updated, and the gray value and the gradient value of the primitive point in the first image are updated as the gray value and the gradient value of the corresponding point in the second image; if the gradient of the primitive point in the first image If the value is not less than the gradient value of the corresponding point in the second image, the gray value and the gradient value of the primitive point in the first image are not changed; and the next image is continuously read as the second image and the first image Shadow Like focus merge until all images have been merged. 2. The image focus synthesis system according to claim 1, wherein the computer is equipped with an image capture card; and the plurality of different focus of the workpiece captured by the manual image measurement machine during the focusing process The image is transmitted to the image capture card through the image data line. 3. The image focus synthesis system of claim 1, wherein the horizontal position of the workpiece during the focusing process is fixed. 4. The image focus synthesis system of claim 1, wherein each of the images is separately stored as a bitmap format file. 17 200825985 5 ηΓ旦申H Patent scope focus synthesis system according to item 1, wherein the plurality of shirt images are stored as a compression file in a bitmap format of the ^^^ field, in the compressed file, each shadow You U gentleman ~ like to share a bitmap file header, and each has a - stored map where ^1; allow & 匕 point gray value of the bitmap data. 6. If the image focus synthesis system described in the five patents of the person who has applied for the patent remains, the coke king will read all the bitmap data of one image, including the image of the household. ^ There is a gray value of the primitive point, and the gradient value of the parent pixel point is calculated according to the gray value. The method of 50% is to make the multi-image 5 of the same workpiece with a gap intercepted by the manual measurement machine obtained by the computer to become an all-focus image. The method comprises the steps of: f taking an image as the first image; taking another: the image as the second image; taking the gray value p and the gradient value g of the point to be merged in the first image; extracting the second image The gray value p0 and the gradient value g〇 of the point corresponding to the point to be merged in the first image; if the gradient g is not smaller than the gradient g0, the gray value P and the gradient value of the merged point in the first image are not changed. g; if the gradient g value is smaller than the gradient value g〇, updating the gray value P of the merged point in the first image is p〇, and the gradient value g is g〇; returning the gray value of the merged point in the first image The steps of p and the gradient value § until the merged points in the first image are extracted; repeat the above steps of reading the other dance image as the second county until all the images are merged. 18 200825985 8. If applying Image focus synthesis method according to item 7 of the patent scope, the party The method further includes the step of: filtering the first image after the merging to remove the burr. 9. The image focus synthesis method according to claim 7, wherein the horizontal position of the workpiece during the focusing process is fixed. The image focus synthesis method according to claim 7, wherein each image is separately stored as a file in a bitmap format. 11. The image focus synthesis method according to claim 7 of the patent application scope, the plurality of images Stored as a compressed file in a bitmap format, in which each image shares a bitmap file header and each has a bitmap data that stores the gray value of the primitive point. The method for synthesizing an image focus according to claim 11, wherein the reading one image refers to reading all the bitmap data of one image at a time, including the gray value of all the primitive points of the image, and The gradient value of each primitive point is calculated based on the gray value.
TW95144678A 2006-12-01 2006-12-01 System and method for image focus synthesizing TW200825985A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW95144678A TW200825985A (en) 2006-12-01 2006-12-01 System and method for image focus synthesizing

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW95144678A TW200825985A (en) 2006-12-01 2006-12-01 System and method for image focus synthesizing

Publications (1)

Publication Number Publication Date
TW200825985A true TW200825985A (en) 2008-06-16

Family

ID=44772243

Family Applications (1)

Application Number Title Priority Date Filing Date
TW95144678A TW200825985A (en) 2006-12-01 2006-12-01 System and method for image focus synthesizing

Country Status (1)

Country Link
TW (1) TW200825985A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI557689B (en) * 2013-04-23 2016-11-11 鴻海精密工業股份有限公司 System and method of computing focuses

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI557689B (en) * 2013-04-23 2016-11-11 鴻海精密工業股份有限公司 System and method of computing focuses

Similar Documents

Publication Publication Date Title
JP4363151B2 (en) Imaging apparatus, image processing method thereof, and program
US9773302B2 (en) Three-dimensional object model tagging
CN1734500B (en) Image processing method and system by using robust bayesian estimation based on mode
AU2008215908B2 (en) Banana codec
JP6701118B2 (en) Image processing apparatus and image processing method
JP4556813B2 (en) Image processing apparatus and program
JP4065488B2 (en) 3D image generation apparatus, 3D image generation method, and storage medium
KR20090009114A (en) Method for constructing a composite image
JP2008059081A (en) Image processing apparatus, image processing method and computer program
JP2007201948A (en) Imaging apparatus, image processing method and program
DE112011103011T5 (en) Stereoscopic (3D) panorama creation on portable devices
JP2005267457A (en) Image processing device, imaging apparatus, image processing method and program
JP5984493B2 (en) Image processing apparatus, image processing method, imaging apparatus, and program
JP2006074512A (en) Photographing device, and image processing method, and program for photographing device
JP2007074578A (en) Image processor, photography instrument, and program
JP2007288731A (en) Real-time panoramic image composing method and apparatus therefor
CN101191719A (en) Image focal point synthetic system and method
JP5573520B2 (en) Image generation apparatus, imaging apparatus, and image generation program
JP2005275447A (en) Image processing device, image processing method and program
KR20200046789A (en) Method and apparatus for generating 3-dimensional data of moving object
JP4363154B2 (en) Imaging apparatus, image processing method thereof, and program
TW200825985A (en) System and method for image focus synthesizing
JP2006101025A (en) Photographic apparatus, and image processing method and program thereof
JP2005269449A (en) Image processor, image processing method and program
JP3241243B2 (en) Panorama image composition system and panorama image composition method