首先,以3x3的MRF為例。
上圖中的一些概念:
藍色節點:觀察量。在Stereo Matching問題中是pixel intensity;
粉色節點:隱變量。在Stereo Matching中表示待求視差值,即labels;
無向邊: 表示節點之間的依賴關系。根據MRF Assumption - 一個節點的狀態僅取決與其相鄰的節點,那么一個隱節點的標簽值只和其4個相鄰隱節點以及觀察節點有關系。
MRF formulation
變量Y和X分別表示觀察量和隱藏量。
其物理意義 - sums up all the cost at each link given an image Y and some labeling X. The aim is to find a labeling for X that produces the lowest energy.
DataCost - matching cost in stereo matching.
SmoothnessCost - pairwise energy/term/potential. 用來約束兩個相鄰節點之間labels的關系。常用的有一下幾種:
Solve the Energy Function - Loopy Belief Propagation
從Belief Propagation演變而來,原本BP是針對Tree結構的算法。當變成可以出現loop的無向圖(MRF)之后,出現了LBP。不一定收斂。
LBP is a message passing algorithm.
如圖,節點x1傳遞給x2的message包括所有incoming message,除了x2到x1的message。
定義節點i到節點j的消息量為:
node i sends a message to node j about label l. It's node i's belief about node j regarding label l. - 是節點i關于節點j取值l時候的belief。
Belief 取值為cost/penalty/probabilities 依賴于MRF energy formulation。
message passing is only performed on the hidden nodes。
Implementation of the LBP algorithm
function LoopyBeliefPropgation
initialise all messages
for t iterations
at every pixel pass messages right
at every pixel pass messages left
at every pixel pass messages up
at every pixel pass messages down
end for
find the best label at every pixel i by calculating belief
end
對于存在loop的無向圖,message passing 理論上會是一個無限等待的過程,實現的時候可以將所有message初始化為0/1;
每次迭代都會更新每個節點的belief的值,通過最優(大/小)選擇每個節點的標簽值。
LBP細節上可以分為3個部分:
- message update
- message initialization
- belief
Three Different Algorithm for LBP
- sum-product
- max-product
- min-sum
1. Sum-Product
message update
其中, exp函數將Datacost/Smoothness轉換為0-1之間的valid probability
the outer summation is a marginalization of the variable l';
the inner product is the joint probability of DataCost, SmoothnessCost and all the incoming messages for a given label l';
算法復雜度是: O(L^2)
normalization
initialization
all messages are initialized as 1.
belief
a product of all incoming messages
it presents the belief that node i takes on label l. 計算每個標簽的belief值,得到最大belief所對應的標簽值。
2. Max-Product
sum-product計算并最大化每個節點的Belief,考察的是節點的marginal probability。But, what we are really interested in is the max joint probability -- i.e. maximum a posterior (MAP) assignment problem.
digression : 可以理解posterior為條件概率
message update
belief calculation 是相同的
3. Min-Sum
算法同Max-Product,轉換到log空間,從而求解最大乘積轉換為最小和。
message update
message initialization
due to minimization - all messages should be initialized as 0
message normalization
in log space:
**belief”
小結:
Min-Sum 算法效率最高,無exp() and all operations are addition
Sum-Product 算法中,為了避免overflow,可以使用scaling
實際上,能量最小也不一定對應了最優的結果。可以做一個實驗,用ground-truth disparity來計算energy,會發現energy的值比最終LBP計算的能量值要更大。應該更多的考慮occlusion。