27 float SlowValueToBoundedFloat(
const uint16 value,
const uint16 unknown_value,
28 const float unknown_result,
29 const float lower_bound,
30 const float upper_bound) {
32 CHECK_LE(value, 32767);
33 if (value == unknown_value)
return unknown_result;
34 const float kScale = (upper_bound - lower_bound) / 32766.f;
35 return value * kScale + (lower_bound - kScale);
38 std::unique_ptr<std::vector<float>> PrecomputeValueToBoundedFloat(
39 const uint16 unknown_value,
const float unknown_result,
40 const float lower_bound,
const float upper_bound) {
41 auto result = common::make_unique<std::vector<float>>();
44 for (
int repeat = 0; repeat != 2; ++repeat) {
45 for (
int value = 0; value != 32768; ++value) {
46 result->push_back(SlowValueToBoundedFloat(
47 value, unknown_value, unknown_result, lower_bound, upper_bound));
53 std::unique_ptr<std::vector<float>> PrecomputeValueToProbability() {
59 std::unique_ptr<std::vector<float>> PrecomputeValueToCorrespondenceCost() {
60 return PrecomputeValueToBoundedFloat(
68 PrecomputeValueToProbability().release();
71 PrecomputeValueToCorrespondenceCost().release();
74 std::vector<uint16> result;
77 for (
int cell = 1; cell != 32768; ++cell) {
79 odds *
Odds((*kValueToProbability)[cell]))) +
87 std::vector<uint16> result;
91 for (
int cell = 1; cell != 32768; ++cell) {
96 (*kValueToCorrespondenceCost)[cell]))))) +
const std::vector< float > *const kValueToCorrespondenceCost
std::vector< uint16 > ComputeLookupTableToApplyOdds(const float odds)
std::vector< uint16 > ComputeLookupTableToApplyCorrespondenceCostOdds(float odds)
float ProbabilityFromOdds(const float odds)
constexpr float kMinProbability
constexpr float kMaxCorrespondenceCost
constexpr float kMaxProbability
float CorrespondenceCostToProbability(const float correspondence_cost)
float Odds(float probability)
const std::vector< float > *const kValueToProbability
constexpr uint16 kUnknownProbabilityValue
float ProbabilityToCorrespondenceCost(const float probability)
uint16 ProbabilityToValue(const float probability)
uint16 CorrespondenceCostToValue(const float correspondence_cost)
constexpr uint16 kUpdateMarker
constexpr uint16 kUnknownCorrespondenceValue
constexpr float kMinCorrespondenceCost