4 A5 43 5 Λ7 經濟部中央標準局員工消费合作社印製 五、發明説明(1 ) 本發明係一種數位影像處理方法,乃有關於利用電腦 來處理由數位相機或其它輸入設備所產生之數位化影像之 方法。 按,利用電腦來處理由數位相機或其它輸入設備所產 5生之數位化影像,已日益普及,傳統之底片修片作業也將 由電腦軟、硬體提供之相關類似功能取代之,而在底片修 片中尤以青春痘之去除及駿紋淡化爲最常見之作業,目前 數位影像處理軟體所提供之方式不外下列二種: Ο在同一數位影像之中,指定影像中特定位置之顏色爲 10 參考色,然後指定缺陷之範圍,而在此指定之範圍內 之數位資料,將由指定之數位資料(參考色)取代之 〇 2)在同一數位影像之中,選取某特定區域,並指定欲改 變數位資料之區域,而將特定區域內之數位資料複製 15 至欲改變數位資料之區域。 上述二方法,均要求使用者以目視指定欲改變數位資 料區域之數位資料値(顏色)及影響範圍方能執行,若在 同一影像中存在有許多缺陷區域,則使用者便須針對每一 特定之缺陷區域指定其數位資料及影響範圍,如此處理起 20來手續即相當繁瑣,且由於其處理係針對使用者所選取之 區域內之所有圖素,故亦常破壞原本正確之數位資料。 本發明之主要目的,旨在藉用缺陷區域之數値資料分 析,以簡化使用者之操作步驟,使用者僅需框出影像中之 缺陷區域,則本發明之方法將依數彳直資料之分析結果’將 -4- (請先閱讀背面之注意事項再.彡躑本頁) .裝· 、*! 線 本紙伕尺度適用中國國家標準(CNS ) A4規格(210X297公楚) 43 5 44543 5 經濟部中央樣準局員工消費合作社印製 五、發明説明(2 ) 缺陷區域內數値資料區分爲缺陷及非缺陷圖素,作業則僅 改變缺陷部份之數値資料,而不影響非缺陷部份,以達到 使用者原先之預期要求。 按照本發明,係爲一種數位影像處理方法,其包括下 5列步驟:(a)提供一組由位置座標所構成之一底稿,其中 ,每一位置座標點上分別具有一組數位資料;(b)由該底 稿經門檻値選擇法得一二値化影像,將其中之數位資料區 分爲缺陷及非缺陷資料;(c)利用缺陷邊界演算法求得此 一二値化影像之邊界位置:(d)利用此邊界之座標位置及 10其相鄰位置之數位資料,計算並改變缺陷區域內各位置之 數位資料,從而達成淡化或去除影像中之缺陷圖素。 本發明之其他目的、方法及其功效,茲配合附圖詳細 敘明於后,俾讓審査委員得以進一步深入了解: 圖一係一二維平面底稿之示意圖; 15 圖二係由此底稿得出之灰階影像圖; 圖三係求得之二値化影像; 圖四係求得之邊界點示意圖; 圖五係修正後之影像; 圖六係圖二之灰階直方圖; 20 圖七係累積機率密度函數圖; 圖八係原始影像之切割門檻値示意圖; 圖九係缺陷邊界點之求得程序。 在步驟(a)中,該組位置座標上之數位資料即代表該 像素之色彩値(color value )。 -5- 本紙張尺度適用中國國家標準(CNS ) A4規格(210X297公釐) (請先閱讀背面之注意事項再rb本頁) -裝.4 A5 43 5 Λ7 Printed by the Consumer Cooperatives of the Central Standards Bureau of the Ministry of Economic Affairs 5. Description of the Invention (1) The present invention is a digital image processing method, which relates to the use of a computer to process digitization generated by a digital camera or other input device Image method. The use of computers to process digital images produced by digital cameras or other input devices has become increasingly popular. Traditional film-repairing operations will also be replaced by similar functions provided by computer software and hardware. The most common operation is to remove acne and diminish the texture of the pimples. The current digital image processing software provides the following two methods: 〇 In the same digital image, the color of the specified position in the specified image is 10 reference color, and then specify the range of the defect, and the digital data within the specified range will be replaced by the specified digital data (reference color) 〇2) in the same digital image, select a specific area, and specify the desired Change the area of digital data, and copy the digital data in a specific area 15 to the area where you want to change the digital data. The above two methods both require the user to visually specify the digital data (color) and influence range of the digital data area to be changed. If there are many defective areas in the same image, the user must target each specific The defective area specifies its digital data and its impact range. In this way, the process is quite tedious since it is 20 years old, and because the processing is based on all the pixels in the area selected by the user, the original digital data is often destroyed. The main purpose of the present invention is to borrow the data analysis of the defect area to simplify the user's operation steps. The user only needs to frame the defect area in the image, and the method of the present invention will straighten the data according to the number. The analysis result will be -4- (please read the precautions on the back first. 彡 踯 this page). Assembling ·, *! The size of the line paper is applicable to the Chinese National Standard (CNS) A4 specification (210X297). 43 5 44543 5 Printed by the Consumer Cooperatives of the Central Sample Bureau of the Ministry of Economic Affairs. 5. Description of the invention (2) The data in the defective area is divided into defective and non-defective pixels. The operation only changes the data of the defective part without affecting the non-defective. To meet the user ’s original expectations. According to the present invention, a digital image processing method includes the following five steps: (a) providing a set of manuscripts composed of position coordinates, wherein each position coordinate point has a set of digital data; ( b) Obtaining the first and second images from the manuscript through threshold selection method, and dividing the digital data into defective and non-defective data; (c) Using the defect boundary algorithm to obtain the boundary position of this first and second image: (D) Calculate and change the digital data of each position in the defect area by using the coordinate position of this boundary and the digital data of 10 adjacent positions, so as to reduce or remove the defective pixels in the image. Other objects, methods and effects of the present invention are described in detail with the accompanying drawings, so that the reviewers can further understand: Figure 1 is a schematic diagram of a two-dimensional flat manuscript; Figure 2 is derived from this manuscript Figures of gray-scale image; Figure 3 is the second image obtained; Figure 4 is the schematic diagram of the boundary points obtained; Figure 5 is the revised image; Figure 6 is the gray-scale histogram of Figure 2; 20 is the seventh series Cumulative probability density function diagram; Figure 8 is a schematic diagram of the cutting threshold of the original image; Figure 9 is the procedure for obtaining the boundary points of the defect. In step (a), the digital data on the set of position coordinates represents the color value of the pixel. -5- This paper size is applicable to China National Standard (CNS) A4 specification (210X297 mm) (Please read the precautions on the back before rb this page)-Packing.
、1T 線 44543 5 A7 B7 經濟.郅中央標準局®C工消費合作社印製 五、發明説明(3 ) 在步驟(b)中,由使用者在底稿上框選一區域,再由 此框選區域影像取得一二値化影像以區分缺陷和非缺陷圖 素,其流程如下: (1) .將該區域影像自原影像中截取出來,另產生一影像2, 5 如圖一所示。 (2) .將影像2轉換爲256色之灰階影像,如圖二所示。 (3) .求得此灰階影像之二値化門檻値,詳細步驟如下: i·求出影像之灰階直方圖(Gray-Level histogram),如圖三 所示。 10 ϋ·以1表示灰階値,〔1,2,…,L〕,L=256,在灰階値i中 之像素數目定義爲吡_像素數目爲N=nl+n2+...+nL. iii. 設此灰階直方圖定義爲常態化且視爲一機率分佈,則 P/ = n/N, ^>0, IPi...............(1) i=l iv. 其間斷型累積機率密度函數(c.d.f.)爲: 15 w(k)= Σρ,.....................(2) ’ 如圖四所示。 ν.期望値之定義如下: Α(Α〇 = Σ/.ρ,.....................(3) i=l vi.累積期望値: βΎ- ^(L)=Z/Pi............(4) i=l 20 vii.使用區別分析法(discriminate analysis)評估切割門檻値 a2(k) = \ Ur wfk) - α (λ-)Ί2 ...............(5) w(k)[l-w(k)] σ2 (£) = max a2 (k) ..............⑹,如圖六所示β lilcSL -6- 本紙張尺度_中賴家轉(CNS ) A视格(21G X 297公t ) 4543 5 B7 五、發明説明(4 ) ⑷.求得之〆値即爲門檻値,使用此値,可由原灰階圖產生 出一二値化影像3,如圖三所示。 步驟(c)如圖九所示,包含以下程序: ⑴.使用二値化影像,計算缺陷區域之重心位置; 5 (2).由此重心位置向右移動,直至找到缺陷的邊界爲止,並 將此點記錄爲起始點; (3)自起始點起,遇缺陷像素則向右轉並前進一座標位置, 遇非缺陷像素則向左轉並前進一座標位置,並依次記錄 所行經之缺陷像素位置(重覆行經之位置僅於第一次記 10 錄之),即可得此缺陷區域之完整邊界。 於求得缺陷區域之邊界座標及二丨直化影像後,便可利 用邊界點鄰近非缺陷區域之像素顏色値,對缺陷像素進行 修正動作,其方法如下: (1) .對取得之缺陷邊界點座標陣列依y軸座標値作排序動作 15 ; (2) .依序比對相同y軸座標値之X座標値,求出其兩邊界點 及其相鄰非缺陷圖素之顔色値; (3) .依相鄰圖素資料,對缺陷區域內之圖素作插補法運算, 計算出X軸方向修正後之數位資料並記錄之: 經濟部中央標準局貝工消費合作社印製 --.--.-------^ I- I 0 (請先閱讀背面之注意事項-?!-. ...Ik本頁) •線 20 (4).重覆步驟(1H3),但改爲依X軸之値作排序,求出y軸 方向之修正後數位資料: (5).將依X軸及y軸方向求出之修正數位資料作平均並塡入 底搞。 於本發明之方法中,步驟Φ)之灰階影像,可以有多種 本紙張尺度適用中國國家標準(CNS ) Λ4現格(210Χ297公釐) 44543 5 Λ7 、一 Β7 i '發明説明(5 ) ~~~ 定義方式,其和不同之缺陷像素修正程序,β卩#胃gg, 可以遂行多種不同之缺陷修正動作,例|如駿紋 時,可將原底稿分爲I (明暗度,Intensity)、η (色相,Hue) 、S (飽和度,Saturation)三個色彩頻道,以i色頻爲輸入 5之灰階影像’並進一步求其二値化影像及缺陷邊界,而在 進行修正動作時,則僅針對I色頻內之像素作插補法運算, 再將I、Η、S三色頻結合成修正後影像,如此原本影像之 色調及飽合度均保持不變,而僅改變亮度’則可得一較自 然之皺紋淡化影像;若欲修正青春痘,則可直接將底稿直 1〇接轉換爲灰階影像,並於修正程序中直接改變所有色頻之 數位資料。 圖式之簡單說明: 圖一係一二維平面底稿之示意圖; 15圖二係由此底稿得出之灰階影像圖; 圖三係求得之二値化影像; 圖四係求得之邊界點示意圖; 圖五係修正後之影像; 圖六係圖二之灰階直方圖: 20圖七係累積機率密度函數圖; 圖八係原始影像之切割門濫値示意圖; 圖九係缺陷邊界點之求得程序。 -8- 本紙張尺度適用中國國家標準(CNS ) Α4規格(2丨0Χ297公釐) ---.--^----^裝 I- (請先閲讀背面之注意事項再〆一!-本頁) ,1Τ 經濟部中央標準局貝工消費合作社印製1T line 44543 5 A7 B7 Economy. 印 Printed by the Central Bureau of Standards® C Industrial Consumer Cooperatives 5. Description of the invention (3) In step (b), the user selects an area on the manuscript, and then selects from this box The area image obtains one or two digitized images to distinguish defective and non-defective pixels. The process is as follows: (1). The area image is cut out from the original image, and another image 2 is generated, as shown in Figure 1. (2). Convert image 2 into a 256-color grayscale image, as shown in Figure 2. (3). Obtain the second transformation threshold of this grayscale image. The detailed steps are as follows: i. Obtain the gray-level histogram of the image, as shown in Figure 3. 10 ϋ · Represents the gray level 1 with 1, [1,2, ..., L], L = 256, and the number of pixels in the gray level 値 i is defined as pi. The number of pixels is N = nl + n2 + ... + nL iii. Let this grayscale histogram be defined as normalized and regarded as a probability distribution, then P / = n / N, ^ > 0, IPi ............ ( 1) i = l iv. The discontinuous cumulative probability density function (cdf) is: 15 w (k) = Σρ, ........... (2 ) 'As shown in Figure 4. ν. Expectation 値 is defined as follows: Α (Α〇 = Σ / .ρ, ........... (3) i = l vi. Cumulative expectation 値: ΒΎ- ^ (L) = Z / Pi ............ (4) i = l 20 vii. Using discriminate analysis to evaluate the cutting threshold 値 a2 (k) = \ Ur wfk)-α (λ-) Ί2 ......... (5) w (k) [lw (k)] σ2 (£) = max a2 (k) .. ............ ⑹, as shown in Figure 6 β lilcSL -6- This paper scale_ 中 赖 家 转 (CNS) A view grid (21G X 297g t) 4543 5 B7 V. Description of the invention (4) 〆 値. The obtained 〆 値 is the threshold 値. Using this 値, one or two digitized images 3 can be generated from the original grayscale map, as shown in Figure 3. Step (c) is shown in Fig. 9 and includes the following procedures: ⑴. Use the binarized image to calculate the position of the center of gravity of the defect area; 5 (2). Move the position of the center of gravity to the right until the boundary of the defect is found, and Record this point as the starting point; (3) From the starting point, when it is defective, it will turn right and advance a target position, and when it is non-defective, it will turn left and advance a target position, and record the course in sequence. The defective pixel position (the position of repeated passage is recorded only in the first recording of 10), and the complete boundary of the defective area can be obtained. After the boundary coordinates of the defect area and the two-dimensionalized image are obtained, the pixel color 値 of the non-defective area adjacent to the boundary point can be used to correct the defective pixel. The method is as follows: (1). The obtained defect boundary The point coordinate array performs the sorting action 15 according to the y-axis coordinate (; (2). The X-coordinate 値 of the same y-axis coordinate 値 is sequentially compared to find the color 値 of its two boundary points and its adjacent non-defective pixels; 3). According to the neighboring pixel data, the pixels in the defect area are interpolated to calculate the digital data corrected in the X-axis direction and recorded: printed by the Shellfish Consumer Cooperative of the Central Standards Bureau of the Ministry of Economic Affairs- .--.------- ^ I- I 0 (Please read the note on the back-?!-. ... Ik page) • Line 20 (4). Repeat the steps (1H3), However, instead of sorting by the X-axis, the corrected digital data in the y-axis direction is obtained: (5). The corrected digital data obtained in the X-axis and y-axis directions are averaged and rounded to the bottom. In the method of the present invention, the gray-scale image of step Φ) can have a variety of paper sizes applicable to the Chinese National Standard (CNS) Λ4 grid (210 × 297 mm) 44543 5 Λ7, a B7 i 'Instructions of the invention (5) ~ ~~ The definition method, which is different from the defective pixel correction program, β 胃 ############################################################ gg ############# η (hue), S (saturation, Saturation) three color channels, with i color frequency as a grayscale image of input 5 'and further find its binary image and defect boundary, and when performing the corrective action, The interpolation method is only performed on the pixels in the I color frequency, and then the I, Η, and S color frequencies are combined into a modified image, so that the original image's hue and saturation are unchanged, and only the brightness is changed. A more natural wrinkle-reducing image can be obtained; if you want to correct acne, you can directly convert the base paper into a grayscale image, and directly change the digital data of all color frequencies in the correction process. Brief description of the drawings: Figure 1 is a schematic diagram of a two-dimensional flat manuscript; Figure 2 is a grayscale image diagram obtained from this manuscript; Figure 3 is a two-dimensionalized image obtained from the manuscript; Figure 4 is a boundary obtained from the system Figure 5 is the corrected image; Figure 6 is the gray-scale histogram of Figure 2; 20 is the cumulative probability density function of Figure 7; Figure 8 is the cut-out of the original image; Figure 9 is the defect boundary point. Get the procedure. -8- This paper size applies to Chinese National Standard (CNS) Α4 size (2 丨 0 × 297mm) ---.-- ^ ---- ^ Installation I- (Please read the precautions on the back first and then take a look!- (This page), Printed by Shellfish Consumer Cooperative, Central Bureau of Standards, Ministry of Economic Affairs