I would like to ask about the SGM method, where the formulas for the P1 and P2 penalty terms come from, and how the parameters in the formula are determined.
// - P1 and P2s are algorithm constants very similar to those from the original SGM algorithm;
// they are set to defaults according to the patch size
// - alpha & beta form the final P2 as P2(1+alphae^(-DI^2/(2*beta^2)))
// where DI is the difference in image intensity I(x)-I(x_prev) in [0,255] range
// - subpixelSteps represents how much sub-pixel accuracy is searched/stored;
// if 1 no sub-pixel precision, if for example 4 a 0.25 sub-pixel accuracy is stored;
// the stored value is quantized and represented as integer: val=(float)valStored/subpixelSteps
SemiGlobalMatcher::SemiGlobalMatcher(SgmSubpixelMode _subpixelMode, Disparity _subpixelSteps, AccumCost _P1, AccumCost P2, float P2alpha, float P2beta)
:
subpixelMode(_subpixelMode),
subpixelSteps(_subpixelSteps),
P1(_P1), P2s(GenerateP2s(P2, P2alpha, P2beta))
{
}
I would like to ask about the SGM method, where the formulas for the P1 and P2 penalty terms come from, and how the parameters in the formula are determined.
openMVS/libs/MVS /SemiGlobalMatcher.cpp
// - P1 and P2s are algorithm constants very similar to those from the original SGM algorithm; // they are set to defaults according to the patch size // - alpha & beta form the final P2 as P2(1+alphae^(-DI^2/(2*beta^2))) // where DI is the difference in image intensity I(x)-I(x_prev) in [0,255] range // - subpixelSteps represents how much sub-pixel accuracy is searched/stored; // if 1 no sub-pixel precision, if for example 4 a 0.25 sub-pixel accuracy is stored; // the stored value is quantized and represented as integer: val=(float)valStored/subpixelSteps SemiGlobalMatcher::SemiGlobalMatcher(SgmSubpixelMode _subpixelMode, Disparity _subpixelSteps, AccumCost _P1, AccumCost P2, float P2alpha, float P2beta) : subpixelMode(_subpixelMode), subpixelSteps(_subpixelSteps), P1(_P1), P2s(GenerateP2s(P2, P2alpha, P2beta)) { }
openMVS/libs/MVS /SemiGlobalMatcher.h
SemiGlobalMatcher(SgmSubpixelMode subpixelMode=SUBPIXEL_LC_BLEND, Disparity subpixelSteps=4, AccumCost P1=3, AccumCost P2=4, float P2alpha=14, float P2beta=38);