Add scaling for float images that are out of 0.0-1.0 range
This commit is contained in:
+14
-1
@@ -113,7 +113,19 @@ void ImageWidget::setImage(std::shared_ptr<RawImage> image, int index)
|
||||
m_image->generateMipMaps();
|
||||
qDebug() << "setImage" << timer.elapsed();
|
||||
|
||||
|
||||
m_unit_scale[0] = 1.0f;
|
||||
m_unit_scale[1] = 0.0f;
|
||||
auto &stats = image->imageStats();
|
||||
if(image->type() == RawImage::FLOAT32 || image->type() == RawImage::FLOAT64)
|
||||
{
|
||||
float min = *std::min_element(stats.m_min, stats.m_min + 4);
|
||||
float max = *std::max_element(stats.m_max, stats.m_max + 4);
|
||||
if(min < 0.0f || max > 1.0f)
|
||||
{
|
||||
m_unit_scale[0] = 1.0f / (max - min);
|
||||
m_unit_scale[1] = min * m_unit_scale[0];
|
||||
}
|
||||
}
|
||||
|
||||
if(m_debayerTex)
|
||||
{
|
||||
@@ -363,6 +375,7 @@ void ImageWidget::paintGL()
|
||||
m_program->setUniformValue("viewport", (float)width(), (float)height());
|
||||
m_program->setUniformValue("offset", std::floor(dx), std::floor(dy));
|
||||
m_program->setUniformValueArray("mtf_param", m_mtfParams.blackPoint, 3, 3);
|
||||
m_program->setUniformValue("unit_scale", m_unit_scale[0], m_unit_scale[1]);
|
||||
m_program->setUniformValue("zoom", 1.0f/m_scale);
|
||||
m_program->setUniformValue("bw", m_bwImg && !m_superpixel);
|
||||
m_program->setUniformValue("false_color", m_falseColor && m_bwImg);
|
||||
|
||||
Reference in New Issue
Block a user