Add support for invert and super pixel

This commit is contained in:
2022-04-09 11:10:07 +02:00
parent 68fbcfbb59
commit 46a4715ce5
11 changed files with 150 additions and 126 deletions
+101
View File
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="32mm"
height="32mm"
viewBox="0 0 32 32"
version="1.1"
id="svg5"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
sodipodi:docname="bayer.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="mm"
showgrid="false"
width="32mm"
inkscape:zoom="3.7543719"
inkscape:cx="37.423037"
inkscape:cy="62.194158"
inkscape:window-width="1868"
inkscape:window-height="1136"
inkscape:window-x="52"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs2">
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath2897">
<circle
style="opacity:1;fill:#ffff00;fill-opacity:0.677435;stroke:#00000d;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="circle2899"
cx="16"
cy="16"
r="15.999999" />
</clipPath>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath3346">
<rect
style="opacity:1;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect3348"
width="15.999999"
height="31.999998"
x="5.6671934e-07"
y="5.6671934e-07" />
</clipPath>
</defs>
<g
inkscape:label="Vrstva 1"
inkscape:groupmode="layer"
id="layer1">
<ellipse
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="ellipse3320"
cx="16"
cy="16.016155"
ry="6.0161538"
rx="5.9999995"
clip-path="url(#clipPath3346)" />
<rect
style="opacity:1;fill:#00ff00;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect3583"
width="15.999998"
height="15.999999"
x="1.0560926e-06"
y="1.0560926e-06" />
<rect
style="opacity:1;fill:#00ff00;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect3687"
width="15.999998"
height="15.999999"
x="15.999999"
y="16" />
<rect
style="opacity:1;fill:#ff0000;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect3689"
width="15.999998"
height="15.999999"
x="15.999999"
y="1.0560926e-06" />
<rect
style="opacity:1;fill:#0000ff;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect3691"
width="15.999998"
height="15.999999"
x="1.0560926e-06"
y="16" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.5 KiB

+3
View File
@@ -4,6 +4,7 @@ uniform sampler2D qt_Texture0;
in vec2 qt_TexCoord0;
uniform vec3 mtf_param;
uniform bool bw;
uniform bool invert;
out vec4 color;
vec4 MTF(vec4 x, vec3 m)
@@ -19,6 +20,8 @@ void main(void)
if(bw)color = color.rrra;
color = MTF(color, mtf_param);
if(invert)color = vec4(1.0) - color;
if(any(lessThan(qt_TexCoord0, vec2(0.0))) || any(greaterThan(qt_TexCoord0, vec2(1.0))))
color = vec4(0.0);
}
+17 -1
View File
@@ -53,6 +53,7 @@ ImageWidget::ImageWidget(QWidget *parent) : QOpenGLWidget(parent)
m_blockRepaint = false;
m_range = UINT16_MAX;
m_imgWidth = m_imgHeight = -1;
m_superpixel = m_invert = false;
}
ImageWidget::~ImageWidget()
@@ -60,7 +61,7 @@ ImageWidget::~ImageWidget()
makeCurrent();
}
void ImageWidget::setImage(RawImage *image)
void ImageWidget::setImage(const RawImage *image)
{
if(image == nullptr)return;
@@ -78,6 +79,7 @@ void ImageWidget::setImage(RawImage *image)
m_image->setWrapMode(QOpenGLTexture::ClampToEdge);
m_image->setBorderColor(0, 0, 0, 0);
m_image->setData(0, rawImageType.pixelFormat, rawImageType.dataType, image->data(), m_transferOptions.get());
m_image->setLevelOfDetailRange(m_superpixel ? 1 : 0, m_image->mipMaxLevel());
m_image->generateMipMaps();
m_bwImg = rawImageType.bw;
update();
@@ -126,6 +128,19 @@ void ImageWidget::setOffset(int dx, int dy)
update();
}
void ImageWidget::superPixel(bool enable)
{
m_superpixel = enable;
m_image->setLevelOfDetailRange(enable ? 1 : 0, m_image->mipMaxLevel());
update();
}
void ImageWidget::invert(bool enable)
{
m_invert = enable;
update();
}
QImage ImageWidget::renderToImage()
{
if(m_imgWidth < 0)return QImage();
@@ -164,6 +179,7 @@ void ImageWidget::paintGL()
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);
m_program->setUniformValue("invert", m_invert);
m_image->bind(0);
f->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+5 -1
View File
@@ -40,16 +40,20 @@ class ImageWidget : public QOpenGLWidget
float m_scale;
bool m_blockRepaint;
bool m_bwImg;
bool m_invert;
bool m_superpixel;
public:
explicit ImageWidget(QWidget *parent = nullptr);
~ImageWidget();
void setImage(RawImage *image);
void setImage(const RawImage *image);
void setImage(const QPixmap &pixmap);
void setScale(float scale);
void blockRepaint(bool block);
public slots:
void setMTFParams(float low, float mid, float high);
void setOffset(int dx, int dy);
void superPixel(bool enable);
void invert(bool enable);
QImage renderToImage();
protected:
void paintGL();
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

