TWI517091B - Method of 2d-to-3d depth image construction and device thereof - Google Patents

Method of 2d-to-3d depth image construction and device thereof Download PDF

Info

Publication number
TWI517091B
TWI517091B TW102139537A TW102139537A TWI517091B TW I517091 B TWI517091 B TW I517091B TW 102139537 A TW102139537 A TW 102139537A TW 102139537 A TW102139537 A TW 102139537A TW I517091 B TWI517091 B TW I517091B
Authority
TW
Taiwan
Prior art keywords
pixel
depth
image
value
pixels
Prior art date
Application number
TW102139537A
Other languages
Chinese (zh)
Other versions
TW201516958A (en
Inventor
范育成
張立承
劉弘寬
Original Assignee
國立臺北科技大學
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 國立臺北科技大學 filed Critical 國立臺北科技大學
Priority to TW102139537A priority Critical patent/TWI517091B/en
Publication of TW201516958A publication Critical patent/TW201516958A/en
Application granted granted Critical
Publication of TWI517091B publication Critical patent/TWI517091B/en

Links

Description

二維至三維的深度影像建立方法及裝置 Two-dimensional to three-dimensional depth image establishing method and device

本發明是有關於一種深度影像建立方法,特別是指一種二維至三維的深度影像建立方法及裝置。 The invention relates to a depth image establishing method, in particular to a two-dimensional to three-dimensional depth image establishing method and device.

深度影像,指的是二維影像中物體與觀看者之間的距離資訊,投影到一平面上所形成的影像,通常是以8個位元代表256種色階的灰階圖來表示,亮度值0代表離觀看者最遠,而亮度值255代表離觀看者最近。 Depth image refers to the distance information between an object and a viewer in a two-dimensional image. The image formed by projection onto a plane is usually represented by a gray scale diagram of 8 bits representing 256 levels. A value of 0 represents the farthest from the viewer, and a luminance value of 255 represents the closest to the viewer.

目前產生深度影像的方式大致可分為三種主要的類別:1)使用深度攝影機、2)使多視角攝影機,以及2)將使用單一攝影機得到的影像進行二維至三維的影像轉換。前兩者,僅可用於拍攝新的影像,對於已存在的舊有二維影像如舊照片、圖畫,只能利用第三種類別的方式。 The current methods of generating depth images can be roughly divided into three main categories: 1) using a depth camera, 2) making a multi-view camera, and 2) performing a two-dimensional to three-dimensional image conversion of an image obtained using a single camera. The first two can only be used to capture new images. For existing old 2D images such as old photos and pictures, only the third category can be used.

使用第三種類別,最重要的部分是進行邊緣偵測,分析出物件的邊緣,並賦予其深度值,然而以目前使用的邊緣偵測方法,套用到中國古典繪畫上,由於繪畫的方式,會使得偵測出來的邊緣所圍繞的區塊過於破碎、過小,因此即便是同一物件,也常被分成多個區塊,而依此 賦予深度值,所得效果不甚良好。 Using the third category, the most important part is to perform edge detection, analyze the edge of the object, and give it the depth value. However, with the currently used edge detection method, it is applied to Chinese classical painting, due to the way of painting. It will make the blocks surrounded by the detected edges too broken and too small, so even the same object is often divided into multiple blocks, and accordingly Given the depth value, the effect is not very good.

此外,中國古典繪畫的著色方式及視角,與西洋的繪畫或現代的照片均不相同,本發明並將利用中國古典繪畫中常見的特徵,對應生成深度影像,以利後端重建虛擬視角,帶給使用者觀看中國古畫不一樣的視覺震撼。 In addition, the coloring methods and perspectives of Chinese classical paintings are different from those of Western paintings or modern photographs. The present invention will use the features commonly found in Chinese classical paintings to generate depth images to facilitate the reconstruction of virtual perspectives at the back end. Give users the visual shock of watching Chinese ancient paintings differently.

因此,本發明之目的,即在提供一種適用中國古典繪畫的二維至三維的深度影像建立方法。 Accordingly, it is an object of the present invention to provide a two-dimensional to three-dimensional depth image creation method suitable for Chinese classical painting.

因此,本發明之另一目的,即在提供一種適用中國古典繪畫的二維至三維的深度影像建立裝置。 Therefore, another object of the present invention is to provide a two-dimensional to three-dimensional depth image establishing apparatus suitable for Chinese classical painting.

於是,本發明二維至三維的深度影像建立方法,由一深度影像建立裝置配合一計算裝置執行,該深度影像建立裝置包含一記憶體及一連接該記憶體的處理器,該記憶體儲存一程式碼,該處理器讀取該程式碼而執行該方法所包含的以下步驟: Therefore, the two-dimensional to three-dimensional depth image establishing method of the present invention is performed by a depth image establishing device and a computing device, the depth image establishing device comprising a memory and a processor connected to the memory, the memory storing one The code, the processor reads the code and performs the following steps included in the method:

(A)自該計算裝置讀取一原始影像,並產生維度相同的一預設背景深度影像及一尚未被賦值的結果背景深度影像,該原始影像包括多個分別具有一亮度值的畫素,該預設背景深度影像包括多個分別具有一深度值的畫素。 (A) reading an original image from the computing device, and generating a predetermined background depth image of the same dimension and a result background depth image that has not been assigned, the original image comprising a plurality of pixels each having a brightness value, The preset background depth image includes a plurality of pixels each having a depth value.

(B)對該原始影像的每一畫素判斷是否其亮度值大於一亮度閾值,若是則視為背景畫素而執行步驟(C),否則視為前景畫素而執行步驟(D)。 (B) determining whether each luminance of the original image has a luminance value greater than a luminance threshold, and if so, performing the step (C) as a background pixel, otherwise performing the step (D) as a foreground pixel.

(C)使位置對應該背景畫素的該結果背景深度影像的畫素被賦予相同位置上該預設背景深度影像的畫素 的深度值。 (C) making the position corresponding to the background pixel the background depth image of the pixel is given the pixel of the preset background depth image at the same position Depth value.

(D)對該原始影像進行超畫素計算,而將該原始影像區分成多個超畫素,各該超畫素包括多個亮度值相近且位置相鄰的畫素,執行步驟(E)。 (D) performing a superpixel calculation on the original image, and dividing the original image into a plurality of superpixels, each of the superpixels including a plurality of pixels having similar luminance values and adjacent positions, and performing step (E) .

