I have experienced many cases where I can extract a path with the IterateNeighborhoodOptimizer but where the GradientDescentOptimizer does not start to decent even though the speed function is continuous (based on a binary segmentation), apparently because the initial local gradient is calculated to be zero (even though start- and end-point, speed function etc are kept the same).
I have a vague feeling that this thresholding:
|
// NOTE: The cost function may undefined / unreachable areas |
|
// (indicated by very large values) which may skew the gradient. |
|
// To avoid this skewing effect, we reset gradient values larger |
|
// than a given threshold. |
|
if ( itk::Math::abs (derivative[i]) > DerivativeThreshold ) |
|
{ |
|
derivative[i] = 0.0; |
|
} |
to a hard coded value of
15.0:
|
constexpr typename DerivativeType::ValueType DerivativeThreshold = 15.0; |
could be the culprit.
Another possible reason I could imagine is that the floating point precision might not suffice under some circumstances to calculate a non-zero gradient even if there is no extrema in the cost function at the current optimizer position.
I use this CLI for the testing:
https://github.com/romangrothausmann/ITK-CLIs/blob/bfb1312142d505cacd6770e4d5acc23475290c8f/min-path_seg.cxx
I have experienced many cases where I can extract a path with the IterateNeighborhoodOptimizer but where the GradientDescentOptimizer does not start to decent even though the speed function is continuous (based on a binary segmentation), apparently because the initial local gradient is calculated to be zero (even though start- and end-point, speed function etc are kept the same).
I have a vague feeling that this thresholding:
ITKMinimalPathExtraction/include/itkSingleImageCostFunction.hxx
Lines 145 to 152 in 6ae35b9
to a hard coded value of
15.0:ITKMinimalPathExtraction/include/itkSingleImageCostFunction.hxx
Line 140 in 6ae35b9
could be the culprit.
Another possible reason I could imagine is that the floating point precision might not suffice under some circumstances to calculate a non-zero gradient even if there is no extrema in the cost function at the current optimizer position.
I use this CLI for the testing:
https://github.com/romangrothausmann/ITK-CLIs/blob/bfb1312142d505cacd6770e4d5acc23475290c8f/min-path_seg.cxx