+2
View File
@@ -44,6 +44,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
m_stretchPanel = new StretchPanel(this);
connect(m_stretchPanel, SIGNAL(paramChanged(float,float,float)), m_imageGL->imageWidget(), SLOT(setMTFParams(float,float,float)));
connect(m_stretchPanel, &StretchPanel::autoStretch, [&](){ m_stretchPanel->stretchImage(m_ringList->currentImage().get()); });
connect(m_stretchPanel, &StretchPanel::invert, m_imageGL->imageWidget(), &ImageWidget::invert);
connect(m_stretchPanel, &StretchPanel::superPixel, m_imageGL->imageWidget(), &ImageWidget::superPixel);
m_ringList = new ImageRingList(this);
m_filesystem = new FilesystemWidget(m_ringList, this);
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

-119
View File
@@ -1,119 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="32mm"
height="32mm"
viewBox="0 0 32 32"
version="1.1"
id="svg5"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
sodipodi:docname="nuke.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="mm"
showgrid="false"
width="32mm"
inkscape:zoom="3.7543719"
inkscape:cx="37.423037"
inkscape:cy="62.194158"
inkscape:window-width="1868"
inkscape:window-height="1136"
inkscape:window-x="52"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs2">
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath2897">
<circle
style="opacity:1;fill:#ffff00;fill-opacity:0.677435;stroke:#00000d;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="circle2899"
cx="16"
cy="16"
r="15.999999" />
</clipPath>
</defs>
<g
inkscape:label="Vrstva 1"
inkscape:groupmode="layer"
id="layer1">
<circle
style="opacity:1;fill:#ffff00;fill-opacity:0.677435;stroke:#00000d;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path75"
cx="16"
cy="16"
r="15.999999" />
<g
id="g2793"
clip-path="url(#clipPath2897)"
transform="rotate(-15,16,16)">
<path
sodipodi:type="star"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path2538"
inkscape:flatsided="true"
sodipodi:sides="3"
sodipodi:cx="0.019383565"
sodipodi:cy="0.022225825"
sodipodi:r1="21.288982"
sodipodi:r2="10.644491"
sodipodi:arg1="0.78539816"
sodipodi:arg2="1.8325957"
inkscape:rounded="1.42247e-16"
inkscape:randomized="0"
d="M 15.072967,15.07581 -20.544194,5.53222 5.5293776,-20.541352 Z"
transform="matrix(0.5300977,0,0,0.53009772,8.0098541,8.0083476)"
inkscape:transform-center-x="1.4604177"
inkscape:transform-center-y="-1.4604177" />
<path
sodipodi:type="star"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path2784"
inkscape:flatsided="true"
sodipodi:sides="3"
sodipodi:cx="0.019383565"
sodipodi:cy="0.022225825"
sodipodi:r1="21.288982"
sodipodi:r2="10.644491"
sodipodi:arg1="0.78539816"
sodipodi:arg2="1.8325957"
inkscape:rounded="1.42247e-16"
inkscape:randomized="0"
d="M 15.072967,15.07581 -20.544194,5.53222 5.5293776,-20.541352 Z"
transform="matrix(0.5300977,0,0,0.53009772,26.89043,13.067383)"
inkscape:transform-center-x="1.4604177"
inkscape:transform-center-y="-1.4604177" />
<path
sodipodi:type="star"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path2786"
inkscape:flatsided="true"
sodipodi:sides="3"
sodipodi:cx="0.019383565"
sodipodi:cy="0.022225825"
sodipodi:r1="21.288982"
sodipodi:r2="10.644491"
sodipodi:arg1="0.78539816"
sodipodi:arg2="1.8325957"
inkscape:rounded="1.42247e-16"
inkscape:randomized="0"
d="M 15.072967,15.07581 -20.544194,5.53222 5.5293776,-20.541352 Z"
transform="matrix(0.5300977,0,0,0.53009772,13.068889,26.888924)"
inkscape:transform-center-x="1.4604177"
inkscape:transform-center-y="-1.4604177" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 4.4 KiB

