201003032 九、發明說明: 【發明所屬之技術領域】 本發明涉及一種光源調節方法及其電腦系統,尤其涉 及一種輪廓光調節方法及其電腦系統。 【先前技術】 影像量測是目前精密量測領域中最廣泛使用的量測 方法,該方法不僅精度高,而且量測速度快。影像量測主 要用於零件或者部件的尺寸誤差和形位誤差的測量,對保 證產品品質起著重要的作用。 傳統的影像量測方法是採用工業光學鏡頭搭配高解 析度的電荷柄合裝置(Charged Coupled Device,CCD), 透過影像擷取卡取得待測工件或者部件的影像,該量測方 法對工件或者部件的很多精密量測都達到了很高的精度。 但是在以前的影像量測過程中,由於影像測量機台上 發光裝置所發出的影像光源會有差異,例如,強度、亮度 等都會不同,即使是相同種類的發光裝置(如:同一種規 格的光源裝置)發出的影像光源也會不同,在對CCD影像 進行處理時,就會對獲取的影像清晰度產生很大的偏差, 使得不同的機台對相同的工件進行影像測量時的重複性 差’從而導致精度不南。 在習知技術中,光源尤其是輪廓光的調節是透過測量 人員手動完成的,光源的強度受到個人主觀意識影響大, 容易造成測量結果的誤差大。同時,手動調節需要測量人 員將注意力高度集中在工件的影像與影像量測機台的光源 6 201003032 調節器上,有—定的勞動強度。 【發明内容】 馨於以上内容’有必要提供 電腦系統,可提高影像測量的重複性與精 員的勞動強度。 、货度’減輕測量人 一種輪廓轴節方法,該方法包括 一初始等級;獲取該初始等級下 _輪廓先調節到 像,並對該影像進行平均值過濾'和二的ΐ域的影 :調節過程中所涉及到的變數;根據上述變數叶; =廊光對應的等級;及根據所計算出的等級自: 时-種調節輪摩光的電腦系統,該電腦系統包括 理=元、計算單元和輪廓光調節單元。其中,影像=理單 =用於將影像量測機台的輪廓光調節到—初始等級, :調=光的區域的影像進行平均值過渡和二值化處 „十异皁凡用於設置輪廓光調節過程中所涉及到的變 ,並根據所述變數計算出所述影像對應的最佳輪廊光的 荨級。輪廓光調節單元用於根據計算單元所計算出的等級 自動調節輪摩光。 相較於習知技術,所述輪廓光調節方法及其電腦系 統’透過分析輪廓光與項影像的_,計算出最佳輪廊 光對應的等級’以自動調節輪扉光,提高影像測量的重複 性與精度,減輕測量人員的勞動強度。 【實施方式】 7 201003032 參閱圖1所示,係本發明輪廓光調節的電腦系統較佳 實施例之運行環境圖。該運行環境圖包括影像量測機台 1、被影像量測機台1量測的工件2及電腦3。所述影像量 測機台1可以是型號為“VMS”系列的影像量測儀,其包括 光源調節器10和電荷耦合裝置12。該電荷耦合裝置12用 於對工件2進行成像,而光源調節器10用於調節所述成像 時影像量測機台1所發出的輪廓光的亮度。電腦3内存儲 一輪廓光調節系統30用於控制光源調節器10,以進行自 動輪廓光調節。 在本實施例中,光源調節器10利用“0〜100”個等級來 調節輪廓光的強弱,根據工件2的顏色及工件2所放置的 背景顏色,每個等級對應一輪廓光的亮度。也就是說,不 同工件2或相同工件2放置在不同背景中,同一等級所示 意的輪廓光的亮度可能會不同。 另外,本實施例中的亮度可利用影像的灰度值來示 意。眾所週知,影像的灰度值範圍為0〜255。當光源調節 器10被調整到0等級時,工件2的影像必定為黑色,即影 像的灰度值為0,輪廓光的亮度低;而當光源調節器10被 調整到1.00等級時,工件2的影像為白色,即影像的灰度 值為255,輪廓光的亮度高。如圖2所示,係本發明不同 輪廓光下影像之灰度值變化曲線圖。 參閱圖3所示,係本發明輪廓光調節系統30之功能 單元圖。該輪廓光調節系統30為電腦程式,按照功能可劃 分為影像處理單元300、計算單元302和輪廓光調節單元 201003032 304,其功能可透過圖4所述之流程圖進行具體描述: 如圖4所示,係本發明輪廓光調節方法較佳實施例之 作業流程圖。 步驟S1,電荷耦合裝置12對工件2進行成像,用戶 在該工件2的影像中選定需調節工件2的輪廓光的區域, 該區域通常為邊界區域。 步驟S3,用戶透過手動調節光源調節器10,使得影 像量測機台1的輪廓光被調整到一初始等級。在本實施例 中,該初始等級不可能太低或太高,於該初始等級下的影 像一定為用戶可識別的影像,例如,其不可能為“0等級” 或“100等級”,本較佳實施例中的初始等級為“10等級’’。 步驟S5,影像處理單元300獲取初始等級下所選定區 域的影像,並對該影像進行平均值過濾和二值化處理,以 減少或消除影像雜訊的影響,改善影像的品質,使得工件 2的影像能夠感應輪廓光,也就是說,處理後的影像的灰 度值可隨著輪廓光的強弱而改變。其中,所述二值化處理 是指將一幅多個灰度級的影像轉化為只有兩個灰度級的影 像,以便於特徵的突出以及圖形的識別,處理後的影像為 黑白色,即灰度值為0和255。 步驟S7,計算單元302設置輪廓光調節過程中所涉及 到的變數,該變數包括最佳輪廓光對應的等級Vp的上臨 近等級Vm、下臨近等級Vn及當前等級Vc。 步驟S9,計算單元302根據上述變數利用迭代逼近法 計算出所述處理後的影像的最佳輪廓光所對應的等級Vp。 9 201003032 步驟Sll,輪廓光調節單元304根據計算單元302所 計算出的等級Vp自動調節輪廓光。 參閱圖5,係步驟S9中利用迭代逼近法計算等級Vp 之具體作業流程圖。 步驟S900’計算單元302初始化輪廓光調節過程中所 涉及到的各變數’即計算單元3〇2設置所述上臨近等級 Vm=100,下臨近等級Vn=l。 步驟S9〇2 ’將輪廓光的當前等級vc調節至201003032 IX. Description of the Invention: [Technical Field] The present invention relates to a light source adjusting method and a computer system thereof, and more particularly to a contour light adjusting method and a computer system thereof. [Prior Art] Image measurement is currently the most widely used measurement method in the field of precision measurement. This method is not only highly accurate, but also has a fast measurement speed. Image measurement is mainly used to measure the dimensional error and shape error of parts or components, which plays an important role in ensuring product quality. The conventional image measuring method uses an industrial optical lens and a high-resolution Charged Coupled Device (CCD) to obtain an image of a workpiece or a component to be tested through an image capturing card. The measuring method is for a workpiece or a component. Many precision measurements have achieved high accuracy. However, in the previous image measurement process, the image light source emitted by the light-emitting device on the image measuring machine may be different, for example, the intensity and brightness may be different, even for the same type of light-emitting device (eg, the same specification). The source of the image emitted by the light source device is also different. When the CCD image is processed, the image sharpness of the acquired image is greatly deviated, so that the repeatability of the image measurement by different machines for the same workpiece is poor. As a result, the accuracy is not south. In the prior art, the adjustment of the light source, especially the contour light, is manually performed by the measuring personnel. The intensity of the light source is greatly influenced by the subjective consciousness of the individual, and the error of the measurement result is easily caused. At the same time, the manual adjustment requires the measurement personnel to focus on the image of the workpiece and the light source of the image measuring machine. The 201003032 regulator has a certain labor intensity. [Summary of the Invention] In the above content, it is necessary to provide a computer system to improve the repeatability of image measurement and the labor intensity of the staff. , the degree of 'reducing a person's profile axis method, the method includes an initial level; obtaining the initial level _ contour is first adjusted to the image, and the image is average filtered 'and the second area of the image: adjustment The variables involved in the process; according to the above-mentioned variable leaves; = the level corresponding to the corridor light; and according to the calculated level from: the computer system for adjusting the wheel light, the computer system includes the rational element, the calculation unit And contour light adjustment unit. Among them, image=management order=is used to adjust the contour light of the image measuring machine to the initial level, and the image of the area of the light=lighting area is averaged and binarized. The variation involved in the light adjustment process, and calculating the level of the optimal corridor light corresponding to the image according to the variable. The contour light adjustment unit is configured to automatically adjust the wheel light according to the level calculated by the calculation unit. Compared with the prior art, the contour light adjustment method and the computer system thereof 'calculate the level corresponding to the optimal corridor light' by analyzing the contour light and the item image _ to automatically adjust the rim light to improve the image measurement. Repetitiveness and precision, reducing the labor intensity of the measuring personnel. [Embodiment] 7 201003032 Referring to Figure 1, the operating environment diagram of the preferred embodiment of the computer system for contour light adjustment of the present invention includes the image amount. The measuring machine 1, the workpiece 2 and the computer 3 measured by the image measuring machine 1. The image measuring machine 1 may be an image measuring instrument of the "VMS" series, which includes a light source adjuster 10 and The charge coupling device 12 is for imaging the workpiece 2, and the light source adjuster 10 is for adjusting the brightness of the contour light emitted by the image measuring machine 1 during the imaging. The computer 3 stores a contour. The light adjustment system 30 is used to control the light source adjuster 10 for automatic contour light adjustment. In the present embodiment, the light source adjuster 10 adjusts the intensity of the contour light by using "0 to 100" levels, according to the color of the workpiece 2 and The background color of the workpiece 2, each level corresponds to the brightness of a contour light. That is to say, different workpieces 2 or the same workpiece 2 are placed in different backgrounds, and the brightness of the contour light of the same level may be different. The brightness in this embodiment can be indicated by the gray value of the image. It is known that the gray value of the image ranges from 0 to 255. When the light source adjuster 10 is adjusted to the 0 level, the image of the workpiece 2 must be black, that is, The gray value of the image is 0, and the brightness of the contour light is low. When the light source adjuster 10 is adjusted to the 1.00 level, the image of the workpiece 2 is white, that is, the gray value of the image is 255, and the contour light is The brightness is high, as shown in Fig. 2, which is a graph of the gray value of the image under different contours of the present invention. Referring to Fig. 3, it is a functional unit diagram of the contour light adjustment system 30 of the present invention. For the computer program, it can be divided into image processing unit 300, calculation unit 302 and contour light adjustment unit 201003032 304 according to functions, and its function can be specifically described through the flowchart shown in FIG. 4: as shown in FIG. Step S1, the charge coupled device 12 images the workpiece 2, and the user selects an area in the image of the workpiece 2 to adjust the contour light of the workpiece 2, which is usually a boundary region. In step S3, the user adjusts the light source adjuster 10 manually so that the contour light of the image measuring machine 1 is adjusted to an initial level. In this embodiment, the initial level may not be too low or too high, and the image at the initial level must be a user-recognizable image, for example, it may not be “0 level” or “100 level”. The initial level in the preferred embodiment is “10 level”. In step S5, the image processing unit 300 acquires an image of the selected area under the initial level, and performs average filtering and binarization processing on the image to reduce or eliminate the image. The influence of the noise improves the quality of the image, so that the image of the workpiece 2 can sense the contour light, that is, the gray value of the processed image can be changed according to the intensity of the contour light. It refers to converting a plurality of grayscale images into images with only two gray levels to facilitate the highlighting of the features and the recognition of the graphics. The processed images are black and white, that is, the grayscale values are 0 and 255. In step S7, the calculation unit 302 sets a variable involved in the contour light adjustment process, which includes the upper adjacent level Vm, the lower adjacent level Vn, and the current level Vc of the level Vp corresponding to the optimum contour light. S9, the calculating unit 302 calculates the level Vp corresponding to the optimal contour light of the processed image by using an iterative approximation method according to the above variable. 9 201003032 Step S11, the contour light adjusting unit 304 calculates the level according to the calculating unit 302. Vp automatically adjusts the contour light. Referring to Fig. 5, it is a specific operation flow chart for calculating the level Vp by the iterative approximation method in step S9. Step S900' The calculation unit 302 initializes the variables involved in the contour light adjustment process, that is, the calculation unit 3 〇2 sets the upper adjacent level Vm=100, and the next adjacent level Vn=l. Step S9〇2 'Adjusts the current level vc of the contour light to
Vc=(Vm+Vn)/2,獲取該當前等級Vct的影像,並計算影 像的灰度值Gc。具體而言,計算單元3〇2獲取影像中每個 圖元的灰度,將所有圖元的灰度相加,然後除以圖元的總 個數戶^刺值就疋影像的灰度值以。在影像的數位化處 “象貝料是未壓縮的,其透過連續的記憶體區 域進仃保存,通常,影 進行存取,㈣,若=巾'^_元的灰度值可透過指針 影像資料的第-個圖’高為Η的8位元灰度影像的 的灰度值可以透過“pix^^㈣,則第(i,j)個圖元 讀取。 P el[j、+i]”或“*(Pixel+j*w+i)”進行 步驟S904,判斷灰疮 下影像的灰度值Gp"值GC是否小於所述最佳輪廓光 在本較佳實施例中,灰度值GP可取0〜255的中間值。 从 取125。 右Gc=Gp,則直接 驟S906,計算單元3〇 Λ步驟S912 ’若Gc<Gp,於步 即使得vn=Ve,當前等級Ve為下臨近等級’ < 進入步驟S910。 201003032 反之,若Gc>Gp,於步驟S908,計算單元302則以當 前等級Vc為上臨近等級,即使得Vm=Vc,然後進入步驟 S910。 步驟S910,計算單元302比較當前的上臨近等級Vm 與當前的下臨近等級Vn之差(Vm-Vn)是否小於一個最 佳預定值V0。本較佳實施例中,該最佳預定值V0等於2。 若(Vm-Vn) <V0,則於步驟S912,表明上述計算與 調節後的等級為最佳輪廓光所對應的等級Vp。 反之,若Vm-Vn>=V0,則返回步驟S902,以當前的 上臨近等級Vm與當前的下臨近等級Vn為計算條件調用 迭代逼近公式Vc=(Vm+Vn)/2重新進行計算與調節。例 如,若步驟S902中計算出的灰度值為Gel,則計算單元 302還需透過當前的上臨近等級Vm與當前的下臨近等級 Vn計算出Vc2,然後獲取等級為Vc2的影像的灰度值 Gc2,如圖2所示,重複執行步驟S904至步驟S912,直到 計算與調節出最佳輪廓光所對應的等級Vp為止。 本發明雖以較佳實施例揭露如上,然其並非用以限定 本發明。任何熟悉此項技藝之人士,在不脫離本發明之精 神及範圍内,當可做更動與潤飾,因此本發明之保護範圍 當視後附之申請專利範圍所界定者為準。 【圖式簡單說明】 圖1係本發明輪廓光調節的電腦系統較佳實施例之運 行環境圖。 圖2係本發明不同輪廓光下影像之灰度值變化曲線 Π 201003032 圖。 - 圖3係本發明輪廓光調節的電腦系統之功能單元圖。 . 圖4係本發明輪廓光調節方法較佳實施例之作業流程 圖。 圖5係本發明利用迭代逼近法計算最佳輪廓光對應的 等級之具體作業流程圖。 【主要元件符號說明】 影像量測機台 1 工件 2 電腦 3 光源調節器 10 電荷耦合裝置 12 輪廓光調節系統 30 影像處理單元 300 計算單元 302 輪廓光調節單元 304 12Vc = (Vm + Vn) / 2, an image of the current level Vct is acquired, and the gray value Gc of the image is calculated. Specifically, the calculating unit 3〇2 acquires the gradation of each primitive in the image, adds the gradations of all the primitives, and then divides the total number of primitives of the primitive to the gradation value of the image. To. In the digitization of the image, the image is uncompressed, and it is stored in a continuous memory area. Usually, the image is accessed. (4) If the gray value of the towel is passed through the pointer image The first picture of the data, the gray value of the 8-bit grayscale image with high Η can be read by "pix^^(4), then the (i, j)th element. P el[j, +i]" or "*(Pixel+j*w+i)" proceeds to step S904 to determine whether the gray value Gp" value GC of the image under the gray sore is smaller than the optimal contour light in the present In a preferred embodiment, the gray value GP may take an intermediate value of 0 to 255. From 125. Right Gc = Gp, then directly to step S906, the calculation unit 3 〇Λ step S912 'if Gc < Gp, in step vn = Ve, the current level Ve is the next adjacent level ' < Go to step S910. 201003032 Conversely, if Gc > Gp, in step S908, the calculation unit 302 takes the current level Vc as the upper adjacent level, that is, makes Vm = Vc, and then proceeds to the step S910. Step S910, the calculating unit 302 compares whether the difference (Vm-Vn) between the current upper adjacent level Vm and the current lower adjacent level Vn is less than a optimal predetermined value V0. In the preferred embodiment, the optimal predetermined value If Vm-Vn>=V0, then return to Step S902, calling the iterative approximation with the current upper neighboring level Vm and the current lower neighboring level Vn as a calculation condition Equation Vc=(Vm+Vn)/2 recalculates and adjusts. For example, if the gradation value calculated in step S902 is Gel, the calculation unit 302 also needs to pass the current upper adjacent level Vm and the current lower adjacent level. Vn calculates Vc2, and then acquires the gray value Gc2 of the image of the level Vc2, as shown in FIG. 2, and repeats steps S904 to S912 until the level Vp corresponding to the optimum contour light is calculated. The present invention is not limited to the scope of the present invention, and the scope of the present invention can be modified and retouched without departing from the spirit and scope of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS Figure 1 is a diagram showing the operating environment of a preferred embodiment of a computer system for contour light adjustment of the present invention. Figure 2 is an image of different contours of the present invention. The gray value variation curve Π 201003032 Fig. 3 is a functional unit diagram of the computer system for contour light adjustment of the present invention. Fig. 4 is a flow chart showing the operation of the preferred embodiment of the contour light adjustment method of the present invention. 5 is a specific operation flow chart of the present invention using the iterative approximation method to calculate the level corresponding to the best contour light. [Main component symbol description] Image measuring machine 1 Workpiece 2 Computer 3 Light source adjuster 10 Charge coupled device 12 Contour light adjusting system 30 image processing unit 300 computing unit 302 contour light adjusting unit 304 12