(E)首先讀取該等前景畫素所對應到該預設背景深度影像上相同位置的畫素的深度值,再分別平均屬於相同超畫素的所有前景畫素對應的深度值而分別得到各該超畫素的一超畫素深度值,然後將該超畫素深度值對應賦值至該結果背景深度影像中對應前景畫素的畫素。 (E) first reading the depth values of the pixels corresponding to the same position on the preset background depth image, and then respectively averaging the depth values corresponding to all the foreground pixels of the same superpixel, respectively A superpixel depth value of each superpixel, and then assigning the superpixel depth value correspondingly to a pixel corresponding to the foreground pixel in the resulting background depth image.

較佳地,還包含於步驟(E)後執行的步驟(F): Preferably, the step (F) performed after the step (E) is further included:

(F)執行一基於影像邊緣的深度修正方法,首先對該原始影像進行邊緣偵測及細線化而得到該原始影像的多個邊緣線,然後根據該等邊緣線對該結果背景深度影像的前景畫素進行掃描與深度值的取代,使得被相同邊緣線圍繞的各畫素的深度值統一。 (F) performing a depth correction method based on the image edge, first performing edge detection and thinning on the original image to obtain a plurality of edge lines of the original image, and then foregrounding the background depth image according to the edge lines The pixels are scanned and replaced with depth values such that the depth values of the pixels surrounded by the same edge line are uniform.

較佳地,其中,該掃描的路徑與深度值的取代的方法包括: Preferably, the method for replacing the scanned path and the depth value comprises:

(F1)由右下至左上使用左右鏡射之N字型的掃描路徑,若在掃描途中,該畫素的深度值小於右邊畫素,則該畫素的深度值會被右邊畫素的深度值所取代。 (F1) From the lower right to the upper left, use the N-shaped scanning path of the left and right mirrors. If the depth value of the pixel is smaller than the right pixel during scanning, the depth value of the pixel will be the depth of the right pixel. The value is replaced.

(F2)由左下至右上使用N字型的掃描路徑,若在掃描途中,該畫素的深度值小於左邊畫素,則該畫素的深度值會被左邊畫素的深度值所取代。 (F2) The N-shaped scan path is used from the lower left to the upper right. If the depth value of the pixel is smaller than the left pixel during scanning, the depth value of the pixel is replaced by the depth value of the left pixel.

(F3)由左上至右下使用Z字型的掃描路徑,若 在掃描途中,該畫素的深度值小於上方畫素,則該畫素的深度值會被上方畫素的深度值所取代。 (F3) Use the Z-shaped scan path from top left to bottom right, if When the depth value of the pixel is smaller than the upper pixel during scanning, the depth value of the pixel is replaced by the depth value of the upper pixel.

(F4)由右上至左下使用左右鏡射之Z字型的掃描路徑,若在掃描途中,該畫素的深度值小於下方畫素,則該畫素的深度值會被下方畫素的深度值所取代。 (F4) From the upper right to the lower left, use the Z-shaped scanning path of the left and right mirrors. If the depth value of the pixel is smaller than the lower pixel during scanning, the depth value of the pixel will be the depth value of the lower pixel. Replaced.

較佳地,其中,該預設背景深度影像是以漸層方式由上而下設定各畫素為代表離使用者由遠而近的深度值。 Preferably, the preset background depth image is set in a stepwise manner from top to bottom to represent each pixel as a depth value that is far from the user.

較佳地,還包含一於步驟(D)前執行的步驟(G):對前景畫素進行標籤連通化計算,給予相連接的畫素相同且唯一的編號,並得到各不相鄰的區塊的畫素數量,並將標籤數量小於一數量閾值的畫素視為背景畫素而執行步驟(C),其餘畫素執行步驟(D)。 Preferably, the method further comprises a step (G) performed before the step (D): performing label connectivity calculation on the foreground pixels, giving the same and unique number of the connected pixels, and obtaining non-adjacent regions. The number of pixels of the block, and the pixel whose number of tags is less than a certain threshold is regarded as the background pixel and step (C) is performed, and the remaining pixels perform step (D).

較佳地,其中,該超畫素計算是先將該原始影像區分成多個方形的網格,各該網格具有一中心畫素,再計算每一中心畫素與其一預定範圍內的多個畫素的多個相關於兩者間亮度的差距及位置的差距的特徵距離,再將各該畫素歸入最短的特徵距離所對應的中心畫素所屬的超畫素。 Preferably, the superpixel calculation is to first divide the original image into a plurality of square grids, each grid has a central pixel, and then calculate each central pixel and a predetermined range thereof. The plurality of pixels are related to the difference in brightness between the two and the feature distance of the difference in position, and then each of the pixels is classified into the super-pixel of the central pixel corresponding to the shortest feature distance.

較佳地,其中,步驟(A)在該原始影像為一彩色影像的情況下,還將該彩色影像轉換灰階,使該原始影像包括該等分別具有該等亮度值的畫素。 Preferably, in the step (A), when the original image is a color image, the color image is further converted into a gray scale, so that the original image includes the pixels each having the brightness values.

於是,本發明二維至三維的深度影像建立裝置,執行如前所述的二維至三維的深度影像建立方法。 Thus, the two-dimensional to three-dimensional depth image establishing device of the present invention performs the two-dimensional to three-dimensional depth image establishing method as described above.

本發明之功效在於:透過判斷是否亮度值大於一亮度閾值來區分前景與背景,並以超畫素進行深度值的平均,而能更準確地生成前景畫素對應的深度值。 The effect of the invention is that the foreground and the background are distinguished by judging whether the brightness value is greater than a brightness threshold, and the depth value is averaged by the super-pixel, and the depth value corresponding to the foreground pixel can be more accurately generated.

1‧‧‧深度影像建立裝置 1‧‧‧Deep image creation device

11‧‧‧記憶體 11‧‧‧ memory

12‧‧‧處理器 12‧‧‧ Processor

2‧‧‧計算裝置 2‧‧‧ Computing device

S1-S8‧‧‧步驟 S1-S8‧‧‧ steps

S11、S31‧‧‧步驟 S11, S31‧‧ steps