+3 -1
View File
@@ -5,6 +5,8 @@
</qresource>
<qresource prefix="/">
<file>icon.png</file>
<file>nuke.svg</file>
<file>bayer.svg</file>
<file>invert.png</file>
<file>nuke.png</file>
</qresource>
</RCC>
+17 -4
View File
@@ -21,22 +21,35 @@ StretchPanel::StretchPanel(QWidget *parent) : QWidget(parent)
setLayout(layout);
m_stfSlider = new STFSlider(this);
layout->addWidget(m_stfSlider, 0, 0);
layout->addWidget(m_stfSlider);
connect(m_stfSlider, SIGNAL(paramChanged(float, float, float)), this, SIGNAL(paramChanged(float,float,float)));
QToolButton *autoStretchButton = new QToolButton(this);
autoStretchButton->setIcon(QIcon(":/nuke.svg"));
autoStretchButton->setIcon(QIcon(":/nuke.png"));
autoStretchButton->setToolTip(tr("Auto Stretch F12"));
autoStretchButton->setShortcut(Qt::Key_F12);
layout->addWidget(autoStretchButton);
connect(autoStretchButton, SIGNAL(pressed()), this, SIGNAL(autoStretch()));
QToolButton *resetButton = new QToolButton(this);
resetButton->setIcon(style()->standardIcon(QStyle::SP_DialogResetButton));
resetButton->setToolTip(tr("Reset Screen Transfer Function F11"));
resetButton->setShortcut(Qt::Key_F11);
connect(resetButton, &QToolButton::pressed, this, &StretchPanel::resetMTF);
QToolButton *invertButton = new QToolButton(this);
invertButton->setIcon(QIcon(":/invert.png"));
invertButton->setCheckable(true);
connect(invertButton, SIGNAL(toggled(bool)), this, SIGNAL(invert(bool)));
QToolButton *superPixelButton = new QToolButton(this);
superPixelButton->setIcon(QIcon(":/bayer.svg"));
superPixelButton->setCheckable(true);
connect(superPixelButton, SIGNAL(toggled(bool)), this, SIGNAL(superPixel(bool)));
layout->addWidget(autoStretchButton);
layout->addWidget(resetButton);
connect(resetButton, SIGNAL(pressed()), this, SLOT(resetMTF()));
layout->addWidget(invertButton);
layout->addWidget(superPixelButton);
}
void StretchPanel::stretchImage(Image *img)
+2
View File
@@ -18,6 +18,8 @@ public slots:
signals:
void paramChanged(float low, float mid, float high);
void autoStretch();
void invert(bool enable);
void superPixel(bool enable);
};
#endif // STRETCHPANEL_H