Presentation is loading. Please wait.

Presentation is loading. Please wait.

Background Blurring shadow@cmlab.csie.ntu.edu.tw 這張照片除了中間樹叢的部份,往前或往後都是模糊的,於是我們很自然的就會把焦點放在中間清楚的樹叢上,這是因為人眼對於texture清晰銳利的部份會比較敏感的緣故。

Similar presentations


Presentation on theme: "Background Blurring shadow@cmlab.csie.ntu.edu.tw 這張照片除了中間樹叢的部份,往前或往後都是模糊的,於是我們很自然的就會把焦點放在中間清楚的樹叢上,這是因為人眼對於texture清晰銳利的部份會比較敏感的緣故。"— Presentation transcript:

1 Background Blurring shadow@cmlab.csie.ntu.edu.tw
這張照片除了中間樹叢的部份,往前或往後都是模糊的,於是我們很自然的就會把焦點放在中間清楚的樹叢上,這是因為人眼對於texture清晰銳利的部份會比較敏感的緣故。

2 Documentation

3 ./ 系統主要分成三部份,前兩塊產生出depth和segment的 資訊之後,可以在第三部份根據不同參數設定產生出不同的 效果
system 1_segmentation Tool1: lazy-snapping with simple UI Tool2: 光影魔術手 2_depthmap depth of background scene (3d-box) depth of each segment 3_refocusblur camera parameter refocusing (inpainting, defocus blur) sample // sample input, parameter and result

4 Segmentation Lazy snapping
Tool1: preprocessing(resize for mean shift ) + lazy snapping Lzsegment.m Input : parameter file name 先做preprocessing,這裡可以用meanshift或是直接downsample成64色階 ,並且在meanshift的地方resize為五分之一加快速度, 讀取stroke_1.bmp, stroke_2.bmp…等前後景筆劃圖,前景是紅色,後景是藍色。然後執行lazy snapping處理 ◎每個segment都存一個灰階的bmp檔,檔名分別是seg_1.bmp, seg_2.bmp…沒有先後順序。將每個segment扣除剩下的background的部份,即是seg_segN.bmp ◎需要libgil2的library Tool2: 光影魔術手 每個segment都存一個png檔,檔名分別是obj_1.png, obj_2.png…將這些png檔的alpha值轉成bmp, 並且扣除只剩下background的部份,即是seg_segN.bmp

5 Depth map depth.m (function depth(parafilename)) Input: nx ny Output:
parameter file name dep_1.dat, dep_2.dat, …dep_(segN-1).dat ★ 每個dep_n.dat的內容: nx ny p1x p1y p2x p2y ★ n表示normal vector, 預設是 (0,0), vector方向代表物體在平面上的法向量方向,長度表示深度變化量 ★ p1,p2…是user劃下的筆劃座標,即此segment的深度參考點,預設是segment最下方的點。如果沒有p1,p2…系統會自動取segment最下方一列的點作為參考點。 Output: dep_1.bmp, dep_2.bmp … dep_segN.bmp

6 Refocus Blur refocus.m ( function [finalresult]=defocus(parafilename) ) Get parameter from file, and load the segment/depth bmp files Get the focus position from focusposition.dat Compute diffusion blur circle diameter for each pixel Devide image into two parts, the part in front of the focus, and run defocus_blur.m Use alpha.m to get alpha map, and find the pixels to run inpaint.m Use the result by inpaint.m to call defocus_blur.m Combine the front part and back part by alpha map return the result image

7 others Inpainting function needs the estexemplarhelper.c
run mex estexemplarhelper.c before the function call at first time The inpainting code (inpaint.m) is from Meanshift code is downloaded from

8 中間檔案/參數 Generate from for
focuspoint.dat UI畫定 refocus.m 的聚焦點資訊 dep_1.dat, dep_2.dat … depth.m每個segment的深度參考點和normal值,如果沒有給予參考點則視為最下方一排 stroke_1.bmp, stroke_2.bmp… Lazy snapping 的前後景分割依據 seg_1.bmp, seg_2.bmp… lzsegment.m 產生,或是用tool2取得obj.png之後,用seg_png2bmp.m產生 depth.m和refocus.m都需要用到的segment map dep_1.bmp, dep_2.bmp… depth.m產生 refocus.m需要用到的深度資訊 v1,v2,a1,a2,b1,b2.. Vanish box和消失點座標,可用UI介面畫定 depth.m產生背景深度資訊所需要 其他camera 參數 使用者自行調整

9 Input parameter file 1.dirname diratory of the files, include '/' on the tail, ex: 'sample1/' 2.imagename file name of input image, ex: test.jpg 3.segN number of segment image, include the background. ex: 2 (foreground*1+background) 4.vx position of vanish point, must be in the rear wall, 5.vy but can be outside of the image 6.ax 7.ay left_top position of the rear wall 8.bx 9.by right_bottom position of the rear wall 10.dc_f lens focal length,(mm) ex: 50 mm, 100 mm ...etc. 11.dpmax the depth of pixels with color level 255 in depth map, (mm) 12.dnear the depth of pixels with color level 0 in depth map, (mm) 13.dc_N the aperture number 14.thr=250 threshold of bokeh color level 15.light_e=0.5 little constant number for light_weight function 16.lens shape default setting 0 is flat disk

10 Camera parameter dc_f 相機的焦距,單位是mm,數值越大景深越淺, 建議在50~100之間
Dpmax rear wall距離成像平面的距離,建議為5~50公尺 (5000~50000) Dnear 場景裡距離成像平面最近的物體距離, 建議為1公尺,至少要在兩倍焦距以上 dc_N 光圈值,數值越大,光圈孔隙越小,景深越深, 為達到淺景深效果建議值在1.4~2.8之間,越小效果越強 thr=250 將pixel產生散景效果的臨界值,建議不要低於240 light_e=0.5 weight function的明度微調參數,為一個大於0的值, 數值越大明度影響越低,建議為0.5~1之間 lens shape 光圈孔隙的形狀,預設為0 對應到refocus/lens/ 資料夾底下的0.bmp, 1.bmp

11 Sample ./ ./sample01 parameter01-.dat original image
seg_1.bmp seg_2.bmp … dep_1.dat dep_2.dat … 可由UI產生 focusposition.dat 可由UI產生,給定要聚焦的點,可以為單一或是多個點,將會取其對應到的深度平均值,格式為 x1 y1 x2 y2 dep_1.bmp dep_2.bmp …

12 執行: 用system的前兩步驟產生出前頁所述的參數和bmp files,並放在所屬資料夾下
result = refocus(parameter file name);


Download ppt "Background Blurring shadow@cmlab.csie.ntu.edu.tw 這張照片除了中間樹叢的部份,往前或往後都是模糊的,於是我們很自然的就會把焦點放在中間清楚的樹叢上,這是因為人眼對於texture清晰銳利的部份會比較敏感的緣故。"

Similar presentations


Ads by Google