本發明之其他的特徵及功效,將於參照圖式的較佳實施例詳細說明中清楚地呈現,其中:圖1是一方塊圖,說明本發明二維至三維的深度影像建立方法的一較佳實施例;圖2是一流程圖,說明該較佳實施例;圖3是一影像圖,說明一原始影像;圖4是一影像圖,說明套用一亮度閾值;圖5是一影像圖,說明去除雜訊後的結果;圖6是一影像圖,說明背景畫素被賦予深度值;圖7是一影像圖,說明超畫素計算的初始化;圖8是一影像圖,說明超畫素計算的結果;圖9是一影像圖,說明平均超畫素對應的深度值;圖10是一影像圖,說明細線化的結果;圖11是示意說明基於影像邊緣的深度修正方法的掃描路徑;及圖12是一影像圖,說明產生的一結果背景深度影像。 Other features and effects of the present invention will be apparent from the following detailed description of the preferred embodiments of the invention. FIG. 1 is a block diagram illustrating a comparison of the two-dimensional to three-dimensional depth image creation methods of the present invention. 2 is a flow chart illustrating the preferred embodiment; FIG. 3 is an image diagram illustrating an original image; FIG. 4 is an image diagram illustrating the application of a brightness threshold; FIG. 5 is an image view. The result of removing the noise is illustrated; FIG. 6 is an image diagram illustrating that the background pixel is given a depth value; FIG. 7 is an image diagram illustrating the initialization of the superpixel calculation; FIG. 8 is an image diagram illustrating the superpixel The result of the calculation; FIG. 9 is an image diagram illustrating the depth value corresponding to the average superpixel; FIG. 10 is an image diagram illustrating the result of thinning; FIG. 11 is a scanning path schematically illustrating the depth correction method based on the image edge; And Figure 12 is an image diagram illustrating a resulting background depth image.

參閱圖1與圖2,本發明二維至三維的深度影像建立方法之較佳實施例,由一深度影像建立裝置1配合一 計算裝置2執行,該深度影像建立裝置1包含一記憶體11及一連接該記憶體11的處理器12,該記憶體11儲存一程式碼,該處理器12讀取該程式碼而執行該方法所包含的以下步驟: Referring to FIG. 1 and FIG. 2, a preferred embodiment of the two-dimensional to three-dimensional depth image establishing method of the present invention is provided by a depth image establishing device 1 The computing device 2 is configured to include a memory 11 and a processor 12 connected to the memory 11. The memory 11 stores a code, and the processor 12 reads the code to execute the method. The following steps are included:

步驟S1一自該計算裝置2讀取一原始影像(如圖3),並產生維度相同的一預設背景深度影像及一尚未被賦值的結果背景深度影像。該預設背景深度影像的賦值方式容後說明。 Step S1 reads an original image from the computing device 2 (as shown in FIG. 3), and generates a preset background depth image of the same dimension and a resulting background depth image that has not been assigned. The assignment method of the preset background depth image is described later.

步驟S11-若該原始影像為一彩色影像,則將其轉換為灰階。如此,待分析的該原始影像包括多個畫素,各畫素分別具有一亮度值。轉換公式為Y=0.299×R+0.587×G+0.114×B,其中Y為該亮度值,而R、G、B分別為彩色影像的三原色的值。 Step S11 - If the original image is a color image, convert it to gray scale. Thus, the original image to be analyzed includes a plurality of pixels, each of which has a luminance value. The conversion formula is Y=0.299×R+0.587×G+0.114×B, where Y is the brightness value, and R, G, and B are the values of the three primary colors of the color image, respectively.

步驟S2-對亮度值進行二值化的動作,把該結果背景深度影像中對應到原始影像較暗部分的畫素設為0,視為影像的物件部分,即前景,而在影像較亮的畫素則設為255,視為影像的背景資訊,如此初步區分前景與背景,產生二值化的該結果背景深度影像(如圖4)。就執行上而言,當一畫素的亮度值大於一亮度閾值,則代表該畫素為背景,接著會進入步驟S4,否則進入步驟S3。 Step S2: performing a binarization operation on the luminance value, and setting a pixel corresponding to a darker portion of the original image in the background depth image to 0 as the object portion of the image, that is, the foreground, and the image is brighter. The pixel is set to 255, which is regarded as the background information of the image, so that the foreground and the background are initially distinguished, and the resulting background depth image is generated (see FIG. 4). In terms of execution, when the luminance value of one pixel is greater than a luminance threshold, the pixel is represented as the background, and then proceeds to step S4, otherwise proceeds to step S3.

補充說明的是,因為是針對中國古典畫,而中國古典畫的作畫方式是在白底上塗上顏色,因此以二值化動作來區分前景與背景,效果特別好。 In addition, because it is for Chinese classical painting, and the Chinese classical painting is painted on a white background, the effect of binarization is to distinguish the foreground from the background. The effect is particularly good.

步驟S3-執行影像標籤連通化,將二值化後所 視為的前景畫素,給予相連接的畫素相同且唯一的編號,並將標籤數量小於一數量閾值的畫素視為雜訊(步驟S31)並改視其為背景畫素,而進入步驟S4。 Step S3 - performing image tag connectivity, and binarizing the device The foreground pixel regarded as the same, unique number assigned to the connected pixels, and the pixel whose number of labels is less than a certain threshold is regarded as noise (step S31) and is changed as the background pixel, and the steps are entered. S4.

在本實施例中是採用的是八相鄰連接,針對影像中的前景畫素進行標籤化的動作,把八相鄰的區域標記為同一編號。標籤連通化的方式為本領域技術人員所熟知,在此不再贅述。 In the present embodiment, eight adjacent connections are used, and the foreground pixels in the image are tagged, and the eight adjacent regions are marked with the same number. The manner in which the labels are connected is well known to those skilled in the art and will not be described herein.

完成標籤連通化後,將標籤數目過小的畫素視為雜訊,濾除這些畫素,將之視為影像的背景部分(如圖5),如此一來,便能將相對應的深度資訊完整的填入影像的物件與背景之中。 After the label is connected, the pixels with too small the number of labels are regarded as noise, and these pixels are filtered out and regarded as the background part of the image (as shown in Fig. 5), so that the corresponding depth information can be obtained. Completely fill in the image of the object and the background.

步驟S4-在確定前景畫素與背景畫素後,本步驟是將背影畫素對應的該結果背景深度影像的畫素(圖5中白色部分)填上深度值。填上的方式是根據該預設背景深度影像。 Step S4: After determining the foreground pixel and the background pixel, the step is to fill in the depth value of the pixel (the white portion in FIG. 5) of the result background depth image corresponding to the back pixel. The way to fill in is based on the preset background depth image.

針對中國古典繪畫做了相關的探討後,發現中國古典繪畫中有別於其他繪畫的定點透視,採用了散點透視的方法,而所謂的散點透視,即是一個畫面中可以有多個視點,把不同角度所看到的影像,組合在同一張畫面上,藉此打破傳統上空間的限制。由於這種特殊的繪畫技巧,使得中國古典繪畫的風格會是由下往上的移動方法,根據探討的結果,本實施例根據上述的中國古典繪畫特性,將該預設背景深度影像以八位元表示,將亮度值0置於預設背景深度影像最上方,代表離觀賞者最遠,反之亮度值 255置於預設背景深度影像下方,代表離觀賞者最近,中間部分則根據影像上下方向的畫素數量,以漸層方式由上而下設定各畫素為代表離使用者由遠而近的深度值。 After a related discussion on Chinese classical painting, it was found that Chinese classical painting is different from the fixed perspective of other paintings, and adopts the method of scatter perspective. The so-called scatter perspective is that there can be multiple viewpoints in one picture. Combine the images seen from different angles on the same picture, thus breaking the traditional space limitation. Due to this special painting technique, the style of Chinese classical painting will be a bottom-up movement method. According to the results of the discussion, this embodiment takes the preset background depth image as eight according to the above-mentioned characteristics of Chinese classical painting. The element indicates that the brightness value 0 is placed at the top of the preset background depth image, which represents the farthest from the viewer, and vice versa. 255 is placed under the preset background depth image, which is the closest to the viewer, and the middle part is set according to the number of pixels in the vertical direction of the image, and the pixels are set from top to bottom in a gradual manner to represent the user from the far side. Depth value.

接著,便使位置對應該背景畫素的該結果背景深度影像的畫素被賦予相同位置上該預設背景深度影像的畫素的深度值(如圖6)。 Then, the pixel of the background depth image corresponding to the background pixel of the position is given the depth value of the pixel of the preset background depth image at the same position (as shown in FIG. 6).

步驟S5-對該原始影像進行超畫素計算,而將該原始影像區分成多個超畫素(superpixel),各該超畫素包括多個亮度值相近且位置相鄰的畫素。超畫素的演算法有多種,本實施例是使用改良自K平均演算法(k-means)的簡單線性疊代群聚(SLIC,Simple Linear Iterative Clustering)演算法。 Step S5: performing superpixel calculation on the original image, and dividing the original image into a plurality of superpixels, each of the superpixels including a plurality of pixels whose luminance values are similar and adjacent to each other. There are many algorithms for superpixels. In this embodiment, a simple linear iterative clustering (SLIC) algorithm using a modified K-means algorithm (k-means) is used.

首先進行初始化,將該原始影像區分成多個正方形的網格(如圖7),每一網格有一中心畫素,然後針對每個畫素的標籤值進行計算,若第i個畫素與第k個網格中心畫素的一相關於兩者間亮度的差距及位置的差距的特徵距離D為最小,則將該畫素的標籤值更新為k,其中特徵距 離,亮度的差距,位置的差距 ,1為亮度值,x及y為位置座標值, m為正規化係數(常數),為前述網格的邊長,N為該 原始影像的總畫素數,K為預設的所欲形成的網格的數量。需說明的是,為了加速計算,僅針對每個網格中心畫素週圍2S×2S之預定範圍的畫素,來計算該畫與中心畫素的特徵距離D。 Initially, the original image is divided into a plurality of square grids (as shown in Fig. 7), each grid has a central pixel, and then the label value of each pixel is calculated, if the i-th pixel is The feature distance D of the kth grid center pixel related to the difference in brightness and the position difference between the two is the smallest, and the label value of the pixel is updated to k, wherein the feature distance , the difference in brightness Location gap , 1 is the brightness value, x and y are the position coordinate values, and m is the normalization coefficient (constant). For the side length of the aforementioned mesh, N is the total number of pixels of the original image, and K is the preset number of meshes to be formed. It should be noted that, in order to speed up the calculation, the feature distance D of the picture and the central pixel is calculated only for a predetermined range of pixels of 2S×2S around each center pixel of the mesh.

當每個畫素都有了相對應標籤值後,分別平均所有相同標籤之畫素的亮度值li及位置座標值xi、yi,得到一個新的網格中心畫素的亮度值lk及位置座標值xk、yk,持續不斷的重覆上述的動作進行更新,直到誤差收斂到所設定的門檻值為止,就得到非常貼近物件邊緣的超畫素(如圖8)。 After each pixel has a corresponding label value, the luminance values l i and the position coordinate values x i and y i of all the pixels of the same label are averaged respectively, and a new grid center pixel luminance value is obtained. k and the position coordinate values x k and y k are continuously repeated to repeat the above actions until the error converges to the set threshold value, and a superpixel close to the edge of the object is obtained (Fig. 8).

步驟S6-在步驟S4後,該結果背景深度影像對應至背景畫素的部分已經被賦予深度值,現在要處理對應至前景畫素的部分。首先讀取該等前景畫素所對應到該預設背景深度影像上相同位置的畫素的深度值,再分別平均屬於相同超畫素的所有前景畫素對應的深度值而分別得到各該超畫素的一超畫素深度值,然後將該超畫素深度值對應賦值至該結果背景深度影像中對應前景畫素的畫素(如圖9)。 Step S6 - After the step S4, the portion of the result background depth image corresponding to the background pixel has been given a depth value, and the portion corresponding to the foreground pixel is now processed. First, the depth values of the pixels corresponding to the same position on the preset background depth image are read, and the depth values corresponding to all foreground pixels belonging to the same superpixel are respectively averaged to obtain the super-values respectively. A super-pixel depth value of the pixel, and then assigning the super-pixel depth value to the pixel corresponding to the foreground pixel in the resulting background depth image (see Figure 9).

