Handle coded thresholds

This commit is contained in:
Dan Paulat 2022-04-10 11:21:15 -05:00
parent cc36922e99
commit cf3c780abf

View file

@ -174,22 +174,23 @@ void Level3ProductView::UpdateColorTable()
lut.resize(numberOfLevels - rangeMin); lut.resize(numberOfLevels - rangeMin);
lut.shrink_to_fit(); lut.shrink_to_fit();
std::for_each(std::execution::par_unseq, std::for_each(
std::execution::par_unseq,
dataRange.begin(), dataRange.begin(),
dataRange.end(), dataRange.end(),
[&](uint16_t i) [&](uint16_t i)
{ {
if (i == RANGE_FOLDED && threshold > RANGE_FOLDED) const size_t lutIndex = i - *dataRange.begin();
{
lut[i - *dataRange.begin()] = p->colorTable_->rf_color();
}
else
{
float f; float f;
// Different products use different scale/offset // Different products use different scale/offset formulas
// formulas
if (numberOfLevels > 16) if (numberOfLevels > 16)
{
if (i == RANGE_FOLDED && threshold > RANGE_FOLDED)
{
lut[lutIndex] = p->colorTable_->rf_color();
}
else
{ {
switch (descriptionBlock->product_code()) switch (descriptionBlock->product_code())
{ {
@ -211,13 +212,35 @@ void Level3ProductView::UpdateColorTable()
f = i * scale + offset; f = i * scale + offset;
break; break;
} }
lut[lutIndex] = p->colorTable_->Color(f);
}
} }
else else
{ {
f = descriptionBlock->data_level_threshold(i); uint16_t th = descriptionBlock->data_level_threshold(i);
if ((th & 0x8000u) == 0)
{
// If bit 0 is zero, then the LSB is numeric
f = static_cast<float>(th);
lut[lutIndex] = p->colorTable_->Color(f);
} }
else
{
// If bit 0 is one, then the LSB is coded
uint16_t lsb = th & 0x00ffu;
lut[i - *dataRange.begin()] = p->colorTable_->Color(f); switch (lsb)
{
case 3: // RF
lut[lutIndex] = p->colorTable_->rf_color();
break;
default: // Ignore other values
lut[lutIndex] = boost::gil::rgba8_pixel_t {0, 0, 0, 0};
break;
}
}
} }
}); });