ColorScale: Add magma and inferno colormaps

This commit is contained in:
leonarski_f committed 2026-01-30 11:28:46 +01:00
1 parent 0879983cca
commit 07fa788fe2
11 files changed
+63 -26

No files matched your search

+16 -9
View File
@@ -872,20 +872,27 @@ PlotType ConvertPlotType(const std::optional<std::string>& input) {
"Plot type not recognized");
}
ColorScaleEnum ConvertColorScale(const std::optional<std::string>& input) {
std::string color = input.value_or("indigo");
ColorScaleEnum ConvertColorScale(const std::optional<std::string> &input) {
std::string color = input.value_or("indigo");
if (color == "viridis")
return ColorScaleEnum::Viridis;
else if (color == "bw")
if (color == "bw")
return ColorScaleEnum::BW;
else if (color == "heat")
return ColorScaleEnum::Heat;
else if (color == "indigo")
if (color == "wb")
return ColorScaleEnum::WB;
if (color == "green")
return ColorScaleEnum::Green3;
if (color == "heat")
return ColorScaleEnum::Heat;
if (color == "indigo")
return ColorScaleEnum::Indigo;
else
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"Color scale unknown");
if (color == "magma")
return ColorScaleEnum::Magma;
if (color == "inferno")
return ColorScaleEnum::Inferno;
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"Color scale unknown");
}
IndexingSettings Convert(const org::openapitools::server::model::Indexing_settings &input) {
+5 -1
View File
@@ -221,14 +221,18 @@ components:
color_scale:
in: query
name: color
description: "Color scale for preview image: 0 - indigo, 1 - viridis, 2 - B/W, 3 - heat"
description: "Color scale for preview image"
schema:
type: string
enum:
- "indigo"
- "viridis"
- "bw"
- "wb"
- "green"
- "heat"
- "magma"
- "inferno"
default: "indigo"
schemas:
grid_scan:
+2 -2
View File
@@ -1376,7 +1376,7 @@ This format doesn&#x27;t transmit information about X-axis, only values, so it i
" class="sc-eVqvcJ sc-fszimp kIppRw drqpJr"><p>Quality of JPEG image (100 - highest; 0 - lowest)</p>
</div></div></div></td></tr><tr class=""><td kind="field" title="show_res_ring" class="sc-kCuUfV sc-fbQrwq gdmNWp dFOJWJ"><span class="sc-hwddKA cteAyA"></span><span class="property-name">show_res_ring</span></td><td class="sc-gGKoUb ixGaBD"><div><div><span class="sc-bEjUoa sc-boKDdR lhyyLL jYezsP"></span><span class="sc-bEjUoa sc-fOOuSg lhyyLL dbKJYq">number</span><span class="sc-bEjUoa sc-fOOuSg lhyyLL dbKJYq"> <!-- -->&lt;<!-- -->float<!-- -->&gt;<!-- --> </span><span> <span class="sc-bEjUoa sc-goiVcJ lhyyLL bDfgbe"> <!-- -->[ 0.1 .. 100 ]<!-- --> </span></span></div><div><span class="sc-bEjUoa lhyyLL"> <!-- -->Default:<!-- --> </span> <span class="sc-bEjUoa sc-dTWiOz lhyyLL kMQdIk">0.1</span></div> <div><div html="&lt;p&gt;Show resolution ring, provided in Angstrom&lt;/p&gt;
" class="sc-eVqvcJ sc-fszimp kIppRw drqpJr"><p>Show resolution ring, provided in Angstrom</p>
</div></div></div></td></tr><tr class=""><td kind="field" title="color" class="sc-kCuUfV sc-fbQrwq gdmNWp dFOJWJ"><span class="sc-hwddKA cteAyA"></span><span class="property-name">color</span></td><td class="sc-gGKoUb ixGaBD"><div><div><span class="sc-bEjUoa sc-boKDdR lhyyLL jYezsP"></span><span class="sc-bEjUoa sc-fOOuSg lhyyLL dbKJYq">string</span></div><div><span class="sc-bEjUoa lhyyLL"> <!-- -->Default:<!-- --> </span> <span class="sc-bEjUoa sc-dTWiOz lhyyLL kMQdIk">&quot;indigo&quot;</span></div><div><span class="sc-bEjUoa lhyyLL"> <!-- -->Enum<!-- -->:</span> <span class="sc-bEjUoa sc-dTWiOz lhyyLL kMQdIk">&quot;indigo&quot;</span> <span class="sc-bEjUoa sc-dTWiOz lhyyLL kMQdIk">&quot;viridis&quot;</span> <span class="sc-bEjUoa sc-dTWiOz lhyyLL kMQdIk">&quot;bw&quot;</span> <span class="sc-bEjUoa sc-dTWiOz lhyyLL kMQdIk">&quot;heat&quot;</span> </div> <div><div html="&lt;p&gt;Color scale for preview image: 0 - indigo, 1 - viridis, 2 - B/W, 3 - heat&lt;/p&gt;
</div></div></div></td></tr><tr class=""><td kind="field" title="color" class="sc-kCuUfV sc-fbQrwq gdmNWp dFOJWJ"><span class="sc-hwddKA cteAyA"></span><span class="property-name">color</span></td><td class="sc-gGKoUb ixGaBD"><div><div><span class="sc-bEjUoa sc-boKDdR lhyyLL jYezsP"></span><span class="sc-bEjUoa sc-fOOuSg lhyyLL dbKJYq">string</span></div><div><span class="sc-bEjUoa lhyyLL"> <!-- -->Default:<!-- --> </span> <span class="sc-bEjUoa sc-dTWiOz lhyyLL kMQdIk">&quot;indigo&quot;</span></div><div><span class="sc-bEjUoa lhyyLL"> <!-- -->Enum<!-- -->:</span> <span class="sc-bEjUoa sc-dTWiOz lhyyLL kMQdIk">&quot;indigo&quot;</span> <span class="sc-bEjUoa sc-dTWiOz lhyyLL kMQdIk">&quot;viridis&quot;</span> <span class="sc-bEjUoa sc-dTWiOz lhyyLL kMQdIk">&quot;bw&quot;</span> <span class="sc-bEjUoa sc-dTWiOz lhyyLL kMQdIk">&quot;wb&quot;</span> <span class="sc-bEjUoa sc-dTWiOz lhyyLL kMQdIk">&quot;green&quot;</span> <span class="sc-bEjUoa sc-dTWiOz lhyyLL kMQdIk">&quot;heat&quot;</span> <span class="sc-bEjUoa sc-dTWiOz lhyyLL kMQdIk">&quot;magma&quot;</span> <span class="sc-bEjUoa sc-dTWiOz lhyyLL kMQdIk">&quot;inferno&quot;</span> </div> <div><div html="&lt;p&gt;Color scale for preview image: 0 - indigo, 1 - viridis, 2 - B/W, 3 - heat&lt;/p&gt;
" class="sc-eVqvcJ sc-fszimp kIppRw drqpJr"><p>Color scale for preview image: 0 - indigo, 1 - viridis, 2 - B/W, 3 - heat</p>
</div></div></div></td></tr><tr class="last "><td kind="field" title="show_res_est" class="sc-kCuUfV sc-fbQrwq gdmNWp dFOJWJ"><span class="sc-hwddKA cteAyA"></span><span class="property-name">show_res_est</span></td><td class="sc-gGKoUb ixGaBD"><div><div><span class="sc-bEjUoa sc-boKDdR lhyyLL jYezsP"></span><span class="sc-bEjUoa sc-fOOuSg lhyyLL dbKJYq">boolean</span></div><div><span class="sc-bEjUoa lhyyLL"> <!-- -->Default:<!-- --> </span> <span class="sc-bEjUoa sc-dTWiOz lhyyLL kMQdIk">false</span></div> <div><div html="&lt;p&gt;Show resolution estimation as a ring&lt;/p&gt;
" class="sc-eVqvcJ sc-fszimp kIppRw drqpJr"><p>Show resolution estimation as a ring</p>
@@ -1424,7 +1424,7 @@ then image might be replaced in the buffer between calling /images and /image.cb
" class="sc-eVqvcJ sc-fszimp kIppRw drqpJr"><p>Test Jungfraujoch system</p>
</div><div tabindex="0" role="button"><div class="sc-xKhEK okJpy"><span>http://localhost:5232</span>/version</div></div></div></div></div></div></div></div></div><div class="sc-evkzZa iZqpqg"></div></div></div>
<script>
const __redoc_state = {"menu":{"activeItemIdx":-1},"spec":{"data":{"openapi":"3.0.3","info":{"title":"Jungfraujoch","description":"API to control Jungfraujoch developed by the Paul Scherrer Institute (Switzerland).\nJungfraujoch is a data acquisition and analysis system for pixel array detectors, primarly PSI JUNGFRAU.\nJungfraujoch uses FPGA boards to acquire data at high data rates.\n\n# License Clarification\n\nWhile this API definition is licensed under GPL-3.0, **the GPL copyleft provisions do not apply**\nwhen this file is used solely to generate OpenAPI clients or when implementing applications that\ninteract with the API. Generated client code and applications using this API definition are not\nsubject to the GPL license requirements and may be distributed under terms of your choosing.\n\nThis exception is similar in spirit to the Linux Kernel's approach to userspace API headers and\nthe GCC Runtime Library Exception. The Linux Kernel developers have explicitly stated that\nuser programs that merely use the kernel interfaces (syscalls, ioctl definitions, etc.) are not\nderivative works of the kernel and are not subject to the terms of the GPL.\n\nThis exception is intended to allow wider use of this API specification without imposing GPL\nrequirements on applications that merely interact with the API, regardless of whether they\ncommunicate through network calls or other mechanisms.\n","version":"1.0.0-rc.123","contact":{"name":"Filip Leonarski (Paul Scherrer Institute)","email":"filip.leonarski@psi.ch"},"license":{"name":"GPL-3.0","url":"https://www.gnu.org/licenses/gpl-3.0.html"}},"servers":[{"url":"http://localhost:5232","description":"Test Jungfraujoch system"}],"components":{"parameters":{"binning":{"in":"query","name":"binning","required":false,"schema":{"default":1,"type":"integer"},"description":"Binning of frames for the plot (0 = default binning)"},"compression":{"in":"query","name":"compression","required":false,"schema":{"type":"boolean","default":false},"description":"Enable DEFLATE compression of output data."},"experimental_coord":{"in":"query","name":"experimental_coord","required":false,"schema":{"type":"boolean","default":false},"description":"If measurement has goniometer axis defined, plot X-axis will represent rotation angle\nIf measurement has grid scan defined, plot X-axis and Y-axis will represent grid position, Z will be used as the final value\nFor still measurement the number is ignored\n"},"azint_unit":{"in":"query","name":"azint_unit","required":false,"schema":{"type":"string","enum":["Q_recipA","d_A","two_theta_deg"],"default":"Q_recipA"},"description":"Unit used for azim int.\n"},"fill_value":{"in":"query","name":"fill","required":false,"schema":{"type":"number","format":"float"},"description":"Fill value for elements that were missed during data collection\n"},"plot_type":{"in":"query","name":"type","required":true,"description":"Type of requested plot","schema":{"type":"string","enum":["bkg_estimate","azint","azint_1d","spot_count","spot_count_low_res","spot_count_indexed","spot_count_ice","indexing_rate","indexing_time","indexing_unit_cell_length","indexing_unit_cell_angle","profile_radius","mosaicity","b_factor","error_pixels","saturated_pixels","image_collection_efficiency","receiver_delay","receiver_free_send_buf","strong_pixels","roi_sum","roi_mean","roi_max_count","roi_pixels","roi_weighted_x","roi_weighted_y","packets_received","max_pixel_value","resolution_estimate","pixel_sum","processing_time","beam_center_x","beam_center_y"]}},"roi":{"in":"query","name":"roi","required":false,"schema":{"type":"string","minLength":1},"description":"Name of ROI for which plot is requested"},"image_id":{"in":"query","name":"id","required":false,"schema":{"type":"integer","format":"int64","default":-1,"minimum":-2},"description":"Image ID in the image buffer. Special values: -1 - last image in the buffer, -2: last indexed image in the buffer"},"saturation":{"in":"query","name":"saturation","required":false,"schema":{"type":"number","format":"float","minimum":-32767,"maximum":32767},"description":"Saturation value to set contrast in the preview image; if not provided, then autocontrast procedure is used"},"background":{"in":"query","name":"background","required":false,"schema":{"type":"number","format":"float","default":0,"minimum":-32767,"maximum":32767},"description":"Background value to set contrast in the preview image"},"show_spots":{"in":"query","name":"show_spots","schema":{"type":"boolean","default":true},"description":"Show spot finding results on the image"},"show_beam_center":{"in":"query","name":"show_beam_center","schema":{"type":"boolean","default":true},"description":"Show beam center on the image"},"show_roi":{"in":"query","name":"show_roi","schema":{"type":"boolean","default":false},"description":"Show ROI areas on the image"},"jpeg_quality":{"in":"query","name":"jpeg_quality","description":"Quality of JPEG image (100 - highest; 0 - lowest)","schema":{"tLine truncated
const __redoc_state = {"menu":{"activeItemIdx":-1},"spec":{"data":{"openapi":"3.0.3","info":{"title":"Jungfraujoch","description":"API to control Jungfraujoch developed by the Paul Scherrer Institute (Switzerland).\nJungfraujoch is a data acquisition and analysis system for pixel array detectors, primarly PSI JUNGFRAU.\nJungfraujoch uses FPGA boards to acquire data at high data rates.\n\n# License Clarification\n\nWhile this API definition is licensed under GPL-3.0, **the GPL copyleft provisions do not apply**\nwhen this file is used solely to generate OpenAPI clients or when implementing applications that\ninteract with the API. Generated client code and applications using this API definition are not\nsubject to the GPL license requirements and may be distributed under terms of your choosing.\n\nThis exception is similar in spirit to the Linux Kernel's approach to userspace API headers and\nthe GCC Runtime Library Exception. The Linux Kernel developers have explicitly stated that\nuser programs that merely use the kernel interfaces (syscalls, ioctl definitions, etc.) are not\nderivative works of the kernel and are not subject to the terms of the GPL.\n\nThis exception is intended to allow wider use of this API specification without imposing GPL\nrequirements on applications that merely interact with the API, regardless of whether they\ncommunicate through network calls or other mechanisms.\n","version":"1.0.0-rc.123","contact":{"name":"Filip Leonarski (Paul Scherrer Institute)","email":"filip.leonarski@psi.ch"},"license":{"name":"GPL-3.0","url":"https://www.gnu.org/licenses/gpl-3.0.html"}},"servers":[{"url":"http://localhost:5232","description":"Test Jungfraujoch system"}],"components":{"parameters":{"binning":{"in":"query","name":"binning","required":false,"schema":{"default":1,"type":"integer"},"description":"Binning of frames for the plot (0 = default binning)"},"compression":{"in":"query","name":"compression","required":false,"schema":{"type":"boolean","default":false},"description":"Enable DEFLATE compression of output data."},"experimental_coord":{"in":"query","name":"experimental_coord","required":false,"schema":{"type":"boolean","default":false},"description":"If measurement has goniometer axis defined, plot X-axis will represent rotation angle\nIf measurement has grid scan defined, plot X-axis and Y-axis will represent grid position, Z will be used as the final value\nFor still measurement the number is ignored\n"},"azint_unit":{"in":"query","name":"azint_unit","required":false,"schema":{"type":"string","enum":["Q_recipA","d_A","two_theta_deg"],"default":"Q_recipA"},"description":"Unit used for azim int.\n"},"fill_value":{"in":"query","name":"fill","required":false,"schema":{"type":"number","format":"float"},"description":"Fill value for elements that were missed during data collection\n"},"plot_type":{"in":"query","name":"type","required":true,"description":"Type of requested plot","schema":{"type":"string","enum":["bkg_estimate","azint","azint_1d","spot_count","spot_count_low_res","spot_count_indexed","spot_count_ice","indexing_rate","indexing_time","indexing_unit_cell_length","indexing_unit_cell_angle","profile_radius","mosaicity","b_factor","error_pixels","saturated_pixels","image_collection_efficiency","receiver_delay","receiver_free_send_buf","strong_pixels","roi_sum","roi_mean","roi_max_count","roi_pixels","roi_weighted_x","roi_weighted_y","packets_received","max_pixel_value","resolution_estimate","pixel_sum","processing_time","beam_center_x","beam_center_y"]}},"roi":{"in":"query","name":"roi","required":false,"schema":{"type":"string","minLength":1},"description":"Name of ROI for which plot is requested"},"image_id":{"in":"query","name":"id","required":false,"schema":{"type":"integer","format":"int64","default":-1,"minimum":-2},"description":"Image ID in the image buffer. Special values: -1 - last image in the buffer, -2: last indexed image in the buffer"},"saturation":{"in":"query","name":"saturation","required":false,"schema":{"type":"number","format":"float","minimum":-32767,"maximum":32767},"description":"Saturation value to set contrast in the preview image; if not provided, then autocontrast procedure is used"},"background":{"in":"query","name":"background","required":false,"schema":{"type":"number","format":"float","default":0,"minimum":-32767,"maximum":32767},"description":"Background value to set contrast in the preview image"},"show_spots":{"in":"query","name":"show_spots","schema":{"type":"boolean","default":true},"description":"Show spot finding results on the image"},"show_beam_center":{"in":"query","name":"show_beam_center","schema":{"type":"boolean","default":true},"description":"Show beam center on the image"},"show_roi":{"in":"query","name":"show_roi","schema":{"type":"boolean","default":false},"description":"Show ROI areas on the image"},"jpeg_quality":{"in":"query","name":"jpeg_quality","description":"Quality of JPEG image (100 - highest; 0 - lowest)","schema":{"tLine truncated
var container = document.getElementById('redoc');
Redoc.hydrate(__redoc_state, container);
+4
View File
@@ -61,6 +61,10 @@ void ColorScale::CalcLUT() const {
case ColorScaleEnum::Green3:
map = &green_colormap;
break;
case ColorScaleEnum::Magma:
map = &magma_colormap; break;
case ColorScaleEnum::Inferno:
map = &inferno_colormap; break;
default:
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"Color scale unknown");
+20 -8
View File
@@ -18,14 +18,16 @@ struct rgb {
float luminance(rgb input);
enum class ColorScaleEnum : int {
Viridis = 0,
Heat = 1,
Indigo = 2,
BW = 3,
WB = 4,
Green1 = 5,
Green2 = 6,
Green3 = 7
Indigo = 0,
Viridis = 1,
Magma = 2,
Inferno = 3,
Heat = 4,
BW = 5,
WB = 6,
Green1 = 7,
Green2 = 8,
Green3 = 9
};
enum class ColorScaleSpecial {
@@ -59,6 +61,16 @@ class ColorScale {
{0, 0, 0}, {0, 255, 0}
};
const std::vector<rgb> magma_colormap = {
{0, 0, 4}, {28, 16, 68}, {79, 18, 123}, {129, 37, 129},
{181, 54, 122}, {229, 80, 100}, {251, 135, 97}, {252, 191, 125}, {252, 253, 191}
};
const std::vector<rgb> inferno_colormap = {
{0, 0, 4}, {31, 12, 72}, {85, 15, 109}, {136, 34, 106},
{186, 54, 85}, {227, 89, 51}, {249, 140, 10}, {252, 195, 63}, {252, 255, 164}
};
ColorScaleEnum current = ColorScaleEnum::Indigo;
rgb gap = {.r = 190, .g = 190, .b = 190}; // Gray
+1 -1
View File
@@ -7,4 +7,4 @@ The project is supported by :
* ETH Domain via Open Research Data Contribute project (Jan - Dec 2023)
* AMD University Program with donation of licenses of Ethernet IP cores and Vivado software
This software uses Viridis colormap from Matplotlib under its BSD-compatible license
This software uses Viridis, Magma and Inferno colormaps from Matplotlib under its BSD-compatible license
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "jungfraujoch-frontend",
"version": "1.0.0-rc.122",
"version": "1.0.0-rc.123",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "jungfraujoch-frontend",
"version": "1.0.0-rc.122",
"version": "1.0.0-rc.123",
"license": "GPL-3.0",
"dependencies": {
"@emotion/react": "^11.10.4",
+4
View File
@@ -405,7 +405,11 @@ class PreviewImage extends Component<MyProps, MyState> {
<MenuItem value={color_scale.INDIGO}>Indigo/white</MenuItem>
<MenuItem value={color_scale.HEAT}>Heat</MenuItem>
<MenuItem value={color_scale.VIRIDIS}>Viridis</MenuItem>
<MenuItem value={color_scale.MAGMA}>Magma</MenuItem>
<MenuItem value={color_scale.INFERNO}>Inferno</MenuItem>
<MenuItem value={color_scale.BW}>Black/white</MenuItem>
<MenuItem value={color_scale.WB}>White/black</MenuItem>
<MenuItem value={color_scale.GREEN}>Green</MenuItem>
</Select>
</FormControl>
<Stack spacing={3} direction="row" sx={{width:"83%"}}>
@@ -10,5 +10,9 @@ export enum color_scale {
INDIGO = 'indigo',
VIRIDIS = 'viridis',
BW = 'bw',
WB = 'wb',
GREEN = 'green',
HEAT = 'heat',
MAGMA = 'magma',
INFERNO = 'inferno',
}
@@ -1122,7 +1122,7 @@ export class DefaultService {
saturation?: number,
jpegQuality: number = 100,
showResRing: number = 0.1,
color: 'indigo' | 'viridis' | 'bw' | 'heat' = 'indigo',
color: 'indigo' | 'viridis' | 'bw' | 'wb' | 'green' | 'heat' | 'magma' | 'inferno' = 'indigo',
showResEst: boolean = false,
): CancelablePromise<Blob> {
return __request(OpenAPI, {
@@ -22,9 +22,11 @@ JFJochViewerToolbarDisplay::JFJochViewerToolbarDisplay(QWidget *parent)
// Initialize QComboBox with the options
color_map_select = new QComboBox(this);
color_map_select->addItem("Viridis", static_cast<int>(ColorScaleEnum::Viridis));
color_map_select->addItem("Heat", static_cast<int>(ColorScaleEnum::Heat));
color_map_select->addItem("Indigo", static_cast<int>(ColorScaleEnum::Indigo));
color_map_select->addItem("Viridis", static_cast<int>(ColorScaleEnum::Viridis));
color_map_select->addItem("Magma", static_cast<int>(ColorScaleEnum::Magma));
color_map_select->addItem("Inferno", static_cast<int>(ColorScaleEnum::Inferno));
color_map_select->addItem("Heat", static_cast<int>(ColorScaleEnum::Heat));
color_map_select->addItem("Black on white", static_cast<int>(ColorScaleEnum::BW));
color_map_select->addItem("White on black", static_cast<int>(ColorScaleEnum::WB));
color_map_select->addItem("Green (gamma)", static_cast<int>(ColorScaleEnum::Green1));