Class SgmCostAggregation
Aggregates the cost along different paths to compute the final cost. Cost is summed up inside of a tensor of size H*W*D with 16bit unsigned elements. At most 16 directions can be considered. In general more paths that are considered the smoother the disparity will be. The cost of a single path is done using a dynamic programming approach. This step is the major step that makes SGM what it is.
See [1] for details, but the cost for each element along a path is specified as follows:
a = Lr(pr,d )
b = Lr(pr,d1) + penalty1
c = Lr(pr,d+1) + penalty1
cost = min(penalty2,b,c) + a
The equation above has been modified from what is stated in [1]. One of the equations is likely to have a typeo in it because their formula doesn't have the stated properties. A simple modification prevents the cost variables from overflowing.
[1] Hirschmuller, Heiko. "Stereo processing by semiglobal matching and mutual information." IEEE Transactions on pattern analysis and machine intelligence 30.2 (2007): 328341.

Field Summary

Constructor Summary

Method Summary
Modifier and TypeMethodDescriptionvoid
configure
(int disparityMin) Configures the minimum disparity.int
int
int
void
Aggregates the cost in the tensor `costYXD`.void
setPathsConsidered
(int pathsConsidered) void
setPenalty1
(int penalty1) void
setPenalty2
(int penalty2)

Field Details

helper


Constructor Details

SgmCostAggregation
public SgmCostAggregation()


Method Details

configure
public void configure(int disparityMin) Configures the minimum disparity. The range is specified implicitly by the cost tensor. Parameters:
disparityMin
 The minimum disparity that will be considered

process
Aggregates the cost in the tensor `costYXD`. From the aggregated cost the disparity can be computed. The input is a tensor 3D stored in a planar image. The name refers to the order data is stored. (Y,X,D) = (band,row,col). D = disparity and is relative to some minimum disparity. Parameters:
costYXD
 Cost for all possible combinations of x,y,d in input image.

getAggregated

getPenalty1
public int getPenalty1() 
setPenalty1
public void setPenalty1(int penalty1) 
getPenalty2
public int getPenalty2() 
setPenalty2
public void setPenalty2(int penalty2) 
getPathsConsidered
public int getPathsConsidered() 
setPathsConsidered
public void setPathsConsidered(int pathsConsidered)
