Update level 3 color tables for 16-level products

This commit is contained in:
Dan Paulat 2022-04-10 10:41:30 -05:00
parent 2dcd87700c
commit 304297be9b
2 changed files with 38 additions and 27 deletions

View file

@ -152,23 +152,26 @@ void Level3ProductView::UpdateColorTable()
float scale = descriptionBlock->scale();
uint16_t threshold = descriptionBlock->threshold();
// If the threshold is 2, the range min should be set to 1 for range folding
uint16_t rangeMin = std::min<uint16_t>(1, threshold);
uint16_t numberOfLevels = descriptionBlock->number_of_levels();
uint16_t rangeMax = (numberOfLevels > 0) ? numberOfLevels - 1 : 0;
if (p->savedColorTable_ == p->colorTable_ && //
p->savedOffset_ == offset && //
p->savedScale_ == scale)
p->savedScale_ == scale && //
numberOfLevels > 16)
{
// The color table LUT does not need updated
return;
}
// If the threshold is 2, the range min should be set to 1 for range folding
uint16_t rangeMin = std::min<uint16_t>(1, threshold);
uint16_t rangeMax = descriptionBlock->number_of_levels();
// Iterate over [rangeMin, numberOfLevels)
boost::integer_range<uint16_t> dataRange =
boost::irange<uint16_t>(rangeMin, rangeMax + 1);
boost::irange<uint16_t>(rangeMin, numberOfLevels);
std::vector<boost::gil::rgba8_pixel_t>& lut = p->colorTableLut_;
lut.resize(rangeMax - rangeMin + 1);
lut.resize(numberOfLevels - rangeMin);
lut.shrink_to_fit();
std::for_each(std::execution::par_unseq,
@ -184,7 +187,10 @@ void Level3ProductView::UpdateColorTable()
{
float f;
// Different products use different scale/offset formulas
// Different products use different scale/offset
// formulas
if (numberOfLevels > 16)
{
switch (descriptionBlock->product_code())
{
case 159:
@ -205,6 +211,11 @@ void Level3ProductView::UpdateColorTable()
f = i * scale + offset;
break;
}
}
else
{
f = descriptionBlock->data_level_threshold(i);
}
lut[i - *dataRange.begin()] = p->colorTable_->Color(f);
}

View file

@ -528,11 +528,11 @@ uint16_t ProductDescriptionBlock::number_of_levels() const
break;
case 134:
numberOfLevels = 254;
numberOfLevels = 256;
break;
case 135:
numberOfLevels = 199;
numberOfLevels = 200;
break;
case 138: