469 732 五、發明說明u) 5 — 1發明領域及背景 A.發明領域 本發明係為一種掃描影像的影像自動裁剪方法,尤指 一種可自動裁剪具有不規則邊緣之掃描物件的方法。 Β.發明背景 目前市面上的掃插器大多 動搜尋預掃影像之文件的功能 自動裁剪方法’皆以框取圖形 例’若掃描的物件為星形,所 因此,實際所要處理的影像便 資料。使用者必須對所框取的 得到所要的星形圖案。而且, 使得處理的速度較慢,常常要 割處理後的結果。 提供預掃(pre-scan)及自 。然而’習知之掃描物件的 外圍的方框為主。以圖1為 框取的實際影像卻為方形β 包含了星形外圍大量的無用 資料進行切割及處理,才能 一般之切割的演算法不佳, 荨待一段時間後才能看到切 具有美術用途之圖形而言,例如應用於網頁的圖 =,其邊緣通常為不規則的形狀,若利用習知之自 G換框裁剪出圖形的外®,再將不須要的背 ^轉換為早—顏色,然後利用其它應用程式的工具, 案顏色設定為透明色,再儲存為特定的檔 到其中所要的_。由於此種方法有賴美 若理’不但使用不方便,且費時耗費人力。 且’就掃描器所提供的功能而言,亦而469 732 V. Description of the invention u) 5-1 Field and background of the invention A. Field of the invention The present invention relates to a method for automatically cropping scanned images, especially a method for automatically cropping scanned objects with irregular edges. Β Background of the Invention Currently, most of the scanners on the market move the function of searching for pre-scanned image files. The automatic cropping methods are all based on the example of frame drawing. . The user must obtain the desired star pattern on the frame. Moreover, the processing speed is slower, and the results after processing are often cut. Provides pre-scan and auto. However, the box around the known scanned object is dominated. The actual image taken in the frame of Figure 1 is a square β, which contains a large amount of useless data around the star's periphery for cutting and processing. The general cutting algorithm is not good. After a while, you can see that the cutting has artistic purposes. In terms of graphics, such as figure = applied to web pages, the edges are usually irregular shapes. If you use the conventional G-frame to cut out the outer shape of a graphic, then convert the unnecessary back ^ to early-color, and then Using the tools of other applications, set the project color to transparent and save it as a specific file to the desired _. Because this method depends on Mei Ruoli ’, it is not only inconvenient to use, but also takes time and manpower. And ’as far as the functionality provided by the scanner,
第4頁 4 69 73 2 五、發明說明(2) 5—2發明目的及概述 基於上述之問題,本發明之主要目的在提出一種影像、 自動裁剪方法,以自動裁剪具有不規則邊緣的物件影像, 進而提高掃描器的應用價值。 ' 本發明之另一目的在提出一種高效率的影像自動裁剪 方法,可將裁煎的範圍逼近不規則邊緣的實際大小,以降 低所須處理的資料量,進而提高處理的效能。 本發明之又一目的在提出一種可透過掃描器直接去除 物件之背景影像的方法’以便於將掃描器廣泛應用於圖形 資料的處理。 基於上述之目的,本發明提出一種可自動裁剪具有不 規則邊緣之掃描物件的方法。本發明在掃描器的上蓋底 j二提供-具有固定式樣的圖案’以當作框取物件時的 考座標,以及作為顏色的比對之用。在掃描器柄次安 便預先掃描底板的圖案,以分析每一個圖 2庫。之後’凡在進行掃描物件之影像的象的 ,、要依據一圖案單位,依序地比對該底 時 儲存的資料及該前置掃描影像的RGfi $ 料庫中所 1案單位中是否包含有掃描物件的色二差資料便可‘判定每 兩個圖案單位的RGB色階差在一設定之%如果判定 定該園案單位中不包含該掃描物件疋二圍^ 該圖案單位的位置。等待完成整個影像的判定錄 結相Page 4 4 69 73 2 V. Description of the invention (2) 5-2 Purpose and summary of the invention Based on the above problems, the main purpose of the present invention is to propose an image and automatic cropping method to automatically crop an image of an object with irregular edges. , Thereby increasing the application value of the scanner. '' Another object of the present invention is to propose a high-efficiency automatic image cropping method, which can approximate the actual size of the irregular frying range to reduce the amount of data to be processed, thereby improving the processing efficiency. Another object of the present invention is to propose a method for directly removing the background image of an object through a scanner ', so as to facilitate the wide application of the scanner to the processing of graphic data. Based on the above objectives, the present invention proposes a method for automatically cutting a scanned object with irregular edges. In the present invention, the upper cover bottom of the scanner is provided with a pattern with a fixed pattern 'to be used as a test coordinate when the object is framed, and used for color comparison. It is easy to pre-scan the pattern of the base plate at the scanner handle to analyze each of the 2 libraries. Afterwards, all the images of the scanned object must be sequentially compared with the data stored at the base and the RGfi $ of the pre-scanned image according to a pattern unit. The color difference data of the scanned object can be used to 'determine the RGB level difference of every two pattern units at a set%. If it is determined that the scan unit does not include the scanned object 疋 the position of the pattern unit. Waiting for the completion of the judgment of the entire image
4 69 73 24 69 73 2
鄰之圖案單位,便為掃描物 緣加以裁剪,便可得到掃描 用在不規則圖形的自動裁剪 的框取速度》 件的影像區域。然後延著其邊 物件的影像。本發明不但可應 ,亦可加快習知對於方形影像 5 — 3圖式之簡單說明 圖1為習知之自動影像框取的示意圖。 圖2A為本發明之一種底板式樣的示意圖。 圖2B為圖2A之底板式樣中的圖案單位放大示意圖。 圖3為本發明之建立底板式樣資料庫的流程圖。 圖4為本發明之利用底板式樣資料庫,進行影像自動 裁剪的流程圖。 5 ~ 4本發明之詳細說明 為解決上述之問題’本發明在掃描器的上蓋底板,提 供具有固疋式樣的圖案,如圖2A所示。此圖案的目的在 當作裁剪物件時的參考座標’以及作為顏色的比對之用。 圖案本身只要具有式樣及大小一致’且排列規則的特性即 可,並不限於使用格狀的圖案。而且圖案之間應減少重疊 的模糊地帶,以增加切割時的準確度。 由於每台掃描器的上蓋底板在安裝時可能有誤差,因 此為求取準確的參考座標,必須在初次啟動掃描器時,讀 取底板的圖案’辯識圖案的座標,以設定一底板式樣的實 料庫。以圖2A的圖案為例,其底板式樣的資料庫建立方法The adjacent pattern units are cropped for the scanned object edge, and the image area for scanning the frame picking speed used in the automatic cropping of irregular graphics can be obtained. Then stretch the image of the object on its side. The present invention can not only respond to, but also speed up, the conventional simple description of the square image 5-3. Fig. 1 is a schematic diagram of conventional automatic image frame selection. FIG. 2A is a schematic diagram of a bottom plate pattern of the present invention. FIG. 2B is an enlarged schematic view of a pattern unit in the bottom plate pattern of FIG. 2A. FIG. 3 is a flowchart of establishing a base plate style database according to the present invention. FIG. 4 is a flowchart of automatic image cropping using a base plate style database according to the present invention. 5 ~ 4 Detailed description of the present invention To solve the above-mentioned problem, the present invention provides a pattern with a fixed pattern on the bottom plate of the scanner cover, as shown in FIG. 2A. The purpose of this pattern is to use it as a reference coordinate when cutting objects and for color comparison. As long as the pattern itself has the characteristics of uniform pattern and size 'and regular arrangement, it is not limited to the use of a checkered pattern. In addition, the overlapping blurred areas should be reduced to increase the accuracy when cutting. Since the upper base plate of each scanner may have errors during installation, in order to obtain accurate reference coordinates, the pattern of the base plate must be read when the scanner is first started to identify the coordinates of the pattern to set a base plate pattern. Material library. Taking the pattern of FIG. 2A as an example, a method for establishing a database of a base plate pattern
第6頁 4 6 9 73 2 五、發明說明(4) 如圖3所示。 步驟31 :以5Odpi的低解析度,預先掃描一次底板的 式樣’以產生底板式樣的前置影像資料(pre-scanned image )。 步驟32 :然後尋找圖案的實際座標,即圖素所在的位 置。從前置掃描的影像中,由左上角開始以一小塊區域當 作取樣的區塊。然後,從其中找尋灰階最黑的區塊。找到 之後’以此為所有黑色圖案的標準大小,定出最左上角黑 色圖案之座標,並依據該座標找出所有黑色圖案的位置 (已知圖案的大小皆相同)。然後,以同樣方式找出所有 灰色圖案的位置(已知只有兩種不同的灰階)。圖案的找 尋方式有許多習知之演算法可應用,不加贅述。 步驟33 :設定每一個圖案的參考座標及rgb參考值。 設定每一個圖案為一個單位,由於所找出的每一個黑色圖 案或灰色圖案單位中’係由許多個圖素所構成,因此以該 圖案單位中的所有圖素之RGB平均值及變異數,作為該圖 案單位的RGB參考值。例如,每個黑色圖案中具有2〇個圖 素’便將該單位中的2〇個圖素的紅’綠,藍色階的值的分 別總合之後’再分別除以2〇,以當作該黑色圖案單位的 RGB平均值’變異數則是將每個圖案單位中2〇個圖素的 紅’綠’藍色階值分別與平均值相減後平方,再加以平均 之值。 然後,以黑色圖案或灰色圈案的區塊當作一個單位, 以設定其參考座標。以圖2B的放大圖為例說明,在找出的Page 6 4 6 9 73 2 V. Description of the invention (4) As shown in FIG. Step 31: Scan the pattern of the bottom plate in advance at a low resolution of 50 dpi to generate pre-scanned image of the bottom plate. Step 32: Then find the actual coordinates of the pattern, that is, the position of the pixel. From the pre-scanned image, a small area is used as the sampled block from the upper left corner. Then, find the darkest block in it. After finding ’, use this as the standard size of all black patterns, determine the coordinates of the black pattern in the upper-left corner, and find the positions of all black patterns based on the coordinates (the known patterns have the same size). Then, find the locations of all gray patterns in the same way (only two different gray levels are known). There are many known algorithms for finding patterns, so I won't go into details. Step 33: Set the reference coordinates and rgb reference value of each pattern. Set each pattern as a unit. Since each of the black or gray pattern units found is composed of many pixels, the RGB average value and the number of variations of all pixels in the pattern unit, RGB reference value as the pattern unit. For example, if there are 20 pixels in each black pattern, the red, green, and blue levels of the 20 pixels in the unit are summed respectively, and then divided by 20 respectively. The variation number of the average RGB value of the black pattern unit is obtained by subtracting the square value of the red 'green' blue level of 20 pixels in each pattern unit from the average value, and then adding the average value. Then, use the black pattern or gray circle as a unit to set its reference coordinates. Take the enlarged view of Figure 2B as an example.
4 6 9 73 2 五、發明說明(5)' " 黑色圖案與灰色圖案中,依序設定參考座標為^由 於參考座標的範圍大於其實際座標,因此可使之後的 比對更為快速有效β 、 步驟34 :然後儲存每一個圖案單位的參考資料,包 含:RGB參考值、該圖案單位中每一個 - 圖案單位的參考座標。 直及該 如此,便建立了底板式樣資料庫的資料。資料庫的建 立只須在掃描器初次安裝時設定一次即可。之後,便可對 任何形狀之圖形資料,進行自動裁剪的處理。 本發明之影像自動裁剪的原理乃是將掃描物件的前置 掃描影像與底板式樣資料庫的參考資料進行比對。使用者 可選擇方型的影像框取,或選擇只框取所要的不規則圖 形。 , 本發明之自動裁剪的方法如圖4所示: 步驟401 :載入底板式樣資料庫的參考.資料。 步驟4 02 :以同樣的解析度,如5〇dpi,進行掃描物件 之預掃程序’以產生掃描物件的前置影像資料。 步驟403 :依據所設定之圖案單位,比對相同單位之 位置中,底板樣式的前置影像參考資料及掃描物件之前置 掃描影像的RGB色階差別。此比對的目的在找出掃插物件 所在的位置。因為未被掃描物件所遮蓋的部份,必然會顯 不底板樣式之圖案的特徵。同理,未顯示底板樣式之圖 特徵的部份’便為掃描物件所在之位置β而且,同一圖案 單位中的顏色均十分接近,而一般掃描物件的影像則無^4 6 9 73 2 V. Description of the invention (5) '" In the black and gray patterns, set the reference coordinates in sequence as ^ Since the range of the reference coordinates is larger than its actual coordinates, subsequent comparisons can be made faster and more effective. β, Step 34: Then store reference information of each pattern unit, including: RGB reference value, each of the pattern units-reference coordinates of the pattern unit. Immediately after that, the data of the base plate pattern database was established. The database can be set up only once when the scanner is first installed. After that, you can automatically crop the graphic data of any shape. The principle of automatic image cropping in the present invention is to compare the pre-scanned image of the scanned object with the reference data of the base plate style database. The user can choose to frame the square image, or choose to frame only the irregular images. The method for automatic cropping according to the present invention is shown in FIG. 4: Step 401: Load reference data of a base plate pattern database. Step 4 02: At the same resolution, such as 50 dpi, perform a pre-scanning process of the scanned object 'to generate pre-image data of the scanned object. Step 403: According to the set pattern unit, in the position of the same unit, the front image reference data of the base plate style and the RGB level difference of the scanned image before the scanned object are compared. The purpose of this comparison is to find out where the objects to be inserted are located. Because the part that is not covered by the scanned object will inevitably show the characteristics of the pattern of the bottom plate. In the same way, the part that does not show the features of the bottom plate pattern is the position β of the scanned object. Moreover, the colors in the same pattern unit are very close, but the image of the scanned object is not ^
4 69 73 2 i、發明說明(6) ' " ~ 特性。另外,同-圖案單位,的平均亮度資料亦相近可 用以作為過漆時的參考。 比對時是以圖案的參考座標為單位比較的。在同—個 圖案單位的位置中,比較掃描物件之前置掃描影像的Rgb 平均值及變異數(var〗ance),與該圖案單位的RGB參考 值。 步驟404 :如果兩者的RGB色階差在一預設的誤差值 内,執行步驟405 ;否則,執行步驟4〇6。 步驟405 :判定該圖案單位中並未包含所掃描之物件 的影像。 步驟406 :如果兩者的色階差異超出一預設的誤差 值’表示該圖案單位包含掃描物件的影像。於是,記錄該 圖案單位的位置。 步驟407 :完成全部圖案單位的比對後,在所記錄的 圖案單位中’連結相鄰的圖案單位,以成為同一組的圖 形。如果一次掃描三張圖片的影像,便會有三組的圖形。 步驟408 :此時,若選擇方型的框取方式,便依據左 上角及右下角之圖案單位的參考座標,計算方框的範圍, 然後比對至實際的圊素單位,以切割方框内的影像資料。 步驟409 :若選擇只框取其中的不規則圖案,便須找 出有記錄之圖案單位的上,下,左,右參考座標,將所要 讀取的不規則圖形切割出來。切割的方式可利用目前現有 的許多演算法進行。 切割完後’只要針對掃描物件邊緣的資料進行透明色4 69 73 2 i. Description of the invention (6) '" ~ Characteristics. In addition, the average brightness data of the same-pattern unit is similar and can be used as a reference when painting. The comparison is based on the pattern's reference coordinates. In the position of the same pattern unit, compare the Rgb average value and variation number (var) of the scan image before the scanned object with the RGB reference value of the pattern unit. Step 404: If the difference between the RGB levels of the two is within a preset error value, go to step 405; otherwise, go to step 406. Step 405: It is determined that the image unit of the scanned object is not included in the pattern unit. Step 406: If the difference between the two color levels exceeds a preset error value ', it means that the pattern unit includes the image of the scanned object. Then, the position of the pattern unit is recorded. Step 407: After the comparison of all the pattern units is completed, the adjacent pattern units are connected in the recorded pattern units to become the same group of graphics. If you scan three images at a time, there will be three groups of graphics. Step 408: At this time, if a rectangular frame selection method is selected, the range of the box is calculated according to the reference coordinates of the pattern unit in the upper left corner and the lower right corner, and then compared to the actual prime unit to cut the box. Image data. Step 409: If you select only the irregular patterns in the frame, you must find the upper, lower, left, and right reference coordinates of the recorded pattern units, and cut out the irregular patterns to be read. The cutting method can be performed by using many existing algorithms. After cutting ’, just make the transparent color for the data on the edge of the scanned object.
4 69 732 五、發明說明(7) — 的處理,即可取出所要的圖形。切割出的不規則區域的精 細度與底板樣式的式樣大小有關β若樣式較小,切割區較 ,精細,所須再處理的區塊範圍亦小,資料量亦較小。但 若式樣太小,則難以找出特徵,而無法與掃描之二 有效的比對。 如此,應用本發明之方法,不但可應用於任 之圖形的剪裁’亦可提高掃描器的應用價值,舉凡任何美 工圖形,皆可經由掃描器的剪裁,而加以應用 二、 理,或其它的影像處理。而且,本發明之方法網頁^慝 掃描的圖形數量,因此可大幅提高掃描及剪载次 以上所述僅為本發明之較佳實施例而已,且厂: 之實用功效,凡依本發明申請專利範圍所作之已達廣= 修飾,皆仍屬本發明專利涵蓋之範圍内。.=等變4 ”4 69 732 V. Description of the invention (7) — You can take out the desired figure. The fineness of the cut out irregular area is related to the size of the bottom plate style. If the style is small, the cut area is relatively large and fine, the range of blocks to be reprocessed is also small, and the amount of data is small. However, if the style is too small, it will be difficult to find the features, and it will not be able to effectively compare with the second scan. In this way, applying the method of the present invention can not only be applied to the cutting of any graphics, but also increase the application value of the scanner. For example, any artistic graphics can be applied through the cutting of the scanner. Image processing. Moreover, the number of scanned graphics on the webpage of the method of the present invention can greatly increase the number of scans and clips. The above description is only the preferred embodiment of the present invention, and the practical effects of the plant are as follows: The scope has been broadened = modifications are still within the scope of the invention patent. . = Equal Variation 4 "