至此,該結果背景深度影像已經初步完成,背景部分為漸層的深度值,前景部分包括多個超畫素,每個超畫素只有一個深度值。然後進入步驟S7。 So far, the result background depth image has been initially completed, the background part is the gradient depth value, the foreground part includes a plurality of super pixels, and each super pixel has only one depth value. Then it proceeds to step S7.

步驟S7-執行一基於影像邊緣的深度修正方法,首先對該原始影像進行邊緣偵測而得到該原始影像的多個邊緣線,然後根據該等邊緣線對該結果背景深度影像的前景畫素進行掃描與深度值的取代,使得被相同邊緣線圍繞的各畫素的深度值統一。 Step S7- Performing an image edge-based depth correction method, first performing edge detection on the original image to obtain a plurality of edge lines of the original image, and then performing foreground pixels on the resulting background depth image according to the edge lines The substitution of the scan and the depth value makes the depth values of the pixels surrounded by the same edge line uniform.

在本實施中是先使用索貝爾(Sobel)邊緣偵測,然後偵測結果取二值化,再進行Z.S(Zhang and Suen,張與 孫)細線化,將寬度大於一個畫素的邊緣畫素細化成只有一個畫素寬,而產生該等邊緣線,並套用在該結果背景深度影像上對應前景畫素的部分(如圖10),意即使位在邊緣線上的前景畫素的深度值等於0。 In this implementation, Sobel edge detection is used first, then the detection result is binarized, and then Z.S (Zhang and Suen, Zhang and Sun) thinning, the edge pixels whose width is larger than one pixel are refined into only one pixel width, and the edge lines are generated, and applied to the part of the result background depth image corresponding to the foreground pixel (Fig. 10) It means that the depth value of the foreground pixel located on the edge line is equal to zero.

一併參閱圖11,接著對非屬邊緣線的畫素進行以下四個掃描路徑與深度值的取代方法: Referring to FIG. 11 together, the following four scanning paths and depth values are replaced by pixels that are not edge lines:

(a)由右下至左上使用左右鏡射之N字型的掃描路徑,若在掃描途中,該畫素的深度值小於右邊畫素,則該畫素的深度值會被右邊畫素的深度值所取代。 (a) From the lower right to the upper left, use the N-shaped scanning path of the left and right mirrors. If the depth value of the pixel is smaller than the right pixel during scanning, the depth value of the pixel will be the depth of the right pixel. The value is replaced.

(b)由左下至右上使用N字型的掃描路徑,若在掃描途中,該畫素的深度值小於左邊畫素,則該畫素的深度值會被左邊畫素的深度值所取代。 (b) The N-shaped scan path is used from the lower left to the upper right. If the depth value of the pixel is smaller than the left pixel during scanning, the depth value of the pixel is replaced by the depth value of the left pixel.

(c)由左上至右下使用Z字型的掃描路徑,若在掃描途中,該畫素的深度值小於上方畫素,則該畫素的深度值會被上方畫素的深度值所取代。 (c) A zigzag scan path is used from the upper left to the lower right. If the depth value of the pixel is smaller than the upper pixel during scanning, the depth value of the pixel is replaced by the depth value of the upper pixel.

(d)由右上至左下使用左右鏡射之Z字型的掃描路徑,若在掃描途中,該畫素的深度值小於下方畫素,則該畫素的深度值會被下方畫素的深度值所取代。 (d) From the upper right to the lower left, use the Z-shaped scanning path of the left and right mirrors. If the depth value of the pixel is smaller than the lower pixel during scanning, the depth value of the pixel will be the depth value of the lower pixel. Replaced.

不斷重複以上的四種掃描路徑與深度值的取代方法,直到被相同邊緣線圍繞的各畫素的深度值統一為止。最後使邊緣線上的前景畫素的深度值等於四相鄰中深度值的最小值,即可消除邊緣資訊。 The above four scanning path and depth value substitution methods are continuously repeated until the depth values of the pixels surrounded by the same edge line are unified. Finally, the edge information is eliminated by making the depth value of the foreground pixel on the edge line equal to the minimum value of the four adjacent medium depth values.

步驟S8-在步驟S7處理完對應到前景畫素的部分後,加上步驟S4的結果,即得到最終的該結果背景深 度影像(如圖12)。 Step S8 - after processing the portion corresponding to the foreground pixel in step S7, adding the result of step S4, the final background depth of the result is obtained. Degree image (Figure 12).

值得一提的是,若直接使用sobel邊緣偵測及Z.S細線化的結果,來對漸層的該預設背景深度影像進行掃描及取代,很容易造成部分被相同邊緣線圍繞的區塊太小,區塊太小則深度值統一的範圍就小,使得得出的結果背景深度影像跟該預設背景深度影像差不多。但本發明是改由對步驟S6利用超畫素所初步完成的該結果背景深度影像(如圖9)進行掃描及取代,因此即便有過小的區塊,但已先利用超畫素進行初步的統一動作,而能更準確地生成前景畫素對應的深度值。 It is worth mentioning that if the results of sobel edge detection and ZS thinning are directly used to scan and replace the progressive background depth image, it is easy to cause some of the blocks surrounded by the same edge line to be too small. If the block is too small, the range of the depth value is uniform, so that the resulting background depth image is similar to the preset background depth image. However, the present invention is to scan and replace the background depth image (Fig. 9) which is initially completed by using superpixels in step S6, so that even if there are too small blocks, the preliminary use of superpixels is first performed. The action is unified, and the depth value corresponding to the foreground pixel can be generated more accurately.

綜上所述,透過二值化動作來區分前景與背景,並以超畫素先初步進行深度值的平均,而能更準確地生成前景畫素對應的深度值,最後再執行該基於影像邊緣的深度修正方法,而能較佳地建立中國古典繪畫的深度影像,故確實能達成本發明之目的。 In summary, the binarization action is used to distinguish the foreground from the background, and the super-pixels are used to initially average the depth values, and the depth values corresponding to the foreground pixels can be more accurately generated, and finally the image-based edges are executed. The depth correction method can better establish the depth image of Chinese classical painting, so it can achieve the purpose of the present invention.

惟以上所述者,僅為本發明之較佳實施例而已,當不能以此限定本發明實施之範圍,即大凡依本發明申請專利範圍及專利說明書內容所作之簡單的等效變化與修飾,皆仍屬本發明專利涵蓋之範圍內。 The above is only the preferred embodiment of the present invention, and the scope of the present invention is not limited thereto, that is, the simple equivalent changes and modifications made by the patent application scope and patent specification content of the present invention, All remain within the scope of the invention patent.

