vfx 2015 Spring @ CSIE.NTU.EDU.TW
project #1: High Dynamic Range Imaging (original link)
使用matlab2014撰寫,執行program資料夾中的main.m,參數都在main.m中最上方修改,output會有hdr和tone mapping後的結果在program資料夾中
% folder: the (relative) path containing the image set.
% type_: 'global' or 'local' tone mapping
% phi: used by local tone mapping
% epsilon: used by local tone mapping (find the max gaussian scale)
% lambda: smoothness factor for gsolve.
% prefix: output LDR file's prefix name
% [srow scol]: the dimension of the resized image for sampling in gsolve.
% shift_bits: the maximum number of bits in the final offsets in
% alignment.
%
function main(folder, type_, alpha_, delta_, white_, phi, epsilon, lambda, prefix, srow, scol, shift_bits)
- alignment
- hdr
- tonemapping(global operator)
- tonemapping(local operator)
將圖片RGB資訊轉成灰階,方便後續採取Median Threshold Bitmap方法對位,為了增加對位的精準以及處理速度,把原圖尺寸一直縮小二分之一 到最後有七張不同尺寸等級的圖片,以論文裡的演算法對每兩張不同曝光時間的照片互相比較,並將每次位移暫存並移動,其餘部分填上黑色,從最小尺寸等級一直到原尺寸,完成alignment對位.
- 直接利用matlab指令將圖片RGB資訊轉成灰階
- 原圖尺寸一直縮小二分之一,到最後每張不同曝光時間的照片一共分別有七張不同尺寸
- 計算所有圖片的中位數,圖片裡的像素若大於中位數計為1,否則為0.第二種方法為找出所有像素在中位數±4範圍內,並記為0,其餘記為1.
- 使用上述兩種方法對每兩張不同曝光時間的圖片進行八個不同方位的比較,算出一個最佳位置
- 從尺寸最小的圖片往上做比較,進行對位
1.我們參考Paul E. Debevec 論文中所提到的演算法,最小化目標方程式
2.滿足矩陣Ax=b,以SVD求解矩陣x,得到g函數,帶入權重值及曝光時間lnΔt
3.計算多張不同曝光時間同像素的點,找出其算術平均值得到HDR圖像
1.Tone Mapping目的為將HDR轉為LDR,假設
####Lw=0.27R+0.67G+0.06B
2.先在圖像中取得每一點的亮度值並取log,取得平均值再做exponetional
3.定義normal-key a值為0.18,並代入平均亮度Lw至下列方程式求得Lm
4.設定場景中最大亮度為1.5,求得Ld
5.最後重新計算LDR每個channel的亮度值
1.找出一定範圍內,使得所有像素亮度都差不多,沒有任何的sharp contrast,對亮度分佈Lm與Gaussian profile做摺積(convolution)轉換, 並拿兩張Gaussian blurred images相減,由於要找出V1與V2在相近區域內有相同的亮度梯度(luminance gradient),給予一個threshold ε,流程如下
2.求得Ld,最後重新計算LDR每個channel的亮度值
##Result
由於原圖之間差異太小,看不出來效果,我們故意拿一張圖位移很多來測試,設定在7層(最大位移為2^7)時會移回來 input: 圖一
圖一位移後 ![test2](https://cloud.githubusercontent.com/assets/11717755/7038036/34aeb92a-ddde-11e4-962c-30bf6e5821e2.jpg) output: ![alignment_test](https://cloud.githubusercontent.com/assets/11717755/7038041/52d82fb2-ddde-11e4-8bc9-f3d5df46f2d8.png) 另外,照片之間差異小時,層數設太大反而會因為照片曝光差太多而失敗,通常設定3層可以得到較好的比較結果input: f4 2"
f4 1" f4 0.5" f4 1/5 f4 1/8 f4 1/15 f4 1/30 output:input:用hdr演算法得到的output(同上圖)
output:a越大圖整體越亮,white越大亮部細節增加,但亮部細節增加的同時暗步細節也會消失,因此需要local的tone mapping來改善
input:用hdr演算法得到的output(同上上圖)
output:
a = 0.5, phi = 8, epsilon = 0.05
可看出和global的結果比起來,local的邊緣較銳利,顏色相近的區域中對比較高
###比較:使用matlab tone mapping function得到的結果(下圖) 整體色調和相機拍到的照片以及hdr檔差很多,從paper實作的結果似乎比較好