Rework stretch to use just MTF

This commit is contained in:
2022-04-06 13:12:47 +02:00
parent 31783dbdeb
commit 2ff1b993a1
8 changed files with 93 additions and 135 deletions
+7 -26
View File
@@ -41,13 +41,13 @@ ImageWidget::ImageWidget(QWidget *parent) : QOpenGLWidget(parent)
setFocusPolicy(Qt::ClickFocus);
m_range = UINT16_MAX;
m_low = 0;
m_mid = 0.5;
m_high = 1;
m_dx = m_dy = 0;
m_scale = 1.0f;
m_blockRepaint = false;
m_range = UINT16_MAX;
m_imgWidth = m_imgHeight = -1;
m_stretch = 0;
}
ImageWidget::~ImageWidget()
@@ -67,6 +67,7 @@ void ImageWidget::setImage(RawImage *image)
m_image->destroy();
m_image->setFormat(rawImageType.textureFormat);
m_image->setSize(image->width(), image->height());
m_image->setMipLevels([&](){ int c = 0; int s = std::min(m_imgWidth, m_imgHeight); while(s>>=1)c++; return c; }());
m_image->allocateStorage();
m_image->setMinMagFilters(QOpenGLTexture::LinearMipMapLinear, QOpenGLTexture::Linear);
m_image->setWrapMode(QOpenGLTexture::ClampToEdge);
@@ -105,28 +106,11 @@ void ImageWidget::blockRepaint(bool block)
if(!block)update();
}
void ImageWidget::setLow(int low)
void ImageWidget::setMTFParams(float low, float mid, float high)
{
m_low = low/m_range;
update();
}
void ImageWidget::setHigh(int high)
{
m_high = high/m_range;
update();
}
void ImageWidget::setStrech(int stretch)
{
m_stretch = stretch;
update();
}
void ImageWidget::setStretchParam(float param)
{
qDebug() << param;
m_param = param;
m_low = low;
m_mid = mid;
m_high = high;
update();
}
@@ -169,13 +153,10 @@ void ImageWidget::paintGL()
if(height() > m_image->height()*m_scale)
dy = -height()*0.5f + m_image->height()*m_scale*0.5f;
float s = 1.0f/(m_high-m_low);
m_program->bind();
m_program->setUniformValue("scale", s, -m_low*s);
m_program->setUniformValue("viewport", (float)width(), (float)height());
m_program->setUniformValue("offset", dx, dy);
m_program->setUniformValue("stretch", m_stretch);
m_program->setUniformValue("a", m_param);
m_program->setUniformValue("mtf_param", m_low, m_mid, m_high);
m_program->setUniformValue("zoom", 1.0f/m_scale);
m_program->setUniformValue("bw", m_bwImg);