S1-S8‧‧‧步驟 S1-S8‧‧‧ steps

S11、S31‧‧‧步驟 S11, S31‧‧ steps

Claims (9)

一種二維至三維的深度影像建立方法,由一深度影像建立裝置配合一計算裝置執行,該深度影像建立裝置包含一記憶體及一連接該記憶體的處理器,該記憶體儲存一程式碼,該處理器讀取該程式碼而執行該方法所包含的以下步驟:(A)自該計算裝置讀取一原始影像,並產生維度相同的一預設背景深度影像及一尚未被賦值的結果背景深度影像,該原始影像包括多個分別具有一亮度值的畫素,該預設背景深度影像包括多個分別具有一深度值的畫素;(B)對該原始影像的每一畫素判斷是否該亮度值大於一亮度閾值,若是則視為背景畫素而執行步驟(C),否則視為前景畫素而執行步驟(D);(C)使位置對應該背景畫素的該結果背景深度影像的畫素被賦予相同位置上該預設背景深度影像的畫素的深度值;(D)對該原始影像進行超畫素計算,而將該原始影像區分成多個超畫素,各該超畫素包括多個亮度值相近且位置相鄰的畫素,執行步驟(E);及(E)讀取該等前景畫素所對應到該預設背景深度影像上相同位置的畫素的深度值,再分別平均屬於相同超畫素的所有前景畫素對應的深度值而分別得到各該超畫素的一超畫素深度值,然後將該超畫素深度值對應賦值 至該結果背景深度影像中對應前景畫素的畫素;其中,該超畫素計算是先將該原始影像區分成多個方形的網格,各該網格具有一中心畫素,針對每個畫素的標籤值進行計算,若第i個畫素與第k個網格中心畫素的一相關於兩者間亮度的差距及位置的差距的特徵距離D為最小,則將該畫素的標籤值更新為k,其中特徵距離 ,亮度的差距,位置的差距,l為亮度值,x及y為位置座標值 ,m為正規化係數(常數),為前述網格的邊長,N為該原始影像的總畫素數,K為預設的所欲形成的網格的數量,並針對每個網格中心畫素週圍之預定範圍的畫素,來計算該畫與中心畫素的特徵距離D,再將各該畫素歸入最短的特徵距離D所對應的中心畫素所屬的超畫素;當每個畫素都有了相對應標籤值後,分別平均所有相同標籤之畫素的亮度值li及位置座標值xi、yi,得到一個新的網格中心畫素的亮度值lk及位置座標值xk、yk,持續不斷的重覆上述的動作進行更新,直到誤差收斂到所設定的門檻值為止,藉此貼近物件邊緣的超畫素。 A two-dimensional to three-dimensional depth image creation method is performed by a depth image creation device and a computing device. The depth image creation device includes a memory and a processor connected to the memory, and the memory stores a code. The processor reads the code and performs the following steps included in the method: (A) reading an original image from the computing device, and generating a preset background depth image of the same dimension and a result background that has not been assigned a depth image, the original image includes a plurality of pixels each having a brightness value, the preset background depth image including a plurality of pixels each having a depth value; (B) determining whether each pixel of the original image is The brightness value is greater than a brightness threshold, if yes, the background pixel is treated as step (C), otherwise the foreground pixel is treated as step (D); (C) the position corresponds to the background pixel of the background pixel The pixel of the image is given a depth value of the pixel of the preset background depth image at the same position; (D) the superpixel calculation is performed on the original image, and the original image is divided into a plurality of super paintings Each of the superpixels includes a plurality of pixels having similar luminance values and adjacent positions, performing step (E); and (E) reading the foreground pixels corresponding to the same position on the preset background depth image. The depth value of the pixel is averaged, and the depth values corresponding to all foreground pixels of the same superpixel are respectively averaged to obtain a super-pixel depth value of each super-pixel, and then the super-pixel depth value is correspondingly assigned to The result is a pixel corresponding to the foreground pixel in the background depth image; wherein the super pixel calculation is to first divide the original image into a plurality of square grids, each grid having a central pixel for each painting The label value of the prime is calculated. If the i-th pixel is related to the k-th grid center pixel, the difference in luminance between the two and the feature distance D of the position difference is the smallest, then the label of the pixel is The value is updated to k, where the feature distance , the difference in brightness Location gap , l is the brightness value, x and y are the position coordinate values, and m is the normalization coefficient (constant). For the side length of the aforementioned mesh, N is the total number of pixels of the original image, K is the preset number of meshes to be formed, and for a predetermined range of pixels around the center pixel of each mesh, To calculate the feature distance D between the picture and the center pixel, and then classify each picture element into the super-pixel of the center pixel corresponding to the shortest feature distance D; when each pixel has a corresponding label value Then, the luminance values l i and the position coordinate values x i , y i of all the pixels of the same label are averaged respectively, and a new grid center pixel luminance value l k and position coordinate values x k , y k are obtained . The above actions are continuously repeated to update until the error converges to the set threshold value, thereby approaching the superpixel of the edge of the object. 如請求項1所述二維至三維的深度影像建立方法,還包含於步驟(E)後執行的步驟(F):(F)執行一基於影像邊緣的深度修正方法,對該原始影像進行邊緣偵測及細線化而得到該原始影像的多個邊緣線,然後根據該等邊緣線對該結果背景深度影像的前景畫素進行一掃描與深度值的取代方法,使得被相同邊 緣線圍繞的各畫素的深度值統一。 The two-dimensional to three-dimensional depth image establishing method according to claim 1, further comprising the step (F) performed after the step (E): (F) performing an image edge-based depth correction method, and performing edge processing on the original image Detecting and thinning to obtain a plurality of edge lines of the original image, and then performing a scan and depth value replacement method on the foreground pixels of the resulting background depth image according to the edge lines, so that the same edge is The depth values of the pixels surrounding the edge are uniform. 如請求項2所述二維至三維的深度影像建立方法,其中,該掃描的路徑與深度值的取代的方法包括:(F1)由右下至左上使用左右鏡射之N字型的掃描路徑,若在掃描途中,該畫素的深度值小於右邊畫素,則該畫素的深度值會被右邊畫素的深度值所取代;(F2)由左下至右上使用N字型的掃描路徑,若在掃描途中,該畫素的深度值小於左邊畫素,則該畫素的深度值會被左邊畫素的深度值所取代;(F3)由左上至右下使用Z字型的掃描路徑,若在掃描途中,該畫素的深度值小於上方畫素,則該畫素的深度值會被上方畫素的深度值所取代;及(F4)由右上至左下使用左右鏡射之Z字型的掃描路徑,若在掃描途中,該畫素的深度值小於下方畫素,則該畫素的深度值會被下方畫素的深度值所取代。 The two-dimensional to three-dimensional depth image establishing method according to claim 2, wherein the method for replacing the path and the depth value of the scanning includes: (F1) using a left-right mirrored N-shaped scanning path from the lower right to the upper left If the depth value of the pixel is smaller than the right pixel during scanning, the depth value of the pixel is replaced by the depth value of the right pixel; (F2) the N-shaped scanning path is used from the lower left to the upper right. If the depth value of the pixel is smaller than the left pixel during scanning, the depth value of the pixel is replaced by the depth value of the left pixel; (F3) the z-shaped scanning path is used from the upper left to the lower right. If the depth value of the pixel is smaller than the upper pixel during scanning, the depth value of the pixel is replaced by the depth value of the upper pixel; and (F4) the left-right to the lower left using the left-right mirroring z-shaped The scan path, if the depth value of the pixel is smaller than the lower pixel during scanning, the depth value of the pixel is replaced by the depth value of the lower pixel. 如請求項1所述二維至三維的深度影像建立方法,其中,該預設背景深度影像是以漸層方式由上而下設定各畫素為代表離使用者由遠而近的深度值。 The two-dimensional to three-dimensional depth image establishing method according to claim 1, wherein the preset background depth image is set in a gradient manner from top to bottom to represent each pixel as a depth value that is far from the user. 如請求項1所述二維至三維的深度影像建立方法,還包含一於步驟(D)前執行的步驟(G):對前景畫素進行標籤連通化計算,給予相連接的畫素相同且唯一的編號,並將標籤數量小於一數量閾值的畫素視為背景畫素而執行步驟(C),其餘畫素執行步驟(D)。 The two-dimensional to three-dimensional depth image establishing method according to claim 1, further comprising a step (G) performed before the step (D): performing label connectivity calculation on the foreground pixels, giving the connected pixels the same and A unique number, and a pixel whose number of labels is less than a threshold is regarded as a background pixel and step (C) is performed, and the remaining pixels perform step (D). 如請求項1至5其中任一項所述的二維至三維的深度影 像建立方法,其中,步驟(A)在該原始影像為一彩色影像的情況下,還將該彩色影像轉換灰階,使該原始影像包括該等分別具有該等亮度值的畫素。 2D to 3D depth image as claimed in any one of claims 1 to 5 In the image creation method, in the case that the original image is a color image, the color image is also converted into a gray scale, so that the original image includes the pixels each having the brightness values. 一種二維至三維的深度影像建立裝置,包含一記憶體及一連接該記憶體的處理器,該記憶體儲存一程式碼,該深度影像建立裝置連接一計算裝置,其中,該處理器讀取該程式碼而自該計算裝置讀取一原始影像,並產生維度相同的一預設背景深度影像及一尚未被賦值的結果背景深度影像,該原始影像包括多個分別具有一亮度值的畫素,該預設背景深度影像包括多個分別具有一深度值的畫素;該處理器對該原始影像的每一畫素判斷是否該亮度值大於一亮度閾值;該處理器若是判斷該亮度值大於該亮度閾值,則視為背景畫素而使位置對應該背景畫素的該結果背景深度影像的畫素被賦予相同位置上該預設背景深度影像的畫素的深度值;該處理器若是判斷該亮度值不大於該亮度閾值,則視為前景畫素而對該原始影像進行超畫素計算,而將該原始影像區分成多個超畫素,各該超畫素包括多個亮度值相近且位置相鄰的畫素,讀取該等前景畫素所對應到該預設背景深度影像上相同位置的畫素的深度值,再分別平均屬於相同超畫素的所有前景畫素對應的深度值而分別得到各該超畫素的一超畫素深度值,然後將該超畫 素深度值對應賦值至該結果背景深度影像中對應前景畫素的畫素;其中,該超畫素計算是先將該原始影像區分成多個方形的網格,各該網格具有一中心畫素,針對每個畫素的標籤值進行計算,若第i個畫素與第k個網格中心畫素的一相關於兩者間亮度的差距及位置的差距的特徵距離D為最小,則將該畫素的標籤值更新為k,其 中特徵距離,亮度的差距,位置的差距,l為亮度值,x及y為位 置座標值,m為正規化係數(常數),為前述網格的邊長,N為該原始影像的總畫素數,K為預設的所欲形成的網格的數量,並針對每個網格中心畫素週圍之預定範圍的畫素,來計算該畫與中心畫素的特徵距離D,再將各該畫素歸入最短的特徵距離D所對應的中心畫素所屬的超畫素;當每個畫素都有了相對應標籤值後,分別平均所有相同標籤之畫素的亮度值li及位置座標值xi、yi,得到一個新的網格中心畫素的亮度值lk及位置座標值xk、yk,持續不斷的重覆上述的動作進行更新,直到誤差收斂到所設定的門檻值為止,藉此貼近物件邊緣的超畫素。 A two-dimensional to three-dimensional depth image establishing device includes a memory and a processor connected to the memory, the memory storing a code, the depth image establishing device is connected to a computing device, wherein the processor reads The program reads an original image from the computing device, and generates a preset background depth image of the same dimension and a result background depth image that has not been assigned. The original image includes a plurality of pixels each having a brightness value. The preset background depth image includes a plurality of pixels each having a depth value; the processor determines, for each pixel of the original image, whether the brightness value is greater than a brightness threshold; if the processor determines that the brightness value is greater than The brightness threshold is regarded as a background pixel, and the pixel corresponding to the background pixel of the background pixel is given a depth value of the pixel of the preset background depth image at the same position; if the processor determines If the brightness value is not greater than the brightness threshold, the foreground pixel is regarded as a foreground pixel and the super-pixel calculation is performed on the original image, and the original image is divided into multiple a superpixel, each of the superpixels includes a plurality of pixels having similar brightness values and adjacent positions, and reading depth values of pixels corresponding to the same position on the preset background depth image by the foreground pixels, and then And respectively, the depth values corresponding to all the foreground pixels of the same superpixel are respectively obtained, respectively, and a superpixel depth value of each superpixel is obtained, and then the superpixel depth value is correspondingly assigned to the corresponding background depth image. a pixel of the foreground pixel; wherein the superpixel calculation is to first divide the original image into a plurality of square grids, each grid having a central pixel, and calculating a label value for each pixel, If the i-th pixel is related to the k-th grid center pixel, the difference in luminance between the two and the feature distance D of the position difference is the smallest, the label value of the pixel is updated to k, wherein the feature distance , the difference in brightness Location gap , l is the brightness value, x and y are the position coordinate values, and m is the normalization coefficient (constant). For the side length of the aforementioned mesh, N is the total number of pixels of the original image, K is the preset number of meshes to be formed, and for a predetermined range of pixels around the center pixel of each mesh, To calculate the feature distance D between the picture and the center pixel, and then classify each picture element into the super-pixel of the center pixel corresponding to the shortest feature distance D; when each pixel has a corresponding label value Then, the luminance values l i and the position coordinate values x i , y i of all the pixels of the same label are averaged respectively, and a new grid center pixel luminance value l k and position coordinate values x k , y k are obtained . The above actions are continuously repeated to update until the error converges to the set threshold value, thereby approaching the superpixel of the edge of the object. 如請求項7所述的二維至三維的深度影像建立裝置,其中,該處理器還對該原始影像進行邊緣偵測及細線化而得到該原始影像的多個邊緣線,然後根據該等邊緣線對該結果背景深度影像的前景畫素進行掃描與深度值的取代,使得被相同邊緣線圍繞的各畫素的深度值統一,該 預設背景深度影像是以漸層方式由上而下設定各畫素為代表離使用者由遠而近的深度值。 The two-dimensional to three-dimensional depth image establishing device of claim 7, wherein the processor further performs edge detection and thinning on the original image to obtain a plurality of edge lines of the original image, and then according to the edges The line scans the foreground pixels of the background depth image to replace the depth values, so that the depth values of the pixels surrounded by the same edge line are unified. The preset background depth image is set in a stepwise manner from top to bottom to set each pixel as a depth value that is far from the user. 如請求項7或8所述的二維至三維的深度影像建立方法,其中,在該原始影像為一彩色影像的情況下,該處理器還將該彩色影像轉換灰階,使該原始影像包括該等分別具有該等亮度值的畫素。 The two-dimensional to three-dimensional depth image establishing method according to claim 7 or 8, wherein, in the case that the original image is a color image, the processor further converts the color image into gray scale, so that the original image includes The pixels each having the brightness values.
TW102139537A 2013-10-31 2013-10-31 Method of 2d-to-3d depth image construction and device thereof TWI517091B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW102139537A TWI517091B (en) 2013-10-31 2013-10-31 Method of 2d-to-3d depth image construction and device thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW102139537A TWI517091B (en) 2013-10-31 2013-10-31 Method of 2d-to-3d depth image construction and device thereof

