Class SgmCostAggregation

java.lang.Object
boofcv.alg.disparity.sgm.SgmCostAggregation

public class SgmCostAggregation extends Object

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 16-bit 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(p-r,d )
b = Lr(p-r,d-1) + penalty1
c = Lr(p-r,d+1) + penalty1

cost = min(penalty2,b,c) + a

Lr(p,d) is the cost along the path at 'p' and disparity 'd'. penalty1 in the penalty associated with a small change in disparity and penalty2 is a large change in disparity

The equation above has been modified from what is stated in [1]. One of the equations is likely to have a type-o 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): 328-341.

See Also:
  • Field Details

  • 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

      public void process(Planar<GrayU16> costYXD)
      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

      public Planar<GrayU16> 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)