Add additional colormaps
This commit is contained in:
@@ -58,6 +58,11 @@ void ImageScrollArea::setBayerMask(int mask)
|
|||||||
m_imageWidget->setBayerMask(mask);
|
m_imageWidget->setBayerMask(mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImageScrollArea::setColormap(int colormap)
|
||||||
|
{
|
||||||
|
m_imageWidget->setColormap(colormap);
|
||||||
|
}
|
||||||
|
|
||||||
void ImageScrollArea::updateScrollbars(int valueH, int stepH, int maxH, int valueV, int stepV, int maxV)
|
void ImageScrollArea::updateScrollbars(int valueH, int stepH, int maxH, int valueV, int stepV, int maxV)
|
||||||
{
|
{
|
||||||
if(maxH > 0)
|
if(maxH > 0)
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ public:
|
|||||||
void allocateThumbnails(const QStringList &paths);
|
void allocateThumbnails(const QStringList &paths);
|
||||||
void showThumbnail(bool enable);
|
void showThumbnail(bool enable);
|
||||||
void setBayerMask(int mask);
|
void setBayerMask(int mask);
|
||||||
|
void setColormap(int colormap);
|
||||||
protected:
|
protected:
|
||||||
void updateScrollbars(int valueH, int stepH, int maxH, int valueV, int stepV, int maxV);
|
void updateScrollbars(int valueH, int stepH, int maxH, int valueV, int stepV, int maxV);
|
||||||
public slots:
|
public slots:
|
||||||
|
|||||||
@@ -258,6 +258,12 @@ void ImageWidgetGL::setBayerMask(int mask)
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImageWidgetGL::setColormap(int colormap)
|
||||||
|
{
|
||||||
|
m_colormapIdx = colormap;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
void ImageWidgetGL::setMTFParams(const MTFParam ¶ms)
|
void ImageWidgetGL::setMTFParams(const MTFParam ¶ms)
|
||||||
{
|
{
|
||||||
m_mtfParams = params;
|
m_mtfParams = params;
|
||||||
@@ -600,6 +606,7 @@ void ImageWidgetGL::paintGL()
|
|||||||
m_program->setUniformValue("filtering", m_scale > 1.0f ? FILTERING : 1);
|
m_program->setUniformValue("filtering", m_scale > 1.0f ? FILTERING : 1);
|
||||||
m_program->setUniformValue("lut_table", 2);
|
m_program->setUniformValue("lut_table", 2);
|
||||||
m_program->setUniformValue("srgb", m_srgb);
|
m_program->setUniformValue("srgb", m_srgb);
|
||||||
|
m_program->setUniformValue("colormapIdx", m_colormapIdx);
|
||||||
f->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
f->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
m_vao->release();
|
m_vao->release();
|
||||||
}
|
}
|
||||||
@@ -702,6 +709,7 @@ void ImageWidgetGL::initializeGL()
|
|||||||
m_program->setAttributeBuffer("qt_MultiTexCoord0", GL_FLOAT, sizeof(float)*2, 2, sizeof(float)*4);
|
m_program->setAttributeBuffer("qt_MultiTexCoord0", GL_FLOAT, sizeof(float)*2, 2, sizeof(float)*4);
|
||||||
m_program->setUniformValue("qt_Texture0", (GLuint)0);
|
m_program->setUniformValue("qt_Texture0", (GLuint)0);
|
||||||
m_program->setUniformValue("lut_table", (GLuint)2);
|
m_program->setUniformValue("lut_table", (GLuint)2);
|
||||||
|
m_program->setUniformValue("colormap", (GLuint)3);
|
||||||
m_program->setUniformValue("scale", 1.0f, 0.0f);
|
m_program->setUniformValue("scale", 1.0f, 0.0f);
|
||||||
|
|
||||||
m_debayerProgram = std::unique_ptr<QOpenGLShaderProgram>(new QOpenGLShaderProgram);
|
m_debayerProgram = std::unique_ptr<QOpenGLShaderProgram>(new QOpenGLShaderProgram);
|
||||||
@@ -764,6 +772,21 @@ void ImageWidgetGL::initializeGL()
|
|||||||
m_lut->allocateStorage();
|
m_lut->allocateStorage();
|
||||||
m_lut->bind(2);
|
m_lut->bind(2);
|
||||||
|
|
||||||
|
QImage colormap(":/colormap.png");
|
||||||
|
colormap = colormap.convertToFormat(QImage::Format_RGBA8888);
|
||||||
|
qDebug() << colormap;
|
||||||
|
m_colormap = std::make_unique<QOpenGLTexture>(QOpenGLTexture::Target1DArray);
|
||||||
|
m_colormap->setSize(colormap.width());
|
||||||
|
m_colormap->setLayers(colormap.height());
|
||||||
|
m_colormap->setFormat(QOpenGLTexture::RGBA8_UNorm);
|
||||||
|
m_colormap->setMinMagFilters(QOpenGLTexture::Linear, QOpenGLTexture::Linear);
|
||||||
|
m_colormap->setWrapMode(QOpenGLTexture::ClampToEdge);
|
||||||
|
m_colormap->allocateStorage();
|
||||||
|
for(int i=0; i<colormap.height(); i++)
|
||||||
|
m_colormap->setData(0, i, QOpenGLTexture::RGBA, QOpenGLTexture::UInt8, colormap.scanLine(i));
|
||||||
|
|
||||||
|
m_colormap->bind(3);
|
||||||
|
|
||||||
if(m_rawImage)
|
if(m_rawImage)
|
||||||
setImage(m_rawImage, m_currentImg);
|
setImage(m_rawImage, m_currentImg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ public:
|
|||||||
virtual void bestFit() = 0;
|
virtual void bestFit() = 0;
|
||||||
|
|
||||||
virtual void setBayerMask(int mask) = 0;
|
virtual void setBayerMask(int mask) = 0;
|
||||||
|
virtual void setColormap(int colormap) = 0;
|
||||||
virtual void setOffset(float dx, float dy) = 0;
|
virtual void setOffset(float dx, float dy) = 0;
|
||||||
virtual void allocateThumbnails(const QStringList &paths) = 0;
|
virtual void allocateThumbnails(const QStringList &paths) = 0;
|
||||||
|
|
||||||
@@ -63,6 +64,7 @@ class ImageWidgetGL : public QOpenGLWidget, public ImageWidget
|
|||||||
std::unique_ptr<QOpenGLVertexArrayObject> m_vaoThumb;
|
std::unique_ptr<QOpenGLVertexArrayObject> m_vaoThumb;
|
||||||
std::unique_ptr<QOpenGLTexture> m_thumbnailTexture;
|
std::unique_ptr<QOpenGLTexture> m_thumbnailTexture;
|
||||||
std::unique_ptr<QOpenGLTexture> m_lut;
|
std::unique_ptr<QOpenGLTexture> m_lut;
|
||||||
|
std::unique_ptr<QOpenGLTexture> m_colormap;
|
||||||
GLuint m_debayerTex = 0;
|
GLuint m_debayerTex = 0;
|
||||||
std::shared_ptr<RawImage> m_rawImage;
|
std::shared_ptr<RawImage> m_rawImage;
|
||||||
std::shared_ptr<WCSDataT> m_wcs;
|
std::shared_ptr<WCSDataT> m_wcs;
|
||||||
@@ -87,6 +89,7 @@ class ImageWidgetGL : public QOpenGLWidget, public ImageWidget
|
|||||||
int m_maxTextureSize = 0;
|
int m_maxTextureSize = 0;
|
||||||
int m_maxArrayLayers = 0;
|
int m_maxArrayLayers = 0;
|
||||||
int m_firstRed[2] = {0, 0};
|
int m_firstRed[2] = {0, 0};
|
||||||
|
int m_colormapIdx = 0;
|
||||||
QVector<ImageThumb> m_thumnails;
|
QVector<ImageThumb> m_thumnails;
|
||||||
Database *m_database = nullptr;
|
Database *m_database = nullptr;
|
||||||
QPointF m_lastPos;
|
QPointF m_lastPos;
|
||||||
@@ -102,6 +105,7 @@ public:
|
|||||||
void allocateThumbnails(const QStringList &paths) override;
|
void allocateThumbnails(const QStringList &paths) override;
|
||||||
QVector2D getImagePixelCoord(const QVector2D &pos);
|
QVector2D getImagePixelCoord(const QVector2D &pos);
|
||||||
void setBayerMask(int mask) override;
|
void setBayerMask(int mask) override;
|
||||||
|
void setColormap(int colormap) override;
|
||||||
void setOffset(float dx, float dy) override;
|
void setOffset(float dx, float dy) override;
|
||||||
void setMTFParams(const MTFParam ¶ms) override;
|
void setMTFParams(const MTFParam ¶ms) override;
|
||||||
void superPixel(bool enable) override;
|
void superPixel(bool enable) override;
|
||||||
|
|||||||
@@ -207,6 +207,29 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
|||||||
settings.setValue("mainwindow/bayermask", data);
|
settings.setValue("mainwindow/bayermask", data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QStringList colormaps = {"Autumn", "Bone", "Jet", "Winter", "Rainbow", "Ocean", "Summer", "Spring", "Cool", "HSV", "Pink", "Hot", "Parula", "Magma",
|
||||||
|
"Inferno", "Plasma", "Viridis", "Cividis", "Twilight", "Twilight shifted", "Turbo", "Deepgreen"};
|
||||||
|
QMenu *colormapMenu = viewMenu->addMenu(tr("Colormap"));
|
||||||
|
QActionGroup *colormapActionGroup = new QActionGroup(this);
|
||||||
|
int idx = 0;
|
||||||
|
QImage cmImg(":/colormap.png");
|
||||||
|
for(QString &colormap : colormaps)
|
||||||
|
{
|
||||||
|
QImage icon = cmImg.copy(0, idx, cmImg.width(), 1).scaled(32, 32);
|
||||||
|
QAction *action = colormapActionGroup->addAction(colormap);
|
||||||
|
action->setIcon(QPixmap::fromImage(icon));
|
||||||
|
action->setCheckable(true); action->setData(idx++);
|
||||||
|
colormapMenu->addAction(action);
|
||||||
|
}
|
||||||
|
viewMenu->addMenu(colormapMenu);
|
||||||
|
connect(colormapActionGroup, &QActionGroup::triggered, [this](QAction *action){
|
||||||
|
int data = action->data().toInt();
|
||||||
|
m_image->setColormap(data);
|
||||||
|
QSettings settings;
|
||||||
|
settings.setValue("mainwindow/colormap", data);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
QAction *thumbnailsAction = viewMenu->addAction(tr("Thumbnails"), Qt::Key_F2, [this](bool checked){
|
QAction *thumbnailsAction = viewMenu->addAction(tr("Thumbnails"), Qt::Key_F2, [this](bool checked){
|
||||||
if(SettingsDialog::loadThumbsizes())m_ringList->clearThumbnails();
|
if(SettingsDialog::loadThumbsizes())m_ringList->clearThumbnails();
|
||||||
m_image->allocateThumbnails(m_ringList->imageNames());
|
m_image->allocateThumbnails(m_ringList->imageNames());
|
||||||
@@ -291,6 +314,12 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
|||||||
case 3:
|
case 3:
|
||||||
bggrAction->setChecked(true); break;
|
bggrAction->setChecked(true); break;
|
||||||
}
|
}
|
||||||
|
int colormap = settings.value("mainwindow/colormap", 4).toInt();
|
||||||
|
if(colormap >= 0 && colormap < colormapActionGroup->actions().size())
|
||||||
|
colormapActionGroup->actions().at(colormap)->setChecked(true);
|
||||||
|
|
||||||
|
m_image->setBayerMask(bayermask);
|
||||||
|
m_image->setColormap(colormap);
|
||||||
|
|
||||||
QStringList standardLocations = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);
|
QStringList standardLocations = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);
|
||||||
if(standardLocations.size())
|
if(standardLocations.size())
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 5.4 KiB |
@@ -18,6 +18,7 @@
|
|||||||
<file>space.nouspiro.tenmon.png</file>
|
<file>space.nouspiro.tenmon.png</file>
|
||||||
<file>../translations/tenmon_pt_BR.qm</file>
|
<file>../translations/tenmon_pt_BR.qm</file>
|
||||||
<file alias="help">../about/help_en</file>
|
<file alias="help">../about/help_en</file>
|
||||||
|
<file>colormap.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
<qresource prefix="/" lang="en">
|
<qresource prefix="/" lang="en">
|
||||||
<file alias="help">../about/help_en</file>
|
<file alias="help">../about/help_en</file>
|
||||||
|
|||||||
+5
-11
@@ -1,5 +1,6 @@
|
|||||||
uniform sampler2D qt_Texture0;
|
uniform sampler2D qt_Texture0;
|
||||||
uniform sampler3D lut_table;
|
uniform sampler3D lut_table;
|
||||||
|
uniform sampler1DArray colormap;
|
||||||
uniform vec3 mtf_param[3];
|
uniform vec3 mtf_param[3];
|
||||||
uniform vec2 unit_scale;
|
uniform vec2 unit_scale;
|
||||||
uniform bool bw;
|
uniform bool bw;
|
||||||
@@ -7,6 +8,7 @@ uniform bool invert;
|
|||||||
uniform bool srgb;
|
uniform bool srgb;
|
||||||
uniform bool false_color;
|
uniform bool false_color;
|
||||||
uniform int filtering;
|
uniform int filtering;
|
||||||
|
uniform int colormapIdx;
|
||||||
in vec2 qt_TexCoord0;
|
in vec2 qt_TexCoord0;
|
||||||
layout(location = 0) out vec4 color;
|
layout(location = 0) out vec4 color;
|
||||||
|
|
||||||
@@ -26,17 +28,9 @@ vec4 MTF(vec4 x, vec4 low, vec4 mid, vec4 high)
|
|||||||
|
|
||||||
vec3 falsecolor(float color)
|
vec3 falsecolor(float color)
|
||||||
{
|
{
|
||||||
const vec3 pallete[] = vec3[](
|
color *= 255.0 / 256.0;
|
||||||
vec3(1.0, 0.0, 1.0), //magneta
|
color += 0.5 / 256.0;
|
||||||
vec3(0.0, 0.0, 1.0), //blue
|
return texture(colormap, vec2(color, colormapIdx)).rgb;
|
||||||
vec3(0.0, 1.0, 1.0), //cyan
|
|
||||||
vec3(0.0, 1.0, 0.0), //green
|
|
||||||
vec3(1.0, 1.0, 0.0), //yellow
|
|
||||||
vec3(1.0, 0.0, 0.0), vec3(1.0, 0.0, 0.0));//red
|
|
||||||
color *= 5.0;
|
|
||||||
int i = int(color);
|
|
||||||
float f = fract(color);
|
|
||||||
return mix(pallete[i], pallete[i+1], f);// * (f * 0.5 + 0.5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 checker()
|
vec3 checker()
|
||||||
|
|||||||
Reference in New Issue
Block a user