Publications (2)

Publication Number Publication Date
TW201516958A TW201516958A (en) 2015-05-01
TWI517091B true TWI517091B (en) 2016-01-11

Family

ID=53720424

Family Applications (1)

Application Number Title Priority Date Filing Date
TW102139537A TWI517091B (en) 2013-10-31 2013-10-31 Method of 2d-to-3d depth image construction and device thereof

Country Status (1)

Country Link
TW (1) TWI517091B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI618031B (en) * 2017-04-12 2018-03-11 和碩聯合科技股份有限公司 Edge detection method of image

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI629665B (en) * 2017-11-24 2018-07-11 住華科技股份有限公司 Defect inspection method and defect inspection system
TWI731604B (en) * 2020-03-02 2021-06-21 國立雲林科技大學 Three-dimensional point cloud data processing method
CN114190972B (en) * 2020-09-18 2024-03-22 苏州佳世达电通有限公司 Volume calculation method of ultrasonic image object and ultrasonic system using same

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI618031B (en) * 2017-04-12 2018-03-11 和碩聯合科技股份有限公司 Edge detection method of image

Also Published As

Publication number Publication date
TW201516958A (en) 2015-05-01

Similar Documents

Publication Publication Date Title
JP7181977B2 (en) Method and system for detecting and combining structural features in 3D reconstruction
US20170103510A1 (en) Three-dimensional object model tagging
CN108352083B (en) 2D image processing for stretching into 3D objects
EP3311361B1 (en) Method and apparatus for determining a depth map for an image
US20100046837A1 (en) Generation of depth map for an image
JP6547386B2 (en) Image processing apparatus and method
JP2014235750A (en) Target detection method and target detection device
CN107622480B (en) Kinect depth image enhancement method
US9530212B2 (en) Image frame conversion method and video frame conversion method and apparatus
TWI517091B (en) Method of 2d-to-3d depth image construction and device thereof
JP6715864B2 (en) Method and apparatus for determining a depth map for an image
CN110544300A (en) Method for automatically generating three-dimensional model based on two-dimensional hand-drawn image characteristics
Kuo et al. Depth estimation from a monocular view of the outdoors
JP6914734B2 (en) Silhouette extractor, method and program
CN104537627A (en) Depth image post-processing method
WO2012172853A1 (en) Apparatus for generating three-dimensional image, method for generating three-dimensional image, program, and recording medium
Mukherjee et al. A hybrid algorithm for disparity calculation from sparse disparity estimates based on stereo vision
CN107590857A (en) For generating the apparatus and method of virtual visual point image
JP6811679B2 (en) Silhouette extractor, method and program
Huang et al. Generation of stereo oil paintings from RGBD images
TWI736335B (en) Depth image based rendering method, electrical device and computer program product
Reddy Automatic 2D-to-3D conversion of single low depth-of-field images
KR101284136B1 (en) Camera parameter and object extraction system for 3d object reconstruction
CN116740250A (en) Texture mapping method with highlight processing
JP2021064334A5 (en)

Legal Events

Date Code Title Description
MM4A Annulment or lapse of patent due to non-payment of fees